pax_global_header00006660000000000000000000000064131650124260014512gustar00rootroot0000000000000052 comment=caaaed9d6189f4ee6319c119137c2c701f76ecd8 apgdiff/000077500000000000000000000000001316501242600124565ustar00rootroot00000000000000apgdiff/.gitignore000066400000000000000000000001041316501242600144410ustar00rootroot00000000000000/target/ nbactions.xml lib build .settings .classpath .project dist apgdiff/README.md000066400000000000000000000165601316501242600137450ustar00rootroot00000000000000# Another PostgreSQL Diff Tool (aka apgdiff) Another PostgreSQL Diff Tool is free PostgreSQL diff tool that is useful for comparison/diffing of database schemas. You can find more information at its website at http://www.apgdiff.com/. If you found an issue in apgdiff, please file it at https://github.com/fordfrog/apgdiff/issues. If you for some reason need to contact author of this application, you can email him at fordfrog@fordfrog.com. ## Changelog ### Version 2.5 (not released yet) #### New Features * MATERIALIZED VIEW support in PostgreSQL 9.3 (Marti Raudsepp) * Better support for inherited tables (Daniel Watson) * Added support for CREATE UNLOGGED TABLE (Anatoliy Basov) * Added support for /**/ comments (yulei) * Support of triggers for views + clause 'INSTEAD OF' (Sergej Bonich) * Add support for GRANT and REVOKE on objects: table, view, sequence, column (serge-pouliquen-itf) * Add support for ALTER TABLE ... OWNER TO (serge-pouliquen-itf) * Add support for CREATE TYPE (Karol Rybak) * Add support for CREATE EXTENSION (Átila Camurça Alves) * Add basic support for CREATE FOREIGN TABLE (Bruno Almeida) #### Fixes * Added hint to use "CREATE TABLE ... CONSTRAINT name PRIMARY KEY/UNIQUE ..." instead of "CREATE TABLE ... PRIMARY KEY/UNIQUE ..." because apgdiff cannot easily support unnamed constraints. * Fixed issue with incorrect end of expression detection because of ignored [ and ] brackets. This caused issues for example in statements like "... DEFAULT ARRAY[1, 2, 3], ..." where end of expression was detected at first comma (and not the third one) which then resulted in parser exception. * Fixed issue when outputting unsupported command information and the unsupported command string is shorter than 20 characters. (Linas Valiukas) * Added Spanish translation. (Sebastian Ortiz) * Fitted English help to 80 characters in width. (Dave Jarvis) * View query changes are now correctly detected even if it has declared columns that didn't change. (Marti Raudsepp) * Fixed issue with the $ sign in the object name (Anatoliy Basov) * Added French translation. (Jeremy Passeron) * Native for OS line endings in resulting diff (Sergej Bonich) ### 2012-09-21: Version 2.4 #### New Features * Added support for ALTER SEQUENCE OWNED BY (patch by Mikhail Petrov). * Added support for CREATE TRIGGER ... UPDATE OF column. * Added switch --ignore-slony-triggers which causes that Slony triggers _slony_logtrigger and _slony_denyaccess are completely ignored during parsing and diffing. * Added switch --ignore-schema-creation which removes the need of CREATE SCHEMA declararions in the input files. #### Fixes * Fixed issue with comments not being added on newly created columns. * Improved logging errors when parsing strings. * Added support for IF NOT EXISTS (patch by Felipe Sateler). * Fixed NPE when search_path contains quoted schema (patch by Steven Elliott). * Fixed dropping of default values when --add-defaults is specified (patch by Jim Mlodgenski). * Fixed all bugs related to incorrect parsing of end of statement, most often resulting in StringIndexOutOfBoundException. * Fixed CREATE TABLE statement output when table contains no column. ### 2010-10-22: Version 2.3 #### New Features * Added support for diffing of COMMENT ON statements. * Added switch --list-charsets to output list of supported charsets. #### Fixes * Added user error messages instead of NullPointerException for cases when referenced database object was not found in the dump. * Fixed bug with parsing quoted object name when both first and second part of the name was quoted. * Fixed bug in parser that caused in some cases invalid match against expected "word". * Fixed bug in parser that caused array data types not detected correctly (was caused by fix of invalid match of "word" above). * Functions are now created after tables are create and updated, because of functions depending on tables and columns. Later will be implemented solution for cases where functions have to be created before table columns. ### 2010-10-09: Version 2.2.2 #### Fixes * Added missing new line after ALTER VIEW ... ALTER COLUMN ... SET/DROP DEFAULT. * Fixed parsing of quoted string values. * Fixed detection of function body separator (did not work when there was another 'AS' specified on the same line after the 'AS' starting function body). * If two dumps are completely same and there is more than one schema in the dumps, the output now does not contain 'SET search_path = ...'. In other words, if two dumps are completely same, no output is produced. * Replaced 'ALTER VIEW name ALTER COLUMN ...' with 'ALTER TABLE view_name ALTER COLUMN ...' to make it compatible with PostgreSQL releases prior to 8.4. * Fixed parsing of '' escapes. #### Other * Added support for localization of apgdiff. * Added Czech localization. ### 2010-10-03: Version 2.2.1 #### New Features * Commands like OWNER TO and ENABLE/DISABLE TRIGGER/RULE are now added to the diff output even for commands that are otherwise being parsed, like ALTER TABLE. #### Fixes * Fixed bug where default values were dropped from VIEW columns even if they were not modified. ### 2010-10-02: Version 2.2 #### New Features * Statements that are not supported by apgdiff yet are now all ignored(till this release apgdiff had to be instructed to know what commands to ignore which was not good solution). This is the same behavior as in 1.* releases. * Added command line switch --output-ignored-statements which can be used to output statements that apgdiff ignores in the dump files. This feature makes more clear what statements were ignored and developer has to handle them manually eventually. ### 2010-09-30: Version 2.1 #### New Features * Added support for ALTER VIEW. * Added support for ALTER TABLE view_name/sequence_name. #### Fixes * Fixed issue with comparison of VIEWs when columns are not specified but query has changed. * Fixed parsing of quoted names at many places. * CREATE RULE is now silently skipped. ### 2010-09-16: Version 2.0.2 #### Fixes * CREATE DOMAIN is now silently skipped. ### 2010-09-16: Version 2.0.1 #### Fixes * CREATE OPERATOR and ALTER LANGUAGE are now silently skipped. ### 2010-09-13: Version 2.0 Including Beta Releases #### New Features * SQL parser has been completely rewritten to allow safer and more flexible parsing of SQL statements. * Statements not supported by apgdiff are now not silenty ignored if apgdiff is not told (by me in code) to ignore them. * Added support for ALTER TABLE ... ALTER COLUMN ... SET STORAGE PLAIN|EXTERNAL|EXTENDED|MAIN. * Added support for CREATE TABLE ... TABLESPACE. * Updated parsing of CREATE TABLE ... WITH/WITHOUT OIDS. * Added support for CREATE TRIGGER ... WHEN and for even TRUNCATE. * Added support for CREATE SEQUENCE ... OWNED BY. * CREATE SCHEMA is now supported for both syntaxes. * Added support for default values on function arguments. * Added support for parsing ALTER TABLE ... ENABLE/DISABLE TRIGGER/PARSER, but they are not diffed for now. #### Fixes * ALTER SEQUENCE and CREATE AGGREGATE are now silently skipped. * Fixed parsing of end of function. * Improved handling of dotted quoted names. * Fixed quoting of SQL reserved keywords. * Fixed parsing of function arguments. * Triggers are now dropped before functions are dropped (bug #2991245). * Improved diffing of CREATE TABLE ... INHERITS. ### Versions Prior to 2.0 These versions are not covered in changelog. apgdiff/build.xml000066400000000000000000000105401316501242600142770ustar00rootroot00000000000000 apgdiff/license.txt000066400000000000000000000020561316501242600146440ustar00rootroot00000000000000Copyright (c) 2006 StartNet s.r.o. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. apgdiff/pom.xml000066400000000000000000000256541316501242600140070ustar00rootroot00000000000000 4.0.0 MavenCentral Maven repository http://repo1.maven.org/maven2 true false cz.startnet apgdiff Another PostgreSQL Diff Tool 2.5.0-SNAPSHOT Simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema. http://www.apgdiff.com/ GitHub Issue Tracker https://github.com/fordfrog/apgdiff/issues?sort=created&state=open 2006 fordfrog Miroslav Šulc miroslav.sulc@startnet.cz StartNet s.r.o. http://www.startnet.biz/ main developer +1 Matthieu Patou CLUSTER and STATISTICS support + ordering of columns according to source DDL Jure Mercun Case insensitivity of parsers + correct handling of quoted names Hans Idink Initial help with support of FUNCTIONs Anders Semb Hermansen Ignoring multiple whitespace while comparing content of functions MIT license.txt repo A business-friendly OSS license scm:git:git://github.com/fordfrog/apgdiff.git scm:git:ssh://git@github.com:fordfrog/apgdiff.git https://github.com/fordfrog/apgdiff.git StartNet s.r.o. http://www.startnet.biz UTF-8 maven-compiler-plugin 3.5.1 1.8 1.8 ${project.build.sourceEncoding} org.apache.maven.plugins maven-surefire-plugin 2.9 maven-surefire-report-plugin 2.9 maven-jar-plugin 2.6 true lib cz.startnet.utils.pgdiff.Main org.apache.maven.plugins maven-source-plugin 2.4 attach-sources verify jar org.apache.maven.plugins maven-javadoc-plugin 2.9.1 attach-javadoc verify jar private todo a To do something: org.apache.maven.plugins maven-assembly-plugin ${basedir}/src/main/assembly/bin.xml ${basedir}/src/main/assembly/src.xml org.apache.maven.plugins maven-resources-plugin 2.6 ${project.build.sourceEncoding} org.apache.maven.plugins maven-clean-plugin 3.0.0 ${project.build.sourceEncoding} stat-scm-sourceforge http://stat-scm.sourceforge.net/maven2 stat-scm-sourceforge-snapshot http://stat-scm.sourceforge.net/maven2-snapshots org.apache.maven.plugins maven-resources-plugin 2.6 maven-plugin org.apache.maven.plugins maven-compiler-plugin 3.5.1 maven-plugin org.apache.maven.plugins maven-clean-plugin 3.0.0 maven-plugin junit junit 4.8.1 test org.hamcrest hamcrest-all 1.1 test maven-project-info-reports-plugin 2.9 maven-javadoc-plugin 2.9 128m 512 1.8 1.8 todo a To do something: net.sf stat-scm 1.2.0 maven-pmd-plugin 2.7.1 utf-8 1.6 org.codehaus.mojo taglist-maven-plugin 2.4 maven-jxr-plugin 2.3 UTF-8 UTF-8 org.codehaus.mojo findbugs-maven-plugin 2.5.2 Ignore Max apgdiff/src/000077500000000000000000000000001316501242600132455ustar00rootroot00000000000000apgdiff/src/main/000077500000000000000000000000001316501242600141715ustar00rootroot00000000000000apgdiff/src/main/assembly/000077500000000000000000000000001316501242600160105ustar00rootroot00000000000000apgdiff/src/main/assembly/bin.xml000066400000000000000000000012011316501242600172740ustar00rootroot00000000000000 bin zip ${project.artifactId}-${project.version} ${project.build.directory}/${project.build.finalName}.${project.packaging} ${basedir}/license.txt ${basedir}/README.md apgdiff/src/main/assembly/src.xml000066400000000000000000000012741316501242600173250ustar00rootroot00000000000000 src zip ${project.artifactId}-${project.version} ${basedir}/src src ${basedir} build.xml pom.xml README.md license.txt apgdiff/src/main/java/000077500000000000000000000000001316501242600151125ustar00rootroot00000000000000apgdiff/src/main/java/cz/000077500000000000000000000000001316501242600155265ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/000077500000000000000000000000001316501242600173725ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/000077500000000000000000000000001316501242600205325ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/pgdiff/000077500000000000000000000000001316501242600217715ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/pgdiff/Main.java000066400000000000000000000026001316501242600235160ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; /** * Compares two PostgreSQL dumps and outputs information about differences in * the database schemas. * * @author fordfrog */ public class Main { /** * APgDiff main method. * * @param args the command line arguments * * @throws UnsupportedEncodingException Thrown if unsupported output * encoding has been encountered. */ public static void main(final String[] args) throws UnsupportedEncodingException { @SuppressWarnings("UseOfSystemOutOrSystemErr") final PrintWriter writer = new PrintWriter(System.out, true); final PgDiffArguments arguments = new PgDiffArguments(); if (arguments.parse(writer, args)) { @SuppressWarnings("UseOfSystemOutOrSystemErr") final PrintWriter encodedWriter = new PrintWriter( new OutputStreamWriter( System.out, arguments.getOutCharsetName())); PgDiff.createDiff(encodedWriter, arguments); encodedWriter.close(); } writer.close(); } /** * Creates a new Main object. */ private Main() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/Pair.java000066400000000000000000000004751316501242600235350ustar00rootroot00000000000000package cz.startnet.utils.pgdiff; public class Pair { private L l; private R r; public Pair(L l, R r){ this.l = l; this.r = r; } public L getL(){ return l; } public R getR(){ return r; } public void setL(L l){ this.l = l; } public void setR(R r){ this.r = r; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java000077500000000000000000000344211316501242600240020ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.loader.PgDumpLoader; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgExtension; import cz.startnet.utils.pgdiff.schema.PgSchema; import java.io.InputStream; import java.io.PrintWriter; /** * Creates diff of two database schemas. * * @author fordfrog */ public class PgDiff { /** * Creates diff on the two database schemas. * * @param writer writer the output should be written to * @param arguments object containing arguments settings */ public static void createDiff(final PrintWriter writer, final PgDiffArguments arguments) { // Avoid reading twice from System.in if (arguments.getOldDumpFile().equals("-") && arguments.getNewDumpFile().equals("-")) return; final PgDatabase oldDatabase = PgDumpLoader.loadDatabaseSchema( arguments.getOldDumpFile(), arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers(), arguments.isIgnoreSchemaCreation()); final PgDatabase newDatabase = PgDumpLoader.loadDatabaseSchema( arguments.getNewDumpFile(), arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers(), arguments.isIgnoreSchemaCreation()); diffDatabaseSchemas(writer, arguments, oldDatabase, newDatabase); } /** * Creates diff on the two database schemas. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldInputStream input stream of file containing dump of the * original schema * @param newInputStream input stream of file containing dump of the new * schema */ public static void createDiff(final PrintWriter writer, final PgDiffArguments arguments, final InputStream oldInputStream, final InputStream newInputStream) { final PgDatabase oldDatabase = PgDumpLoader.loadDatabaseSchema( oldInputStream, arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers(), arguments.isIgnoreSchemaCreation()); final PgDatabase newDatabase = PgDumpLoader.loadDatabaseSchema( newInputStream, arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers(), arguments.isIgnoreSchemaCreation()); diffDatabaseSchemas(writer, arguments, oldDatabase, newDatabase); } /** * Creates new schemas (not the objects inside the schemas). * * @param writer writer the output should be written to * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void createNewSchemas(final PrintWriter writer, final PgDatabase oldDatabase, final PgDatabase newDatabase) { for (final PgSchema newSchema : newDatabase.getSchemas()) { if (oldDatabase.getSchema(newSchema.getName()) == null) { writer.println(); writer.println(newSchema.getCreationSQL()); } } } /** * Creates new extensions. * * @param writer writer the output should be written to * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void createNewExtensions(final PrintWriter writer, final PgDatabase oldDatabase, final PgDatabase newDatabase) { for (final PgExtension newExtension : newDatabase.getExtensions()) { if (oldDatabase.getExtension(newExtension.getName()) == null) { writer.println(); writer.println(newExtension.getCreationSQL()); } } } /** * Creates diff from comparison of two database schemas. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void diffDatabaseSchemas(final PrintWriter writer, final PgDiffArguments arguments, final PgDatabase oldDatabase, final PgDatabase newDatabase) { if (arguments.isAddTransaction()) { writer.println("START TRANSACTION;"); } if (oldDatabase.getComment() == null && newDatabase.getComment() != null || oldDatabase.getComment() != null && newDatabase.getComment() != null && !oldDatabase.getComment().equals(newDatabase.getComment())) { writer.println(); writer.print("COMMENT ON DATABASE current_database() IS "); writer.print(newDatabase.getComment()); writer.println(';'); } else if (oldDatabase.getComment() != null && newDatabase.getComment() == null) { writer.println(); writer.println("COMMENT ON DATABASE current_database() IS NULL;"); } dropOldSchemas(writer, oldDatabase, newDatabase); createNewSchemas(writer, oldDatabase, newDatabase); dropOldExtensions(writer, oldDatabase, newDatabase); createNewExtensions(writer, oldDatabase, newDatabase); updateSchemas(writer, arguments, oldDatabase, newDatabase); if (arguments.isAddTransaction()) { writer.println(); writer.println("COMMIT TRANSACTION;"); } if (arguments.isOutputIgnoredStatements()) { if (!oldDatabase.getIgnoredStatements().isEmpty()) { writer.println(); writer.print("/* "); writer.println(Resources.getString( "OriginalDatabaseIgnoredStatements")); for (final String statement : oldDatabase.getIgnoredStatements()) { writer.println(); writer.println(statement); } writer.println("*/"); } if (!newDatabase.getIgnoredStatements().isEmpty()) { writer.println(); writer.print("/* "); writer.println( Resources.getString("NewDatabaseIgnoredStatements")); for (final String statement : newDatabase.getIgnoredStatements()) { writer.println(); writer.println(statement); } writer.println("*/"); } } } /** * Drops old schemas that do not exist anymore. * * @param writer writer the output should be written to * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void dropOldSchemas(final PrintWriter writer, final PgDatabase oldDatabase, final PgDatabase newDatabase) { for (final PgSchema oldSchema : oldDatabase.getSchemas()) { if (newDatabase.getSchema(oldSchema.getName()) == null) { writer.println(); writer.println("DROP SCHEMA " +PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(oldSchema.getName()) + " CASCADE;"); } } } /** * Drops old extensions that do not exist anymore. * * @param writer writer the output should be written to * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void dropOldExtensions(final PrintWriter writer, final PgDatabase oldDatabase, final PgDatabase newDatabase) { for (final PgExtension oldExtension : oldDatabase.getExtensions()) { if (newDatabase.getExtension(oldExtension.getName()) == null) { writer.println(); writer.println("DROP EXTENSION " +PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(oldExtension.getName()) + " CASCADE;"); } } } /** * Updates objects in schemas. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldDatabase original database schema * @param newDatabase new database schema */ private static void updateSchemas(final PrintWriter writer, final PgDiffArguments arguments, final PgDatabase oldDatabase, final PgDatabase newDatabase) { final boolean setSearchPath = newDatabase.getSchemas().size() > 1 || !newDatabase.getSchemas().get(0).getName().equals("public"); for (final PgSchema newSchema : newDatabase.getSchemas()) { final SearchPathHelper searchPathHelper; if (setSearchPath) { searchPathHelper = new SearchPathHelper("SET search_path = " + PgDiffUtils.getQuotedName(newSchema.getName(), true) + ", pg_catalog;"); } else { searchPathHelper = new SearchPathHelper(null); } final PgSchema oldSchema = oldDatabase.getSchema(newSchema.getName()); if (oldSchema != null) { if (oldSchema.getComment() == null && newSchema.getComment() != null || oldSchema.getComment() != null && newSchema.getComment() != null && !oldSchema.getComment().equals( newSchema.getComment())) { writer.println(); writer.print("COMMENT ON SCHEMA "); writer.print( PgDiffUtils.getQuotedName(newSchema.getName())); writer.print(" IS "); writer.print(newSchema.getComment()); writer.println(';'); } else if (oldSchema.getComment() != null && newSchema.getComment() == null) { writer.println(); writer.print("COMMENT ON SCHEMA "); writer.print( PgDiffUtils.getQuotedName(newSchema.getName())); writer.println(" IS NULL;"); } } PgDiffTriggers.dropTriggers( writer, oldSchema, newSchema, searchPathHelper); PgDiffFunctions.dropFunctions( writer, arguments, oldSchema, newSchema, searchPathHelper); PgDiffViews.dropViews( writer, oldSchema, newSchema, searchPathHelper); PgDiffConstraints.dropConstraints( writer, oldSchema, newSchema, true, searchPathHelper); PgDiffConstraints.dropConstraints( writer, oldSchema, newSchema, false, searchPathHelper); PgDiffIndexes.dropIndexes( writer, oldSchema, newSchema, searchPathHelper); PgDiffTables.dropClusters( writer, oldSchema, newSchema, searchPathHelper); PgDiffTables.dropTables( writer, oldSchema, newSchema, searchPathHelper); PgDiffSequences.dropSequences( writer, oldSchema, newSchema, searchPathHelper); PgDiffPolicies.dropPolicies( writer, oldSchema, newSchema, searchPathHelper); PgDiffSequences.createSequences( writer, oldSchema, newSchema, searchPathHelper); PgDiffSequences.alterSequences( writer, arguments, oldSchema, newSchema, searchPathHelper); PgDiffTypes.alterTypes(writer, arguments, oldSchema, newSchema, searchPathHelper); PgDiffTypes.createTypes(writer, oldSchema, newSchema, searchPathHelper); PgDiffTypes.dropTypes(writer, oldSchema, newSchema, searchPathHelper); PgDiffTables.createTables( writer, oldSchema, newSchema, searchPathHelper); PgDiffTables.alterTables( writer, arguments, oldSchema, newSchema, searchPathHelper); PgDiffSequences.alterCreatedSequences( writer, oldSchema, newSchema, searchPathHelper); PgDiffFunctions.createFunctions( writer, arguments, oldSchema, newSchema, searchPathHelper); PgDiffConstraints.createConstraints( writer, oldSchema, newSchema, true, searchPathHelper); PgDiffConstraints.createConstraints( writer, oldSchema, newSchema, false, searchPathHelper); PgDiffIndexes.createIndexes( writer, oldSchema, newSchema, searchPathHelper); PgDiffTables.createClusters( writer, oldSchema, newSchema, searchPathHelper); PgDiffTriggers.createTriggers( writer, oldSchema, newSchema, searchPathHelper); PgDiffViews.createViews( writer, oldSchema, newSchema, searchPathHelper); PgDiffViews.alterViews( writer, oldSchema, newSchema, searchPathHelper); PgDiffPolicies.createPolicies( writer, oldSchema, newSchema, searchPathHelper); PgDiffPolicies.alterPolicies( writer, oldSchema, newSchema, searchPathHelper); PgDiffFunctions.alterComments( writer, oldSchema, newSchema, searchPathHelper); PgDiffConstraints.alterComments( writer, oldSchema, newSchema, searchPathHelper); PgDiffIndexes.alterComments( writer, oldSchema, newSchema, searchPathHelper); PgDiffTriggers.alterComments( writer, oldSchema, newSchema, searchPathHelper); } } /** * Creates a new instance of PgDiff. */ private PgDiff() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffArguments.java000077500000000000000000000255541316501242600256770ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import java.io.PrintWriter; import java.nio.charset.Charset; import java.util.SortedMap; /** * Contains parsed command line arguments. * * @author fordfrog */ public class PgDiffArguments { /** * Input file charset name. */ private String inCharsetName = "UTF-8"; /** * Path to the new dump file. */ private String newDumpFile; /** * Path to the original dump file. */ private String oldDumpFile; /** * Output file charset name. */ private String outCharsetName = "UTF-8"; /** * Whether DEFAULT ... should be added in case new column has NOT NULL * constraint. The default value is dropped later. */ private boolean addDefaults; /** * Whether to enclose all statements in transaction. */ private boolean addTransaction; /** * Whether to ignore whitespace while comparing content of functions. */ private boolean ignoreFunctionWhitespace; /** * Whether to ignore START WITH on SEQUENCEs. */ private boolean ignoreStartWith; /** * Whether to display apgdiff version. */ private boolean version; /** * Whether to output information about ignored statements. */ private boolean outputIgnoredStatements; /** * Whether to list supported charsets. */ private boolean listCharsets; /** * Whether Slony triggers should be ignored. */ private boolean ignoreSlonyTriggers; /** * Whether Schema creation should be ignored. */ private boolean ignoreSchemaCreation; /** * Drop If Exists and Create If Exists where possible */ private boolean useIfExists; /** * Setter for {@link #addDefaults}. * * @param addDefaults {@link #addDefaults} */ public void setAddDefaults(final boolean addDefaults) { this.addDefaults = addDefaults; } /** * Getter for {@link #addDefaults}. * * @return {@link #addDefaults} */ public boolean isAddDefaults() { return addDefaults; } /** * Setter for {@link #addTransaction}. * * @param addTransaction {@link #addTransaction} */ public void setAddTransaction(final boolean addTransaction) { this.addTransaction = addTransaction; } /** * Getter for {@link #addTransaction}. * * @return {@link #addTransaction} */ public boolean isAddTransaction() { return addTransaction; } /** * Setter for {@link #ignoreFunctionWhitespace}. * * @param ignoreFunctionWhitespace {@link #ignoreFunctionWhitespace} */ public void setIgnoreFunctionWhitespace( final boolean ignoreFunctionWhitespace) { this.ignoreFunctionWhitespace = ignoreFunctionWhitespace; } /** * Getter for {@link #ignoreFunctionWhitespace}. * * @return {@link #ignoreFunctionWhitespace} */ public boolean isIgnoreFunctionWhitespace() { return ignoreFunctionWhitespace; } /** * Setter for {@link #ignoreStartWith}. * * @param ignoreStartWith {@link #ignoreStartWith} */ public void setIgnoreStartWith(final boolean ignoreStartWith) { this.ignoreStartWith = ignoreStartWith; } /** * Getter for {@link #ignoreStartWith}. * * @return {@link #ignoreStartWith} */ public boolean isIgnoreStartWith() { return ignoreStartWith; } /** * Setter for {@link #newDumpFile}. * * @param newDumpFile {@link #newDumpFile} */ public void setNewDumpFile(final String newDumpFile) { this.newDumpFile = newDumpFile; } /** * Getter for {@link #newDumpFile}. * * @return {@link #newDumpFile} */ public String getNewDumpFile() { return newDumpFile; } /** * Setter for {@link #oldDumpFile}. * * @param oldDumpFile {@link #oldDumpFile} */ public void setOldDumpFile(final String oldDumpFile) { this.oldDumpFile = oldDumpFile; } /** * Getter for {@link #oldDumpFile}. * * @return {@link #oldDumpFile} */ public String getOldDumpFile() { return oldDumpFile; } /** * Getter for {@link #outputIgnoredStatements}. * * @return {@link #outputIgnoredStatements} */ public boolean isOutputIgnoredStatements() { return outputIgnoredStatements; } /** * Setter for {@link #outputIgnoredStatements}. * * @param outputIgnoredStatements {@link #outputIgnoredStatements} */ public void setOutputIgnoredStatements( final boolean outputIgnoredStatements) { this.outputIgnoredStatements = outputIgnoredStatements; } /** * Setter for {@link #version}. * * @param version {@link #version} */ public void setVersion(final boolean version) { this.version = version; } /** * Getter for {@link #version}. * * @return {@link #version} */ public boolean isVersion() { return version; } /** * Parses command line arguments or outputs instructions. * * @param writer writer to be used for info output * @param args array of arguments * * @return true if arguments were parsed and execution can continue, * otherwise false */ @SuppressWarnings("AssignmentToForLoopParameter") public boolean parse(final PrintWriter writer, final String[] args) { boolean success = true; final int argsLength; if (args.length >= 2) { argsLength = args.length - 2; } else { argsLength = args.length; } for (int i = 0; i < argsLength; i++) { if ("--add-defaults".equals(args[i])) { setAddDefaults(true); } else if ("--add-transaction".equals(args[i])) { setAddTransaction(true); } else if ("--ignore-function-whitespace".equals(args[i])) { setIgnoreFunctionWhitespace(true); } else if ("--ignore-slony-triggers".equals(args[i])) { setIgnoreSlonyTriggers(true); } else if ("--ignore-start-with".equals(args[i])) { setIgnoreStartWith(true); } else if ("--ignore-schema-creation".equals(args[i])) { setIgnoreSchemaCreation(true); } else if ("--in-charset-name".equals(args[i])) { setInCharsetName(args[i + 1]); i++; } else if ("--list-charsets".equals(args[i])) { setListCharsets(true); } else if ("--out-charset-name".equals(args[i])) { setOutCharsetName(args[i + 1]); i++; } else if ("--output-ignored-statements".equals(args[i])) { setOutputIgnoredStatements(true); } else if ("--version".equals(args[i])) { setVersion(true); } else if ("--drop-if-exists".equals(args[i])) { PgDiffUtils.setUseExists(true); } else { writer.print(Resources.getString("ErrorUnknownOption")); writer.print(": "); writer.println(args[i]); success = false; break; } } if (args.length == 1 && isVersion()) { printVersion(writer); success = false; } else if (args.length == 1 && isListCharsets()) { listCharsets(writer); success = false; } else if (args.length < 2) { printUsage(writer); success = false; } else if (success) { setOldDumpFile(args[args.length - 2]); setNewDumpFile(args[args.length - 1]); } return success; } /** * Prints program usage. * * @param writer writer to print the usage to */ private void printUsage(final PrintWriter writer) { writer.println( Resources.getString("UsageHelp").replace("${tab}", "\t")); } /** * Prints program version. * * @param writer writer to print the usage to */ private void printVersion(final PrintWriter writer) { writer.print(Resources.getString("Version")); writer.print(": "); writer.println(Resources.getString("VersionNumber")); } /** * Getter for {@link #inCharsetName}. * * @return {@link #inCharsetName} */ public String getInCharsetName() { return inCharsetName; } /** * Setter for {@link #inCharsetName}. * * @param inCharsetName {@link #inCharsetName} */ public void setInCharsetName(final String inCharsetName) { this.inCharsetName = inCharsetName; } /** * Getter for {@link #outCharsetName}. * * @return {@link #outCharsetName} */ public String getOutCharsetName() { return outCharsetName; } /** * Setter for {@link #outCharsetName}. * * @param outCharsetName {@link #outCharsetName} */ public void setOutCharsetName(final String outCharsetName) { this.outCharsetName = outCharsetName; } /** * Getter for {@link #listCharsets}. * * @return {@link #listCharsets} */ public boolean isListCharsets() { return listCharsets; } /** * Setter for {@link #listCharsets}. * * @param listCharsets {@link #listCharsets} */ public void setListCharsets(final boolean listCharsets) { this.listCharsets = listCharsets; } /** * Lists supported charsets. * * @param writer writer */ private void listCharsets(final PrintWriter writer) { final SortedMap charsets = Charset.availableCharsets(); for (final String name : charsets.keySet()) { writer.println(name); } } /** * Getter for {@link #ignoreSlonyTriggers}. * * @return {@link #ignoreSlonyTriggers} */ public boolean isIgnoreSlonyTriggers() { return ignoreSlonyTriggers; } /** * Setter for {@link #ignoreSlonyTriggers}. * * @param ignoreSlonyTriggers {@link #ignoreSlonyTriggers} */ public void setIgnoreSlonyTriggers(final boolean ignoreSlonyTriggers) { this.ignoreSlonyTriggers = ignoreSlonyTriggers; } /** * Getter for {@link #ignoreSchemaCreation}. * * @return {@link #ignoreSchemaCreation} */ public boolean isIgnoreSchemaCreation() { return this.ignoreSchemaCreation; } /** * Setter for {@link #ignoreSchemaCreation}. * * @param ignoreSchemaCreation {@link #ignoreSchemaCreation} */ public void setIgnoreSchemaCreation(final boolean ignoreSchemaCreation) { this.ignoreSchemaCreation = ignoreSchemaCreation; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffConstraints.java000077500000000000000000000223351316501242600262330ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgConstraint; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * Diffs constraints. * * @author fordfrog */ public class PgDiffConstraints { /** * Outputs statements for creation of new constraints. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param primaryKey determines whether primary keys should be * processed or any other constraints should be * processed * @param searchPathHelper search path helper */ public static void createConstraints(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final boolean primaryKey, final SearchPathHelper searchPathHelper ) { for (final PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } // Add new constraints for (final PgConstraint constraint : getNewConstraints(oldTable, newTable, primaryKey)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(constraint.getCreationSQL()); } } } /** * Outputs statements for dropping non-existent or modified constraints. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param primaryKey determines whether primary keys should be * processed or any other constraints should be * processed * @param searchPathHelper search path helper */ public static void dropConstraints(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final boolean primaryKey, final SearchPathHelper searchPathHelper ) { for (final PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } // Drop constraints that no more exist or are modified for (final PgConstraint constraint : getDropConstraints(oldTable, newTable, primaryKey)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(constraint.getDropSQL()); } } } /** * Returns list of constraints that should be dropped. * * @param oldTable original table or null * @param newTable new table or null * @param primaryKey determines whether primary keys should be processed or * any other constraints should be processed * * @return list of constraints that should be dropped * * @todo Constraints that are depending on a removed field should not be * added to drop because they are already removed. */ private static List getDropConstraints(final PgTable oldTable, final PgTable newTable, final boolean primaryKey) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null && oldTable != null) { for (final PgConstraint constraint : oldTable.getConstraints()) { if (constraint.isPrimaryKeyConstraint() == primaryKey && (!newTable.containsConstraint(constraint.getName()) || !newTable.getConstraint(constraint.getName()).equals( constraint))) { list.add(constraint); } } } return list; } /** * Returns list of constraints that should be added. * * @param oldTable original table * @param newTable new table * @param primaryKey determines whether primary keys should be processed or * any other constraints should be processed * * @return list of constraints that should be added */ private static List getNewConstraints(final PgTable oldTable, final PgTable newTable, final boolean primaryKey) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null) { if (oldTable == null) { for (final PgConstraint constraint : newTable.getConstraints()) { if (constraint.isPrimaryKeyConstraint() == primaryKey) { list.add(constraint); } } } else { for (final PgConstraint constraint : newTable.getConstraints()) { if ((constraint.isPrimaryKeyConstraint() == primaryKey) && (!oldTable.containsConstraint( constraint.getName()) || !oldTable.getConstraint(constraint.getName()). equals(constraint))) { list.add(constraint); } } } } return list; } /** * Outputs statements for constraint comments that have changed. * * @param writer writer * @param oldSchema old schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterComments(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (PgTable oldTable : oldSchema.getTables()) { final PgTable newTable = newSchema.getTable(oldTable.getName()); if (newTable == null) { continue; } for (final PgConstraint oldConstraint : oldTable.getConstraints()) { final PgConstraint newConstraint = newTable.getConstraint(oldConstraint.getName()); if (newConstraint == null) { continue; } if (oldConstraint.getComment() == null && newConstraint.getComment() != null || oldConstraint.getComment() != null && newConstraint.getComment() != null && !oldConstraint.getComment().equals( newConstraint.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON "); if (newConstraint.isPrimaryKeyConstraint()) { writer.print("INDEX "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getName())); } else { writer.print("CONSTRAINT "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getName())); writer.print(" ON "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getTableName())); } writer.print(" IS "); writer.print(newConstraint.getComment()); writer.println(';'); } else if (oldConstraint.getComment() != null && newConstraint.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON "); if (newConstraint.isPrimaryKeyConstraint()) { writer.print("INDEX "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getName())); } else { writer.print("CONSTRAINT "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getName())); writer.print(" ON "); writer.print(PgDiffUtils.getQuotedName( newConstraint.getTableName())); } writer.println(" IS NULL;"); } } } } /** * Creates a new instance of PgDiffConstraints. */ private PgDiffConstraints() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffFunctions.java000077500000000000000000000125651316501242600257000ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgFunction; import cz.startnet.utils.pgdiff.schema.PgSchema; import java.io.PrintWriter; /** * Diffs functions. * * @author fordfrog */ public class PgDiffFunctions { /** * Outputs statements for new or modified functions. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createFunctions(final PrintWriter writer, final PgDiffArguments arguments, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { // Add new functions and replace modified functions for (final PgFunction newFunction : newSchema.getFunctions()) { final PgFunction oldFunction; if (oldSchema == null) { oldFunction = null; } else { oldFunction = oldSchema.getFunction(newFunction.getSignature()); } if ((oldFunction == null) || !newFunction.equals( oldFunction, arguments.isIgnoreFunctionWhitespace())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(newFunction.getCreationSQL()); } } } /** * Outputs statements for dropping of functions that exist no more. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropFunctions(final PrintWriter writer, final PgDiffArguments arguments, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } // Drop functions that exist no more for (final PgFunction oldFunction : oldSchema.getFunctions()) { if (!newSchema.containsFunction(oldFunction.getSignature())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(oldFunction.getDropSQL()); } } } /** * Outputs statements for function comments that have changed. * * @param writer writer * @param oldSchema old schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterComments(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (final PgFunction oldfunction : oldSchema.getFunctions()) { final PgFunction newFunction = newSchema.getFunction(oldfunction.getSignature()); if (newFunction == null) { continue; } if (oldfunction.getComment() == null && newFunction.getComment() != null || oldfunction.getComment() != null && newFunction.getComment() != null && !oldfunction.getComment().equals( newFunction.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON FUNCTION "); writer.print(PgDiffUtils.getQuotedName(newFunction.getName())); writer.print('('); boolean addComma = false; for (final PgFunction.Argument argument : newFunction.getArguments()) { if (addComma) { writer.print(", "); } else { addComma = true; } writer.print(argument.getDeclaration(false)); } writer.print(") IS "); writer.print(newFunction.getComment()); writer.println(';'); } else if (oldfunction.getComment() != null && newFunction.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON FUNCTION "); writer.print(PgDiffUtils.getQuotedName(newFunction.getName())); writer.print('('); boolean addComma = false; for (final PgFunction.Argument argument : newFunction.getArguments()) { if (addComma) { writer.print(", "); } else { addComma = true; } writer.print(argument.getDeclaration(false)); } writer.println(") IS NULL;"); } } } /** * Creates a new instance of PgDiffFunctions. */ private PgDiffFunctions() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffIndexes.java000077500000000000000000000150761316501242600253270ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgIndex; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * Diffs indexes. * * @author fordfrog */ public class PgDiffIndexes { /** * Outputs statements for creation of new indexes. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createIndexes(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final String newTableName = newTable.getName(); // Add new indexes if (oldSchema == null) { for (PgIndex index : newTable.getIndexes()) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(index.getCreationSQL()); } } else { for (PgIndex index : getNewIndexes( oldSchema.getTable(newTableName), newTable)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(index.getCreationSQL()); } } } } /** * Outputs statements for dropping indexes that exist no more. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropIndexes(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final String newTableName = newTable.getName(); final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTableName); } // Drop indexes that do not exist in new schema or are modified for (final PgIndex index : getDropIndexes(oldTable, newTable)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(index.getDropSQL()); } } } /** * Returns list of indexes that should be dropped. * * @param oldTable original table * @param newTable new table * * @return list of indexes that should be dropped * * @todo Indexes that are depending on a removed field should not be added * to drop because they are already removed. */ private static List getDropIndexes(final PgTable oldTable, final PgTable newTable) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null && oldTable != null) { for (final PgIndex index : oldTable.getIndexes()) { if (!newTable.containsIndex(index.getName()) || !newTable.getIndex(index.getName()).equals(index)) { list.add(index); } } } return list; } /** * Returns list of indexes that should be added. * * @param oldTable original table * @param newTable new table * * @return list of indexes that should be added */ private static List getNewIndexes(final PgTable oldTable, final PgTable newTable) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null) { if (oldTable == null) { for (final PgIndex index : newTable.getIndexes()) { list.add(index); } } else { for (final PgIndex index : newTable.getIndexes()) { if (!oldTable.containsIndex(index.getName()) || !oldTable.getIndex(index.getName()). equals(index)) { list.add(index); } } } } return list; } /** * Outputs statements for index comments that have changed. * * @param writer writer * @param oldSchema old schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterComments(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (final PgIndex oldIndex : oldSchema.getIndexes()) { final PgIndex newIndex = newSchema.getIndex(oldIndex.getName()); if (newIndex == null) { continue; } if (oldIndex.getComment() == null && newIndex.getComment() != null || oldIndex.getComment() != null && newIndex.getComment() != null && !oldIndex.getComment().equals( newIndex.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON INDEX "); writer.print( PgDiffUtils.getQuotedName(newIndex.getName())); writer.print(" IS "); writer.print(newIndex.getComment()); writer.println(';'); } else if (oldIndex.getComment() != null && newIndex.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON INDEX "); writer.print( PgDiffUtils.getQuotedName(newIndex.getName())); writer.println(" IS NULL;"); } } } /** * Creates a new instance of PgDiffIndexes. */ private PgDiffIndexes() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffPolicies.java000066400000000000000000000167021316501242600254710ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.*; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Iterator; public class PgDiffPolicies { public static void createPolicies(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final String newTableName = newTable.getName(); final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTableName); } for (final PgPolicy policy : newTable.getPolicies()) { PgPolicy oldPolicy = oldTable != null?oldTable.getPolicy(policy.getName()):null; if(oldPolicy == null){ searchPathHelper.outputSearchPath(writer); createPolicySQL(writer, policy); } } } } public static void alterPolicies(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final String newTableName = newTable.getName(); if (oldSchema != null) { final PgTable oldTable = oldSchema.getTable(newTableName); if (oldTable != null){ for (final PgPolicy policy : oldTable.getPolicies()) { PgPolicy newPolicy = newTable.getPolicy(policy.getName()); if(newPolicy != null){ // ALTER POLICY doesn't support changing command(ALL, // SELECT..) so we drop it and create it String newCommand = newPolicy.getCommand(); String oldCommand = policy.getCommand(); if(newCommand != null && oldCommand != null && !newCommand.equals(oldCommand)){ searchPathHelper.outputSearchPath(writer); dropPolicySQL(writer, newPolicy); createPolicySQL(writer, newPolicy); } else if ( (policy.getUsing() == null && newPolicy.getUsing() != null) ||(policy.getUsing() != null && newPolicy.getUsing() == null) ||(policy.getUsing() != null && newPolicy.getUsing() != null && !policy.getUsing().equals(newPolicy.getUsing())) ){ searchPathHelper.outputSearchPath(writer); alterPolicySQL(writer, newPolicy); } else if ( (policy.getWithCheck() == null && newPolicy.getWithCheck() != null) ||(policy.getWithCheck() != null && newPolicy.getWithCheck() == null) ||(policy.getWithCheck() != null && newPolicy.getWithCheck() != null && !policy.getWithCheck().equals(newPolicy.getWithCheck())) ){ searchPathHelper.outputSearchPath(writer); alterPolicySQL(writer, newPolicy); } else { List tempOldRoles = new ArrayList(policy.getRoles()); boolean equalRoles = newPolicy.getRoles().containsAll(policy.getRoles()) && policy.getRoles().containsAll(newPolicy.getRoles()); if(!equalRoles){ searchPathHelper.outputSearchPath(writer); alterPolicySQL(writer, newPolicy); } } } } } } } } public static void dropPolicies(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final String newTableName = newTable.getName(); if (oldSchema != null) { final PgTable oldTable = oldSchema.getTable(newTableName); if (oldTable != null){ for (final PgPolicy policy : oldTable.getPolicies()) { if(newTable.getPolicy(policy.getName()) == null){ searchPathHelper.outputSearchPath(writer); dropPolicySQL(writer, policy); } } } } } } private static void createPolicySQL(final PrintWriter writer, final PgPolicy policy){ writer.print("CREATE POLICY " + PgDiffUtils.getQuotedName(policy.getName()) + " ON " + PgDiffUtils.getQuotedName(policy.getTableName())); writer.print(" FOR " + policy.getCommand()); String roles = ""; writer.print(" TO "); for (Iterator iterator = policy.getRoles().iterator(); iterator.hasNext();) roles += iterator.next() + (iterator.hasNext()? ", " : ""); writer.print(roles); if (policy.getUsing() != null){ writer.println(); writer.println("USING ("); writer.print(" "); writer.println(policy.getUsing()); writer.print(")"); } if (policy.getWithCheck() != null){ writer.println(); writer.println("WITH CHECK ("); writer.print(" "); writer.println(policy.getWithCheck()); writer.print(")"); } writer.println(";"); } private static void alterPolicySQL(final PrintWriter writer, final PgPolicy policy){ writer.print("ALTER POLICY " + PgDiffUtils.getQuotedName(policy.getName()) + " ON " + PgDiffUtils.getQuotedName(policy.getTableName())); String roles = ""; writer.print(" TO "); for (Iterator iterator = policy.getRoles().iterator(); iterator.hasNext();) roles += iterator.next() + (iterator.hasNext()? ", " : ""); writer.print(roles); if (policy.getUsing() != null){ writer.println(); writer.println("USING ("); writer.print(" "); writer.println(policy.getUsing()); writer.print(")"); } if (policy.getWithCheck() != null){ writer.println(); writer.println("WITH CHECK ("); writer.print(" "); writer.println(policy.getWithCheck()); writer.print(")"); } writer.println(";"); } private static void dropPolicySQL(final PrintWriter writer, final PgPolicy policy){ writer.println("DROP POLICY " + PgDiffUtils.getQuotedName(policy.getName()) + " ON " + PgDiffUtils.getQuotedName(policy.getTableName()) + ";"); } private PgDiffPolicies() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffSequences.java000077500000000000000000000332311316501242600256540ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgSequence; import cz.startnet.utils.pgdiff.schema.PgSequencePrivilege; import java.io.PrintWriter; /** * Diffs sequences. * * @author fordfrog */ public class PgDiffSequences { /** * Outputs statements for creation of new sequences. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createSequences(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { // Add new sequences for (final PgSequence sequence : newSchema.getSequences()) { if (oldSchema == null || !oldSchema.containsSequence(sequence.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(sequence.getCreationSQL()); for (PgSequencePrivilege sequencePrivilege : sequence .getPrivileges()) { writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(sequence.getName()) + " FROM " + sequencePrivilege.getRoleName() + ";"); if (!"".equals(sequencePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + sequencePrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(sequence.getName()) + " TO " + sequencePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(sequencePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + sequencePrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(sequence.getName()) + " TO " + sequencePrivilege.getRoleName() + ";"); } } } } } /** * Outputs statements for altering of new sequences. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterCreatedSequences(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { // Alter created sequences for (final PgSequence sequence : newSchema.getSequences()) { if ((oldSchema == null || !oldSchema.containsSequence(sequence.getName())) && sequence.getOwnedBy() != null && !sequence.getOwnedBy().isEmpty()) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(sequence.getOwnedBySQL()); } } } /** * Outputs statements for dropping of sequences that do not exist anymore. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropSequences(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } // Drop sequences that do not exist in new schema for (final PgSequence sequence : oldSchema.getSequences()) { if (!newSchema.containsSequence(sequence.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(sequence.getDropSQL()); } } } /** * Outputs statement for modified sequences. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterSequences(final PrintWriter writer, final PgDiffArguments arguments, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } final StringBuilder sbSQL = new StringBuilder(100); for (final PgSequence newSequence : newSchema.getSequences()) { final PgSequence oldSequence = oldSchema.getSequence(newSequence.getName()); if (oldSequence == null) { continue; } sbSQL.setLength(0); final String oldIncrement = oldSequence.getIncrement(); final String newIncrement = newSequence.getIncrement(); if (newIncrement != null && !newIncrement.equals(oldIncrement)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tINCREMENT BY "); sbSQL.append(newIncrement); } final String oldMinValue = oldSequence.getMinValue(); final String newMinValue = newSequence.getMinValue(); if (newMinValue == null && oldMinValue != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tNO MINVALUE"); } else if (newMinValue != null && !newMinValue.equals(oldMinValue)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tMINVALUE "); sbSQL.append(newMinValue); } final String oldMaxValue = oldSequence.getMaxValue(); final String newMaxValue = newSequence.getMaxValue(); if (newMaxValue == null && oldMaxValue != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tNO MAXVALUE"); } else if (newMaxValue != null && !newMaxValue.equals(oldMaxValue)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tMAXVALUE "); sbSQL.append(newMaxValue); } if (!arguments.isIgnoreStartWith()) { final String oldStart = oldSequence.getStartWith(); final String newStart = newSequence.getStartWith(); if (newStart != null && !newStart.equals(oldStart)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tRESTART WITH "); sbSQL.append(newStart); } } final String oldCache = oldSequence.getCache(); final String newCache = newSequence.getCache(); if (newCache != null && !newCache.equals(oldCache)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tCACHE "); sbSQL.append(newCache); } final boolean oldCycle = oldSequence.isCycle(); final boolean newCycle = newSequence.isCycle(); if (oldCycle && !newCycle) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tNO CYCLE"); } else if (!oldCycle && newCycle) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tCYCLE"); } final String oldOwnedBy = oldSequence.getOwnedBy(); final String newOwnedBy = newSequence.getOwnedBy(); if (newOwnedBy != null && !newOwnedBy.equals(oldOwnedBy)) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tOWNED BY "); sbSQL.append(newOwnedBy); } if (sbSQL.length() > 0) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName())); writer.print(sbSQL.toString()); writer.println(';'); } if (oldSequence.getComment() == null && newSequence.getComment() != null || oldSequence.getComment() != null && newSequence.getComment() != null && !oldSequence.getComment().equals( newSequence.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON SEQUENCE "); writer.print(PgDiffUtils.getQuotedName(newSequence.getName())); writer.print(" IS "); writer.print(newSequence.getComment()); writer.println(';'); } else if (oldSequence.getComment() != null && newSequence.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON SEQUENCE "); writer.print(newSequence.getName()); writer.println(" IS NULL;"); } alterPrivileges(writer, oldSequence, newSequence, searchPathHelper); } } private static void alterPrivileges(final PrintWriter writer, final PgSequence oldSequence, final PgSequence newSequence, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; for (PgSequencePrivilege oldSequencePrivilege : oldSequence .getPrivileges()) { PgSequencePrivilege newSequencePrivilege = newSequence .getPrivilege(oldSequencePrivilege.getRoleName()); if (newSequencePrivilege == null) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON SEQUENCE " + PgDiffUtils.getQuotedName(oldSequence.getName()) + " FROM " + oldSequencePrivilege.getRoleName() + ";"); } else if (!oldSequencePrivilege.isSimilar(newSequencePrivilege)) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " FROM " + newSequencePrivilege.getRoleName() + ";"); if (!"".equals(newSequencePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newSequencePrivilege.getPrivilegesSQL(true) + " ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " TO " + newSequencePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newSequencePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newSequencePrivilege.getPrivilegesSQL(false) + " ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " TO " + newSequencePrivilege.getRoleName() + ";"); } } // else similar privilege will not be updated } for (PgSequencePrivilege newSequencePrivilege : newSequence .getPrivileges()) { PgSequencePrivilege oldSequencePrivilege = oldSequence .getPrivilege(newSequencePrivilege.getRoleName()); if (oldSequencePrivilege == null) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " FROM " + newSequencePrivilege.getRoleName() + ";"); if (!"".equals(newSequencePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newSequencePrivilege.getPrivilegesSQL(true) + " ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " TO " + newSequencePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newSequencePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newSequencePrivilege.getPrivilegesSQL(false) + " ON SEQUENCE " + PgDiffUtils.getQuotedName(newSequence.getName()) + " TO " + newSequencePrivilege.getRoleName() + ";"); } } } } /** * Creates a new instance of PgDiffSequences. */ private PgDiffSequences() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java000077500000000000000000001210031316501242600251260ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgColumnPrivilege; import cz.startnet.utils.pgdiff.schema.PgColumnUtils; import cz.startnet.utils.pgdiff.schema.PgInheritedColumn; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Diffs tables. * * @author fordfrog */ public class PgDiffTables { /** * Outputs statements for creation of clusters. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropClusters(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } final String oldCluster; if (oldTable == null) { oldCluster = null; } else { oldCluster = oldTable.getClusterIndexName(); } final String newCluster = newTable.getClusterIndexName(); if (oldCluster != null && newCluster == null && newTable.containsIndex(oldCluster)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" SET WITHOUT CLUSTER;"); } } } /** * Outputs statements for dropping of clusters. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createClusters(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } final String oldCluster; if (oldTable == null) { oldCluster = null; } else { oldCluster = oldTable.getClusterIndexName(); } final String newCluster = newTable.getClusterIndexName(); if ((oldCluster == null && newCluster != null) || (oldCluster != null && newCluster != null && newCluster.compareTo(oldCluster) != 0)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print(" CLUSTER ON "); writer.print(PgDiffUtils.getQuotedName(newCluster)); writer.println(';'); } } } /** * Outputs statements for altering tables. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterTables(final PrintWriter writer, final PgDiffArguments arguments, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable newTable : newSchema.getTables()) { if (oldSchema == null || !oldSchema.containsTable(newTable.getName())) { continue; } final PgTable oldTable = oldSchema.getTable(newTable.getName()); updateTableColumns( writer, arguments, oldTable, newTable, searchPathHelper); checkWithOIDS(writer, oldTable, newTable, searchPathHelper); checkInherits(writer, oldTable, newTable, newSchema, searchPathHelper); addInheritedColumnDefaults(writer, arguments, oldTable, newTable, searchPathHelper); checkTablespace(writer, oldTable, newTable, searchPathHelper); addAlterStatistics(writer, oldTable, newTable, searchPathHelper); addAlterStorage(writer, oldTable, newTable, searchPathHelper); alterComments(writer, oldTable, newTable, searchPathHelper); alterOwnerTo(writer, oldTable, newTable, searchPathHelper); alterPrivileges(writer, oldTable, newTable, searchPathHelper); alterPrivilegesColumns(writer, oldTable, newTable, searchPathHelper); alterRLS(writer, oldTable, newTable, searchPathHelper); } } /** * Generate the needed alter table xxx set statistics when needed. * * @param writer writer the output should be written to * @param oldTable original table * @param newTable new table * @param searchPathHelper search path helper */ private static void addAlterStatistics(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { @SuppressWarnings("CollectionWithoutInitialCapacity") final Map stats = new HashMap(); for (final PgColumn newColumn : newTable.getColumns()) { final PgColumn oldColumn = oldTable.getColumn(newColumn.getName()); if (oldColumn != null) { final Integer oldStat = oldColumn.getStatistics(); final Integer newStat = newColumn.getStatistics(); Integer newStatValue = null; if (newStat != null && (oldStat == null || !newStat.equals(oldStat))) { newStatValue = newStat; } else if (oldStat != null && newStat == null) { newStatValue = Integer.valueOf(-1); } if (newStatValue != null) { stats.put(newColumn.getName(), newStatValue); } } } for (final Map.Entry entry : stats.entrySet()) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE ONLY "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(entry.getKey())); writer.print(" SET STATISTICS "); writer.print(entry.getValue()); writer.println(';'); } } /** * Generate the needed alter table xxx set storage when needed. * * @param writer writer the output should be written to * @param oldTable original table * @param newTable new table * @param searchPathHelper search path helper */ private static void addAlterStorage(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { for (final PgColumn newColumn : newTable.getColumns()) { final PgColumn oldColumn = oldTable.getColumn(newColumn.getName()); final String oldStorage = (oldColumn == null || oldColumn.getStorage() == null || oldColumn.getStorage().isEmpty()) ? null : oldColumn.getStorage(); final String newStorage = (newColumn.getStorage() == null || newColumn.getStorage().isEmpty()) ? null : newColumn.getStorage(); if (newStorage == null && oldStorage != null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(MessageFormat.format(Resources.getString( "WarningUnableToDetermineStorageType"), newTable.getName() + '.' + newColumn.getName())); continue; } if (newStorage == null || newStorage.equalsIgnoreCase(oldStorage)) { continue; } searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE ONLY "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(newColumn.getName())); writer.print(" SET STORAGE "); writer.print(newStorage); writer.print(';'); } } /** * Adds statements for creation of new columns to the list of statements. * * @param statements list of statements * @param arguments object containing arguments settings * @param oldTable original table * @param newTable new table * @param dropDefaultsColumns list for storing columns for which default * value should be dropped */ private static void addCreateTableColumns(final List statements, final PgDiffArguments arguments, final PgTable oldTable, final PgTable newTable, final List dropDefaultsColumns) { for (final PgColumn column : newTable.getColumns()) { if (!oldTable.containsColumn(column.getName())) { statements.add("\tADD COLUMN "+ PgDiffUtils.getCreateIfNotExists() + column.getFullDefinition(arguments.isAddDefaults())); if (arguments.isAddDefaults() && !column.getNullValue() && (column.getDefaultValue() == null || column.getDefaultValue().isEmpty())) { dropDefaultsColumns.add(column); } } } } /** * Adds statements for removal of columns to the list of statements. * * @param statements list of statements * @param oldTable original table * @param newTable new table */ private static void addDropTableColumns(final List statements, final PgTable oldTable, final PgTable newTable) { for (final PgColumn column : oldTable.getColumns()) { if (!newTable.containsColumn(column.getName())) { statements.add("\tDROP COLUMN " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(column.getName())); } } } /** * Adds statements for modification of columns to the list of statements. * * @param statements list of statements * @param arguments object containing arguments settings * @param oldTable original table * @param newTable new table * @param dropDefaultsColumns list for storing columns for which default * value should be dropped */ private static void addModifyTableColumns(final List statements, final PgDiffArguments arguments, final PgTable oldTable, final PgTable newTable, final List dropDefaultsColumns) { for (final PgColumn newColumn : newTable.getColumns()) { if (!oldTable.containsColumn(newColumn.getName())) { continue; } final PgColumn oldColumn = oldTable.getColumn(newColumn.getName()); final String newColumnName = PgDiffUtils.getQuotedName(newColumn.getName()); if (!oldColumn.getType().equals(newColumn.getType())) { statements.add("\tALTER COLUMN " + newColumnName + " TYPE " + newColumn.getType() + " USING " + newColumnName + "::" + newColumn.getType() + " /* " + MessageFormat.format( Resources.getString("TypeParameterChange"), newTable.getName(), oldColumn.getType(), newColumn.getType()) + " */"); } final String oldDefault = (oldColumn.getDefaultValue() == null) ? "" : oldColumn.getDefaultValue(); final String newDefault = (newColumn.getDefaultValue() == null) ? "" : newColumn.getDefaultValue(); if (!oldDefault.equals(newDefault)) { if (newDefault.length() == 0) { statements.add("\tALTER COLUMN " + newColumnName + " DROP DEFAULT"); } else { statements.add("\tALTER COLUMN " + newColumnName + " SET DEFAULT " + newDefault); } } if (oldColumn.getNullValue() != newColumn.getNullValue()) { if (newColumn.getNullValue()) { statements.add("\tALTER COLUMN " + newColumnName + " DROP NOT NULL"); } else { if (arguments.isAddDefaults()) { final String defaultValue = PgColumnUtils.getDefaultValue( newColumn.getType()); if (defaultValue != null) { statements.add("\tALTER COLUMN " + newColumnName + " SET DEFAULT " + defaultValue); dropDefaultsColumns.add(newColumn); } } statements.add("\tALTER COLUMN " + newColumnName + " SET NOT NULL"); } } } } /** * Checks whether there is a discrepancy in INHERITS for original and new * table. * * @param writer writer the output should be written to * @param oldTable original table * @param newTable new table * @param newSchema new schema * @param searchPathHelper search path helper */ private static void checkInherits(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final Pair inheritPairO : oldTable.getInherits()) { final String schemaName = inheritPairO.getL(); final String tableName = inheritPairO.getR(); boolean isFound = false; for (final Pair inheritPairN : newTable.getInherits()) { if(schemaName.equals(inheritPairN.getL()) && tableName.equals(inheritPairN.getR())) { isFound = true; break; } } if (!isFound) { String inheritTableName = null; if(newSchema.getName().equals(schemaName)){ inheritTableName = PgDiffUtils.getQuotedName(tableName); } else { inheritTableName = String.format("%s.%s",PgDiffUtils.getQuotedName(schemaName),PgDiffUtils.getQuotedName(tableName)); } searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); writer.println("\tNO INHERIT " + inheritTableName + ';'); } } for (final Pair inheritPairN : newTable.getInherits()) { final String schemaName = inheritPairN.getL(); final String tableName = inheritPairN.getR(); boolean isFound = false; for (final Pair inheritPairO : oldTable.getInherits()) { if(schemaName.equals(inheritPairO.getL()) && tableName.equals(inheritPairO.getR())) { isFound = true; break; } } if (!isFound) { String inheritTableName = null; if(newSchema.getName().equals(schemaName)){ inheritTableName = PgDiffUtils.getQuotedName(tableName); } else { inheritTableName = String.format("%s.%s",PgDiffUtils.getQuotedName(schemaName),PgDiffUtils.getQuotedName(tableName)); } searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); writer.println("\tINHERIT " + inheritTableName + ';'); } } } /** * Outputs statements for defaults of tables who's column belongs to * an inherited table. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldTable original table * @param newTable new table * @param searchPathHelper search path helper */ private static void addInheritedColumnDefaults(final PrintWriter writer, final PgDiffArguments arguments, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { for (final PgInheritedColumn newColumn : newTable.getInheritedColumns()) { if (!oldTable.containsInheritedColumn(newColumn.getInheritedColumn().getName())) { continue; } final PgInheritedColumn oldColumn = oldTable.getInheritedColumn(newColumn.getInheritedColumn().getName()); final String newColumnName = PgDiffUtils.getQuotedName(newColumn.getInheritedColumn().getName()); final String oldDefault = (oldColumn.getDefaultValue() == null) ? "" : oldColumn.getDefaultValue(); final String newDefault = (newColumn.getDefaultValue() == null) ? "" : newColumn.getDefaultValue(); if (!oldDefault.equals(newDefault)) { writer.println(); writer.print("ALTER TABLE ONLY "); writer.println(PgDiffUtils.getQuotedName(newTable.getName())); writer.print("\tALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(newColumn.getInheritedColumn().getName())); if (newDefault.length() == 0) { writer.print(" DROP DEFAULT"); } else { writer.print(" SET DEFAULT "); writer.print(newDefault); } writer.println(";"); } } } /** * Checks whether OIDS are dropped from the new table. There is no way to * add OIDS to existing table so we do not create SQL statement for addition * of OIDS but we issue warning. * * @param writer writer the output should be written to * @param oldTable original table * @param newTable new table * @param searchPathHelper search path helper */ private static void checkWithOIDS(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { if (oldTable.getWith() == null && newTable.getWith() == null || oldTable.getWith() != null && oldTable.getWith().equals(newTable.getWith())) { return; } searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); if (newTable.getWith() == null || "OIDS=false".equalsIgnoreCase(newTable.getWith())) { writer.println("\tSET WITHOUT OIDS;"); } else if ("OIDS".equalsIgnoreCase(newTable.getWith()) || "OIDS=true".equalsIgnoreCase(newTable.getWith())) { writer.println("\tSET WITH OIDS;"); } else { writer.println("\tSET " + newTable.getWith() + ";"); } } /** * Checks tablespace modification. * * @param writer writer * @param oldTable old table * @param newTable new table * @param searchPathHelper search path helper */ private static void checkTablespace(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { if (oldTable.getTablespace() == null && newTable.getTablespace() == null || oldTable.getTablespace() != null && oldTable.getTablespace().equals(newTable.getTablespace())) { return; } searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); writer.println("\tTABLESPACE " + newTable.getTablespace() + ';'); } /** * Outputs statements for creation of new tables. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createTables(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgTable table : newSchema.getTables()) { if (oldSchema == null || !oldSchema.containsTable(table.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(table.getCreationSQL(newSchema)); writer.println(); if (table.getOwnerTo() != null) { writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " OWNER TO " + table.getOwnerTo() + ";"); } for (PgRelationPrivilege tablePrivilege : table.getPrivileges()) { writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " FROM " + tablePrivilege.getRoleName() + ";"); if (!"".equals(tablePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + tablePrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " TO " + tablePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(tablePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + tablePrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " TO " + tablePrivilege.getRoleName() + ";"); } } if (table.hasRLSEnabled() != null && table.hasRLSEnabled()) { writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " ENABLE ROW LEVEL SECURITY;"); } if (table.hasRLSForced() != null && table.hasRLSForced()) { writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " FORCE ROW LEVEL SECURITY;"); } } } } /** * Outputs statements for dropping tables. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropTables(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (final PgTable table : oldSchema.getTables()) { if (!newSchema.containsTable(table.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(table.getDropSQL()); } } } /** * Outputs statements for addition, removal and modifications of table * columns. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldTable original table * @param newTable new table * @param searchPathHelper search path helper */ private static void updateTableColumns(final PrintWriter writer, final PgDiffArguments arguments, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List statements = new ArrayList(); @SuppressWarnings("CollectionWithoutInitialCapacity") final List dropDefaultsColumns = new ArrayList(); addDropTableColumns(statements, oldTable, newTable); addCreateTableColumns( statements, arguments, oldTable, newTable, dropDefaultsColumns); addModifyTableColumns( statements, arguments, oldTable, newTable, dropDefaultsColumns); if (!statements.isEmpty()) { final String quotedTableName = PgDiffUtils.getQuotedName(newTable.getName()); searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER " + ((newTable.isForeign()) ? "FOREIGN ":"") + "TABLE " + quotedTableName); for (int i = 0; i < statements.size(); i++) { writer.print(statements.get(i)); writer.println((i + 1) < statements.size() ? "," : ";"); } if (!dropDefaultsColumns.isEmpty()) { writer.println(); writer.println("ALTER " + ((newTable.isForeign()) ? "FOREIGN ":"") + "TABLE " + quotedTableName); for (int i = 0; i < dropDefaultsColumns.size(); i++) { writer.print("\tALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName( dropDefaultsColumns.get(i).getName())); writer.print(" DROP DEFAULT"); writer.println( (i + 1) < dropDefaultsColumns.size() ? "," : ";"); } } } } private static void alterPrivilegesColumns(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; for (PgColumn newColumn : newTable.getColumns()) { final PgColumn oldColumn = oldTable.getColumn(newColumn.getName()); if (oldColumn != null) { for (PgColumnPrivilege oldColumnPrivilege : oldColumn .getPrivileges()) { PgColumnPrivilege newColumnPrivilege = newColumn .getPrivilege(oldColumnPrivilege.getRoleName()); if (newColumnPrivilege == null) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL (" + PgDiffUtils.getQuotedName(newColumn.getName()) + ") ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " FROM " + oldColumnPrivilege.getRoleName() + ";"); } } } if (newColumn != null) { for (PgColumnPrivilege newColumnPrivilege : newColumn .getPrivileges()) { PgColumnPrivilege oldColumnPrivilege = null; if (oldColumn != null) { oldColumnPrivilege = oldColumn .getPrivilege(newColumnPrivilege.getRoleName()); } if (!newColumnPrivilege.isSimilar(oldColumnPrivilege)) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL (" + PgDiffUtils.getQuotedName(newColumn.getName()) + ") ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " FROM " + newColumnPrivilege.getRoleName() + ";"); if (!"".equals(newColumnPrivilege.getPrivilegesSQL( true, PgDiffUtils.getQuotedName(newColumn.getName())))) { writer.println("GRANT " + newColumnPrivilege.getPrivilegesSQL(true, PgDiffUtils.getQuotedName(newColumn .getName())) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable .getName()) + " TO " + newColumnPrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newColumnPrivilege.getPrivilegesSQL( false, PgDiffUtils.getQuotedName(newColumn.getName())))) { writer.println("GRANT " + newColumnPrivilege.getPrivilegesSQL( false, PgDiffUtils .getQuotedName(newColumn .getName())) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable .getName()) + " TO " + newColumnPrivilege.getRoleName() + ";"); } } } } } } /** * Outputs statements for tables and columns for which comments have * changed. * * @param writer writer * @param oldTable old table * @param newTable new table * @param searchPathHelper search path helper */ private static void alterComments(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { if (oldTable.getComment() == null && newTable.getComment() != null || oldTable.getComment() != null && newTable.getComment() != null && !oldTable.getComment().equals(newTable.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print(" IS "); writer.print(newTable.getComment()); writer.println(';'); } else if (oldTable.getComment() != null && newTable.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" IS NULL;"); } for (final PgColumn newColumn : newTable.getColumns()) { final PgColumn oldColumn = oldTable.getColumn(newColumn.getName()); final String oldComment = oldColumn == null ? null : oldColumn.getComment(); final String newComment = newColumn.getComment(); if (newComment != null && (oldComment == null ? newComment != null : !oldComment.equals(newComment))) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName(newColumn.getName())); writer.print(" IS "); writer.print(newColumn.getComment()); writer.println(';'); } else if (oldComment != null && newComment == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName(newColumn.getName())); writer.println(" IS NULL;"); } } } private static void alterPrivileges(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; for (PgRelationPrivilege oldTablePrivilege : oldTable.getPrivileges()) { PgRelationPrivilege newTablePrivilege = newTable .getPrivilege(oldTablePrivilege.getRoleName()); if (newTablePrivilege == null) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(oldTable.getName()) + " FROM " + oldTablePrivilege.getRoleName() + ";"); } else if (!oldTablePrivilege.isSimilar(newTablePrivilege)) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " FROM " + newTablePrivilege.getRoleName() + ";"); if (!"".equals(newTablePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newTablePrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " TO " + newTablePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newTablePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newTablePrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " TO " + newTablePrivilege.getRoleName() + ";"); } } // else similar privilege will not be updated } for (PgRelationPrivilege newTablePrivilege : newTable.getPrivileges()) { PgRelationPrivilege oldTablePrivilege = oldTable .getPrivilege(newTablePrivilege.getRoleName()); if (oldTablePrivilege == null) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " FROM " + newTablePrivilege.getRoleName() + ";"); if (!"".equals(newTablePrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newTablePrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " TO " + newTablePrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newTablePrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newTablePrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " TO " + newTablePrivilege.getRoleName() + ";"); } } } } private static void alterOwnerTo(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { final String oldOwnerTo = oldTable.getOwnerTo(); final String newOwnerTo = newTable.getOwnerTo(); if (newOwnerTo != null && !newOwnerTo.equals(oldOwnerTo)) { writer.println(); writer.println("ALTER " + ((newTable.isForeign()) ? "FOREIGN ":"") + "TABLE " + PgDiffUtils.getQuotedName(newTable.getName()) + " OWNER TO " + newTable.getOwnerTo() + ";"); } } private static void alterRLS(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { if ((oldTable.hasRLSEnabled() == null || oldTable.hasRLSEnabled() != null && !oldTable.hasRLSEnabled()) && newTable.hasRLSEnabled() != null && newTable.hasRLSEnabled()) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" ENABLE ROW LEVEL SECURITY;"); } if (oldTable.hasRLSEnabled() != null && oldTable.hasRLSEnabled() && (newTable.hasRLSEnabled() == null || newTable.hasRLSEnabled() != null && !newTable.hasRLSEnabled())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" DISABLE ROW LEVEL SECURITY;"); } if ((oldTable.hasRLSForced() == null || oldTable.hasRLSForced() != null && !oldTable.hasRLSForced()) && newTable.hasRLSForced() != null && newTable.hasRLSForced()) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" FORCE ROW LEVEL SECURITY;"); } if (oldTable.hasRLSForced() != null && oldTable.hasRLSForced() && (newTable.hasRLSForced() == null || newTable.hasRLSForced() != null && !newTable.hasRLSForced())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newTable.getName())); writer.println(" NO FORCE ROW LEVEL SECURITY;"); } } /** * Creates a new instance of PgDiffTables. */ private PgDiffTables() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffTriggers.java000077500000000000000000000156451316501242600255200ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgRelation; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTrigger; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * Diffs triggers. * * @author fordfrog */ public class PgDiffTriggers { /** * Outputs statements for creation of new triggers. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createTriggers(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper ) { for (final PgRelation newRelation : newSchema.getRels()) { final PgRelation oldRelation; if (oldSchema == null) { oldRelation = null; } else { oldRelation = oldSchema.getRelation(newRelation.getName()); } // Add new triggers for (final PgTrigger trigger : getNewTriggers(oldRelation, newRelation)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(trigger.getCreationSQL()); } } } /** * Outputs statements for dropping triggers. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropTriggers(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgRelation newRelation : newSchema.getRels()) { final PgRelation oldRelation; if (oldSchema == null) { oldRelation = null; } else { oldRelation = oldSchema.getRelation(newRelation.getName()); } // Drop triggers that no more exist or are modified for (final PgTrigger trigger : getDropTriggers(oldRelation, newRelation)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(trigger.getDropSQL()); } } } /** * Returns list of triggers that should be dropped. * * @param oldRelation original relation * @param newRelation new relation * * @return list of triggers that should be dropped */ private static List getDropTriggers(final PgRelation oldRelation, final PgRelation newRelation) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newRelation != null && oldRelation != null) { final List newTriggers = newRelation.getTriggers(); for (final PgTrigger oldTrigger : oldRelation.getTriggers()) { if (!newTriggers.contains(oldTrigger)) { list.add(oldTrigger); } } } return list; } /** * Returns list of triggers that should be added. * * @param oldRelation original relation * @param newRelation new relation * * @return list of triggers that should be added */ private static List getNewTriggers(final PgRelation oldRelation, final PgRelation newRelation) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newRelation != null) { if (oldRelation == null) { list.addAll(newRelation.getTriggers()); } else { for (final PgTrigger newTrigger : newRelation.getTriggers()) { if (!oldRelation.getTriggers().contains(newTrigger)) { list.add(newTrigger); } } } } return list; } /** * Outputs statements for trigger comments that have changed. * * @param writer writer * @param oldSchema old schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterComments(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (PgRelation oldRelation : oldSchema.getRels()) { final PgRelation newRelation = newSchema.getRelation(oldRelation.getName()); if (newRelation == null) { continue; } for (final PgTrigger oldTrigger : oldRelation.getTriggers()) { final PgTrigger newTrigger = newRelation.getTrigger(oldTrigger.getName()); if (newTrigger == null) { continue; } if (oldTrigger.getComment() == null && newTrigger.getComment() != null || oldTrigger.getComment() != null && newTrigger.getComment() != null && !oldTrigger.getComment().equals( newTrigger.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON TRIGGER "); writer.print( PgDiffUtils.getQuotedName(newTrigger.getName())); writer.print(" ON "); writer.print(PgDiffUtils.getQuotedName( newTrigger.getRelationName())); writer.print(" IS "); writer.print(newTrigger.getComment()); writer.println(';'); } else if (oldTrigger.getComment() != null && newTrigger.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON TRIGGER "); writer.print( PgDiffUtils.getQuotedName(newTrigger.getName())); writer.print(" ON "); writer.print(PgDiffUtils.getQuotedName( newTrigger.getRelationName())); writer.println(" IS NULL;"); } } } } /** * Creates a new instance of PgDiffTriggers. */ private PgDiffTriggers() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffTypes.java000077500000000000000000000243361316501242600250330ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgColumnUtils; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgType; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Diffs types. * * @author fordfrog */ public class PgDiffTypes { /** * Outputs statements for altering types. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterTypes(final PrintWriter writer, final PgDiffArguments arguments, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgType newType : newSchema.getTypes()) { if (oldSchema == null || !oldSchema.containsType(newType.getName())) { continue; } final PgType oldType = oldSchema.getType(newType.getName()); updateTypeColumns( writer, arguments, oldType, newType, searchPathHelper); } } /** * Adds statements for creation of new columns to the list of statements. * * @param statements list of statements * @param arguments object containing arguments settings * @param oldType original type * @param newType new type * @param dropDefaultsColumns list for storing columns for which default * value should be dropped */ private static void addCreateTypeColumns(final List statements, final PgDiffArguments arguments, final PgType oldType, final PgType newType, final List dropDefaultsColumns) { for (final PgColumn column : newType.getColumns()) { if (!oldType.containsColumn(column.getName())) { statements.add("\tADD ATTRIBUTE " + column.getFullDefinition(arguments.isAddDefaults())); if (arguments.isAddDefaults() && !column.getNullValue() && (column.getDefaultValue() == null || column.getDefaultValue().isEmpty())) { dropDefaultsColumns.add(column); } } } } /** * Adds statements for removal of columns to the list of statements. * * @param statements list of statements * @param oldType original type * @param newType new type */ private static void addDropTypeColumns(final List statements, final PgType oldType, final PgType newType) { for (final PgColumn column : oldType.getColumns()) { if (!newType.containsColumn(column.getName())) { statements.add("\tDROP ATTRIBUTE " + PgDiffUtils.getQuotedName(column.getName())); } } } /** * Adds statements for modification of columns to the list of statements. * * @param statements list of statements * @param arguments object containing arguments settings * @param oldType original type * @param newType new type * @param dropDefaultsColumns list for storing columns for which default * value should be dropped */ private static void addModifyTypeColumns(final List statements, final PgDiffArguments arguments, final PgType oldType, final PgType newType, final List dropDefaultsColumns) { for (final PgColumn newColumn : newType.getColumns()) { if (!oldType.containsColumn(newColumn.getName())) { continue; } final PgColumn oldColumn = oldType.getColumn(newColumn.getName()); final String newColumnName = PgDiffUtils.getQuotedName(newColumn.getName()); if (!oldColumn.getType().equals(newColumn.getType())) { statements.add("\tALTER ATTRIBUTE " + newColumnName + " TYPE " + newColumn.getType() + " /* " + MessageFormat.format( Resources.getString("TypeParameterChange"), newType.getName(), oldColumn.getType(), newColumn.getType()) + " */"); } final String oldDefault = (oldColumn.getDefaultValue() == null) ? "" : oldColumn.getDefaultValue(); final String newDefault = (newColumn.getDefaultValue() == null) ? "" : newColumn.getDefaultValue(); if (!oldDefault.equals(newDefault)) { if (newDefault.length() == 0) { statements.add("\tALTER ATTRIBUTE " + newColumnName + " DROP DEFAULT"); } else { statements.add("\tALTER ATTRIBUTE " + newColumnName + " SET DEFAULT " + newDefault); } } if (oldColumn.getNullValue() != newColumn.getNullValue()) { if (newColumn.getNullValue()) { statements.add("\tALTER ATTRIBUTE " + newColumnName + " DROP NOT NULL"); } else { if (arguments.isAddDefaults()) { final String defaultValue = PgColumnUtils.getDefaultValue( newColumn.getType()); if (defaultValue != null) { statements.add("\tALTER ATTRIBUTE " + newColumnName + " SET DEFAULT " + defaultValue); dropDefaultsColumns.add(newColumn); } } statements.add("\tALTER ATTRIBUTE " + newColumnName + " SET NOT NULL"); } } } } /** * Outputs statements for creation of new types. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createTypes(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper ) { for (final PgType type : newSchema.getTypes()) { if (oldSchema == null || !oldSchema.containsType(type.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(type.getCreationSQL()); } } } /** * Outputs statements for dropping types. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropTypes(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper ) { if (oldSchema == null) { return; } for (final PgType type : oldSchema.getTypes()) { if (!newSchema.containsType(type.getName())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(type.getDropSQL()); } } } /** * Outputs statements for addition, removal and modifications of type * columns. * * @param writer writer the output should be written to * @param arguments object containing arguments settings * @param oldType original type * @param newType new type * @param searchPathHelper search path helper */ private static void updateTypeColumns(final PrintWriter writer, final PgDiffArguments arguments, final PgType oldType, final PgType newType, final SearchPathHelper searchPathHelper) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List statements = new ArrayList(); @SuppressWarnings("CollectionWithoutInitialCapacity") final List dropDefaultsColumns = new ArrayList(); addDropTypeColumns(statements, oldType, newType); addCreateTypeColumns( statements, arguments, oldType, newType, dropDefaultsColumns); addModifyTypeColumns( statements, arguments, oldType, newType, dropDefaultsColumns); if (!statements.isEmpty()) { final String quotedTypeName = PgDiffUtils.getQuotedName(newType.getName()); searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TYPE " + quotedTypeName); for (int i = 0; i < statements.size(); i++) { writer.print(statements.get(i)); writer.println((i + 1) < statements.size() ? "," : ";"); } if (!dropDefaultsColumns.isEmpty()) { writer.println(); writer.println("ALTER TYPE " + quotedTypeName); for (int i = 0; i < dropDefaultsColumns.size(); i++) { writer.print("\tALTER ATTRIBUTE "); writer.print(PgDiffUtils.getQuotedName( dropDefaultsColumns.get(i).getName())); writer.print(" DROP DEFAULT"); writer.println( (i + 1) < dropDefaultsColumns.size() ? "," : ";"); } } } } /** * Creates a new instance of PgDiffTypes. */ private PgDiffTypes() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffUtils.java000077500000000000000000000265021316501242600250240ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import java.util.Locale; /** * Utilities for creation of diffs. * * @author fordfrog */ public class PgDiffUtils { /** * Array of reserved keywords. Non-reserved keywords are excluded. Source * http://www.postgresql.org/docs/9.0/static/sql-keywords-appendix.html. */ private static final String[] KEYWORDS = new String[]{ "ABS", "ABSOLUTE", "ACTION", "ADD", "ADMIN", "AFTER", "AGGREGATE", "ALIAS", "ALL", "ALLOCATE", "ALTER", "ANALYSE", "ANALYZE", "AND", "ANY", "ARE", "ARRAY", "ARRAY_AGG", "AS", "ASC", "ASENSITIVE", "ASSERTION", "ASYMMETRIC", "AT", "ATOMIC", "AUTHORIZATION", "AVG", "BEFORE", "BEGIN", "BETWEEN", "BIGINT", "BINARY", "BIT", "BIT_LENGTH", "BLOB", "BOOLEAN", "BOTH", "BREADTH", "BY", "CALL", "CALLED", "CARDINALITY", "CASCADE", "CASCADED", "CASE", "CAST", "CATALOG", "CEIL", "CEILING", "CHAR", "CHARACTER", "CHARACTER_LENGTH", "CHAR_LENGTH", "CHECK", "CLASS", "CLOB", "CLOSE", "COALESCE", "COLLATE", "COLLATION", "COLLECT", "COLUMN", "COMMIT", "COMPLETION", "CONCURRENTLY", "CONDITION", "CONNECT", "CONNECTION", "CONSTRAINT", "CONSTRAINTS", "CONSTRUCTOR", "CONTINUE", "CONVERT", "CORR", "CORRESPONDING", "COUNT", "COVAR_POP", "COVAR_SAMP", "CREATE", "CROSS", "CUBE", "CUME_DIST", "CURRENT", "CURRENT_CATALOG", "CURRENT_DATE", "CURRENT_DEFAULT_TRANSFORM_GROUP", "CURRENT_PATH", "CURRENT_ROLE", "CURRENT_SCHEMA", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_TRANSFORM_GROUP_FOR_TYPE", "CURRENT_USER", "CURSOR", "CYCLE", "DATA", "DATALINK", "DATE", "DAY", "DEALLOCATE", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE", "DEFERRED", "DELETE", "DENSE_RANK", "DEPTH", "DEREF", "DESC", "DESCRIBE", "DESCRIPTOR", "DESTROY", "DESTRUCTOR", "DETERMINISTIC", "DIAGNOSTICS", "DICTIONARY", "DISCONNECT", "DISTINCT", "DLNEWCOPY", "DLPREVIOUSCOPY", "DLURLCOMPLETE", "DLURLCOMPLETEONLY", "DLURLCOMPLETEWRITE", "DLURLPATH", "DLURLPATHONLY", "DLURLPATHWRITE", "DLURLSCHEME", "DLURLSERVER", "DLVALUE", "DO", "DOMAIN", "DOUBLE", "DROP", "DYNAMIC", "EACH", "ELEMENT", "ELSE", "END", "END-EXEC", "EQUALS", "ESCAPE", "EVERY", "EXCEPT", "EXCEPTION", "EXEC", "EXECUTE", "EXISTS", "EXP", "EXTERNAL", "EXTRACT", "FALSE", "FETCH", "FILTER", "FIRST", "FIRST_VALUE", "FLOAT", "FLOOR", "FOR", "FOREIGN", "FOUND", "FREE", "FREEZE", "FROM", "FULL", "FUNCTION", "FUSION", "GENERAL", "GET", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "GROUPING", "HAVING", "HOLD", "HOST", "HOUR", "IDENTITY", "IGNORE", "ILIKE", "IMMEDIATE", "IMPORT", "IN", "INDICATOR", "INITIALIZE", "INITIALLY", "INNER", "INOUT", "INPUT", "INSENSITIVE", "INSERT", "INT", "INTEGER", "INTERSECT", "INTERSECTION", "INTERVAL", "INTO", "IS", "ISNULL", "ISOLATION", "ITERATE", "JOIN", "KEY", "LAG", "LANGUAGE", "LARGE", "LAST", "LAST_VALUE", "LATERAL", "LEAD", "LEADING", "LEFT", "LESS", "LEVEL", "LIKE", "LIKE_REGEX", "LIMIT", "LN", "LOCAL", "LOCALTIME", "LOCALTIMESTAMP", "LOCATOR", "LOWER", "MAP", "MATCH", "MAX", "MAX_CARDINALITY", "MEMBER", "MERGE", "METHOD", "MIN", "MINUTE", "MOD", "MODIFIES", "MODIFY", "MODULE", "MONTH", "MULTISET", "NAMES", "NATIONAL", "NATURAL", "NCHAR", "NCLOB", "NEW", "NEXT", "NO", "NONE", "NORMALIZE", "NOT", "NOTNULL", "NTH_VALUE", "NTILE", "NULL", "NULLIF", "NUMERIC", "OBJECT", "OCCURRENCES_REGEX", "OCTET_LENGTH", "OF", "OFF", "OFFSET", "OLD", "ON", "ONLY", "OPEN", "OPERATION", "OPTION", "OR", "ORDER", "ORDINALITY", "OUT", "OUTER", "OUTPUT", "OVER", "OVERLAPS", "OVERLAY", "PAD", "PARAMETER", "PARAMETERS", "PARTIAL", "PARTITION", "PATH", "PERCENTILE_CONT", "PERCENTILE_DISC", "PERCENT_RANK", "PLACING", "POSITION", "POSITION_REGEX", "POSTFIX", "POWER", "PRECISION", "PREFIX", "PREORDER", "PREPARE", "PRESERVE", "PRIMARY", "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "RANGE", "RANK", "READ", "READS", "REAL", "RECURSIVE", "REF", "REFERENCES", "REFERENCING", "REGR_AVGX", "REGR_AVGY", "REGR_COUNT", "REGR_INTERCEPT", "REGR_R2", "REGR_SLOPE", "REGR_SXX", "REGR_SXY", "REGR_SYY", "RELATIVE", "RELEASE", "RESTRICT", "RESULT", "RETURN", "RETURNING", "RETURNS", "REVOKE", "RIGHT", "ROLE", "ROLLBACK", "ROLLUP", "ROUTINE", "ROW", "ROWS", "ROW_NUMBER", "SAVEPOINT", "SCHEMA", "SCOPE", "SCROLL", "SEARCH", "SECOND", "SECTION", "SELECT", "SENSITIVE", "SEQUENCE", "SESSION", "SESSION_USER", "SET", "SETS", "SIMILAR", "SIZE", "SMALLINT", "SOME", "SPACE", "SPECIFIC", "SPECIFICTYPE", "SQL", "SQLCODE", "SQLERROR", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SQRT", "START", "STATE", "STATEMENT", "STATIC", "STDDEV_POP", "STDDEV_SAMP", "STRUCTURE", "SUBMULTISET", "SUBSTRING", "SUBSTRING_REGEX", "SUM", "SYMMETRIC", "SYSTEM", "SYSTEM_USER", "TABLE", "TABLESAMPLE", "TEMPORARY", "TERMINATE", "THAN", "THEN", "TIME", "TIMESTAMP", "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING", "TRANSACTION", "TRANSLATE", "TRANSLATE_REGEX", "TRANSLATION", "TREAT", "TRIGGER", "TRIM", "TRIM_ARRAY", "TRUE", "TRUNCATE", "UESCAPE", "UNDER", "UNION", "UNIQUE", "UNKNOWN", "UNNEST", "UPDATE", "UPPER", "USAGE", "USER", "USING", "VALUE", "VALUES", "VARBINARY", "VARCHAR", "VARIABLE", "VARIADIC", "VARYING", "VAR_POP", "VAR_SAMP", "VERBOSE", "VIEW", "WHEN", "WHENEVER", "WHERE", "WIDTH_BUCKET", "WINDOW", "WITH", "WITHIN", "WITHOUT", "WORK", "WRITE", "XML", "XMLAGG", "XMLATTRIBUTES", "XMLBINARY", "XMLCAST", "XMLCOMMENT", "XMLCONCAT", "XMLDOCUMENT", "XMLELEMENT", "XMLEXISTS", "XMLFOREST", "XMLITERATE", "XMLNAMESPACES", "XMLPARSE", "XMLPI", "XMLQUERY", "XMLROOT", "XMLSERIALIZE", "XMLTABLE", "XMLTEXT", "XMLVALIDATE", "YEAR", "ZONE"}; /** * Determine if use CREATE IF NOT EXISTS OR DROP IF EXISTS where is possible */ private static boolean useIfExists; /** * If name contains only lower case characters and digits and is not * keyword, it is returned not quoted, otherwise the string is returned * quoted. * * @param name name * @param excludeKeywords whether check against keywords should be skipped * * @return quoted string if needed, otherwise not quoted string */ public static String getQuotedName(final String name, final boolean excludeKeywords) { if (name.indexOf('-') != -1 || name.indexOf('.') != -1) { return '"' + name + '"'; } for (int i = 0; i < name.length(); i++) { final char chr = name.charAt(i); if (Character.isUpperCase(chr)) { return '"' + name + '"'; } } if (excludeKeywords) { return name; } final String upperName = name.toUpperCase(Locale.ENGLISH); for (final String keyword : KEYWORDS) { if (keyword.equals(upperName)) { return '"' + name + '"'; } } return name; } /** * If name contains only lower case characters and digits and is not * keyword, it is returned not quoted, otherwise the string is returned * quoted. * * @param name name * * @return quoted string if needed, otherwise not quoted string */ public static String getQuotedName(final String name) { return getQuotedName(name, false); } /** * IF useIfExists is true return DROP IF NOT EXISTS * * * @return DROP IF NOT EXISTS STRING */ public static String getDropIfExists() { if (useIfExists) { return "IF EXISTS "; } return ""; } /** * IF useIfExists is true return IF NOT EXISTS * * * @return IF NOT EXISTS STRING */ public static String getCreateIfNotExists() { if (useIfExists) { return "IF NOT EXISTS "; } return ""; } public static void setUseExists(final boolean useExists) { useIfExists = useExists; } /** * Creates a new PgDiffUtils object. */ private PgDiffUtils() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java000077500000000000000000000451361316501242600250250ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgColumnPrivilege; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgView; import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * Diffs views. * * @author fordfrog */ public class PgDiffViews { /** * Outputs statements for creation of views. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void createViews(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { for (final PgView newView : newSchema.getViews()) { if (oldSchema == null || !oldSchema.containsView(newView.getName()) || isViewModified( oldSchema.getView(newView.getName()), newView)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(newView.getCreationSQL()); for (PgRelationPrivilege viewPrivilege : newView.getPrivileges()) { writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + viewPrivilege.getRoleName() + ";"); if (!"".equals(viewPrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + viewPrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + viewPrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(viewPrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + viewPrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + viewPrivilege.getRoleName() + ";"); } } } } } /** * Outputs statements for dropping views. * * @param writer writer the output should be written to * @param oldSchema original schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void dropViews(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper ) { if (oldSchema == null) { return; } for (final PgView oldView : oldSchema.getViews()) { final PgView newView = newSchema.getView(oldView.getName()); if (newView == null || isViewModified(oldView, newView)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(oldView.getDropSQL()); } } } /** * Returns true if either column names or query of the view has been * modified. * * @param oldView old view * @param newView new view * * @return true if view has been modified, otherwise false */ private static boolean isViewModified(final PgView oldView, final PgView newView) { if (!oldView.getQuery().trim().equals(newView.getQuery().trim())) return true; if (oldView.isMaterialized() != newView.isMaterialized()) return true; final List oldViewColumnNames = oldView.getDeclaredColumnNames(); final List newViewColumnNames = newView.getDeclaredColumnNames(); if (oldViewColumnNames != null && newViewColumnNames != null) { return !oldViewColumnNames.equals(newViewColumnNames); } else { // At least one of the two is null. Are both? return oldViewColumnNames != newViewColumnNames; } } /** * Outputs statements for altering view default values. * * @param writer writer * @param oldSchema old schema * @param newSchema new schema * @param searchPathHelper search path helper */ public static void alterViews(final PrintWriter writer, final PgSchema oldSchema, final PgSchema newSchema, final SearchPathHelper searchPathHelper) { if (oldSchema == null) { return; } for (final PgView oldView : oldSchema.getViews()) { final PgView newView = newSchema.getView(oldView.getName()); if (newView == null) { continue; } diffDefaultValues(writer, oldView, newView, searchPathHelper); if (oldView.getComment() == null && newView.getComment() != null || oldView.getComment() != null && newView.getComment() != null && !oldView.getComment().equals( newView.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON VIEW "); writer.print( PgDiffUtils.getQuotedName(newView.getName())); writer.print(" IS "); writer.print(newView.getComment()); writer.println(';'); } else if (oldView.getComment() != null && newView.getComment() == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON VIEW "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.println(" IS NULL;"); } final List columnNames = new ArrayList(newView.getColumns().size()); for (final PgColumn col : newView.getColumns()) { columnNames.add(col.getName()); } for (final PgColumn col : oldView.getColumns()) { if (!columnNames.contains(col.getName())) { columnNames.add(col.getName()); } } for (final String columnName : columnNames) { String oldComment = null; String newComment = null; PgColumn oldCol = oldView.getColumn(columnName); PgColumn newCol = newView.getColumn(columnName); if (oldCol != null) oldComment = oldCol.getComment(); if (newCol != null) newComment = newCol.getComment(); if (oldComment == null && newComment != null || oldComment != null && newComment != null && !oldComment.equals(newComment)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName(newCol.getName())); writer.print(" IS "); writer.print(newCol.getComment()); writer.println(';'); } else if (oldComment != null && newComment == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName(oldCol.getName())); writer.println(" IS NULL;"); } } alterPrivileges(writer, oldView, newView, searchPathHelper); alterPrivilegesColumns(writer, oldView, newView, searchPathHelper); } } /** * Diffs default values in views. * * @param writer writer * @param oldView old view * @param newView new view * @param searchPathHelper search path helper */ private static void diffDefaultValues(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { // modify defaults that are in old view for (final PgColumn oldCol : oldView.getColumns()) { if (oldCol.getDefaultValue() == null) continue; PgColumn newCol = newView.getColumn(oldCol.getName()); if (newCol != null && newCol.getDefaultValue() != null) { if (!oldCol.getDefaultValue().equals( newCol.getDefaultValue())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print( PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(newCol.getName())); writer.print(" SET DEFAULT "); writer.print(newCol.getDefaultValue()); writer.println(';'); } } else { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(oldCol.getName())); writer.println(" DROP DEFAULT;"); } } // add new defaults for (final PgColumn newCol : newView.getColumns()) { PgColumn oldCol = oldView.getColumn(newCol.getName()); if ((oldCol != null && oldCol.getDefaultValue() != null) || newCol.getDefaultValue() == null) { continue; } searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(newCol.getName())); writer.print(" SET DEFAULT "); writer.print(newCol.getDefaultValue()); writer.println(';'); } } private static void alterPrivileges(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; for (PgRelationPrivilege oldViewPrivilege : oldView.getPrivileges()) { PgRelationPrivilege newViewPrivilege = newView .getPrivilege(oldViewPrivilege.getRoleName()); if (newViewPrivilege == null) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(oldView.getName()) + " FROM " + oldViewPrivilege.getRoleName() + ";"); } else if (!oldViewPrivilege.isSimilar(newViewPrivilege)) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + newViewPrivilege.getRoleName() + ";"); if (!"".equals(newViewPrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newViewPrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + newViewPrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newViewPrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newViewPrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + newViewPrivilege.getRoleName() + ";"); } } // else similar privilege will not be updated } for (PgRelationPrivilege newViewPrivilege : newView.getPrivileges()) { PgRelationPrivilege oldViewPrivilege = oldView .getPrivilege(newViewPrivilege.getRoleName()); if (oldViewPrivilege == null) { if (!emptyLinePrinted) { writer.println(); } writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + newViewPrivilege.getRoleName() + ";"); if (!"".equals(newViewPrivilege.getPrivilegesSQL(true))) { writer.println("GRANT " + newViewPrivilege.getPrivilegesSQL(true) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + newViewPrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newViewPrivilege.getPrivilegesSQL(false))) { writer.println("GRANT " + newViewPrivilege.getPrivilegesSQL(false) + " ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " TO " + newViewPrivilege.getRoleName() + ";"); } } } } private static void alterPrivilegesColumns(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; for (PgColumn newColumn : newView.getColumns()) { final PgColumn oldColumn = oldView.getColumn(newColumn.getName()); if (oldColumn != null) { for (PgColumnPrivilege oldColumnPrivilege : oldColumn .getPrivileges()) { PgColumnPrivilege newColumnPrivilege = newColumn .getPrivilege(oldColumnPrivilege.getRoleName()); if (newColumnPrivilege == null) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL (" + PgDiffUtils.getQuotedName(newColumn.getName()) + ") ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + oldColumnPrivilege.getRoleName() + ";"); } } } if (newColumn != null) { for (PgColumnPrivilege newColumnPrivilege : newColumn .getPrivileges()) { PgColumnPrivilege oldColumnPrivilege = null; if (oldColumn != null) { oldColumnPrivilege = oldColumn .getPrivilege(newColumnPrivilege.getRoleName()); } if (!newColumnPrivilege.isSimilar(oldColumnPrivilege)) { if (!emptyLinePrinted) { emptyLinePrinted = true; writer.println(); } writer.println("REVOKE ALL (" + PgDiffUtils.getQuotedName(newColumn.getName()) + ") ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + newColumnPrivilege.getRoleName() + ";"); if (!"".equals(newColumnPrivilege.getPrivilegesSQL( true, PgDiffUtils.getQuotedName(newColumn.getName())))) { writer.println("GRANT " + newColumnPrivilege.getPrivilegesSQL(true, PgDiffUtils.getQuotedName(newColumn .getName())) + " ON TABLE " + PgDiffUtils.getQuotedName(newView .getName()) + " TO " + newColumnPrivilege.getRoleName() + " WITH GRANT OPTION;"); } if (!"".equals(newColumnPrivilege.getPrivilegesSQL( false, PgDiffUtils.getQuotedName(newColumn.getName())))) { writer.println("GRANT " + newColumnPrivilege.getPrivilegesSQL( false, PgDiffUtils .getQuotedName(newColumn .getName())) + " ON TABLE " + PgDiffUtils.getQuotedName(newView .getName()) + " TO " + newColumnPrivilege.getRoleName() + ";"); } } } } } } /** * Creates a new instance of PgDiffViews. */ private PgDiffViews() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/Resources.java000066400000000000000000000013331316501242600246060ustar00rootroot00000000000000/** * Copyright 2010 StartNet s.r.o. */ package cz.startnet.utils.pgdiff; import java.util.ResourceBundle; /** * Utility class for accessing localized resources. * * @author fordfrog */ public class Resources { /** * Resource bundle. */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("cz/startnet/utils/pgdiff/Resources"); /** * Returns string from resource bundle based on the key. * * @param key key * * @return string */ public static String getString(final String key) { return RESOURCE_BUNDLE.getString(key); } /** * Creates new instance of Resources. */ private Resources() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/SearchPathHelper.java000066400000000000000000000017501316501242600260210ustar00rootroot00000000000000/** * Copyright 2010 StartNet s.r.o. */ package cz.startnet.utils.pgdiff; import java.io.PrintWriter; /** * Helps to output search path only if it was not output yet. * * @author fordfrog */ public class SearchPathHelper { /** * Statement to output. */ private final String searchPath; /** * Flag determining whether the statement was already output. */ private boolean wasOutput; /** * Creates new instance of SearchPathHelper. * * @param searchPath {@link #searchPath} */ public SearchPathHelper(final String searchPath) { this.searchPath = searchPath; } /** * Outputs search path if it was not output yet. * * @param writer writer */ public void outputSearchPath(final PrintWriter writer) { if (!wasOutput && searchPath != null && !searchPath.isEmpty()) { writer.println(); writer.println(searchPath); wasOutput = true; } } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/loader/000077500000000000000000000000001316501242600232375ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/pgdiff/loader/FileException.java000066400000000000000000000020171316501242600266400ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.loader; /** * Exception thrown if problem occurred while reading or writing file. * * @author fordfrog */ public class FileException extends RuntimeException { /** * Serial version uid. */ private static final long serialVersionUID = 1L; /** * Creates a new instance of {@code FileException} without detail message. */ public FileException() { } /** * Constructs an instance of {@code FileException} with the specified detail * message. * * @param msg the detail message */ public FileException(final String msg) { super(msg); } /** * Constructs an instance of {@code FileException} with the specified detail * message. * * @param msg the detail message * @param cause cause of the exception */ public FileException(final String msg, final Throwable cause) { super(msg, cause); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java000066400000000000000000000462651316501242600264420ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.loader; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.parsers.AlterSequenceParser; import cz.startnet.utils.pgdiff.parsers.AlterRelationParser; import cz.startnet.utils.pgdiff.parsers.CommentParser; import cz.startnet.utils.pgdiff.parsers.CreateExtensionParser; import cz.startnet.utils.pgdiff.parsers.CreateFunctionParser; import cz.startnet.utils.pgdiff.parsers.CreateTypeParser; import cz.startnet.utils.pgdiff.parsers.CreateIndexParser; import cz.startnet.utils.pgdiff.parsers.CreateSchemaParser; import cz.startnet.utils.pgdiff.parsers.CreateSequenceParser; import cz.startnet.utils.pgdiff.parsers.CreateTableParser; import cz.startnet.utils.pgdiff.parsers.CreateTriggerParser; import cz.startnet.utils.pgdiff.parsers.CreateViewParser; import cz.startnet.utils.pgdiff.parsers.GrantRevokeParser; import cz.startnet.utils.pgdiff.parsers.CreatePolicyParser; import cz.startnet.utils.pgdiff.schema.PgDatabase; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.text.MessageFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Loads PostgreSQL dump into classes. * * @author fordfrog */ public class PgDumpLoader { //NOPMD /** * Pattern for testing whether it is CREATE SCHEMA statement. */ private static final Pattern PATTERN_CREATE_SCHEMA = Pattern.compile( "^CREATE[\\s]+SCHEMA[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for parsing default schema (search_path). */ private static final Pattern PATTERN_DEFAULT_SCHEMA = Pattern.compile( "^SET[\\s]+search_path[\\s]*=[\\s]*\"?([^,\\s\"]+)\"?" + "(?:,[\\s]+.*)?;$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE TABLE statement. */ private static final Pattern PATTERN_CREATE_TABLE = Pattern.compile( "^CREATE[\\s]+(UNLOGGED\\s|FOREIGN\\s)*TABLE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE VIEW or CREATE MATERIALIZED * VIEW statement. */ private static final Pattern PATTERN_CREATE_VIEW = Pattern.compile( "^CREATE[\\s]+(?:OR[\\s]+REPLACE[\\s]+)?(?:MATERIALIZED[\\s]+)?VIEW[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is ALTER TABLE statement. */ private static final Pattern PATTERN_ALTER_TABLE = Pattern.compile("^ALTER[\\s](FOREIGN)*TABLE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE SEQUENCE statement. */ private static final Pattern PATTERN_CREATE_SEQUENCE = Pattern.compile( "^CREATE[\\s]+SEQUENCE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is ALTER SEQUENCE statement. */ private static final Pattern PATTERN_ALTER_SEQUENCE = Pattern.compile("^ALTER[\\s]+SEQUENCE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE INDEX statement. */ private static final Pattern PATTERN_CREATE_INDEX = Pattern.compile( "^CREATE[\\s]+(?:UNIQUE[\\s]+)?INDEX[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is SELECT statement. */ private static final Pattern PATTERN_SELECT = Pattern.compile( "^SELECT[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is INSERT INTO statement. */ private static final Pattern PATTERN_INSERT_INTO = Pattern.compile( "^INSERT[\\s]+INTO[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is UPDATE statement. */ private static final Pattern PATTERN_UPDATE = Pattern.compile( "^UPDATE[\\s].*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is DELETE FROM statement. */ private static final Pattern PATTERN_DELETE_FROM = Pattern.compile( "^DELETE[\\s]+FROM[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE TRIGGER statement. */ private static final Pattern PATTERN_CREATE_TRIGGER = Pattern.compile( "^CREATE[\\s]+TRIGGER[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE FUNCTION or CREATE OR REPLACE * FUNCTION statement. */ private static final Pattern PATTERN_CREATE_FUNCTION = Pattern.compile( "^CREATE[\\s]+(?:OR[\\s]+REPLACE[\\s]+)?FUNCTION[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is ALTER VIEW statement. */ private static final Pattern PATTERN_ALTER_VIEW = Pattern.compile( "^ALTER[\\s]+(?:MATERIALIZED[\\s]+)?VIEW[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is COMMENT statement. */ private static final Pattern PATTERN_COMMENT = Pattern.compile( "^COMMENT[\\s]+ON[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE TYPE statement. */ private static final Pattern PATTERN_CREATE_TYPE = Pattern.compile( "^CREATE[\\s]+TYPE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is GRANT statement. */ private static final Pattern PATTERN_GRANT = Pattern.compile( "^GRANT[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is REVOKE statement. */ private static final Pattern PATTERN_REVOKE = Pattern.compile( "^REVOKE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing a dollar quoting tag. */ private static final Pattern PATTERN_DOLLAR_TAG= Pattern.compile( "[\"\\s]", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE EXTENSION statement. */ private static final Pattern PATTERN_CREATE_EXTENSION = Pattern.compile( "^CREATE[\\s]+EXTENSION[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE POLICY statement. */ private static final Pattern PATTERN_CREATE_POLICY = Pattern.compile( "^CREATE[\\s]+POLICY[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** /** * Storage of unprocessed line part. */ private static String lineBuffer; /** * Loads database schema from dump file. * * @param inputStream input stream that should be read * @param charsetName charset that should be used to read the * file * @param outputIgnoredStatements whether ignored statements should be * included in the output * @param ignoreSlonyTriggers whether Slony triggers should be ignored * @param ignoreSchemaCreation whether schema creation should be ignored * * @return database schema from dump file */ public static PgDatabase loadDatabaseSchema(final InputStream inputStream, final String charsetName, final boolean outputIgnoredStatements, final boolean ignoreSlonyTriggers, final boolean ignoreSchemaCreation) { final PgDatabase database = new PgDatabase(); BufferedReader reader = null; try { reader = new BufferedReader( new InputStreamReader(inputStream, charsetName)); } catch (final UnsupportedEncodingException ex) { throw new UnsupportedOperationException( Resources.getString("UnsupportedEncoding") + ": " + charsetName, ex); } String statement = getWholeStatement(reader); while (statement != null) { if (PATTERN_CREATE_SCHEMA.matcher(statement).matches()) { CreateSchemaParser.parse(database, statement); } else if (PATTERN_CREATE_EXTENSION.matcher(statement).matches()) { CreateExtensionParser.parse(database, statement); } else if (PATTERN_DEFAULT_SCHEMA.matcher(statement).matches()) { final Matcher matcher = PATTERN_DEFAULT_SCHEMA.matcher(statement); matcher.matches(); database.setDefaultSchema(matcher.group(1)); } else if (PATTERN_CREATE_TABLE.matcher(statement).matches()) { CreateTableParser.parse(database, statement, ignoreSchemaCreation); } else if (PATTERN_ALTER_TABLE.matcher(statement).matches() || PATTERN_ALTER_VIEW.matcher(statement).matches()) { AlterRelationParser.parse( database, statement, outputIgnoredStatements); } else if (PATTERN_CREATE_SEQUENCE.matcher(statement).matches()) { CreateSequenceParser.parse(database, statement); } else if (PATTERN_ALTER_SEQUENCE.matcher(statement).matches()) { AlterSequenceParser.parse( database, statement, outputIgnoredStatements); } else if (PATTERN_CREATE_INDEX.matcher(statement).matches()) { CreateIndexParser.parse(database, statement); } else if (PATTERN_CREATE_VIEW.matcher(statement).matches()) { CreateViewParser.parse(database, statement); } else if (PATTERN_CREATE_TRIGGER.matcher(statement).matches()) { CreateTriggerParser.parse( database, statement, ignoreSlonyTriggers); } else if (PATTERN_CREATE_FUNCTION.matcher(statement).matches()) { CreateFunctionParser.parse(database, statement); } else if (PATTERN_CREATE_TYPE.matcher(statement).matches()) { CreateTypeParser.parse(database, statement); } else if (PATTERN_COMMENT.matcher(statement).matches()) { CommentParser.parse( database, statement, outputIgnoredStatements); } else if (PATTERN_SELECT.matcher(statement).matches() || PATTERN_INSERT_INTO.matcher(statement).matches() || PATTERN_UPDATE.matcher(statement).matches() || PATTERN_DELETE_FROM.matcher(statement).matches()) { } else if (PATTERN_GRANT.matcher(statement).matches()) { GrantRevokeParser.parse(database, statement, outputIgnoredStatements); } else if (PATTERN_REVOKE.matcher(statement).matches()) { GrantRevokeParser.parse(database, statement, outputIgnoredStatements); } else if (PATTERN_CREATE_POLICY.matcher(statement).matches()) { CreatePolicyParser.parse(database, statement); // we just ignore these statements } else if (outputIgnoredStatements) { database.addIgnoredStatement(statement); } else { // these statements are ignored if outputIgnoredStatements // is false } statement = getWholeStatement(reader); } return database; } /** * Loads database schema from dump file. * * @param file name of file containing the dump * @param charsetName charset that should be used to read the * file * @param outputIgnoredStatements whether ignored statements should be * included in the output * @param ignoreSlonyTriggers whether Slony triggers should be ignored * @param ignoreSchemaCreation whether Schema creation should be ignored * * @return database schema from dump file */ public static PgDatabase loadDatabaseSchema(final String file, final String charsetName, final boolean outputIgnoredStatements, final boolean ignoreSlonyTriggers, final boolean ignoreSchemaCreation) { if (file.equals("-")) return loadDatabaseSchema(System.in, charsetName, outputIgnoredStatements, ignoreSlonyTriggers, ignoreSchemaCreation); FileInputStream fis = null; try { fis = new FileInputStream(file); return loadDatabaseSchema(fis, charsetName, outputIgnoredStatements, ignoreSlonyTriggers, ignoreSchemaCreation); } catch (final FileNotFoundException ex) { throw new FileException(MessageFormat.format( Resources.getString("FileNotFound"), file), ex); } finally { if (fis != null) { try { fis.close(); } catch (IOException ex){} } } } /** * Reads whole statement from the reader into single-line string. * * @param reader reader to be read * * @return whole statement from the reader into single-line string */ private static String getWholeStatement(final BufferedReader reader) { final StringBuilder sbStatement = new StringBuilder(1024); if (lineBuffer != null) { sbStatement.append(lineBuffer); lineBuffer = null; stripComment(sbStatement); } int pos = sbStatement.indexOf(";"); while (true) { if (pos == -1) { final String newLine; try { newLine = reader.readLine(); } catch (IOException ex) { throw new FileException( Resources.getString("CannotReadFile"), ex); } if (newLine == null) { if (sbStatement.toString().trim().length() == 0) { return null; } else { throw new RuntimeException(MessageFormat.format( Resources.getString("EndOfStatementNotFound"), sbStatement.toString())); } } if (sbStatement.length() > 0) { sbStatement.append(System.getProperty("line.separator")); } pos = sbStatement.length(); sbStatement.append(newLine); stripComment(sbStatement); pos = sbStatement.indexOf(";", pos); } else { if (!isQuoted(sbStatement, pos)) { if (pos == sbStatement.length() - 1) { lineBuffer = null; } else { lineBuffer = sbStatement.substring(pos + 1); sbStatement.setLength(pos + 1); } return sbStatement.toString().trim(); } pos = sbStatement.indexOf(";", pos + 1); } } } /** * Strips comment from statement line. * * @param sbStatement string builder containing statement */ private static void stripComment(final StringBuilder sbStatement) { int pos = sbStatement.indexOf("--"); while (pos >= 0) { if (pos == 0) { sbStatement.setLength(0); return; } else { if (!isQuoted(sbStatement, pos)) { sbStatement.setLength(pos); return; } } pos = sbStatement.indexOf("--", pos + 1); } int endPos = sbStatement.indexOf("*/"); while (endPos >= 0) { if (!isQuoted(sbStatement, endPos)) { int startPos = sbStatement.lastIndexOf("/*", endPos); if (startPos < endPos && !isQuoted(sbStatement, startPos)) { sbStatement.replace(startPos, endPos + 2, ""); } } endPos = sbStatement.indexOf("*/", endPos+2); } } /** * Checks whether specified position in the string builder is quoted. It * might be quoted either by single quote or by dollar sign quoting. * * @param sbString string builder * @param pos position to be checked * * @return true if the specified position is quoted, otherwise false */ @SuppressWarnings("AssignmentToForLoopParameter") private static boolean isQuoted(final StringBuilder sbString, final int pos) { boolean isQuoted = false; boolean insideDoubleQuotes = false; boolean insideSingeQuote = false; // Determine if double quote is inside of a single quote. for (int curPos = 0; curPos < pos; curPos++) { // Check if the quote is inside of a double quotes if (sbString.charAt(curPos) == '\"' && !insideSingeQuote ){ insideDoubleQuotes = !insideDoubleQuotes; } if (sbString.charAt(curPos) == '\'' && !insideDoubleQuotes ){ insideSingeQuote = !insideSingeQuote; } if(!insideDoubleQuotes){ if (sbString.charAt(curPos) == '\'') { isQuoted = !isQuoted; // if quote was escaped by backslash, it's like double quote if (pos > 0 && sbString.charAt(pos - 1) == '\\') { isQuoted = !isQuoted; } } else if (sbString.charAt(curPos) == '$' && !isQuoted) { final int endPos = sbString.indexOf("$", curPos + 1); if (endPos == -1) { return false; } final String tag = sbString.substring(curPos, endPos + 1); if (!isCorrectTag(tag)) { return false; } final int endTagPos = sbString.indexOf(tag, endPos + 1); // if end tag was not found or it was found after the checked // position, it's quoted if (endTagPos == -1 || endTagPos > pos) { return true; } curPos = endTagPos + tag.length() - 1; } } } return isQuoted; } /** * Checks whether dollar quoting tag is correct. * * @param tag tag to be checked * * @return true if the tag is correct, otherwise false */ private static boolean isCorrectTag(final String tag) { return !PATTERN_DOLLAR_TAG.matcher(tag).find(); } /** * Creates a new instance of PgDumpLoader. */ private PgDumpLoader() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/loader/package-info.java000066400000000000000000000001251316501242600264240ustar00rootroot00000000000000/** * Contains PostgreSQL dump loader. */ package cz.startnet.utils.pgdiff.loader; apgdiff/src/main/java/cz/startnet/utils/pgdiff/package-info.java000066400000000000000000000001621316501242600251570ustar00rootroot00000000000000/** * Contains tool that creates diff file from two PostgreSQL dump files. */ package cz.startnet.utils.pgdiff; apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/000077500000000000000000000000001316501242600234505ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/AlterRelationParser.java000066400000000000000000000376711316501242600302530ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.*; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; /** * Parses ALTER TABLE statements. * * @author fordfrog */ public class AlterRelationParser { /** * Parses ALTER TABLE statement. * * @param database database * @param statement ALTER TABLE statement * @param outputIgnoredStatements whether ignored statements should be * output in the diff */ public static void parse(final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { final Parser parser = new Parser(statement); parser.expect("ALTER"); /* * PostgreSQL allows using ALTER TABLE on views as well as other * relation types, so we just ignore type here and derive its type from * the original CREATE command. */ parser.expectOptional("FOREIGN"); //OK FOREIGN TABLE if (parser.expectOptional("TABLE")) { parser.expectOptional("ONLY"); } else if (parser.expectOptional("MATERIALIZED", "VIEW") || parser.expectOptional("VIEW")) { // OK, view } else { parser.throwUnsupportedCommand(); } final String relName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(relName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(relName); final PgRelation rel = schema.getRelation(objectName); if (rel == null) { final PgSequence sequence = schema.getSequence(objectName); if (sequence != null) { parseSequence(parser, sequence, outputIgnoredStatements, relName, database); return; } throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindObject"), relName, statement)); } PgTable table = null; if (rel instanceof PgTable) { table = (PgTable) rel; } while (!parser.expectOptional(";")) { if (parser.expectOptional("ALTER")) { parseAlterColumn(parser, rel); } else if (parser.expectOptional("CLUSTER", "ON")) { rel.setClusterIndexName( ParserUtils.getObjectName(parser.parseIdentifier())); } else if (parser.expectOptional("OWNER", "TO")) { rel.setOwnerTo(parser.parseIdentifier()); } else if (table != null && parser.expectOptional("ADD")) { if (parser.expectOptional("FOREIGN", "KEY")) { parseAddForeignKey(parser, table); } else if (parser.expectOptional("CONSTRAINT")) { parseAddConstraint(parser, table, schema); } else { parser.throwUnsupportedCommand(); } } else if (table != null && parser.expectOptional("ENABLE", "ROW", "LEVEL", "SECURITY")) { table.setRLSEnabled(true); } else if (table != null && parser.expectOptional("DISABLE", "ROW", "LEVEL", "SECURITY")) { table.setRLSEnabled(false); } else if (table != null && parser.expectOptional("FORCE", "ROW", "LEVEL", "SECURITY")) { table.setRLSForced(true); } else if (table != null && parser.expectOptional("NO", "FORCE", "ROW", "LEVEL", "SECURITY")) { table.setRLSForced(false); } else if (table != null && parser.expectOptional("ENABLE")) { parseEnable( parser, outputIgnoredStatements, relName, database); } else if (table != null && parser.expectOptional("DISABLE")) { parseDisable( parser, outputIgnoredStatements, relName, database); } else { parser.throwUnsupportedCommand(); } if (parser.expectOptional(";")) { break; } else { parser.expect(","); } } } /** * Parses ENABLE statements. * * @param parser parser * @param outputIgnoredStatements whether ignored statements should be * output in the diff * @param tableName table name as it was specified in the * statement * @param database database information * */ private static void parseEnable(final Parser parser, final boolean outputIgnoredStatements, final String tableName, final PgDatabase database) { if (parser.expectOptional("REPLICA")) { if (parser.expectOptional("TRIGGER")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " ENABLE REPLICA TRIGGER " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else if (parser.expectOptional("RULE")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " ENABLE REPLICA RULE " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } else if (parser.expectOptional("ALWAYS")) { if (parser.expectOptional("TRIGGER")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " ENABLE ALWAYS TRIGGER " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else if (parser.expectOptional("RULE")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " ENABLE RULE " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } } /** * Parses DISABLE statements. * * @param parser parser * @param outputIgnoredStatements whether ignored statements should be * output in the diff * @param tableName table name as it was specified in the * statement * @param database database information * */ private static void parseDisable(final Parser parser, final boolean outputIgnoredStatements, final String tableName, final PgDatabase database) { if (parser.expectOptional("TRIGGER")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " DISABLE TRIGGER " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else if (parser.expectOptional("RULE")) { if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " DISABLE RULE " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } /** * Parses ADD CONSTRAINT action. * * @param parser parser * @param table table * @param schema schema */ private static void parseAddConstraint(final Parser parser, final PgTable table, final PgSchema schema) { final String constraintName = ParserUtils.getObjectName(parser.parseIdentifier()); final PgConstraint constraint = new PgConstraint(constraintName); constraint.setTableName(table.getName()); table.addConstraint(constraint); if (parser.expectOptional("PRIMARY", "KEY")) { schema.addPrimaryKey(constraint); constraint.setDefinition("PRIMARY KEY " + parser.getExpression()); } else { constraint.setDefinition(parser.getExpression()); } } /** * Parses ALTER COLUMN action. * * @param parser parser * @param rel view/table */ private static void parseAlterColumn(final Parser parser, final PgRelation rel) { parser.expectOptional("COLUMN"); final String columnName = ParserUtils.getObjectName(parser.parseIdentifier()); if (parser.expectOptional("SET")) { if (parser.expectOptional("STATISTICS")) { final PgColumn column = rel.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } column.setStatistics(parser.parseInteger()); } else if (parser.expectOptional("NOT NULL")) { if (rel.containsColumn(columnName)) { final PgColumn column = rel.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } column.setNullValue(false); } else if (rel.containsInheritedColumn(columnName)) { final PgInheritedColumn inheritedColumn = rel.getInheritedColumn(columnName); if (inheritedColumn == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } inheritedColumn.setNullValue(false); } else { throw new ParserException(MessageFormat.format( Resources.getString("CannotFindColumnInTable"), columnName, rel.getName())); } } else if (parser.expectOptional("DEFAULT")) { final String defaultValue = parser.getExpression(); if (rel.containsColumn(columnName)) { final PgColumn column = rel.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } column.setDefaultValue(defaultValue); } else if (rel.containsInheritedColumn(columnName)) { final PgInheritedColumn column = rel.getInheritedColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } column.setDefaultValue(defaultValue); } else { throw new ParserException(MessageFormat.format( Resources.getString("CannotFindColumnInTable"), columnName, rel.getName())); } } else if (parser.expectOptional("STORAGE")) { final PgColumn column = rel.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, rel.getName(), parser.getString())); } if (parser.expectOptional("PLAIN")) { column.setStorage("PLAIN"); } else if (parser.expectOptional("EXTERNAL")) { column.setStorage("EXTERNAL"); } else if (parser.expectOptional("EXTENDED")) { column.setStorage("EXTENDED"); } else if (parser.expectOptional("MAIN")) { column.setStorage("MAIN"); } else { parser.throwUnsupportedCommand(); } } else { parser.throwUnsupportedCommand(); } } else { parser.throwUnsupportedCommand(); } } /** * Parses ADD FOREIGN KEY action. * * @param parser parser * @param table pg table */ private static void parseAddForeignKey(final Parser parser, final PgTable table) { final List columnNames = new ArrayList(1); parser.expect("("); while (!parser.expectOptional(")")) { columnNames.add( ParserUtils.getObjectName(parser.parseIdentifier())); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } final String constraintName = ParserUtils.generateName( table.getName() + "_", columnNames, "_fkey"); final PgConstraint constraint = new PgConstraint(constraintName); table.addConstraint(constraint); constraint.setDefinition(parser.getExpression()); constraint.setTableName(table.getName()); } /** * Parses ALTER TABLE sequence. * * @param parser parser * @param sequence sequence * @param outputIgnoredStatements whether ignored statements should be * output in the diff * @param sequenceName sequence name as it was specified in the * statement * @param database database information */ private static void parseSequence(final Parser parser, final PgSequence sequence, final boolean outputIgnoredStatements, final String sequenceName, final PgDatabase database) { while (!parser.expectOptional(";")) { if (parser.expectOptional("OWNER", "TO")) { // we do not parse this one so we just consume the identifier if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + sequenceName + " OWNER TO " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } } /** * Creates a new instance of AlterTableParser. */ private AlterRelationParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/AlterSequenceParser.java000066400000000000000000000044011316501242600302270ustar00rootroot00000000000000/** * Copyright 2010 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgSequence; import java.text.MessageFormat; /** * Parses ALTER SEQUENCE statements. * * @author mix86 */ public class AlterSequenceParser { /** * Parses ALTER SEQUENCE statement. * * @param database database * @param statement ALTER SEQUENCE statement * @param outputIgnoredStatements whether ignored statements should be * output in the diff */ public static void parse(final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { final Parser parser = new Parser(statement); parser.expect("ALTER", "SEQUENCE"); final String sequenceName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(sequenceName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(sequenceName); final PgSequence sequence = schema.getSequence(objectName); if (sequence == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSequence"), sequenceName, statement)); } while (!parser.expectOptional(";")) { if (parser.expectOptional("OWNED", "BY")) { if (parser.expectOptional("NONE")) { sequence.setOwnedBy(null); } else { sequence.setOwnedBy(parser.getExpression()); } } else { parser.throwUnsupportedCommand(); } } } /** * Creates new instance of AlterSequenceParser. */ private AlterSequenceParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CommentParser.java000066400000000000000000000257501316501242600271030ustar00rootroot00000000000000/** * Copyright 2010 StartNet s.r.o. */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.*; import java.text.MessageFormat; /** * COMMENT parser. * * @author fordfrog */ public class CommentParser { /** * Parses COMMENT statements. * * @param database database * @param statement COMMENT statement * @param outputIgnoredStatements whether ignored statements should be * output into the diff */ public static void parse(final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { final Parser parser = new Parser(statement); parser.expect("COMMENT", "ON"); if (parser.expectOptional("TABLE")) { parseTable(parser, database); } else if (parser.expectOptional("COLUMN")) { parseColumn(parser, database); } else if (parser.expectOptional("CONSTRAINT")) { parseConstraint(parser, database); } else if (parser.expectOptional("DATABASE")) { parseDatabase(parser, database); } else if (parser.expectOptional("FUNCTION")) { parseFunction(parser, database); } else if (parser.expectOptional("INDEX")) { parseIndex(parser, database); } else if (parser.expectOptional("SCHEMA")) { parseSchema(parser, database); } else if (parser.expectOptional("SEQUENCE")) { parseSequence(parser, database); } else if (parser.expectOptional("TRIGGER")) { parseTrigger(parser, database); } else if (parser.expectOptional("VIEW")) { parseView(parser, database); } else if (outputIgnoredStatements) { database.addIgnoredStatement(statement); } } /** * Parses COMMENT ON TABLE. * * @param parser parser * @param database database */ private static void parseTable(final Parser parser, final PgDatabase database) { final String tableName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(tableName); final String schemaName = ParserUtils.getSchemaName(tableName, database); final PgTable table = database.getSchema(schemaName).getTable(objectName); parser.expect("IS"); table.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON CONSTRAINT. * * @param parser parser * @param database database */ private static void parseConstraint(final Parser parser, final PgDatabase database) { final String constraintName = ParserUtils.getObjectName(parser.parseIdentifier()); parser.expect("ON"); final String tableName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(tableName); final String schemaName = ParserUtils.getSchemaName(constraintName, database); final PgConstraint constraint = database.getSchema(schemaName). getTable(objectName).getConstraint(constraintName); parser.expect("IS"); constraint.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON DATABASE. * * @param parser parser * @param database database */ private static void parseDatabase(final Parser parser, final PgDatabase database) { parser.parseIdentifier(); parser.expect("IS"); database.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON INDEX. * * @param parser parser * @param database database */ private static void parseIndex(final Parser parser, final PgDatabase database) { final String indexName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(indexName); final String schemaName = ParserUtils.getSchemaName(indexName, database); final PgSchema schema = database.getSchema(schemaName); final PgIndex index = schema.getIndex(objectName); if (index == null) { final PgConstraint primaryKey = schema.getPrimaryKey(objectName); parser.expect("IS"); primaryKey.setComment(getComment(parser)); parser.expect(";"); } else { parser.expect("IS"); index.setComment(getComment(parser)); parser.expect(";"); } } /** * Parses COMMENT ON SCHEMA. * * @param parser parser * @param database database */ private static void parseSchema(final Parser parser, final PgDatabase database) { final String schemaName = ParserUtils.getObjectName(parser.parseIdentifier()); final PgSchema schema = database.getSchema(schemaName); parser.expect("IS"); schema.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON SEQUENCE. * * @param parser parser * @param database database */ private static void parseSequence(final Parser parser, final PgDatabase database) { final String sequenceName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(sequenceName); final String schemaName = ParserUtils.getSchemaName(sequenceName, database); final PgSequence sequence = database.getSchema(schemaName).getSequence(objectName); parser.expect("IS"); sequence.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON TRIGGER. * * @param parser parser * @param database database */ private static void parseTrigger(final Parser parser, final PgDatabase database) { final String triggerName = ParserUtils.getObjectName(parser.parseIdentifier()); parser.expect("ON"); final String tableName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(tableName); final String schemaName = ParserUtils.getSchemaName(triggerName, database); final PgTrigger trigger = database.getSchema(schemaName). getTable(objectName).getTrigger(triggerName); parser.expect("IS"); trigger.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON VIEW. * * @param parser parser * @param database database */ private static void parseView(final Parser parser, final PgDatabase database) { final String viewName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(viewName); final String schemaName = ParserUtils.getSchemaName(viewName, database); final PgView view = database.getSchema(schemaName).getView(objectName); parser.expect("IS"); view.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON COLUMN. * * @param parser parser * @param database database */ private static void parseColumn(final Parser parser, final PgDatabase database) { final String columnName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(columnName); final String relName = ParserUtils.getSecondObjectName(columnName); final String schemaName = ParserUtils.getThirdObjectName(columnName); final PgSchema schema = database.getSchema(schemaName); final PgRelation rel = schema.getRelation(relName); final PgColumn column = rel.getColumn(objectName); if (column == null) { throw new ParserException(MessageFormat.format( Resources.getString("CannotFindColumnInTable"), columnName, rel.getName())); } parser.expect("IS"); column.setComment(getComment(parser)); parser.expect(";"); } /** * Parses COMMENT ON FUNCTION. * * @param parser parser * @param database database */ private static void parseFunction(final Parser parser, final PgDatabase database) { final String functionName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(functionName); final String schemaName = ParserUtils.getSchemaName(functionName, database); final PgSchema schema = database.getSchema(schemaName); parser.expect("("); final PgFunction tmpFunction = new PgFunction(); tmpFunction.setName(objectName); while (!parser.expectOptional(")")) { final String mode; if (parser.expectOptional("IN")) { mode = "IN"; } else if (parser.expectOptional("OUT")) { mode = "OUT"; } else if (parser.expectOptional("INOUT")) { mode = "INOUT"; } else if (parser.expectOptional("VARIADIC")) { mode = "VARIADIC"; } else { mode = null; } final int position = parser.getPosition(); String argumentName = null; String dataType = parser.parseDataType(); final int position2 = parser.getPosition(); if (!parser.expectOptional(")") && !parser.expectOptional(",")) { parser.setPosition(position); argumentName = ParserUtils.getObjectName(parser.parseIdentifier()); dataType = parser.parseDataType(); } else { parser.setPosition(position2); } final PgFunction.Argument argument = new PgFunction.Argument(); argument.setDataType(dataType); argument.setMode(mode); argument.setName(argumentName); tmpFunction.addArgument(argument); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } final PgFunction function = schema.getFunction(tmpFunction.getSignature()); parser.expect("IS"); function.setComment(getComment(parser)); parser.expect(";"); } /** * Parses comment from parser. If comment is "null" string then null is * returned, otherwise the parsed string is returned. * * @param parser parser * * @return string or null */ private static String getComment(final Parser parser) { final String comment = parser.parseString(); if ("null".equalsIgnoreCase(comment)) { return null; } return comment; } /** * Creates new instance of CommentParser. */ private CommentParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateExtensionParser.java000066400000000000000000000027221316501242600305730ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgExtension; import cz.startnet.utils.pgdiff.schema.PgSchema; /** * Parses CREATE EXTENSION statements. * * @author atila */ public class CreateExtensionParser { /** * Parses CREATE EXTENSION statement. * * @param database database * @param statement CREATE EXTENSION statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE", "EXTENSION"); parser.expectOptional("IF", "NOT", "EXISTS"); final String extensionName = parser.parseIdentifier(); final PgExtension extension = new PgExtension(extensionName); parser.expectOptional("WITH"); if (parser.expectOptional("SCHEMA")) { extension.setSchema(new PgSchema(parser.parseString())); } if (parser.expectOptional("VERSION")) { extension.setVersion(parser.parseString()); } if (parser.expectOptional("FROM")) { extension.setFrom(parser.parseString()); } database.addExtension(extension); } /** * Creates a new instance of CreateExtensionParser. */ private CreateExtensionParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateFunctionParser.java000066400000000000000000000070571316501242600304120ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgFunction; import cz.startnet.utils.pgdiff.schema.PgSchema; import java.text.MessageFormat; /** * Parses CREATE FUNCTION and CREATE OR REPLACE FUNCTION statements. * * @author fordfrog */ public class CreateFunctionParser { /** * Parses CREATE FUNCTION and CREATE OR REPLACE FUNCTION statement. * * @param database database * @param statement CREATE FUNCTION statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); parser.expect("FUNCTION"); final String functionName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(functionName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final PgFunction function = new PgFunction(); function.setName(ParserUtils.getObjectName(functionName)); schema.addFunction(function); parser.expect("("); while (!parser.expectOptional(")")) { final String mode; if (parser.expectOptional("IN")) { mode = "IN"; } else if (parser.expectOptional("OUT")) { mode = "OUT"; } else if (parser.expectOptional("INOUT")) { mode = "INOUT"; } else if (parser.expectOptional("VARIADIC")) { mode = "VARIADIC"; } else { mode = null; } final int position = parser.getPosition(); String argumentName = null; String dataType = parser.parseDataType(); final int position2 = parser.getPosition(); if (!parser.expectOptional(")") && !parser.expectOptional(",") && !parser.expectOptional("=") && !parser.expectOptional("DEFAULT")) { parser.setPosition(position); argumentName = ParserUtils.getObjectName(parser.parseIdentifier()); dataType = parser.parseDataType(); } else { parser.setPosition(position2); } final String defaultExpression; if (parser.expectOptional("=") || parser.expectOptional("DEFAULT")) { defaultExpression = parser.getExpression(); } else { defaultExpression = null; } final PgFunction.Argument argument = new PgFunction.Argument(); argument.setDataType(dataType); argument.setDefaultExpression(defaultExpression); argument.setMode(mode); argument.setName(argumentName); function.addArgument(argument); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } function.setBody(parser.getRest()); } /** * Creates a new instance of CreateFunctionParser. */ private CreateFunctionParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateIndexParser.java000066400000000000000000000043451316501242600276710ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.*; import java.text.MessageFormat; /** * Parses CREATE INDEX statements. * * @author fordfrog */ public class CreateIndexParser { /** * Parses CREATE INDEX statement. * * @param database database * @param statement CREATE INDEX statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE"); final boolean unique = parser.expectOptional("UNIQUE"); parser.expect("INDEX"); parser.expectOptional("CONCURRENTLY"); final String indexName = ParserUtils.getObjectName(parser.parseIdentifier()); parser.expect("ON"); final String tableName = parser.parseIdentifier(); final String definition = parser.getRest(); final String schemaName = ParserUtils.getSchemaName(tableName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(tableName); final PgTable table = schema.getTable(objectName); final PgView view = schema.getView(objectName); final PgIndex index = new PgIndex(indexName); if (table != null) { table.addIndex(index); } else if (view != null) { view.addIndex(index); } else { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindObject"), tableName, statement)); } schema.addIndex(index); index.setDefinition(definition.trim()); index.setTableName(objectName); index.setUnique(unique); } /** * Creates a new instance of CreateIndexParser. */ private CreateIndexParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreatePolicyParser.java000066400000000000000000000054601316501242600300600ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.*; import java.text.MessageFormat; public class CreatePolicyParser { public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); final PgPolicy policy = new PgPolicy(); parser.expect("CREATE", "POLICY"); final String policyName = parser.parseIdentifier(); parser.expect("ON"); final String qualifiedTableName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(qualifiedTableName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final PgTable table = schema.getTable(ParserUtils.getObjectName(qualifiedTableName)); if (table == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTable"), qualifiedTableName, statement)); } if (parser.expectOptional("FOR")) { String command = parser.expectOptionalOneOf("ALL", "SELECT", "INSERT", "UPDATE", "DELETE"); policy.setCommand(command); } else { policy.setCommand("ALL"); } if (parser.expectOptional("TO")) { if (parser.expectOptional("PUBLIC")){ policy.getRoles().add("PUBLIC"); } else { String role = parser.parseIdentifier(); policy.getRoles().add(role); while (role != null) { if (parser.expectOptional(",")) { parser.skipWhitespace(); role = parser.parseIdentifier(); policy.getRoles().add(role); } else { role = null; } } } } else { policy.getRoles().add("PUBLIC"); } if (parser.expectOptional("USING")){ parser.expect("("); policy.setUsing(parser.getExpression()); parser.expect(")"); } if (parser.expectOptional("WITH", "CHECK")){ parser.expect("("); policy.setWithCheck(parser.getExpression()); parser.expect(")"); } policy.setName(policyName); policy.setTableName(table.getName()); table.addPolicy(policy); } private CreatePolicyParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateSchemaParser.java000066400000000000000000000034061316501242600300170ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; /** * Parses CREATE SCHEMA statements. * * @author fordfrog */ public class CreateSchemaParser { /** * Parses CREATE SCHEMA statement. * * @param database database * @param statement CREATE SCHEMA statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE", "SCHEMA"); if (parser.expectOptional("AUTHORIZATION")) { final PgSchema schema = new PgSchema( ParserUtils.getObjectName(parser.parseIdentifier())); database.addSchema(schema); schema.setAuthorization(schema.getName()); final String definition = parser.getRest(); if (definition != null && !definition.isEmpty()) { schema.setDefinition(definition); } } else { final PgSchema schema = new PgSchema( ParserUtils.getObjectName(parser.parseIdentifier())); database.addSchema(schema); if (parser.expectOptional("AUTHORIZATION")) { schema.setAuthorization( ParserUtils.getObjectName(parser.parseIdentifier())); } final String definition = parser.getRest(); if (definition != null && !definition.isEmpty()) { schema.setDefinition(definition); } } } /** * Creates a new CreateSchemaParser object. */ private CreateSchemaParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateSequenceParser.java000066400000000000000000000062271316501242600303730ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgSequence; import java.text.MessageFormat; /** * Parses CREATE SEQUENCE statements. * * @author fordfrog */ public class CreateSequenceParser { /** * Parses CREATE SEQUENCE statement. * * @param database database * @param statement CREATE SEQUENCE statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE", "SEQUENCE"); final String sequenceName = parser.parseIdentifier(); final PgSequence sequence = new PgSequence(ParserUtils.getObjectName(sequenceName)); final String schemaName = ParserUtils.getSchemaName(sequenceName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } schema.addSequence(sequence); while (!parser.expectOptional(";")) { if (parser.expectOptional("INCREMENT")) { parser.expectOptional("BY"); sequence.setIncrement(parser.parseString()); } else if (parser.expectOptional("MINVALUE")) { sequence.setMinValue(parser.parseString()); } else if (parser.expectOptional("MAXVALUE")) { sequence.setMaxValue(parser.parseString()); } else if (parser.expectOptional("START")) { parser.expectOptional("WITH"); sequence.setStartWith(parser.parseString()); } else if (parser.expectOptional("CACHE")) { sequence.setCache(parser.parseString()); } else if (parser.expectOptional("CYCLE")) { sequence.setCycle(true); } else if (parser.expectOptional("OWNED", "BY")) { if (parser.expectOptional("NONE")) { sequence.setOwnedBy(null); } else { sequence.setOwnedBy(ParserUtils.getObjectName( parser.parseIdentifier())); } } else if (parser.expectOptional("NO")) { if (parser.expectOptional("MINVALUE")) { sequence.setMinValue(null); } else if (parser.expectOptional("MAXVALUE")) { sequence.setMaxValue(null); } else if (parser.expectOptional("CYCLE")) { sequence.setCycle(false); } else { parser.throwUnsupportedCommand(); } } else { parser.throwUnsupportedCommand(); } } } /** * Creates a new instance of CreateSequenceParser. */ private CreateSequenceParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateTableParser.java000066400000000000000000000132041316501242600276430ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgConstraint; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; import java.text.MessageFormat; /** * Parses CREATE TABLE statements. * * @author fordfrog */ public class CreateTableParser { /** * Parses CREATE TABLE statement. * * @param database database * @param statement CREATE TABLE statement * @param ignoreSchemaCreation whether schema creation should be ignored */ public static void parse(final PgDatabase database, final String statement, final boolean ignoreSchemaCreation) { final Parser parser = new Parser(statement); parser.expect("CREATE"); final boolean unlogged = parser.expectOptional("UNLOGGED"); final boolean foreign = parser.expectOptional("FOREIGN"); parser.expect("TABLE"); // Optional IF NOT EXISTS, irrelevant for our purposes parser.expectOptional("IF", "NOT", "EXISTS"); final String tableName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(tableName, database); PgSchema schema = database.getSchema(schemaName); if (schema == null) { if (ignoreSchemaCreation) { schema = new PgSchema(schemaName); database.addSchema(schema); } else { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } } final PgTable table = new PgTable(ParserUtils.getObjectName(tableName), database, schema); table.setUnlogged(unlogged); table.setForeign(foreign); schema.addRelation(table); parser.expect("("); while (!parser.expectOptional(")")) { if (parser.expectOptional("CONSTRAINT")) { parseConstraint(parser, table); } else if (parser.expectOptional("PRIMARY", "KEY")) { throw new ParserException(Resources.getString( "CreateTablePrimaryKeyNotSupported")); } else if (parser.expectOptional("UNIQUE")) { throw new ParserException( Resources.getString("CreateTableUniqueNotSupported")); } else { parseColumn(parser, table); } if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } while (!parser.expectOptional(";")) { if (parser.expectOptional("INHERITS")) { parseInherits(database, parser, table); } else if (parser.expectOptional("WITHOUT")) { table.setWith("OIDS=false"); } else if (parser.expectOptional("WITH")) { if (parser.expectOptional("OIDS") || parser.expectOptional("OIDS=true")) { table.setWith("OIDS=true"); } else if (parser.expectOptional("OIDS=false")) { table.setWith("OIDS=false"); } else { table.setWith(parser.getExpression()); } } else if (parser.expectOptional("TABLESPACE")) { table.setTablespace(parser.parseString()); } else if (parser.expectOptional("SERVER")) { table.setForeignServer(parser.getExpression()); } else { parser.throwUnsupportedCommand(); } } } /** * Parses INHERITS. * * @param database database * @param parser parser * @param table pg table */ private static void parseInherits(final PgDatabase database,final Parser parser, final PgTable table) { parser.expect("("); while (!parser.expectOptional(")")) { final String parsedString = parser.parseIdentifier(); final String tableName = ParserUtils.getObjectName(parsedString); final String schemaName = parsedString.contains(".") ? ParserUtils.getSecondObjectName(parsedString) : database.getDefaultSchema().getName(); table.addInherits(schemaName, tableName); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } } /** * Parses CONSTRAINT definition. * * @param parser parser * @param table table */ private static void parseConstraint(final Parser parser, final PgTable table) { final PgConstraint constraint = new PgConstraint( ParserUtils.getObjectName(parser.parseIdentifier())); table.addConstraint(constraint); constraint.setDefinition(parser.getExpression()); constraint.setTableName(table.getName()); } /** * Parses column definition. * * @param parser parser * @param table table */ private static void parseColumn(final Parser parser, final PgTable table) { final PgColumn column = new PgColumn( ParserUtils.getObjectName(parser.parseIdentifier())); table.addColumn(column); column.parseDefinition(parser.getExpression()); } /** * Creates a new instance of CreateTableParser. */ private CreateTableParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateTriggerParser.java000066400000000000000000000073751316501242600302330ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTrigger; /** * Parses CREATE TRIGGER statements. * * @author fordfrog */ public class CreateTriggerParser { /** * Parses CREATE TRIGGER statement. * * @param database database * @param statement CREATE TRIGGER statement * @param ignoreSlonyTriggers whether Slony triggers should be ignored */ public static void parse(final PgDatabase database, final String statement, final boolean ignoreSlonyTriggers) { final Parser parser = new Parser(statement); parser.expect("CREATE", "TRIGGER"); final String triggerName = parser.parseIdentifier(); final String objectName = ParserUtils.getObjectName(triggerName); final PgTrigger trigger = new PgTrigger(); trigger.setName(objectName); if (parser.expectOptional("BEFORE")) { trigger.setEventTimeQualification(PgTrigger.EventTimeQualification.before); } else if (parser.expectOptional("AFTER")) { trigger.setEventTimeQualification(PgTrigger.EventTimeQualification.after); } else if (parser.expectOptional("INSTEAD OF")) { trigger.setEventTimeQualification(PgTrigger.EventTimeQualification.instead_of); } boolean first = true; while (true) { if (!first && !parser.expectOptional("OR")) { break; } else if (parser.expectOptional("INSERT")) { trigger.setOnInsert(true); } else if (parser.expectOptional("UPDATE")) { trigger.setOnUpdate(true); if (parser.expectOptional("OF")) { do { trigger.addUpdateColumn(parser.parseIdentifier()); } while (parser.expectOptional(",")); } } else if (parser.expectOptional("DELETE")) { trigger.setOnDelete(true); } else if (parser.expectOptional("TRUNCATE")) { trigger.setOnTruncate(true); } else if (first) { break; } else { parser.throwUnsupportedCommand(); } first = false; } parser.expect("ON"); final String relationName = parser.parseIdentifier(); trigger.setRelationName(ParserUtils.getObjectName(relationName)); if (parser.expectOptional("FOR")) { parser.expectOptional("EACH"); if (parser.expectOptional("ROW")) { trigger.setForEachRow(true); } else if (parser.expectOptional("STATEMENT")) { trigger.setForEachRow(false); } else { parser.throwUnsupportedCommand(); } } if (parser.expectOptional("WHEN")) { parser.expect("("); trigger.setWhen(parser.getExpression()); parser.expect(")"); } parser.expect("EXECUTE", "PROCEDURE"); trigger.setFunction(parser.getRest()); final boolean ignoreSlonyTrigger = ignoreSlonyTriggers && ("_slony_logtrigger".equals(trigger.getName()) || "_slony_denyaccess".equals(trigger.getName())); if (!ignoreSlonyTrigger) { final PgSchema schema = database.getSchema( ParserUtils.getSchemaName(relationName, database)); schema.getRelation(trigger.getRelationName()).addTrigger(trigger); } } /** * Creates a new CreateTableParser object. */ private CreateTriggerParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateTypeParser.java000066400000000000000000000053151316501242600275410ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgType; import java.text.MessageFormat; import javax.xml.parsers.ParserConfigurationException; /** * Parses CREATE TABLE statements. * * @author fordfrog */ public class CreateTypeParser { /** * Parses CREATE TYPE statement. * * @param database database * @param statement CREATE TYPE statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE", "TYPE"); final String typeName = parser.parseIdentifier(); final PgType type = new PgType(ParserUtils.getObjectName(typeName)); final String schemaName = ParserUtils.getSchemaName(typeName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } schema.addType(type); parser.expect("AS"); if (parser.expectOptional("ENUM")) { type.setIsEnum(true); } parser.expect("("); while (!parser.expectOptional(")")) { if (type.getIsEnum()) { String name = parser.getExpression(); type.addEnumValue(name); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } else { parseColumn(parser, type); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } } while (!parser.expectOptional(";")) { } } /** * Parses column definition. * * @param parser parser * @param type type */ private static void parseColumn(final Parser parser, final PgType type) { final PgColumn column = new PgColumn( ParserUtils.getObjectName(parser.parseIdentifier())); type.addColumn(column); column.parseDefinition(parser.getExpression()); } /** * Creates a new instance of CreateTableParser. */ private CreateTypeParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateViewParser.java000066400000000000000000000042331316501242600275300ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgView; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; /** * Parses CREATE VIEW statements. * * @author fordfrog */ public class CreateViewParser { /** * Parses CREATE VIEW statement. * * @param database database * @param statement CREATE VIEW statement */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); final boolean materialized = parser.expectOptional("MATERIALIZED"); parser.expect("VIEW"); final String viewName = parser.parseIdentifier(); final boolean columnsExist = parser.expectOptional("("); final List columnNames = new ArrayList(10); if (columnsExist) { while (!parser.expectOptional(")")) { columnNames.add( ParserUtils.getObjectName(parser.parseIdentifier())); parser.expectOptional(","); } } parser.expect("AS"); final String query = parser.getRest(); final PgView view = new PgView(ParserUtils.getObjectName(viewName)); view.setMaterialized(materialized); view.setDeclaredColumnNames(columnNames); view.setQuery(query); final String schemaName = ParserUtils.getSchemaName(viewName, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } schema.addRelation(view); } /** * Creates a new instance of CreateViewParser. */ private CreateViewParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/GrantRevokeParser.java000066400000000000000000000450641316501242600277300ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import cz.startnet.utils.pgdiff.Resources; import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgColumnPrivilege; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgFunction; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgSequence; import cz.startnet.utils.pgdiff.schema.PgSequencePrivilege; import cz.startnet.utils.pgdiff.schema.PgTable; import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import cz.startnet.utils.pgdiff.schema.PgView; /** * Parses GRANT statements. * * @author user */ public class GrantRevokeParser { /** * Parses GRANT statement. * * @param database * database * @param statement * GRANT statement * @param outputIgnoredStatements * whether ignored statements should be output in the diff */ public static void parse(final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { boolean grant; // Map> privileges = new TreeMap>(); List privileges = new ArrayList(); List> privilegesColumns = new ArrayList>(); List identifiers = new ArrayList(); List roles = new ArrayList(); boolean grantOption = false; String revokeMode; final Parser parser = new Parser(statement); grant = parser.expect("GRANT", true); if (!grant) { parser.expect("REVOKE"); grantOption = parser.expect("GRANT OPTION FOR", true); } String privilege = parser.expectOptionalOneOf("ALL", "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", "USAGE"); List columns = null; if (privilege == null) { // unknown privilege so unsupported object privilege // object role_name is using a different syntax so will always pass // here if (outputIgnoredStatements) { database.addIgnoredStatement(statement); return; } else { return; } } if (privilege != null && "ALL".equalsIgnoreCase(privilege)) { parser.expectOptional("PRIVILEGES"); } if (privilege != null && ("ALL".equalsIgnoreCase(privilege)) || ("SELECT".equalsIgnoreCase(privilege)) || ("INSERT".equalsIgnoreCase(privilege)) || ("UPDATE".equalsIgnoreCase(privilege)) || ("REFERENCES".equalsIgnoreCase(privilege))) { columns = parseColumns(parser, database, statement, outputIgnoredStatements); } else { columns = null; } privileges.add(privilege); privilegesColumns.add(columns); while (privilege != null) { if (parser.expectOptional(",")) { privilege = parser.expectOptionalOneOf("SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", "USAGE"); if (privilege != null && ("ALL".equalsIgnoreCase(privilege)) || ("SELECT".equalsIgnoreCase(privilege)) || ("INSERT".equalsIgnoreCase(privilege)) || ("UPDATE".equalsIgnoreCase(privilege)) || ("REFERENCES".equalsIgnoreCase(privilege))) { columns = parseColumns(parser, database, statement, outputIgnoredStatements); } else { columns = null; } privileges.add(privilege); privilegesColumns.add(columns); } else { privilege = null; } } boolean separator = parser.expectOptional("ON"); if (!separator) { // column object if (outputIgnoredStatements) { database.addIgnoredStatement(statement); return; } } // TODO check 'ALL TABLES IN SCHEMA' may not work String objectType = parser.expectOptionalOneOf("TABLE", "ALL TABLES IN SCHEMA", "SEQUENCE", "ALL SEQUENCES IN SCHEMA", "DATABASE", "DOMAIN", "FOREIGN DATA WRAPPER", "FOREIGN SERVER", "FUNCTION", "ALL FUNCTIONS IN SCHEMA", "LANGUAGE", "LARGE OBJECT", "SCHEMA", "TABLESPACE", "TYPE"); if (objectType == null) { objectType = "TABLE"; } String identifier = parser.parseIdentifier(); if ("FUNCTION".equalsIgnoreCase(objectType) || "ALL FUNCTIONS IN SCHEMA".equalsIgnoreCase(objectType)) { parseConsumeFunctionSignature(parser, database, statement, outputIgnoredStatements); } identifiers.add(identifier); while (identifier != null) { if (parser.expectOptional(",")) { identifier = parser.parseIdentifier(); if ("FUNCTION".equalsIgnoreCase(objectType) || "ALL FUNCTIONS IN SCHEMA" .equalsIgnoreCase(objectType)) { parseConsumeFunctionSignature(parser, database, statement, outputIgnoredStatements); } identifiers.add(identifier); } else { identifier = null; } } if (grant) { parser.expect("TO"); } else { parser.expect("FROM"); } parser.expectOptional("GROUP"); String role = parser.parseIdentifier(); roles.add(role); while (role != null) { if (parser.expectOptional(",")) { parser.expectOptional("GROUP"); role = parser.parseIdentifier(); roles.add(role); } else { role = null; } } if (grant) { grantOption = parser.expectOptional("WITH GRANT OPTION"); } else { revokeMode = parser.expectOptionalOneOf("RESTRICT", "CASCADE"); if ("CASCADE".equalsIgnoreCase(revokeMode)) { if (outputIgnoredStatements) { database.addIgnoredStatement(statement); return; } } } if ("TABLE".equalsIgnoreCase(objectType) && columns == null) { for (String name : identifiers) { final String schemaName = ParserUtils.getSchemaName(name, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(name); final PgTable table = schema.getTable(objectName); final PgView view = schema.getView(objectName); if (table != null) { for (String roleName : roles) { PgRelationPrivilege tablePrivilege = table .getPrivilege(roleName); if (tablePrivilege == null) { tablePrivilege = new PgRelationPrivilege(roleName); table.addPrivilege(tablePrivilege); } for (String priv : privileges) { tablePrivilege.setPrivileges(priv, grant, grantOption); } } } else if (view != null) { for (String roleName : roles) { PgRelationPrivilege viewPrivilege = view .getPrivilege(roleName); if (viewPrivilege == null) { viewPrivilege = new PgRelationPrivilege(roleName); view.addPrivilege(viewPrivilege); } for (String priv : privileges) { viewPrivilege.setPrivileges(priv, grant, grantOption); } } } else { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindObject"), name, statement)); } } } else if ("TABLE".equalsIgnoreCase(objectType) && columns != null) { for (String name : identifiers) { final String schemaName = ParserUtils.getSchemaName(name, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(name); final PgTable table = schema.getTable(objectName); final PgView view = schema.getView(objectName); if (table != null) { for (int i = 0; i < privileges.size(); i++) { String privKey = privileges.get(i); List privValue = privilegesColumns.get(i); for (String columnName : privValue) { if (table.containsColumn(columnName)) { final PgColumn column = table .getColumn(columnName); if (column == null) { throw new RuntimeException( MessageFormat.format( Resources .getString("CannotFindTableColumn"), columnName, table.getName(), parser .getString())); } for (String roleName : roles) { PgColumnPrivilege columnPrivilege = column .getPrivilege(roleName); if (columnPrivilege == null) { columnPrivilege = new PgColumnPrivilege( roleName); column.addPrivilege(columnPrivilege); } columnPrivilege.setPrivileges(privKey, grant, grantOption); } } else { throw new ParserException( MessageFormat.format( Resources .getString("CannotFindColumnInTable"), columnName, table.getName())); } } } } else if (view != null) { for (int i = 0; i < privileges.size(); i++) { String privKey = privileges.get(i); List privValue = privilegesColumns.get(i); for (String columnName : privValue) { if (view.containsColumn(columnName)) { final PgColumn column = view .getColumn(columnName); if (column == null) { throw new RuntimeException( MessageFormat.format( Resources .getString("CannotFindTableColumn"), columnName, view.getName(), parser .getString())); } for (String roleName : roles) { PgColumnPrivilege columnPrivilege = column .getPrivilege(roleName); if (columnPrivilege == null) { columnPrivilege = new PgColumnPrivilege( roleName); column.addPrivilege(columnPrivilege); } columnPrivilege.setPrivileges(privKey, grant, grantOption); } } else { throw new ParserException( MessageFormat.format( Resources .getString("CannotFindColumnInTable"), columnName, view.getName())); } } } } else { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindObject"), name, statement)); } } } else if ("SEQUENCE".equalsIgnoreCase(objectType)) { for (String name : identifiers) { // final String sequenceName = parser.parseIdentifier(); final String schemaName = ParserUtils.getSchemaName(name, database); final PgSchema schema = database.getSchema(schemaName); if (schema == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSchema"), schemaName, statement)); } final String objectName = ParserUtils.getObjectName(name); final PgSequence sequence = schema.getSequence(objectName); if (sequence == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindSequence"), name, statement)); } for (String roleName : roles) { PgSequencePrivilege sequencePrivilege = sequence .getPrivilege(roleName); if (sequencePrivilege == null) { sequencePrivilege = new PgSequencePrivilege(roleName); sequence.addPrivilege(sequencePrivilege); } for (String priv : privileges) { sequencePrivilege.setPrivileges(priv, grant, grantOption); } } } } else { if (outputIgnoredStatements) { database.addIgnoredStatement(statement); } } } private static void parseConsumeFunctionSignature(final Parser parser, final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { parser.expect("("); while (!parser.expectOptional(")")) { final String mode; if (parser.expectOptional("IN")) { mode = "IN"; } else if (parser.expectOptional("OUT")) { mode = "OUT"; } else if (parser.expectOptional("INOUT")) { mode = "INOUT"; } else if (parser.expectOptional("VARIADIC")) { mode = "VARIADIC"; } else { mode = null; } final int position = parser.getPosition(); String argumentName = null; String dataType = parser.parseDataType(); final int position2 = parser.getPosition(); if (!parser.expectOptional(")") && !parser.expectOptional(",")) { parser.setPosition(position); argumentName = ParserUtils.getObjectName(parser .parseIdentifier()); dataType = parser.parseDataType(); } else { parser.setPosition(position2); } final PgFunction.Argument argument = new PgFunction.Argument(); argument.setDataType(dataType); argument.setMode(mode); argument.setName(argumentName); if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } } private static List parseColumns(final Parser parser, final PgDatabase database, final String statement, final boolean outputIgnoredStatements) { List result = new ArrayList(); boolean present = parser.expectOptional("("); if (!present) { return null; } String identifier = parser.parseIdentifier(); result.add(identifier); String separator = parser.expectOptionalOneOf(",", ")"); while (separator != null && ",".equalsIgnoreCase(separator)) { identifier = parser.parseIdentifier(); result.add(identifier); separator = parser.expectOptionalOneOf(",", ")"); } return result; } /** * Creates a new GrantParser object. */ private GrantRevokeParser() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/Parser.java000066400000000000000000000363271316501242600255620ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.Resources; import java.text.MessageFormat; import java.util.Locale; /** * Class for parsing strings. * * @author fordfrog */ @SuppressWarnings("FinalClass") public final class Parser { /** * String to be parsed. */ private String string; /** * Current position. */ private int position; /** * Creates new instance of Parser. * * @param string {@link #string} */ public Parser(final String string) { this.string = string; skipWhitespace(); } /** * Checks whether the string contains given word on current position. If not * then throws an exception. * * @param words list of words to check */ public void expect(final String... words) { for (final String word : words) { expect(word, false); } } /** * Checks whether the string contains given word on current position. If not * and expectation is optional then position is not changed and method * returns true. If expectation is not optional, exception with error * description is thrown. If word is found, position is moved at first * non-whitespace character following the word. * * @param word word to expect * @param optional true if word is optional, otherwise false * * @return true if word was found, otherwise false */ public boolean expect(final String word, final boolean optional) { final int wordEnd = position + word.length(); if (wordEnd <= string.length() && string.substring(position, wordEnd).equalsIgnoreCase(word) && (wordEnd == string.length() || Character.isWhitespace(string.charAt(wordEnd)) || string.charAt(wordEnd) == '(' || string.charAt(wordEnd) == ')' || string.charAt(wordEnd) == ';' || string.charAt(wordEnd) == ',' || string.charAt(wordEnd) == '[' || "(".equals(word) || ",".equals(word) || "[".equals(word) || "]".equals(word))) { position = wordEnd; skipWhitespace(); return true; } if (optional) { return false; } int dumpEndPosition = position + 20; if (string.length() - (position + 1) < 20) { dumpEndPosition = string.length() - 1; } throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedWord"), string, word, position + 1, string.substring(position, dumpEndPosition))); } /** * Checks whether string contains at current position sequence of the words. * * @param words array of words * * @return true if whole sequence was found, otherwise false */ public boolean expectOptional(final String... words) { final boolean found = expect(words[0], true); if (!found) { return false; } for (int i = 1; i < words.length; i++) { skipWhitespace(); expect(words[i]); } return true; } /** * Moves position in the string to next non-whitespace string. */ public void skipWhitespace() { for (; position < string.length(); position++) { if (!Character.isWhitespace(string.charAt(position))) { break; } } } /** * Parses identifier from current position. If identifier is quoted, it is * returned quoted. If the identifier is not quoted, it is converted to * lowercase. If identifier does not start with letter then exception is * thrown. Position is placed at next first non-whitespace character. * * @return parsed identifier */ public String parseIdentifier() { String identifier = parseIdentifierInternal(); if (string.charAt(position) == '.') { position++; identifier += '.' + parseIdentifierInternal(); } skipWhitespace(); return identifier; } /** * Parses single part of the identifier. * * @return parsed identifier */ private String parseIdentifierInternal() { final boolean quoted = string.charAt(position) == '"'; if (quoted) { final int endPos = string.indexOf('"', position + 1); final String result = string.substring(position, endPos + 1); position = endPos + 1; return result; } else { int endPos = position; for (; endPos < string.length(); endPos++) { final char chr = string.charAt(endPos); if (Character.isWhitespace(chr) || chr == ',' || chr == ')' || chr == '(' || chr == ';' || chr == '.') { break; } } final String result = string.substring(position, endPos).toLowerCase( Locale.ENGLISH); position = endPos; return result; } } /** * Returns rest of the string. If the string ends with ';' then it is * removed from the string before returned. If there is nothing more in the * string, null is returned. * * @return rest of the string, without trailing ';' if present, or null if * there is nothing more in the string */ public String getRest() { final String result; if (string.charAt(string.length() - 1) == ';') { if (position == string.length() - 1) { return null; } else { result = string.substring(position, string.length() - 1); } } else { result = string.substring(position); } position = string.length(); return result; } /** * Parses integer from the string. If next word is not integer then * exception is thrown. * * @return parsed integer value */ public int parseInteger() { int endPos = position; for (; endPos < string.length(); endPos++) { if (!Character.isLetterOrDigit(string.charAt(endPos))) { break; } } try { final int result = Integer.parseInt(string.substring(position, endPos)); position = endPos; skipWhitespace(); return result; } catch (final NumberFormatException ex) { throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedInteger"), string, position + 1, string.substring(position, position + 20)), ex); } } /** * Parses string from the string. String can be either quoted or unqouted. * Quoted string is parsed till next unescaped quote. Unquoted string is * parsed till whitespace, ',' ')' or ';' is found. If string should be * empty, exception is thrown. * * @return parsed string, if quoted then including quotes */ public String parseString() { final boolean quoted = string.charAt(position) == '\''; if (quoted) { boolean escape = false; int endPos = position + 1; for (; endPos < string.length(); endPos++) { final char chr = string.charAt(endPos); if (chr == '\\') { escape = !escape; } else if (!escape && chr == '\'') { if (endPos + 1 < string.length() && string.charAt(endPos + 1) == '\'') { endPos++; } else { break; } } } final String result; try { result = string.substring(position, endPos + 1); } catch (final Throwable ex) { throw new RuntimeException("Failed to get substring: " + string + " start pos: " + position + " end pos: " + (endPos + 1), ex); } position = endPos + 1; skipWhitespace(); return result; } else { int endPos = position; for (; endPos < string.length(); endPos++) { final char chr = string.charAt(endPos); if (Character.isWhitespace(chr) || chr == ',' || chr == ')' || chr == ';') { break; } } if (position == endPos) { throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedString"), string, position + 1)); } final String result = string.substring(position, endPos); position = endPos; skipWhitespace(); return result; } } /** * Returns expression that is ended either with ',', ')' or with end of the * string. If expression is empty then exception is thrown. * * @return expression string */ public String getExpression() { final int endPos = getExpressionEnd(); if (position == endPos) { throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedExpression"), string, position + 1, string.substring(position, position + 20))); } final String result = string.substring(position, endPos).trim(); position = endPos; return result; } /** * Returns position of last character of single command within statement * (like CREATE TABLE). Last character is either ',' or ')'. If no such * character is found and method reaches the end of the command then * position after the last character in the command is returned. * * @return end position of the command * * @todo Support for dollar quoted strings is missing here. */ private int getExpressionEnd() { int bracesCount = 0; boolean singleQuoteOn = false; int charPos = position; for (; charPos < string.length(); charPos++) { final char chr = string.charAt(charPos); if (chr == '(' || chr == '[') { bracesCount++; } else if (chr == ')' || chr == ']') { if (bracesCount == 0) { break; } else { bracesCount--; } } else if (chr == '\'') { singleQuoteOn = !singleQuoteOn; // escaped single quote is like two single quotes if (charPos > 0 && string.charAt(charPos - 1) == '\\') { singleQuoteOn = !singleQuoteOn; } } else if ((chr == ',') && !singleQuoteOn && (bracesCount == 0)) { break; } else if (chr == ';' && bracesCount == 0 && !singleQuoteOn) { break; } } return charPos; } /** * Returns current position in the string. * * @return current position in the string */ public int getPosition() { return position; } /** * Returns parsed string. * * @return parsed string */ public String getString() { return string; } /** * Throws exception about unsupported command in statement. */ public void throwUnsupportedCommand() { throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringUnsupportedCommand"), string, position + 1, string.substring(position, string.length() > position + 20 ? position + 20 : string.length()))); } /** * Checks whether one of the words is present at current position. If the * word is present then the word is returned and position is updated. * * @param words words to check * * @return found word or null if non of the words has been found * * @see #expectOptional(java.lang.String[]) */ public String expectOptionalOneOf(final String... words) { for (final String word : words) { if (expectOptional(word)) { return word; } } return null; } /** * Returns substring from the string. * * @param startPos start position * @param endPos end position exclusive * * @return substring */ public String getSubString(final int startPos, final int endPos) { return string.substring(startPos, endPos); } /** * Changes current position in the string. * * @param position new position */ public void setPosition(final int position) { this.position = position; } /** * Parses data type from the string. Position is updated. If data type * definition is not found then exception is thrown. * * @return data type string */ public String parseDataType() { int endPos = position; while (endPos < string.length() && !Character.isWhitespace(string.charAt(endPos)) && string.charAt(endPos) != '(' && string.charAt(endPos) != ')' && string.charAt(endPos) != ',') { endPos++; } if (endPos == position) { throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedDataType"), string, position + 1, string.substring(position, position + 20))); } String dataType = string.substring(position, endPos); position = endPos; skipWhitespace(); if ("character".equalsIgnoreCase(dataType) && expectOptional("varying")) { dataType = "character varying"; } else if ("double".equalsIgnoreCase(dataType) && expectOptional("precision")) { dataType = "double precision"; } final boolean timestamp = "timestamp".equalsIgnoreCase(dataType) || "time".equalsIgnoreCase(dataType); if (string.charAt(position) == '(') { dataType += getExpression(); } if (timestamp) { if (expectOptional("with", "time", "zone")) { dataType += " with time zone"; } else if (expectOptional("without", "time", "zone")) { dataType += " without time zone"; } } if (expectOptional("[")) { expect("]"); dataType += "[]"; } return dataType; } /** * Checks whether the whole string has been consumed. * * @return true if there is nothing left to parse, otherwise false */ public boolean isConsumed() { return position == string.length() || position + 1 == string.length() && string.charAt(position) == ';'; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/ParserException.java000066400000000000000000000017761316501242600274410ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; /** * Thrown if parsing problem occurred. * * @author fordfrog */ public class ParserException extends RuntimeException { /** * Serial version uid. */ private static final long serialVersionUID = 1L; /** * Creates a new instance of {@code ParserException} without detail message. */ public ParserException() { } /** * Constructs an instance of {@code ParserException} with the specified * detail message. * * @param msg the detail message */ public ParserException(final String msg) { super(msg); } /** * Constructs an instance of {@code ParserException} with the specified * detail message. * * @param msg the detail message * @param cause cause of the exception */ public ParserException(final String msg, final Throwable cause) { super(msg, cause); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/ParserUtils.java000066400000000000000000000112111316501242600265640ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.schema.PgDatabase; import java.util.ArrayList; import java.util.List; /** * Parser utilities. * * @author fordfrog */ public class ParserUtils { /** * Returns object name from optionally schema qualified name. * * @param name optionally schema qualified name * * @return name of the object */ public static String getObjectName(final String name) { final String[] names = splitNames(name); return names[names.length - 1]; } /** * Returns second (from right) object name from optionally schema qualified * name. * * @param name optionally schema qualified name * * @return name of the object */ public static String getSecondObjectName(final String name) { final String[] names = splitNames(name); return names[names.length - 2]; } /** * Returns third (from right) object name from optionally schema qualified * name. * * @param name optionally schema qualified name * * @return name of the object or null if there is no third object name */ public static String getThirdObjectName(final String name) { final String[] names = splitNames(name); return names.length >= 3 ? names[names.length - 3] : null; } /** * Returns schema name from optionally schema qualified name. * * @param name optionally schema qualified name * @param database database * * @return name of the schema */ public static String getSchemaName(final String name, final PgDatabase database) { final String[] names = splitNames(name); if (names.length < 2) { return database.getDefaultSchema().getName(); } else { return names[0]; } } /** * Generates unique name from the prefix, list of names, and postfix. * * @param prefix prefix * @param names list of names * @param postfix postfix * * @return generated name */ public static String generateName(final String prefix, final List names, final String postfix) { final String adjName; if (names.size() == 1) { adjName = names.get(0); } else { final StringBuilder sbString = new StringBuilder(names.size() * 15); for (final String name : names) { if (sbString.length() > 0) { sbString.append(','); } sbString.append(name); } adjName = Integer.toHexString(sbString.toString().hashCode()); } final StringBuilder sbResult = new StringBuilder(30); if (prefix != null && !prefix.isEmpty()) { sbResult.append(prefix); } sbResult.append(adjName); if (postfix != null && !postfix.isEmpty()) { sbResult.append(postfix); } return sbResult.toString(); } /** * Splits qualified names by dots. If names are quoted then quotes are * removed. * * @param string qualified name * * @return array of names */ private static String[] splitNames(final String string) { if (string.indexOf('"') == -1) { return string.split("\\."); } else { final List strings = new ArrayList(2); int startPos = 0; while (true) { if (string.charAt(startPos) == '"') { final int endPos = string.indexOf('"', startPos + 1); strings.add(string.substring(startPos + 1, endPos)); if (endPos + 1 == string.length()) { break; } else if (string.charAt(endPos + 1) == '.') { startPos = endPos + 2; } else { startPos = endPos + 1; } } else { final int endPos = string.indexOf('.', startPos); if (endPos == -1) { strings.add(string.substring(startPos)); break; } else { strings.add(string.substring(startPos, endPos)); startPos = endPos + 1; } } } return strings.toArray(new String[strings.size()]); } } /** * Creates a new instance of ParserUtils. */ private ParserUtils() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/parsers/package-info.java000066400000000000000000000001451316501242600266370ustar00rootroot00000000000000/** * Parsers for parsing DDLs from PostgreSQL dumps. */ package cz.startnet.utils.pgdiff.parsers; apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/000077500000000000000000000000001316501242600232315ustar00rootroot00000000000000apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java000066400000000000000000000153341316501242600256260ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Stores column information. * * @author fordfrog */ public class PgColumn { /** * Pattern for parsing NULL arguments. */ private static final Pattern PATTERN_NULL = Pattern.compile("^(.+)[\\s]+NULL$", Pattern.CASE_INSENSITIVE); /** * Pattern for parsing NOT NULL arguments. */ private static final Pattern PATTERN_NOT_NULL = Pattern.compile( "^(.+)[\\s]+NOT[\\s]+NULL$", Pattern.CASE_INSENSITIVE); /** * Pattern for parsing DEFAULT value. */ private static final Pattern PATTERN_DEFAULT = Pattern.compile( "^(.+)[\\s]+DEFAULT[\\s]+(.+)$", Pattern.CASE_INSENSITIVE); /** * Specific statistics value. */ private Integer statistics; /** * Default value of the column. */ private String defaultValue; /** * Name of the column. */ private String name; /** * Type of the column. Always null for view columns. */ private String type; /** * Determines whether null value is allowed in the column. */ private boolean nullValue = true; /** * Contains information about column storage type. */ private String storage; /** * Comment. */ private String comment; /** * List of privileges defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List privileges = new ArrayList(); /** * Creates a new PgColumn object. * * @param name name of the column */ public PgColumn(final String name) { this.name = name; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Setter for {@link #defaultValue}. * * @param defaultValue {@link #defaultValue} */ public void setDefaultValue(final String defaultValue) { this.defaultValue = defaultValue; } /** * Getter for {@link #defaultValue}. * * @return {@link #defaultValue} */ public String getDefaultValue() { return defaultValue; } /** * Returns full definition of the column. * * @param addDefaults whether default value should be added in case NOT NULL * constraint is specified but no default value is set * * @return full definition of the column */ public String getFullDefinition(final boolean addDefaults) { final StringBuilder sbDefinition = new StringBuilder(100); sbDefinition.append(PgDiffUtils.getQuotedName(name)); sbDefinition.append(' '); sbDefinition.append(type); if (defaultValue != null && !defaultValue.isEmpty()) { sbDefinition.append(" DEFAULT "); sbDefinition.append(defaultValue); } else if (!nullValue && addDefaults) { final String defaultColValue = PgColumnUtils.getDefaultValue(type); if (defaultColValue != null) { sbDefinition.append(" DEFAULT "); sbDefinition.append(defaultColValue); } } if (!nullValue) { sbDefinition.append(" NOT NULL"); } return sbDefinition.toString(); } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Setter for {@link #nullValue}. * * @param nullValue {@link #nullValue} */ public void setNullValue(final boolean nullValue) { this.nullValue = nullValue; } /** * Getter for {@link #nullValue}. * * @return {@link #nullValue} */ public boolean getNullValue() { return nullValue; } /** * Setter for {@link #statistics}. * * @param statistics {@link #statistics} */ public void setStatistics(final Integer statistics) { this.statistics = statistics; } /** * Getter for {@link #statistics}. * * @return {@link #statistics} */ public Integer getStatistics() { return statistics; } /** * Getter for {@link #storage}. * * @return {@link #storage} */ public String getStorage() { return storage; } /** * Setter for {@link #storage}. * * @param storage {@link #storage} */ public void setStorage(final String storage) { this.storage = storage; } /** * Setter for {@link #type}. * * @param type {@link #type} */ public void setType(final String type) { this.type = type; } /** * Getter for {@link #type}. * * @return {@link #type} */ public String getType() { return type; } public void addPrivilege(final PgColumnPrivilege privilege) { privileges.add(privilege); } public PgColumnPrivilege getPrivilege(final String roleName) { for (PgColumnPrivilege privilege : privileges) { if (privilege.getRoleName().equals(roleName)) { return privilege; } } return null; } public List getPrivileges() { return Collections.unmodifiableList(privileges); } /** * Parses definition of the column * * @param definition definition of the column */ public void parseDefinition(final String definition) { String string = definition; Matcher matcher = PATTERN_NOT_NULL.matcher(string); if (matcher.matches()) { string = matcher.group(1).trim(); setNullValue(false); } else { matcher = PATTERN_NULL.matcher(string); if (matcher.matches()) { string = matcher.group(1).trim(); setNullValue(true); } } matcher = PATTERN_DEFAULT.matcher(string); if (matcher.matches()) { string = matcher.group(1).trim(); setDefaultValue(matcher.group(2).trim()); } setType(string); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnPrivilege.java000066400000000000000000000140261316501242600274720ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; /** * Stores tablePrivileges information. * * @author user */ public class PgColumnPrivilege { private final String roleName; private boolean select = false; private boolean insert = false; private boolean update = false; private boolean references = false; private boolean selectWithGrantOption = false; private boolean insertWithGrantOption = false; private boolean updateWithGrantOption = false; private boolean referencesWithGrantOption = false; /** * Creates a new PgTablePrivilege object. * * @param roleName * name of the role */ public PgColumnPrivilege(final String roleName) { this.roleName = roleName; } /** * @return the roleName */ public String getRoleName() { return roleName; } public void setPrivileges(final String privilege, final boolean value, final boolean grantOption) { if ("SELECT".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { select = true; if (grantOption) { selectWithGrantOption = true; } } else { selectWithGrantOption = false; if (!grantOption) { select = false; } } } if ("INSERT".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { insert = true; if (grantOption) { insertWithGrantOption = true; } } else { insertWithGrantOption = false; if (!grantOption) { insert = false; } } } if ("UPDATE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { update = true; if (grantOption) { updateWithGrantOption = true; } } else { updateWithGrantOption = false; if (!grantOption) { update = false; } } } if ("REFERENCES".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { references = true; if (grantOption) { referencesWithGrantOption = true; } } else { referencesWithGrantOption = false; if (!grantOption) { references = false; } } } } /** * true the privileges are the same (no matter of roleName). * * @param other * privileges to compare * @return isSimilar */ public boolean isSimilar(final PgColumnPrivilege other) { if (other == null) { return false; } if (select != other.select) { return false; } if (selectWithGrantOption != other.selectWithGrantOption) { return false; } if (insert != other.insert) { return false; } if (insertWithGrantOption != other.insertWithGrantOption) { return false; } if (update != other.update) { return false; } if (updateWithGrantOption != other.updateWithGrantOption) { return false; } if (references != other.references) { return false; } if (referencesWithGrantOption != other.referencesWithGrantOption) { return false; } return true; } public String getPrivilegesSQL(final boolean withGrantOption, String columnName) { if (withGrantOption) { if (selectWithGrantOption && insertWithGrantOption && updateWithGrantOption && referencesWithGrantOption) { return "ALL (" + columnName + ")"; } String result = ""; if (selectWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "SELECT (" + columnName + ")"; } if (insertWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "INSERT (" + columnName + ")"; } if (updateWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "UPDATE (" + columnName + ")"; } if (referencesWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "REFERENCES (" + columnName + ")"; } return result; } else { if (select && insert && update && references) { return "ALL (" + columnName + ")"; } String result = ""; if (select) { if (!"".equals(result)) { result += ", "; } result += "SELECT (" + columnName + ")"; } if (insert) { if (!"".equals(result)) { result += ", "; } result += "INSERT (" + columnName + ")"; } if (update) { if (!"".equals(result)) { result += ", "; } result += "UPDATE (" + columnName + ")"; } if (references) { if (!"".equals(result)) { result += ", "; } result += "REFERENCES (" + columnName + ")"; } return result; } } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnUtils.java000066400000000000000000000034121316501242600266410ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import java.util.Locale; /** * Utilities for {@link PgColumn}. * * @author fordfrog */ public class PgColumnUtils { /** * Returns default value for given column type. If no default value is * specified then null is returned. * * @param type column type * * @return found default value or null */ public static String getDefaultValue(final String type) { final String defaultValue; final String adjType = type.toLowerCase(Locale.ENGLISH); if ("smallint".equals(adjType) || "integer".equals(adjType) || "bigint".equals(adjType) || adjType.startsWith("decimal") || adjType.startsWith("numeric") || "real".equals(adjType) || "double precision".equals(adjType) || "int2".equals(adjType) || "int4".equals(adjType) || "int8".equals(adjType) || adjType.startsWith("float") || "double".equals(adjType) || "money".equals(adjType)) { defaultValue = "0"; } else if (adjType.startsWith("character varying") || adjType.startsWith("varchar") || adjType.startsWith("character") || adjType.startsWith("char") || "text".equals(adjType)) { defaultValue = "''"; } else if ("boolean".equals(adjType)) { defaultValue = "false"; } else { defaultValue = null; } return defaultValue; } /** * Creates a new PgColumnUtils object. */ private PgColumnUtils() { } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgConstraint.java000077500000000000000000000122671316501242600265220ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.regex.Pattern; /** * Stores table constraint information. * * @author fordfrog */ public class PgConstraint { /** * Pattern for checking whether the constraint is PRIMARY KEY constraint. */ private static final Pattern PATTERN_PRIMARY_KEY = Pattern.compile(".*PRIMARY[\\s]+KEY.*", Pattern.CASE_INSENSITIVE); /** * Definition of the constraint. */ private String definition; /** * Name of the constraint. */ private String name; /** * Name of the table the constraint is defined on. */ private String tableName; /** * Comment. */ private String comment; /** * Creates a new PgConstraint object. * * @param name {@link #name} */ public PgConstraint(String name) { this.name = name; } /** * Creates and returns SQL for creation of the constraint. * @return created SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("ALTER TABLE "); sbSQL.append(PgDiffUtils.getQuotedName(getTableName())); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tADD CONSTRAINT "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(getName())); sbSQL.append(' '); sbSQL.append(getDefinition()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON CONSTRAINT "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(tableName)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Setter for {@link #definition}. * * @param definition {@link #definition} */ public void setDefinition(final String definition) { this.definition = definition; } /** * Getter for {@link #definition}. * * @return {@link #definition} */ public String getDefinition() { return definition; } /** * Creates and returns SQL for dropping the constraint. * @return created SQL */ public String getDropSQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("ALTER TABLE "); sbSQL.append(PgDiffUtils.getQuotedName(getTableName())); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tDROP CONSTRAINT "); sbSQL.append(PgDiffUtils.getDropIfExists()); sbSQL.append(PgDiffUtils.getQuotedName(getName())); sbSQL.append(';'); return sbSQL.toString(); } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Returns true if this is a PRIMARY KEY constraint, otherwise false. * * @return true if this is a PRIMARY KEY constraint, otherwise false */ public boolean isPrimaryKeyConstraint() { return PATTERN_PRIMARY_KEY.matcher(definition).matches(); } /** * Setter for {@link #tableName}. * * @param tableName {@link #tableName} */ public void setTableName(final String tableName) { this.tableName = tableName; } /** * Getter for {@link #tableName}. * * @return {@link #tableName} */ public String getTableName() { return tableName; } /** * {@inheritDoc} * * @param object {@inheritDoc} * * @return {@inheritDoc} */ @Override public boolean equals(final Object object) { boolean equals = false; if (this == object) { equals = true; } else if (object instanceof PgConstraint) { final PgConstraint constraint = (PgConstraint) object; equals = definition.equals(constraint.getDefinition()) && name.equals(constraint.getName()) && tableName.equals(constraint.getTableName()); } return equals; } /** * {@inheritDoc} * * @return {@inheritDoc} */ @Override public int hashCode() { return (getClass().getName() + "|" + definition + "|" + name + "|" + tableName).hashCode(); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgDatabase.java000066400000000000000000000101171316501242600260670ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Stores database information. * * @author fordfrog */ public class PgDatabase { /** * List of database schemas. */ private final List schemas = new ArrayList(1); /** * Array of ignored statements. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List ignoredStatements = new ArrayList(); /** * Current default schema. */ private PgSchema defaultSchema; /** * Comment. */ private String comment; /** * List of extensions. */ private final List extensions = new ArrayList(); /** * Creates a new PgDatabase object. */ public PgDatabase() { schemas.add(new PgSchema("public")); defaultSchema = schemas.get(0); } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Sets default schema according to the {@code name} of the schema. * * @param name name of the schema */ public void setDefaultSchema(final String name) { defaultSchema = getSchema(name); } /** * Getter for {@link #defaultSchema}. * * @return {@link #defaultSchema} */ public PgSchema getDefaultSchema() { return defaultSchema; } /** * Getter for {@link #ignoredStatements}. * * @return {@link #ignoredStatements} */ public List getIgnoredStatements() { return Collections.unmodifiableList(ignoredStatements); } /** * Adds ignored statement to the list of ignored statements. * * @param ignoredStatement ignored statement */ public void addIgnoredStatement(final String ignoredStatement) { ignoredStatements.add(ignoredStatement); } /** * Returns schema of given name or null if the schema has not been found. If * schema name is null then default schema is returned. * * @param name schema name or null which means default schema * * @return found schema or null */ public PgSchema getSchema(final String name) { if (name == null) { return getDefaultSchema(); } for (final PgSchema schema : schemas) { if (schema.getName().equals(name)) { return schema; } } return null; } /** * Getter for {@link #schemas}. The list cannot be modified. * * @return {@link #schemas} */ public List getSchemas() { return Collections.unmodifiableList(schemas); } /** * Adds {@code schema} to the lists of schemas. * * @param schema schema */ public void addSchema(final PgSchema schema) { schemas.add(schema); } /** * Getter for {@link #extensions}. The list cannot be modified. * * @return {@link #extensions} */ public List getExtensions() { return Collections.unmodifiableList(extensions); } /** * Adds {@code extension} to the list of extensions. * * @param extension extension */ public void addExtension(final PgExtension extension) { extensions.add(extension); } /** * Returns extension of given name or null if the extension has not been found. * * @param name extension name * @return found extension or null */ public PgExtension getExtension(final String name) { for (final PgExtension extension : extensions) { if (extension.getName().equals(name)) { return extension; } } return null; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgExtension.java000066400000000000000000000061331316501242600263420ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; /** * * @author atila */ public class PgExtension { /** * Name of the extension. */ private final String name; /** * PgSchema */ private PgSchema schema; /** * Version of the extension. */ private String version; /** * Previous version of the extension. */ private String from; public PgExtension(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Getter for {@link #schema}. * * @return {@link #schema} */ public PgSchema getSchema() { return schema; } /** * Setter for {@link #schema}. * * @param schema {@link #schema} */ public void setSchema(PgSchema schema) { this.schema = schema; } /** * Getter for {@link #version}. * * @return {@link #version} */ public String getVersion() { return version; } /** * Setter for {@link #version}. * * @param version {@link #version} */ public void setVersion(String version) { this.version = version; } /** * Getter for {@link #from}. * * @return {@link #from} */ public String getFrom() { return from; } /** * Setter for {@link #from}. * * @param from {@link #from} */ public void setFrom(String from) { this.from = from; } /** * Returns creation SQL of the function. * * @return creation SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(); sbSQL.append("CREATE EXTENSION "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (schema != null) { sbSQL.append(" SCHEMA "); sbSQL.append(schema.getName()); } if (version != null && !version.isEmpty()) { sbSQL.append(" VERSION "); sbSQL.append(version); } if (from != null && !from.isEmpty()) { sbSQL.append(" FROM "); sbSQL.append(from); } sbSQL.append(';'); return sbSQL.toString(); } @Override public boolean equals(final Object object) { boolean equals = false; if (this == object) { equals = true; } else if (object instanceof PgExtension) { final PgExtension extension = (PgExtension) object; equals = name.equals(extension.getName()) && from.equals(extension.getFrom()) && version.equals(extension.getVersion()); } return equals; } @Override public int hashCode() { return (getClass().getName() + "|" + name + "|" + version + "|" + from).hashCode(); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgFunction.java000077500000000000000000000304711316501242600261600ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; /** * Stores function information. * * @author fordfrog */ public class PgFunction { /** * Name of the function including argument types. */ private String name; /** * List of arguments. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List arguments = new ArrayList(); /** * Whole definition of the function from RETURNS keyword. */ private String body; /** * Comment. */ private String comment; /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Returns creation SQL of the function. * * @return creation SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(500); sbSQL.append("CREATE OR REPLACE FUNCTION "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append('('); boolean addComma = false; for (final Argument argument : arguments) { if (addComma) { sbSQL.append(", "); } sbSQL.append(argument.getDeclaration(true)); addComma = true; } sbSQL.append(") "); sbSQL.append(body); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON FUNCTION "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append('('); addComma = false; for (final Argument argument : arguments) { if (addComma) { sbSQL.append(", "); } sbSQL.append(argument.getDeclaration(false)); addComma = true; } sbSQL.append(") IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Setter for {@link #body}. * * @param body {@link #body} */ public void setBody(final String body) { this.body = body; } /** * Getter for {@link #body}. * * @return {@link #body} */ public String getBody() { return body; } /** * Creates and returns SQL for dropping the function. * * @return created SQL */ public String getDropSQL() { final StringBuilder sbString = new StringBuilder(100); sbString.append("DROP FUNCTION "); sbString.append(PgDiffUtils.getDropIfExists()); sbString.append(name); sbString.append('('); boolean addComma = false; for (final Argument argument : arguments) { if ("OUT".equalsIgnoreCase(argument.getMode())) { continue; } if (addComma) { sbString.append(", "); } sbString.append(argument.getDeclaration(false)); addComma = true; } sbString.append(");"); return sbString.toString(); } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Getter for {@link #arguments}. List cannot be modified. * * @return {@link #arguments} */ public List getArguments() { return Collections.unmodifiableList(arguments); } /** * Adds argument to the list of arguments. * * @param argument argument */ public void addArgument(final Argument argument) { arguments.add(argument); } /** * Returns function signature. It consists of unquoted name and argument * data types. * * @return function signature */ public String getSignature() { final StringBuilder sbString = new StringBuilder(100); sbString.append(name); sbString.append('('); boolean addComma = false; for (final Argument argument : arguments) { if ("OUT".equalsIgnoreCase(argument.getMode())) { continue; } if (addComma) { sbString.append(','); } sbString.append(argument.getDataType().toLowerCase(Locale.ENGLISH)); addComma = true; } sbString.append(')'); return sbString.toString(); } @Override public boolean equals(final Object object) { if (!(object instanceof PgFunction)) { return false; } else if (object == this) { return true; } return equals(object, false); } /** * Compares two objects whether they are equal. If both objects are of the * same class but they equal just in whitespace in {@link #body}, they are * considered being equal. * * @param object object to be compared * @param ignoreFunctionWhitespace whether multiple whitespaces in function * {@link #body} should be ignored * * @return true if {@code object} is pg function and the function code is * the same when compared ignoring whitespace, otherwise returns * false */ public boolean equals(final Object object, final boolean ignoreFunctionWhitespace) { boolean equals = false; if (this == object) { equals = true; } else if (object instanceof PgFunction) { final PgFunction function = (PgFunction) object; if (name == null && function.getName() != null || name != null && !name.equals(function.getName())) { return false; } final String thisBody; final String thatBody; if (ignoreFunctionWhitespace) { thisBody = body.replaceAll("\\s+", " "); thatBody = function.getBody().replaceAll("\\s+", " "); } else { thisBody = body; thatBody = function.getBody(); } if (thisBody == null && thatBody != null || thisBody != null && !thisBody.equals(thatBody)) { return false; } if (arguments.size() != function.getArguments().size()) { return false; } else { for (int i = 0; i < arguments.size(); i++) { if (!arguments.get(i).equals(function.getArguments().get(i))) { return false; } } } return true; } return equals; } @Override public int hashCode() { final StringBuilder sbString = new StringBuilder(500); sbString.append(body); sbString.append('|'); sbString.append(name); for (final Argument argument : arguments) { sbString.append('|'); sbString.append(argument.getDeclaration(true)); } return sbString.toString().hashCode(); } /** * Function argument information. */ @SuppressWarnings("PublicInnerClass") public static class Argument { /** * Argument mode. */ private String mode = "IN"; /** * Argument name. */ private String name; /** * Argument data type. */ private String dataType; /** * Argument default expression. */ private String defaultExpression; /** * Getter for {@link #dataType}. * * @return {@link #dataType} */ public String getDataType() { return dataType; } /** * Setter for {@link #dataType}. * * @param dataType {@link #dataType} */ public void setDataType(final String dataType) { this.dataType = dataType; } /** * Getter for {@link #defaultExpression}. * * @return {@link #defaultExpression} */ public String getDefaultExpression() { return defaultExpression; } /** * Setter for {@link #defaultExpression}. * * @param defaultExpression {@link #defaultExpression} */ public void setDefaultExpression(final String defaultExpression) { this.defaultExpression = defaultExpression; } /** * Getter for {@link #mode}. * * @return {@link #mode} */ public String getMode() { return mode; } /** * Setter for {@link #mode}. * * @param mode {@link #mode} */ public void setMode(final String mode) { this.mode = mode == null || mode.isEmpty() ? "IN" : mode; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Creates argument declaration. * * @param includeDefaultValue whether to include default value * * @return argument declaration */ public String getDeclaration(final boolean includeDefaultValue) { final StringBuilder sbString = new StringBuilder(50); if (mode != null && !"IN".equalsIgnoreCase(mode)) { sbString.append(mode); sbString.append(' '); } if (name != null && !name.isEmpty()) { sbString.append(PgDiffUtils.getQuotedName(name)); sbString.append(' '); } sbString.append(dataType); if (includeDefaultValue && defaultExpression != null && !defaultExpression.isEmpty()) { sbString.append(" = "); sbString.append(defaultExpression); } return sbString.toString(); } @Override public boolean equals(final Object obj) { if (!(obj instanceof Argument)) { return false; } else if (this == obj) { return true; } final Argument argument = (Argument) obj; return (dataType == null ? argument.getDataType() == null : dataType.equalsIgnoreCase(argument.getDataType())) && (defaultExpression == null ? argument.getDefaultExpression() == null : defaultExpression.equals(defaultExpression)) && (mode == null ? argument.getMode() == null : mode.equalsIgnoreCase(argument.getMode())) && (name == null ? argument.getName() == null : name.equals(argument.getName())); } @Override public int hashCode() { final StringBuilder sbString = new StringBuilder(50); sbString.append( mode == null ? null : mode.toUpperCase(Locale.ENGLISH)); sbString.append('|'); sbString.append(name); sbString.append('|'); sbString.append(dataType == null ? null : dataType.toUpperCase(Locale.ENGLISH)); sbString.append('|'); sbString.append(defaultExpression); return sbString.toString().hashCode(); } } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgIndex.java000077500000000000000000000112611316501242600254360ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; /** * Stores table index information. * * @author fordfrog */ public class PgIndex { /** * Definition of the index. */ private String definition; /** * Name of the index. */ private String name; /** * Table name the index is defined on. */ private String tableName; /** * Whether the index is unique. */ private boolean unique; /** * Comment. */ private String comment; /** * Creates a new PgIndex object. * * @param name {@link #name} */ public PgIndex(final String name) { this.name = name; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Creates and returns SQL for creation of the index. * * @return created SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("CREATE "); if (isUnique()) { sbSQL.append("UNIQUE "); } sbSQL.append("INDEX "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(getName())); sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(getTableName())); sbSQL.append(' '); sbSQL.append(getDefinition()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON INDEX "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Setter for {@link #definition}. * * @param definition {@link #definition} */ public void setDefinition(final String definition) { this.definition = definition; } /** * Getter for {@link #definition}. * * @return {@link #definition} */ public String getDefinition() { return definition; } /** * Creates and returns SQL statement for dropping the index. * * @return created SQL statement */ public String getDropSQL() { return "DROP INDEX " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + ";"; } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Setter for {@link #tableName}. * * @param tableName {@link #tableName} */ public void setTableName(final String tableName) { this.tableName = tableName; } /** * Getter for {@link #tableName}. * * @return {@link #tableName} */ public String getTableName() { return tableName; } /** * {@inheritDoc} * * @param object {@inheritDoc} * * @return {@inheritDoc} */ @Override public boolean equals(final Object object) { boolean equals = false; if (this == object) { equals = true; } else if (object instanceof PgIndex) { final PgIndex index = (PgIndex) object; equals = definition.equals(index.getDefinition()) && name.equals(index.getName()) && tableName.equals(index.getTableName()) && unique == index.isUnique(); } return equals; } /** * {@inheritDoc} * * @return {@inheritDoc} */ @Override public int hashCode() { return (getClass().getName() + "|" + definition + "|" + name + "|" + tableName + "|" + unique).hashCode(); } /** * Getter for {@link #unique}. * * @return {@link #unique} */ public boolean isUnique() { return unique; } /** * Setter for {@link #unique}. * * @param unique {@link #unique} */ public void setUnique(final boolean unique) { this.unique = unique; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgInheritedColumn.java000066400000000000000000000031111316501242600274500ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; /** * Stores inherited column information. * * @author dwatson78 */ public class PgInheritedColumn { /** * Inherited column */ private final PgColumn inheritedColumn; public PgInheritedColumn(final PgColumn inheritedColumn) { this.inheritedColumn = inheritedColumn; } /** * Getter for {@link #inheritedColumn}. * * @return {@link #inheritedColumn} */ public PgColumn getInheritedColumn() { return inheritedColumn; } /** * Default value of the column. */ private String defaultValue; /** * Determines whether null value is allowed in the column. */ private boolean nullValue = true; /** * Setter for {@link #defaultValue}. * * @param defaultValue {@link #defaultValue} */ public void setDefaultValue(final String defaultValue) { this.defaultValue = defaultValue; } /** * Getter for {@link #defaultValue}. * * @return {@link #defaultValue} */ public String getDefaultValue() { return defaultValue; } /** * Setter for {@link #nullValue}. * * @param nullValue {@link #nullValue} */ public void setNullValue(final boolean nullValue) { this.nullValue = nullValue; } /** * Getter for {@link #nullValue}. * * @return {@link #nullValue} */ public boolean getNullValue() { return nullValue; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgPolicy.java000066400000000000000000000027501316501242600256260ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.Objects; /** * * Stores POLICY information. * */ public class PgPolicy { private String name; private String tableName; private String command; private List roles = new ArrayList(); private String using; private String withCheck; public void setName(final String name) { this.name = name; } public String getName() { return name; } public void setTableName(final String tableName) { this.tableName = tableName; } public String getTableName() { return tableName; } public void setCommand(final String command) { this.command = command; } public String getCommand() { return command; } public List getRoles() { return roles; } public void addRole(final String role) { roles.add(role); } public void setUsing(final String using) { this.using = using; } public String getUsing() { return using; } public void setWithCheck(final String withCheck) { this.withCheck = withCheck; } public String getWithCheck() { return withCheck; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelation.java000077500000000000000000000233431316501242600261500ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Base class for tables and views. * * @author Marti Raudsepp */ public abstract class PgRelation { /** * List of columns defined on the relation. */ @SuppressWarnings("CollectionWithoutInitialCapacity") protected final List columns = new ArrayList(); /** * List of indexes defined on the relation. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List indexes = new ArrayList(); /** * List of triggers defined on the table/view. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List triggers = new ArrayList(); /** * Name of the index on which the table/matview is clustered */ private String clusterIndexName; /** * Name of the relation. */ protected String name; /** * Tablespace value. */ protected String tablespace; /** * Comment. */ String comment; /** * List of privileges defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List privileges = new ArrayList(); /** * Column the table is owner to. */ private String ownerTo; /** * Setter for {@link #clusterIndexName}. * * @param name {@link #clusterIndexName} */ public void setClusterIndexName(final String name) { clusterIndexName = name; } /** * Getter for {@link #clusterIndexName}. * * @return {@link #clusterIndexName} */ public String getClusterIndexName() { return clusterIndexName; } /** * Finds column according to specified column {@code name}. * * @param name name of the column to be searched * * @return found column or null if no such column has been found */ public PgColumn getColumn(final String name) { for (PgColumn column : columns) { if (column.getName().equals(name)) { return column; } } return null; } /** * Getter for {@link #columns}. The list cannot be modified. * * @return {@link #columns} */ public List getColumns() { return Collections.unmodifiableList(columns); } /** * Generates SQL code for declaring relation and column comments * * @return SQL code for declaring relation and column comments */ protected String getCommentDefinitionSQL() { final StringBuilder sbSQL = new StringBuilder(100); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON "); sbSQL.append(getRelationKind()); sbSQL.append(' '); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } for (final PgColumn column : columns) { if (column.getComment() != null && !column.getComment().isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON COLUMN "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append('.'); sbSQL.append(PgDiffUtils.getQuotedName(column.getName())); sbSQL.append(" IS "); sbSQL.append(column.getComment()); sbSQL.append(';'); } } return sbSQL.toString(); } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Finds index according to specified index {@code name}. * * @param name name of the index to be searched * * @return found index or null if no such index has been found */ public PgIndex getIndex(final String name) { for (PgIndex index : indexes) { if (index.getName().equals(name)) { return index; } } return null; } /** * Finds trigger according to specified trigger {@code name}. * * @param name name of the trigger to be searched * * @return found trigger or null if no such trigger has been found */ public PgTrigger getTrigger(final String name) { for (PgTrigger trigger : triggers) { if (trigger.getName().equals(name)) { return trigger; } } return null; } /** * Getter for {@link #indexes}. The list cannot be modified. * * @return {@link #indexes} */ public List getIndexes() { return Collections.unmodifiableList(indexes); } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Getter for {@link #triggers}. The list cannot be modified. * * @return {@link #triggers} */ public List getTriggers() { return Collections.unmodifiableList(triggers); } /** * Getter for {@link #tablespace}. * * @return {@link #tablespace} */ public String getTablespace() { return tablespace; } /** * Setter for {@link #tablespace}. * * @param tablespace {@link #tablespace} */ public void setTablespace(final String tablespace) { this.tablespace = tablespace; } /** * Adds {@code column} to the list of columns. * * @param column column */ public void addColumn(final PgColumn column) { columns.add(column); } /** * Adds {@code index} to the list of indexes. * * @param index index */ public void addIndex(final PgIndex index) { indexes.add(index); } /** * Adds {@code trigger} to the list of triggers. * * @param trigger trigger */ public void addTrigger(final PgTrigger trigger) { triggers.add(trigger); } /** * Returns relation kind for CREATE/ALTER/DROP commands. * * @return relation kind */ public abstract String getRelationKind(); /** * Creates and returns SQL statement for dropping the relation. * * @return created SQL statement */ public String getDropSQL() { return "DROP " + getRelationKind() + " " + PgDiffUtils.getDropIfExists()+ PgDiffUtils.getQuotedName(getName()) + ";"; } /** * Returns true if table contains given column {@code name}, otherwise * false. * * @param name name of the column * * @return true if table contains given column {@code name}, otherwise false */ public boolean containsColumn(final String name) { for (PgColumn column : columns) { if (column.getName().equals(name)) { return true; } } return false; } /** * Finds inheritedColumn according to specified name {@code name}. * * @param name name of the inheritedColumn to be searched * * @return found inheritedColumn or null if no such inheritedColumn * has been found */ public PgInheritedColumn getInheritedColumn(final String name) { return null; } /** * Returns true if table contains given inheritedColumn {@code name}, * otherwise false. * * @param name name of the inheritedColumn * * @return true if table contains given inheritedColumn {@code name}, * otherwise false */ public boolean containsInheritedColumn(final String name) { return false; } /** * Returns true if table/matview contains given index {@code name}, otherwise false. * * @param name name of the index * * @return true if table/matview contains given index {@code name}, otherwise false */ public boolean containsIndex(final String name) { for (PgIndex index : indexes) { if (index.getName().equals(name)) { return true; } } return false; } public List getPrivileges() { return Collections.unmodifiableList(privileges); } /** * Getter for {@link #ownerTo}. * * @return {@link #ownerTo} */ public String getOwnerTo() { return ownerTo; } /** * Setter for {@link #ownerTo}. * * @param ownerTo * {@link #ownerTo} */ public void setOwnerTo(final String ownerTo) { this.ownerTo = ownerTo; } public void addPrivilege(final PgRelationPrivilege privilege) { privileges.add(privilege); } public PgRelationPrivilege getPrivilege(final String roleName) { for (PgRelationPrivilege privilege : privileges) { if (privilege.getRoleName().equals(roleName)) { return privilege; } } return null; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelationPrivilege.java000066400000000000000000000150421316501242600300110ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; /** * Stores relPrivileges information. * * @author user */ public class PgRelationPrivilege { private final String roleName; private boolean select = false; private boolean insert = false; private boolean update = false; private boolean delete = false; private boolean truncate = false; private boolean references = false; private boolean trigger = false; private boolean selectWithGrantOption = false; private boolean insertWithGrantOption = false; private boolean updateWithGrantOption = false; private boolean deleteWithGrantOption = false; private boolean truncateWithGrantOption = false; private boolean referencesWithGrantOption = false; private boolean triggerWithGrantOption = false; /** * Creates a new PgTablePrivilege object. * * @param roleName * name of the role */ public PgRelationPrivilege(final String roleName) { this.roleName = roleName; } /** * @return the roleName */ public String getRoleName() { return roleName; } public void setPrivileges(final String privilege, final boolean value, final boolean grantOption) { if ("SELECT".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { select = true; if (grantOption) { selectWithGrantOption = true; } } else { selectWithGrantOption = false; if (!grantOption) { select = false; } } } if ("INSERT".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { insert = true; if (grantOption) { insertWithGrantOption = true; } } else { insertWithGrantOption = false; if (!grantOption) { insert = false; } } } if ("UPDATE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { update = true; if (grantOption) { updateWithGrantOption = true; } } else { updateWithGrantOption = false; if (!grantOption) { update = false; } } } if ("DELETE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { delete = true; if (grantOption) { deleteWithGrantOption = true; } } else { deleteWithGrantOption = false; if (!grantOption) { delete = false; } } } if ("TRUNCATE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { truncate = true; if (grantOption) { truncateWithGrantOption = true; } } else { truncateWithGrantOption = false; if (!grantOption) { truncate = false; } } } if ("REFERENCES".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { references = true; if (grantOption) { referencesWithGrantOption = true; } } else { referencesWithGrantOption = false; if (!grantOption) { references = false; } } } if ("TRIGGER".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { trigger = true; if (grantOption) { triggerWithGrantOption = true; } } else { triggerWithGrantOption = false; if (!grantOption) { trigger = false; } } } } /** * true the privileges are the same (no matter of roleName). * * @param other * privileges to compare * @return isSimilar */ public boolean isSimilar(final PgRelationPrivilege other) { if (other == null) { return false; } if (select != other.select) { return false; } if (selectWithGrantOption != other.selectWithGrantOption) { return false; } if (insert != other.insert) { return false; } if (insertWithGrantOption != other.insertWithGrantOption) { return false; } if (update != other.update) { return false; } if (updateWithGrantOption != other.updateWithGrantOption) { return false; } if (delete != other.delete) { return false; } if (deleteWithGrantOption != other.deleteWithGrantOption) { return false; } if (truncate != other.truncate) { return false; } if (truncateWithGrantOption != other.truncateWithGrantOption) { return false; } if (references != other.references) { return false; } if (referencesWithGrantOption != other.referencesWithGrantOption) { return false; } if (trigger != other.trigger) { return false; } if (triggerWithGrantOption != other.triggerWithGrantOption) { return false; } return true; } public String getPrivilegesSQL(final boolean withGrantOption) { if (withGrantOption) { if (selectWithGrantOption && insertWithGrantOption && updateWithGrantOption && deleteWithGrantOption && truncateWithGrantOption && referencesWithGrantOption && triggerWithGrantOption) { return "ALL"; } String result = ""; if (selectWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "SELECT"; } if (insertWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "INSERT"; } if (updateWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "UPDATE"; } if (deleteWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "DELETE"; } if (truncateWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "TRUNCATE"; } if (referencesWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "REFERENCES"; } if (triggerWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "TRIGGER"; } return result; } else { if (select && insert && update && delete && truncate && references && trigger) { return "ALL"; } String result = ""; if (select) { if (!"".equals(result)) { result += ", "; } result += "SELECT"; } if (insert) { if (!"".equals(result)) { result += ", "; } result += "INSERT"; } if (update) { if (!"".equals(result)) { result += ", "; } result += "UPDATE"; } if (delete) { if (!"".equals(result)) { result += ", "; } result += "DELETE"; } if (truncate) { if (!"".equals(result)) { result += ", "; } result += "TRUNCATE"; } if (references) { if (!"".equals(result)) { result += ", "; } result += "REFERENCES"; } if (trigger) { if (!"".equals(result)) { result += ", "; } result += "TRIGGER"; } return result; } } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgSchema.java000077500000000000000000000321671316501242600255770ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Stores schema information. * * @author fordfrog */ public class PgSchema { /** * List of functions defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List functions = new ArrayList(); /** * List of sequences defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List sequences = new ArrayList(); /** * List of rels defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List rels = new ArrayList(); /** * List of types defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List types = new ArrayList(); /** * List of indexes defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List indexes = new ArrayList(); /** * List of primary keys defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List primaryKeys = new ArrayList(); /** * Name of the schema. */ private final String name; /** * Schema authorization. */ private String authorization; /** * Optional definition of schema elements. */ private String definition; /** * Comment. */ private String comment; /** * Creates a new PgSchema object. * * @param name {@link #name} */ public PgSchema(final String name) { this.name = name; } /** * Setter for {@link #authorization}. * * @param authorization {@link #authorization} */ public void setAuthorization(final String authorization) { this.authorization = authorization; } /** * Getter for {@link #authorization}. * * @return {@link #authorization} */ public String getAuthorization() { return authorization; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Getter for {@link #definition}. * * @return {@link #definition} */ public String getDefinition() { return definition; } /** * Setter for {@link #definition}. * * @param definition {@link #definition} */ public void setDefinition(final String definition) { this.definition = definition; } /** * Creates and returns SQL for creation of the schema. * * @return created SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(50); sbSQL.append("CREATE SCHEMA "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(getName())); if (getAuthorization() != null) { sbSQL.append(" AUTHORIZATION "); sbSQL.append(PgDiffUtils.getQuotedName(getAuthorization())); } sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON SCHEMA "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Finds function according to specified function {@code signature}. * * @param signature signature of the function to be searched * * @return found function or null if no such function has been found */ public PgFunction getFunction(final String signature) { for (PgFunction function : functions) { if (function.getSignature().equals(signature)) { return function; } } return null; } /** * Getter for {@link #functions}. The list cannot be modified. * * @return {@link #functions} */ public List getFunctions() { return Collections.unmodifiableList(functions); } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Finds index according to specified index {@code name}. * * @param name name of the index to be searched * * @return found index or null if no such index has been found */ public PgIndex getIndex(final String name) { for (PgIndex index : indexes) { if (index.getName().equals(name)) { return index; } } return null; } /** * Finds primary key according to specified primary key {@code name}. * * @param name name of the primary key to be searched * * @return found primary key or null if no such primary key has been found */ public PgConstraint getPrimaryKey(final String name) { for (PgConstraint constraint : primaryKeys) { if (constraint.getName().equals(name)) { return constraint; } } return null; } /** * Finds sequence according to specified sequence {@code name}. * * @param name name of the sequence to be searched * * @return found sequence or null if no such sequence has been found */ public PgSequence getSequence(final String name) { for (PgSequence sequence : sequences) { if (sequence.getName().equals(name)) { return sequence; } } return null; } /** * Getter for {@link #indexes}. The list cannot be modified. * * @return {@link #indexes} */ public List getIndexes() { return Collections.unmodifiableList(indexes); } /** * Getter for {@link #primaryKeys}. The list cannot be modified. * * @return {@link #primaryKeys} */ public List getPrimaryKeys() { return Collections.unmodifiableList(primaryKeys); } /** * Getter for {@link #sequences}. The list cannot be modified. * * @return {@link #sequences} */ public List getSequences() { return Collections.unmodifiableList(sequences); } /** * Finds table/view according to specified {@code name}. * * @param name name of the table/view to be searched * * @return found table or null if no such table has been found */ public PgRelation getRelation(final String name) { for (PgRelation rel : rels) { if (rel.getName().equals(name)) { return rel; } } return null; } /** * Finds table according to specified table {@code name}. * * @param name name of the table to be searched * * @return found table or null if no such table has been found */ public PgTable getTable(final String name) { PgRelation rel = this.getRelation(name); if (rel == null || !(rel instanceof PgTable)) return null; return (PgTable) rel; } /** * Get a list of tables from {@link #rels}. * * @return list of tables */ public List getTables() { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); for (PgRelation rel : rels) { if (rel instanceof PgTable) { list.add((PgTable) rel); } } return list; } /** * Getter for {@link #rels}. The list cannot be modified. * * @return {@link #rels} */ public List getRels() { return Collections.unmodifiableList(rels); } /** * Finds view according to specified view {@code name}. * * @param name name of the view to be searched * * @return found view or null if no such view has been found */ public PgView getView(final String name) { PgRelation rel = this.getRelation(name); if (rel == null || !(rel instanceof PgView)) return null; return (PgView) rel; } /** * Get a list of views from {@link #rels}. * * @return list of views */ public List getViews() { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); for (PgRelation rel : rels) { if (rel instanceof PgView) { list.add((PgView) rel); } } return list; } /** * Adds {@code index} to the list of indexes. * * @param index index */ public void addIndex(final PgIndex index) { indexes.add(index); } /** * Adds {@code primary key} to the list of primary keys. * * @param primaryKey index */ public void addPrimaryKey(final PgConstraint primaryKey) { primaryKeys.add(primaryKey); } /** * Adds {@code function} to the list of functions. * * @param function function */ public void addFunction(final PgFunction function) { functions.add(function); } /** * Adds {@code sequence} to the list of sequences. * * @param sequence sequence */ public void addSequence(final PgSequence sequence) { sequences.add(sequence); } /** * Adds {@code rel} table or view to the list of rels. * * @param rel relation */ public void addRelation(final PgRelation rel) { rels.add(rel); } /** * Adds {@code type} to the list of types. * * @param type type */ public void addType(final PgType type) { types.add(type); } /** * Returns a list of types * * @return types List of PgType */ public List getTypes() { return types; } /** * Finds type according to specified name {@code name}. * * @param name name of the type to be searched * * @return found type or null if no such table has been found */ public PgType getType(final String name) { for (PgType type : types) { if (type.getName().equals(name)) { return type; } } return null; } /** * Returns true if schema contains type with given {@code name}, otherwise * false. * * @param name name of the table * * @return true if schema contains table with given {@code name}, otherwise * false. */ public boolean containsType(final String name) { for (PgType type : types) { if (type.getName().equals(name)) { return true; } } return false; } /** * Returns true if schema contains function with given {@code signature}, * otherwise false. * * @param signature signature of the function * * @return true if schema contains function with given {@code signature}, * otherwise false */ public boolean containsFunction(final String signature) { for (PgFunction function : functions) { if (function.getSignature().equals(signature)) { return true; } } return false; } /** * Returns true if schema contains sequence with given {@code name}, * otherwise false. * * @param name name of the sequence * * @return true if schema contains sequence with given {@code name}, * otherwise false */ public boolean containsSequence(final String name) { for (PgSequence sequence : sequences) { if (sequence.getName().equals(name)) { return true; } } return false; } /** * Returns true if schema contains table with given {@code name}, otherwise * false. * * @param name name of the table * * @return true if schema contains table with given {@code name}, otherwise * false. */ public boolean containsTable(final String name) { return getTable(name) != null; } /** * Returns true if schema contains view with given {@code name}, otherwise * false. * * @param name name of the view * * @return true if schema contains view with given {@code name}, otherwise * false. */ public boolean containsView(final String name) { return getView(name) != null; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java000077500000000000000000000176511316501242600261500ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import java.util.ArrayList; import java.util.Collections; import java.util.List; import cz.startnet.utils.pgdiff.PgDiffUtils; /** * Stores sequence information. * * @author fordfrog */ public class PgSequence { /** * Value for CACHE or null if no value is specified. */ private String cache; /** * Value for INCREMENT BY or null if no value is specified. */ private String increment; /** * Value for MAXVALUE or null if no value is specified. */ private String maxValue; /** * Value for MINVALUE or null if no value is specified. */ private String minValue; /** * Name of the sequence. */ private String name; /** * Value for START WITH or null if no value is specified. */ private String startWith; /** * True if CYCLE, false if NO CYCLE. */ private boolean cycle; /** * Column the sequence is owned by. */ private String ownedBy; /** * Comment. */ private String comment; /** * List of privileges defined on the sequence. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List privileges = new ArrayList(); /** * Creates a new PgSequence object. * * @param name name of the sequence */ public PgSequence(final String name) { this.name = name; } /** * Setter for {@link #cache}. * * @param cache {@link #cache} */ public void setCache(final String cache) { this.cache = cache; } /** * Getter for {@link #cache}. * * @return {@link #cache} */ public String getCache() { return cache; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Creates and returns SQL statement for creation of the sequence. * * @return created SQL statement */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("CREATE SEQUENCE "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (startWith != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tSTART WITH "); sbSQL.append(startWith); } if (increment != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tINCREMENT BY "); sbSQL.append(increment); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\t"); if (maxValue == null) { sbSQL.append("NO MAXVALUE"); } else { sbSQL.append("MAXVALUE "); sbSQL.append(maxValue); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\t"); if (minValue == null) { sbSQL.append("NO MINVALUE"); } else { sbSQL.append("MINVALUE "); sbSQL.append(minValue); } if (cache != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tCACHE "); sbSQL.append(cache); } if (cycle) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tCYCLE"); } sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON SEQUENCE "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Creates and returns SQL statement for modification "OWNED BY" parameter. * * @return created SQL statement */ public String getOwnedBySQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("ALTER SEQUENCE "); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (ownedBy != null && !ownedBy.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tOWNED BY "); sbSQL.append(ownedBy); } sbSQL.append(';'); return sbSQL.toString(); } /** * Setter for {@link #cycle}. * * @param cycle {@link #cycle} */ public void setCycle(final boolean cycle) { this.cycle = cycle; } /** * Getter for {@link #cycle}. * * @return {@link #cycle} */ public boolean isCycle() { return cycle; } /** * Creates and returns SQL statement for dropping the sequence. * * @return created SQL */ public String getDropSQL() { return "DROP SEQUENCE " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + ";"; } /** * Setter for {@link #increment}. * * @param increment {@link #increment} */ public void setIncrement(final String increment) { this.increment = increment; } /** * Getter for {@link #increment}. * * @return {@link #increment} */ public String getIncrement() { return increment; } /** * Setter for {@link #maxValue}. * * @param maxValue {@link #maxValue} */ public void setMaxValue(final String maxValue) { this.maxValue = maxValue; } /** * Getter for {@link #maxValue}. * * @return {@link #maxValue} */ public String getMaxValue() { return maxValue; } /** * Setter for {@link #minValue}. * * @param minValue {@link #minValue} */ public void setMinValue(final String minValue) { this.minValue = minValue; } /** * Getter for {@link #minValue}. * * @return {@link #minValue} */ public String getMinValue() { return minValue; } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Setter for {@link #startWith}. * * @param startWith {@link #startWith} */ public void setStartWith(final String startWith) { this.startWith = startWith; } /** * Getter for {@link #startWith}. * * @return {@link #startWith} */ public String getStartWith() { return startWith; } /** * Getter for {@link #ownedBy}. * * @return {@link #ownedBy} */ public String getOwnedBy() { return ownedBy; } /** * Setter for {@link #ownedBy}. * * @param ownedBy {@link #ownedBy} */ public void setOwnedBy(final String ownedBy) { this.ownedBy = ownedBy; } public List getPrivileges() { return Collections.unmodifiableList(privileges); } public PgSequencePrivilege getPrivilege(final String roleName) { for (PgSequencePrivilege privilege : privileges) { if (privilege.getRoleName().equals(roleName)) { return privilege; } } return null; } public void addPrivilege(final PgSequencePrivilege privilege) { privileges.add(privilege); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequencePrivilege.java000066400000000000000000000066311316501242600300100ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; /** * Stores sequencePrivileges information. * * @author user */ public class PgSequencePrivilege { private final String roleName; private boolean usage = false; private boolean select = false; private boolean update = false; private boolean usageWithGrantOption = false; private boolean selectWithGrantOption = false; private boolean updateWithGrantOption = false; /** * Creates a new PgSequencePrivilege object. * * @param roleName * name of the role */ public PgSequencePrivilege(final String roleName) { this.roleName = roleName; } /** * @return the roleName */ public String getRoleName() { return roleName; } public void setPrivileges(final String privilege, final boolean value, final boolean grantOption) { if ("USAGE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { usage = true; if (grantOption) { usageWithGrantOption = true; } } else { usageWithGrantOption = false; if (!grantOption) { usage = false; } } } if ("SELECT".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { select = true; if (grantOption) { selectWithGrantOption = true; } } else { selectWithGrantOption = false; if (!grantOption) { select = false; } } } if ("UPDATE".equalsIgnoreCase(privilege) || "ALL".equalsIgnoreCase(privilege)) { if (value) { update = true; if (grantOption) { updateWithGrantOption = true; } } else { updateWithGrantOption = false; if (!grantOption) { update = false; } } } } /** * true the privileges are the same (no matter of roleName). * * @param other * privileges to compare * @return isSimilar */ public boolean isSimilar(final PgSequencePrivilege other) { if (other == null) { return false; } if (usage != other.usage) { return false; } if (usageWithGrantOption != other.usageWithGrantOption) { return false; } if (select != other.select) { return false; } if (selectWithGrantOption != other.selectWithGrantOption) { return false; } if (update != other.update) { return false; } if (updateWithGrantOption != other.updateWithGrantOption) { return false; } return true; } public String getPrivilegesSQL(final boolean withGrantOption) { if (withGrantOption) { if (usageWithGrantOption && selectWithGrantOption && updateWithGrantOption) { return "ALL"; } String result = ""; if (usageWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "USAGE"; } if (selectWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "SELECT"; } if (updateWithGrantOption) { if (!"".equals(result)) { result += ", "; } result += "UPDATE"; } return result; } else { if (usage && select && update) { return "ALL"; } String result = ""; if (select) { if (!"".equals(result)) { result += ", "; } result += "SELECT"; } if (usage) { if (!"".equals(result)) { result += ", "; } result += "USAGE"; } if (update) { if (!"".equals(result)) { result += ", "; } result += "UPDATE"; } return result; } } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java000077500000000000000000000327731316501242600254310ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.Pair; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Stores table information. * * @author fordfrog */ public class PgTable extends PgRelation { /** * List of inheritedColumns defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List inheritedColumns = new ArrayList(); /** * List of constraints defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List constraints = new ArrayList(); /** * List of names of inherited tables. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List> inherits = new ArrayList>(); /** * WITH clause. If value is null then it is not set, otherwise can be set to * OIDS=true, OIDS=false, or storage parameters can be set. */ private String with; /** * Is this a UNLOGGED table? */ private boolean unlogged; /** * Is this a FOREIGN table? */ private boolean foreign; /** * Does this table have RLS enabled? */ private Boolean rlsEnabled; /** * Does this table have RLS forced? */ private Boolean rlsForced; private String foreignServer; /** * RLS Policies */ private List policies = new ArrayList(); /** * PgDatabase */ private final PgDatabase database; /** * PgSchema */ private final PgSchema schema; /** * Creates a new PgTable object. * * @param name {@link #name} * @param database name of database * @param schema name of schema */ public PgTable(final String name, final PgDatabase database, final PgSchema schema) { setName(name); this.database = database; this.schema = schema; } /** * Finds constraint according to specified constraint {@code name}. * * @param name name of the constraint to be searched * * @return found constraint or null if no such constraint has been found */ public PgConstraint getConstraint(final String name) { for (PgConstraint constraint : constraints) { if (constraint.getName().equals(name)) { return constraint; } } return null; } /** * Getter for {@link #constraints}. The list cannot be modified. * * @return {@link #constraints} */ public List getConstraints() { return Collections.unmodifiableList(constraints); } /** * Returns relation kind for CREATE/ALTER/DROP commands. * * @return relation kind */ public String getRelationKind() { return "TABLE"; } /** * Creates and returns SQL for creation of the table. * * @param schema schema of current statement * * @return created SQL statement */ public String getCreationSQL(final PgSchema schema) { final StringBuilder sbSQL = new StringBuilder(1000); sbSQL.append("CREATE "); if (isUnlogged()) { sbSQL.append("UNLOGGED "); } if (isForeign()) { sbSQL.append("FOREIGN "); } sbSQL.append("TABLE "); sbSQL.append(PgDiffUtils.getCreateIfNotExists()); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ("); sbSQL.append(System.getProperty("line.separator")); boolean first = true; if (columns.isEmpty()) { sbSQL.append(')'); } else { for (PgColumn column : columns) { if (first) { first = false; } else { sbSQL.append(","); sbSQL.append(System.getProperty("line.separator")); } sbSQL.append("\t"); sbSQL.append(column.getFullDefinition(false)); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append(")"); } if (inherits != null && !inherits.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("INHERITS ("); first = true; for (final Pair inheritPair : inherits) { if (first) { first = false; } else { sbSQL.append(", "); } String inheritTableName = null; if(schema.getName().equals(inheritPair.getL())){ inheritTableName = inheritPair.getR(); } else { inheritTableName = String.format("%s.%s", inheritPair.getL(), inheritPair.getR()); } sbSQL.append(inheritTableName); } sbSQL.append(")"); } if (with != null && !with.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); if ("OIDS=false".equalsIgnoreCase(with)) { sbSQL.append("WITHOUT OIDS"); } else { sbSQL.append("WITH "); if ("OIDS".equalsIgnoreCase(with) || "OIDS=true".equalsIgnoreCase(with)) { sbSQL.append("OIDS"); } else { sbSQL.append(with); } } } if (isForeign()) { sbSQL.append("SERVER "); sbSQL.append(getForeignServer()); } if (tablespace != null && !tablespace.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("TABLESPACE "); sbSQL.append(tablespace); } sbSQL.append(';'); //Inherited column default override for (PgInheritedColumn column : getInheritedColumns()) { if(column.getDefaultValue() != null){ sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("ALTER TABLE ONLY "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tALTER COLUMN "); sbSQL.append( PgDiffUtils.getQuotedName(column.getInheritedColumn().getName())); sbSQL.append(" SET DEFAULT "); sbSQL.append(column.getDefaultValue()); sbSQL.append(';'); } } for (PgColumn column : getColumnsWithStatistics()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("ALTER TABLE ONLY "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ALTER COLUMN "); sbSQL.append( PgDiffUtils.getQuotedName(column.getName())); sbSQL.append(" SET STATISTICS "); sbSQL.append(column.getStatistics()); sbSQL.append(';'); } sbSQL.append(getCommentDefinitionSQL()); return sbSQL.toString(); } /** * Setter for {@link #inherits}. * * @param schemaName name of schema * @param tableName name of inherited table */ public void addInherits(final String schemaName, final String tableName) { inherits.add(new Pair(schemaName, tableName)); final PgTable inheritedTable = database.getSchema(schemaName).getTable(tableName); for( PgColumn column : inheritedTable.getColumns() ) { PgInheritedColumn inheritedColumn = new PgInheritedColumn(column); inheritedColumns.add(inheritedColumn); } } /** * Getter for {@link #inherits}. * * @return {@link #inherits} */ public List> getInherits() { return Collections.unmodifiableList(inherits); } /** * Setter for {@link #with}. * * @param with {@link #with} */ public void setWith(final String with) { this.with = with; } /** * Getter for {@link #with} * * @return {@link #with} */ public String getWith() { return with; } /** * Getter for {@link #tablespace}. * * @return {@link #tablespace} */ public String getTablespace() { return tablespace; } /** * Setter for {@link #tablespace}. * * @param tablespace {@link #tablespace} */ public void setTablespace(final String tablespace) { this.tablespace = tablespace; } /** * Adds {@code column} to the list of columns. * * @param column column */ public void addColumn(final PgColumn column) { columns.add(column); } /** * Adds {@code inheritedColumn} to the list of inheritedColumns. * * @param inheritedColumn inheritedColumn */ public void addInheritedColumn(final PgInheritedColumn inheritedColumn) { inheritedColumns.add(inheritedColumn); } /** * Finds inheritedColumn according to specified name {@code name}. * * @param name name of the inheritedColumn to be searched * * @return found inheritedColumn or null if no such inheritedColumn * has been found */ public PgInheritedColumn getInheritedColumn(final String name) { if (inherits != null && !inherits.isEmpty()) { for (PgInheritedColumn inheritedColumn : inheritedColumns) { if (inheritedColumn.getInheritedColumn().getName().equals(name)) { return inheritedColumn; } } } return null; } /** * Getter for {@link #inheritedColumns}. The list cannot be modified. * * @return {@link #inheritedColumns} */ public List getInheritedColumns() { return Collections.unmodifiableList(inheritedColumns); } /** * Adds {@code constraint} to the list of constraints. * * @param constraint constraint */ public void addConstraint(final PgConstraint constraint) { constraints.add(constraint); } /** * Returns true if table contains given inheritedColumn {@code name}, * otherwise false. * * @param name name of the inheritedColumn * * @return true if table contains given inheritedColumn {@code name}, * otherwise false */ public boolean containsInheritedColumn(final String name) { if (inherits != null && !inherits.isEmpty()) { for (PgInheritedColumn inheritedColumn : inheritedColumns) { if (inheritedColumn.getInheritedColumn().getName().equals(name)) { return true; } } } return false; } /** * Returns true if table contains given constraint {@code name}, otherwise * false. * * @param name name of the constraint * * @return true if table contains given constraint {@code name}, otherwise * false */ public boolean containsConstraint(final String name) { for (PgConstraint constraint : constraints) { if (constraint.getName().equals(name)) { return true; } } return false; } /** * Returns list of columns that have statistics defined. * * @return list of columns that have statistics defined */ private List getColumnsWithStatistics() { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); for (PgColumn column : columns) { if (column.getStatistics() != null) { list.add(column); } } return list; } public boolean isUnlogged() { return unlogged; } public void setUnlogged(boolean unlogged) { this.unlogged = unlogged; } /** * Foreign Tables */ @Override public String getDropSQL() { return "DROP " + ((isForeign()) ? "FOREIGN ":"") + getRelationKind() + " " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + ";"; } public boolean isForeign() { return foreign; } public void setForeign(boolean foreign) { this.foreign = foreign; } public void setForeignServer(String server){ foreignServer = server; } public String getForeignServer(){ return foreignServer; } public Boolean hasRLSEnabled() { return rlsEnabled; } public void setRLSEnabled(Boolean rlsEnabled) { this.rlsEnabled = rlsEnabled; } public Boolean hasRLSForced() { return rlsForced; } public void setRLSForced(Boolean rlsForced) { this.rlsForced = rlsForced; } public void addPolicy(final PgPolicy policy) { policies.add(policy); } public PgPolicy getPolicy(final String name) { for (PgPolicy policy : policies) { if (policy.getName().equals(name)) { return policy; } } return null; } public List getPolicies() { return Collections.unmodifiableList(policies); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgTrigger.java000077500000000000000000000272131316501242600257760ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.HashMap; import java.util.Map; /** * Stores trigger information. * * @author fordfrog */ public class PgTrigger { /** * Enumeration of when, with respect to event, a trigger should fire. * e.g. BEFORE, AFTER or INSTEAD OF an event. */ public enum EventTimeQualification { before, after, instead_of; private static final Map stringRepresentation; static { HashMap aMap = new HashMap(); aMap.put(EventTimeQualification.before, "BEFORE"); aMap.put(EventTimeQualification.after, "AFTER"); aMap.put(EventTimeQualification.instead_of, "INSTEAD OF"); stringRepresentation = Collections.unmodifiableMap(aMap); } public static String toString(EventTimeQualification eventTimeQualification) { return stringRepresentation.get(eventTimeQualification); } } /** * Function name and arguments that should be fired on the trigger. */ private String function; /** * Name of the trigger. */ private String name; /** * Name of the relation the trigger is defined on. */ private String relationName; /** * Whether the trigger should be fired BEFORE, AFTER or INSTEAD OF an event. * Default is before. */ private EventTimeQualification eventTimeQualification = EventTimeQualification.before; /** * Whether the trigger should be fired FOR EACH ROW or FOR EACH STATEMENT. * Default is FOR EACH STATEMENT. */ private boolean forEachRow; /** * Whether the trigger should be fired on DELETE. */ private boolean onDelete; /** * Whether the trigger should be fired on INSERT. */ private boolean onInsert; /** * Whether the trigger should be fired on UPDATE. */ private boolean onUpdate; /** * Whether the trigger should be fired on TRUNCATE. */ private boolean onTruncate; /** * Optional list of columns for UPDATE event. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List updateColumns = new ArrayList(); /** * WHEN condition. */ private String when; /** * Comment. */ private String comment; /** * Setter for {@link #eventTimeQualification}. * * @param eventTimeQualification {@link #eventTimeQualification} */ public void setEventTimeQualification(final EventTimeQualification eventTimeQualification) { this.eventTimeQualification = eventTimeQualification; } /** * Getter for {@link #eventTimeQualification}. * * @return {@link #eventTimeQualification} */ public EventTimeQualification getEventTimeQualification() { return eventTimeQualification; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } /** * Setter for {@link #comment}. * * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; } /** * Creates and returns SQL for creation of trigger. * * @return created SQL */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(100); sbSQL.append("CREATE TRIGGER "); sbSQL.append(PgDiffUtils.getQuotedName(getName())); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\t"); sbSQL.append(EventTimeQualification.toString(getEventTimeQualification())); boolean firstEvent = true; if (isOnInsert()) { sbSQL.append(" INSERT"); firstEvent = false; } if (isOnUpdate()) { if (firstEvent) { firstEvent = false; } else { sbSQL.append(" OR"); } sbSQL.append(" UPDATE"); if (!updateColumns.isEmpty()) { sbSQL.append(" OF"); boolean first = true; for (final String columnName : updateColumns) { if (first) { first = false; } else { sbSQL.append(','); } sbSQL.append(' '); sbSQL.append(columnName); } } } if (isOnDelete()) { if (!firstEvent) { sbSQL.append(" OR"); } sbSQL.append(" DELETE"); } if (isOnTruncate()) { if (!firstEvent) { sbSQL.append(" OR"); } sbSQL.append(" TRUNCATE"); } sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(getRelationName())); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tFOR EACH "); sbSQL.append(isForEachRow() ? "ROW" : "STATEMENT"); if (when != null && !when.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tWHEN ("); sbSQL.append(when); sbSQL.append(')'); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\tEXECUTE PROCEDURE "); sbSQL.append(getFunction()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("COMMENT ON TRIGGER "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(relationName)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } return sbSQL.toString(); } /** * Creates and returns SQL for dropping the trigger. * * @return created SQL */ public String getDropSQL() { return "DROP TRIGGER " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + " ON " + PgDiffUtils.getQuotedName(getRelationName()) + ";"; } /** * Setter for {@link #forEachRow}. * * @param forEachRow {@link #forEachRow} */ public void setForEachRow(final boolean forEachRow) { this.forEachRow = forEachRow; } /** * Getter for {@link #forEachRow}. * * @return {@link #forEachRow} */ public boolean isForEachRow() { return forEachRow; } /** * Setter for {@link #function}. * * @param function {@link #function} */ public void setFunction(final String function) { this.function = function; } /** * Getter for {@link #function}. * * @return {@link #function} */ public String getFunction() { return function; } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Setter for {@link #onDelete}. * * @param onDelete {@link #onDelete} */ public void setOnDelete(final boolean onDelete) { this.onDelete = onDelete; } /** * Getter for {@link #onDelete}. * * @return {@link #onDelete} */ public boolean isOnDelete() { return onDelete; } /** * Setter for {@link #onInsert}. * * @param onInsert {@link #onInsert} */ public void setOnInsert(final boolean onInsert) { this.onInsert = onInsert; } /** * Getter for {@link #onInsert}. * * @return {@link #onInsert} */ public boolean isOnInsert() { return onInsert; } /** * Setter for {@link #onUpdate}. * * @param onUpdate {@link #onUpdate} */ public void setOnUpdate(final boolean onUpdate) { this.onUpdate = onUpdate; } /** * Getter for {@link #onUpdate}. * * @return {@link #onUpdate} */ public boolean isOnUpdate() { return onUpdate; } /** * Getter for {@link #onTruncate}. * * @return {@link #onTruncate} */ public boolean isOnTruncate() { return onTruncate; } /** * Setter for {@link #onTruncate}. * * @param onTruncate {@link #onTruncate} */ public void setOnTruncate(final boolean onTruncate) { this.onTruncate = onTruncate; } /** * Setter for {@link #relationName}. * * @param relationName {@link #relationName} */ public void setRelationName(final String relationName) { this.relationName = relationName; } /** * Getter for {@link #relationName}. * * @return {@link #relationName} */ public String getRelationName() { return relationName; } /** * Getter for {@link #updateColumns}. * * @return {@link #updateColumns} */ public List getUpdateColumns() { return Collections.unmodifiableList(updateColumns); } /** * Adds column name to the list of update columns. * * @param columnName column name */ public void addUpdateColumn(final String columnName) { updateColumns.add(columnName); } /** * Getter for {@link #when}. * * @return {@link #when} */ public String getWhen() { return when; } /** * Setter for {@link #when}. * * @param when {@link #when} */ public void setWhen(final String when) { this.when = when; } @Override public boolean equals(final Object object) { boolean equals = false; if (this == object) { equals = true; } else if (object instanceof PgTrigger) { final PgTrigger trigger = (PgTrigger) object; equals = (eventTimeQualification == trigger.getEventTimeQualification()) && (forEachRow == trigger.isForEachRow()) && function.equals(trigger.getFunction()) && name.equals(trigger.getName()) && (onDelete == trigger.isOnDelete()) && (onInsert == trigger.isOnInsert()) && (onUpdate == trigger.isOnUpdate()) && (onTruncate == trigger.isOnTruncate()) && relationName.equals(trigger.getRelationName()); if (equals) { final List sorted1 = new ArrayList(updateColumns); final List sorted2 = new ArrayList(trigger.getUpdateColumns()); Collections.sort(sorted1); Collections.sort(sorted2); equals = sorted1.equals(sorted2); } } return equals; } @Override public int hashCode() { return (getClass().getName() + "|" + eventTimeQualification + "|" + forEachRow + "|" + function + "|" + name + "|" + onDelete + "|" + onInsert + "|" + onUpdate + "|" + onTruncate + "|" + relationName).hashCode(); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgType.java000077500000000000000000000127621316501242600253170ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Stores table information. * * @author fordfrog */ public class PgType { /** * List of columns defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List columns = new ArrayList(); private final List enumValues = new ArrayList(); /** * Name of the table. */ private String name; private Boolean isEnum = false; /** * Creates a new PgTable object. * * @param name {@link #name} */ public PgType(final String name) { this.name = name; } /** * Finds column according to specified column {@code name}. * * @param name name of the column to be searched * * @return found column or null if no such column has been found */ public PgColumn getColumn(final String name) { for (PgColumn column : columns) { if (column.getName().equals(name)) { return column; } } return null; } /** * Getter for {@link #columns}. The list cannot be modified. * * @return {@link #columns} */ public List getColumns() { return Collections.unmodifiableList(columns); } /** * Creates and returns SQL for creation of the table. * * @return created SQL statement */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(1000); sbSQL.append("CREATE TYPE "); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (isEnum) { sbSQL.append(" AS ENUM ("); } else { sbSQL.append(" AS ("); } sbSQL.append(System.getProperty("line.separator")); boolean first = true; if (isEnum) { for (String enumValue : enumValues) { if (first) { first = false; } else { sbSQL.append(","); sbSQL.append(System.getProperty("line.separator")); } sbSQL.append("\t"); sbSQL.append(enumValue); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append(")"); } else { if (columns.isEmpty()) { sbSQL.append(')'); } else { for (PgColumn column : columns) { if (first) { first = false; } else { sbSQL.append(","); sbSQL.append(System.getProperty("line.separator")); } sbSQL.append("\t"); sbSQL.append(column.getFullDefinition(false)); } sbSQL.append(System.getProperty("line.separator")); sbSQL.append(")"); } } sbSQL.append(';'); for (PgColumn column : getColumnsWithStatistics()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("ALTER TABLE ONLY "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ALTER COLUMN "); sbSQL.append( PgDiffUtils.getQuotedName(column.getName())); sbSQL.append(';'); } return sbSQL.toString(); } /** * Creates and returns SQL statement for dropping the table. * * @return created SQL statement */ public String getDropSQL() { return "DROP TYPE "+ PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + ";"; } /** * Setter for {@link #name}. * * @param name {@link #name} */ public void setName(final String name) { this.name = name; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * Adds {@code column} to the list of columns. * * @param column column */ public void addColumn(final PgColumn column) { columns.add(column); } /** * Returns true if table contains given column {@code name}, otherwise * false. * * @param name name of the column * * @return true if table contains given column {@code name}, otherwise false */ public boolean containsColumn(final String name) { for (PgColumn column : columns) { if (column.getName().equals(name)) { return true; } } return false; } /** * Returns list of columns that have statistics defined. * * @return list of columns that have statistics defined */ private List getColumnsWithStatistics() { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); for (PgColumn column : columns) { if (column.getStatistics() != null) { list.add(column); } } return list; } public void setIsEnum(boolean value) { isEnum = value; } public boolean getIsEnum() { return isEnum; } public void addEnumValue(String value) { enumValues.add(value); } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java000066400000000000000000000130441316501242600252770ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.List; /** * Stores view information. * * @author fordfrog */ public class PgView extends PgRelation { /** * Were column names explicitly declared as part of the view? */ private boolean declareColumnNames = false; /** * Is this a MATERIALIZED view? */ private boolean materialized; /** * SQL query of the view. */ private String query; /** * Creates a new PgView object. * * @param name {@link #name} */ public PgView(final String name) { setName(name); } /** * Sets the list of declared column names for the view. * * @param columnNames list of column names */ public void setDeclaredColumnNames(final List columnNames) { // Can only be set once for a view, before defaults/comments are set assert !declareColumnNames; assert columns.isEmpty(); if (columnNames == null || columnNames.isEmpty()) return; declareColumnNames = true; for (final String colName: columnNames) { addColumn(new PgColumn(colName)); } } /** * Returns a list of column names if the names were declared along with the view, null otherwise. * * @return list of column names or null */ public List getDeclaredColumnNames() { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (!declareColumnNames) return null; for (PgColumn column : columns) { list.add(column.getName()); } return list; } /** * Returns relation kind for CREATE/ALTER/DROP commands. * * @return relation kind */ public String getRelationKind() { if (materialized) return "MATERIALIZED VIEW"; else return "VIEW"; } /** * Creates and returns SQL for creation of the view. * * @return created SQL statement */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(query.length() * 2); sbSQL.append("CREATE "); sbSQL.append(getRelationKind()); sbSQL.append(' '); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (declareColumnNames) { assert columns != null && !columns.isEmpty(); sbSQL.append(" ("); for (int i = 0; i < columns.size(); i++) { if (i > 0) { sbSQL.append(", "); } sbSQL.append(PgDiffUtils.getQuotedName(columns.get(i).getName())); } sbSQL.append(')'); } sbSQL.append(" AS"); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("\t"); sbSQL.append(query); sbSQL.append(';'); /* Column default values */ for (final PgColumn col : getColumns()) { String defaultValue = col.getDefaultValue(); if (defaultValue != null && !defaultValue.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("ALTER "); sbSQL.append(getRelationKind()); sbSQL.append(' '); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ALTER COLUMN "); sbSQL.append(PgDiffUtils.getQuotedName(col.getName())); sbSQL.append(" SET DEFAULT "); sbSQL.append(defaultValue); sbSQL.append(';'); } } sbSQL.append(getCommentDefinitionSQL()); return sbSQL.toString(); } /** * Setter for {@link #materialized}. * * @param materialized {@link #materialized} */ public void setMaterialized(boolean materialized) { this.materialized = materialized; } /** * Getter for {@link #materialized}. * * @return {@link #materialized} */ public boolean isMaterialized() { return materialized; } /** * Setter for {@link #query}. * * @param query {@link #query} */ public void setQuery(final String query) { this.query = query; } /** * Getter for {@link #query}. * * @return {@link #query} */ public String getQuery() { return query; } /** * Finds column according to specified column {@code name}. * * @param name name of the column to be searched * * @return found column or null if no such column has been found */ public PgColumn getColumn(final String name) { PgColumn col = super.getColumn(name); if (col == null && !declareColumnNames) { /* * In views, we don't always know columns beforehand; create a new * column if the view didn't declare col names. */ col = new PgColumn(name); addColumn(col); } return col; } /** * Returns true if table contains given column {@code name}, otherwise * false. * * @param name name of the column * * @return true if table contains given column {@code name}, otherwise false */ public boolean containsColumn(final String name) { return true; } } apgdiff/src/main/java/cz/startnet/utils/pgdiff/schema/package-info.java000066400000000000000000000001301316501242600264120ustar00rootroot00000000000000/** * Contains PostgreSQL schema objects. */ package cz.startnet.utils.pgdiff.schema; apgdiff/src/main/resources/000077500000000000000000000000001316501242600162035ustar00rootroot00000000000000apgdiff/src/main/resources/cz/000077500000000000000000000000001316501242600166175ustar00rootroot00000000000000apgdiff/src/main/resources/cz/startnet/000077500000000000000000000000001316501242600204635ustar00rootroot00000000000000apgdiff/src/main/resources/cz/startnet/utils/000077500000000000000000000000001316501242600216235ustar00rootroot00000000000000apgdiff/src/main/resources/cz/startnet/utils/pgdiff/000077500000000000000000000000001316501242600230625ustar00rootroot00000000000000apgdiff/src/main/resources/cz/startnet/utils/pgdiff/Resources.properties000066400000000000000000000073141316501242600271570ustar00rootroot00000000000000VersionNumber=2.4.1-SNAPSHOT UsageHelp=\ Usage: apgdiff [options] \n\ \n\ Options:\n\ \n\ --version:\n\ ${tab}displays apgdiff version\n\ \n\ --add-defaults:\n\ ${tab}adds DEFAULT ... in case new column has NOT NULL constraint but no\n\ ${tab}default value (the default value is dropped later).\n\ \n\ --add-transaction:\n\ ${tab}adds START TRANSACTION and COMMIT TRANSACTION to generated diff file.\n\ \n\ --ignore-function-whitespace:\n\ ${tab}ignores multiple spaces and new lines when comparing content of\n\ ${tab}functions - WARNING: this may cause functions to appear to be\n\ ${tab}same in cases they are not, so use this feature only if you know\n\ ${tab}what you are doing.\n\ \n\ --ignore-start-with:\n\ ${tab}ignores START WITH modifications on SEQUENCEs (default: do not ignore\n\ ${tab}these changes).\n\ \n\ --ignore-schema-creation:\n\ ${tab}Removes the need of CREATE SCHEMA command on the input schemas\n\ \n\ --in-charset-name :\n\ ${tab}charset that should be used for reading input files (standard charset\n\ ${tab}name supported by Java; the default is UTF-8).\n\ \n\ --out-charset-name :\n\ ${tab}charset that should be used for writing output (standard charset name\n\ ${tab}supported by Java, default is UTF-8)\n\ \n\ --output-ignored-statements:\n\ ${tab}outputs information about DDL statements that apgdiff ignores at this\n\ ${tab}moment (it will not output any SELECT, INSERT, UPDATE and/or DELETE\n\ ${tab}statements).\n\ \n\ --ignore-slony-triggers:\n\ ${tab}when parsing SQL statements, ignores Slony triggers named\n\ ${tab}_slony_logtrigger and _slony_denyaccess.\n\ \n\ --list-charsets\n\ ${tab}lists all supported charsets Version=Version OriginalDatabaseIgnoredStatements=Original database ignored statements NewDatabaseIgnoredStatements=New database ignored statements ErrorUnknownOption=ERROR: Unknown option WarningUnableToDetermineStorageType=WARNING: Column {0} in new table has no STORAGE set but in old table storage was set. Unable to determine STORAGE type. TypeParameterChange=TYPE change - table: {0} original: {1} new: {2} UnsupportedEncoding=Unsupported encoding CannotReadFile=Cannot read file FileNotFound=File ''{0}'' not found CannotFindColumnInTable=Cannot find column ''{0}'' in table ''{1}'' CannotParseStringExpectedWord=Cannot parse string: {0}\nExpected {1} at position {2} ''{3}'' CannotParseStringExpectedInteger=Cannot parse string: {0}\nExpected integer at position {1} ''{2}'' CannotParseStringExpectedString=Cannot parse string: {0}\nExpected string at position {1} CannotParseStringExpectedExpression=Cannot parse string: {0}\nExpected expression at position {1} ''{2}'' CannotParseStringUnsupportedCommand=Cannot parse string: {0}\nUnsupported command at position {1} ''{2}'' CannotParseStringExpectedDataType=Cannot parse string: {0}\nExpected data type definition at position {1} ''{2}'' CannotFindSchema=Cannot find schema ''{0}'' for statement ''{1}''. Missing CREATE SCHEMA statement? CannotFindView=Cannot find view ''{0}'' for statement ''{1}''. Missing CREATE VIEW statement? CannotFindObject=Cannot find object ''{0}'' for statement ''{1}''. CannotFindTableColumn=Cannot find column ''{0}'' in table ''{1}'' for statement ''{2}''. CannotFindTable=Cannot find table ''{0}'' for statement ''{1}''. Missing CREATE TABLE? CannotFindSequence=Cannot find sequence ''{0}'' for statement ''{1}''. Missing CREATE SEQUENCE? EndOfStatementNotFound=Cannot find ending semicolon of statement: {0} CreateTablePrimaryKeyNotSupported="CREATE TABLE ... PRIMARY KEY ..." is not supported. Use "CREATE TABLE ... CONSTRAINT name PRIMARY KEY ..." instead. CreateTableUniqueNotSupported="CREATE TABLE ... UNIQUE ..." is not supported. Use "CREATE TABLE ... CONSTRAINT name UNIQUE..." instead. apgdiff/src/main/resources/cz/startnet/utils/pgdiff/Resources_cs.properties000066400000000000000000000114311316501242600276370ustar00rootroot00000000000000UsageHelp=\ Pou\u017eit\u00ed: apgdiff [volby] \n\ \n\ Volby:\n\ \n\ --version:\n\ ${tab}zobraz\u00ed verzi programu\n\ \n\ --add-defaults:\n\ ${tab}p\u0159id\u00e1 DEFAULT ... v p\u0159\u00edpad\u011b, \u017ee nov\u00fd sloupec m\u00e1 definovan\u00e9 omezen\u00ed NOT\n\ ${tab}NULL, ale \u017e\u00e1dnou v\u00fdchoz\u00ed hodnotu (v\u00fdchoz\u00ed hodnota je v takov\u00e9m p\u0159\u00edpad\u011b\n\ ${tab}n\u00e1sledn\u011b odstran\u011bna)\n\ \n\ --add-transaction:\n\ ${tab}p\u0159id\u00e1 START TRANSACTION a COMMIT TRANSACTION do generovan\u00e9ho souboru\n\ \n\ --ignore-function-whitespace:\n\ ${tab}ignoruje v\u00edce mezer a nov\u00e9 \u0159\u00e1dky p\u0159i porovn\u00e1v\u00e1n\u00ed obsahu funkc\u00ed - VAROV\u00c1N\u00cd:\n\ ${tab}toto m\u016f\u017ee zp\u016fsobit, \u017ee funkce budou vyhodnoceny jako shodn\u00e9 i v p\u0159\u00edpadech,\n\ ${tab}ve kter\u00fdch se li\u0161\u00ed, proto pou\u017e\u00edvejte tuhle funkci jen pokud v\u00edte, co\n\ ${tab}d\u011bl\u00e1te\n\ \n\ --ignore-start-with:\n\ ${tab}ignoruje zm\u011bny START WITH v SEQUENCE objektech (v\u00fdchoz\u00ed chov\u00e1n\u00ed je, \u017ee se\n\ ${tab}tyto zm\u011bny neignoruj\u00ed)\n\ \n\ --in-charset-name :\n\ ${tab}k\u00f3dov\u00e1n\u00ed, kter\u00e9 se m\u00e1 pou\u017e\u00edt pro \u010dten\u00ed vstupn\u00edch soubor\u016f (standardn\u00ed n\u00e1zvy\n\ ${tab}k\u00f3dov\u00e1n\u00ed podporovan\u00e9 Javou, v\u00fdchoz\u00ed je UTF-8)\n\ \n\ --out-charset-name :\n\ ${tab}k\u00f3dov\u00e1n\u00ed, kter\u00e9 se m\u00e1 pou\u017e\u00edt pro z\u00e1pis v\u00fdstupn\u00edho souboru (standardn\u00ed\n\ ${tab}n\u00e1zvy k\u00f3dov\u00e1n\u00ed podporovan\u00e9 Javou, v\u00fdchoz\u00ed je UTF-8)\n\ \n\ --output-ignored-statements:\n\ ${tab}vyp\u00ed\u0161e informace o DDL p\u0159\u00edkazech, kter\u00e9 zat\u00edm apgdiff ignoruje (do v\u00fdstupu\n\ ${tab}nebudou zapsan\u00e9 p\u0159\u00edkazy SELECT, INSERT, UPDATE a/nebo DELETE)\n\ \n\ --ignore-slony-triggers:\n\ ${tab}b\u011bhem parsov\u00e1n\u00ed SQL p\u0159\u00edkaz\u016f ignoruje Slony triggery _slony_logtrigger a\n\ ${tab}_slony_denyaccess\n\ \n\ --list-charsets\n\ ${tab}vyp\u00ed\u0161e v\u0161echna podporovan\u00e1 k\u00f3dov\u00e1n\u00ed Version=Verze OriginalDatabaseIgnoredStatements=Ignorovan\u00e9 p\u0159\u00edkazy z p\u016fvodn\u00ed datab\u00e1ze NewDatabaseIgnoredStatements=Ignorovan\u00e9 p\u0159\u00edkazy z nov\u00e9 datab\u00e1ze ErrorUnknownOption=CHYBA: Nezn\u00e1m\u00e1 volba WarningUnableToDetermineStorageType=VAROV\u00c1N\u00cd: Sloupec {0} v nov\u00e9 tabulce nem\u00e1 nastaven parametr STORAGE, ale v p\u016fvodn\u00ed tabulce byl nastaven\u00fd. Nelze ur\u010dit typ STORAGE. TypeParameterChange=Zm\u011bna parametru TYPE - tabulka: {0} p\u016fvodn\u00ed: {1} nov\u00fd: {2} UnsupportedEncoding=Nepodporovan\u00e9 k\u00f3dov\u00e1n\u00ed CannotReadFile=Nelze \u010d\u00edst soubor FileNotFound=Soubor ''{0}'' nebyl nalezen CannotFindColumnInTable=Nelze nal\u00e9zt sloupec ''{0}'' v tabulce ''{1}'' CannotParseStringExpectedWord=Nelze parsovat text: {0}\nO\u010dek\u00e1v\u00e1no {1} na pozici {2} ''{3}'' CannotParseStringExpectedInteger=Nelze parsovat text: {0}\nO\u010dek\u00e1v\u00e1n integer na pozici {1} ''{2}'' CannotParseStringExpectedString=Nelze parsovat text: {0}\nO\u010dek\u00e1v\u00e1n \u0159et\u011bzec na pozici {1} CannotParseStringExpectedExpression=Nelze parsovat text: {0}\nO\u010dek\u00e1v\u00e1n v\u00fdraz na pozici {1} ''{2}'' CannotParseStringUnsupportedCommand=Nelze parsovat text: {0}\nNepodporovan\u00fd p\u0159\u00edkaz na pozici {1} ''{2}'' CannotParseStringExpectedDataType=Nelze parsovat text: {0}\nO\u010dek\u00e1v\u00e1na definice datov\u00e9ho typu na pozici {1} ''{2}'' CannotFindSchema=Nelze nal\u00e9zt sch\u00e9ma ''{0}'' pro p\u0159\u00edkaz ''{1}''. Chyb\u00ed p\u0159\u00edkaz CREATE SCHEMA? CannotFindView=Nelze nal\u00e9zt pohled ''{0}'' pro p\u0159\u00edkaz ''{1}''. Chyb\u00ed p\u0159\u00edkaz CREATE VIEW? CannotFindObject=Nelze nal\u00e9zt objekt ''{0}'' pro p\u0159\u00edkaz ''{1}''. CannotFindTableColumn=Nelze nal\u00e9zt sloupec ''{0}'' v tabulce ''{1}'' pro p\u0159\u00edkaz ''{2}''. CannotFindTable=Nelze nal\u00e9zt tabulku ''{0}'' pro p\u0159\u00edkaz ''{1}''. Chyb\u00ed p\u0159\u00edkaz CREATE TABLE? CannotFindSequence=Nelze nal\u00e9zt sekvenci ''{0}'' pro p\u0159\u00edkaz ''{1}''. Chyb\u00ed p\u0159\u00edkaz CREATE SEQUENCE? EndOfStatementNotFound=Nelze nal\u00e9z ukon\u010duj\u00edc\u00ed st\u0159edn\u00edk: {0} CreateTablePrimaryKeyNotSupported="CREATE TABLE ... PRIMARY KEY ..." nen\u00ed podporov\u00e1no. Pou\u017eijte m\u00edsto toho "CREATE TABLE ... CONSTRAINT n\u00e1zev PRIMARY KEY ...". CreateTableUniqueNotSupported="CREATE TABLE ... UNIQUE ..." nen\u00ed podporov\u00e1no. Pou\u017eijte m\u00edsto toho "CREATE TABLE ... CONSTRAINT n\u00e1zev UNIQUE ...". apgdiff/src/main/resources/cz/startnet/utils/pgdiff/Resources_es.properties000066400000000000000000000101031316501242600276340ustar00rootroot00000000000000UsageHelp=\ Uso: apgdiff [opciones] \n\ \n\ Opciones:\n\ \n\ --version:\n\ ${tab}muestra la versi\u00f3n de apgdiff\n\ \n\ --add-defaults:\n\ ${tab}agrega DEFAULT ... en caso de que la nueva columna tenga la restricci\u00f3n\n\ ${tab}NOT NULL, pero no tiene opci\u00f3n de valor por defecto (el valor\n\ ${tab}por defecto eliminado despu\u00e9s de la conversi\u00f3n.)\n\ \n\ --add-transaction:\n\ ${tab}agrega START TRANSACTION y COMMIT TRANSACTION al archivo diff generado\n\ \n\ --ignore-function-whitespace:\n\ ${tab}ignora multiples espacios y nuevas l\u00edneas cuando est\u00e1 comparando\n\ ${tab}el contenido de funciones - ADVERTENCIA: esto puede causar\n\ ${tab}que funciones parezcan ser las mismas en casos que no lo son,\n\ ${tab}s\u00f3lo usa \u00e9sta caracter\u00edstica si sabes lo que estas haciendo\n\ \n\ --ignore-start-with:\n\ ${tab}ignora START WITH modificaciones de SEQUENCEs (por defecto no ignora\n\ ${tab}estos cambios)\n\ \n\ --in-charset-name :\n\ ${tab}charset que deber\u00eda ser usado para leer los archivos de entrada\n\ ${tab}(charset est\u00e1ndar soportado por Java, charset por defecto es UTF-8)\n\ \n\ --out-charset-name :\n\ ${tab}charset que deber\u00eda ser usado para escribir los archivos de salida\n\ ${tab}(charset est\u00e1ndar soportado por Java, charset por defecto UTF-8)\n\ \n\ --output-ignored-statements:\n\ ${tab}muestra informaci\u00f3n acerca de declaraciones DDL que apgdiff ignora\n\ ${tab}en estos momentos (no mostrar\u00e1 informaci\u00f3n de ning\u00fana declaraci\u00f3n\n\ ${tab}SELECT, INSERT, UPDATE y/o DELETE)\n\ \n\ --ignore-slony-triggers:\n\ ${tab}cuando se analizan las declaraciones SQL, ignora los disparadores Slony\n\ ${tab}llamados _slony_logtrigger y _slony_denyaccess\n\ \n\ --list-charsets\n\ ${tab}lista todos los charsets soportados Version=Versi\u00f3n OriginalDatabaseIgnoredStatements=Declaraciones de base de datos original ignoradas NewDatabaseIgnoredStatements=Declaraciones de base de datos nueva ignoradas ErrorUnknownOption=ERROR: opci\u00f3n desconocida WarningUnableToDetermineStorageType=ADVERTENCIA: Columna {0} en la tabla nueva no tiene STORAGE pero en la tabla vieja est\u00e1 declarado. No es posible determinar el tipo de STORAGE. TypeParameterChange=TIPO cambio - tabla: {0} original: {1} nueva: {2} UnsupportedEncoding=Encoding no soportado CannotReadFile=No se puede leer el archivo FileNotFound=Archivo ''{0}'' no encontrado CannotFindColumnInTable=No se puede encontrar la columna ''{0}'' en la tabla ''{1}'' CannotParseStringExpectedWord=No se puede an\u00e1lizar la cadena: {0}\nEsperando {1} en la posici\u00f3n {2} ''{3}'' CannotParseStringExpectedInteger=No se puede an\u00e1lizar la cadena: {0}\nEsperando entero en la posici\u00f3n {1} ''{2}'' CannotParseStringExpectedString=No se puede an\u00e1lizar la cadena: {0}\nEsperando cadena en la posici\u00f3n {1} CannotParseStringExpectedExpression=No se puede an\u00e1lizar la cadena: {0}\nEsperando cadena en la posici\u00f3n {1} ''{2}'' CannotParseStringUnsupportedCommand=No se puede an\u00e1lizar la cadena: {0}\nComando no soportado en la posici\u00f3n {1} ''{2}'' CannotParseStringExpectedDataType=No se puede an\u00e1lizar la cadena: {0}\nEsperando definici\u00f3n del tipo de dato en la posici\u00f3n {1} ''{2}'' CannotFindSchema=No se puede encontrar el esquema ''{0}'' para la declaraci\u00f3n ''{1}''. Falta la declaraci\u00f3n CREATE SCHEMA? CannotFindView=No se puede encontrar la vista ''{0}'' para la declaraci\u00f3n ''{1}''. Falta la declaraci\u00f3n CREATE VIEW? CannotFindObject=No se puede encontrar el objeto ''{0}'' para la declaraci\u00f3n ''{1}''. CannotFindTableColumn=No se puede encontrar la columna ''{0}'' en la tabla ''{1}'' para la declaraci\u00f3n ''{2}''. CannotFindTable=No se puede encontrar la tabla ''{0}'' para la declaraci\u00f3n ''{1}''. Falta la declaraci\u00f3n CREATE TABLE? CannotFindSequence=No se puede encontrar la secuencia ''{0}'' para la declaraci\u00f3n ''{1}''. Falta la declaraci\u00f3n CREATE SEQUENCE? EndOfStatementNotFound=No se puede encontrar punto y coma final para la declaraci\u00f3n: {0} apgdiff/src/main/resources/cz/startnet/utils/pgdiff/Resources_fr.properties000066400000000000000000000077051316501242600276520ustar00rootroot00000000000000VersionNumber=2.4 UsageHelp=\ Usage: apgdiff [options] \n\ \n\ Options:\n\ \n\ --version:\n\ ${tab}affiche la version d''apgdiff version\n\ \n\ --add-defaults:\n\ ${tab}ajoute DEFAULT ... dans le cas ou une colonne a une contrainte NOT NULL mais pas de valeur\n\ ${tab}par défaut (la valeur par défaut est supprimée ensuite)\n\ \n\ --add-transaction:\n\ ${tab}ajoute START TRANSACTION et COMMIT TRANSACTION au fichier de diff généré\n\ \n\ --ignore-function-whitespace:\n\ ${tab}ignore les espaces consécutifs et les retours chariots quand il compare le contenu de fonctions\n\ ${tab}- WARNING: cela pourrait faire croire que deux fonctions sont identiques alors que\n\ ${tab}ce n''est pas le cas, utilisez cette option seulement si vous savez ce que vous faites\n\ \n\ --ignore-start-with:\n\ ${tab}ignorer les modifications START WITH sur les SEQUENCEs (par defaut cela n''est pas\n\ ${tab}ignoré)\n\ \n\ --in-charset-name :\n\ ${tab}charset a utiliser pour lire les fichiers d''entrée (utilisez les noms de charsets\n\ ${tab}supporté par Java, par defaut c''est UTF-8)\n\ \n\ --out-charset-name :\n\ ${tab}charset a utiliser pour écrire les fichiers de sortie (utilisez les noms de charsets\n\ ${tab}supporté par Java, par defaut c''est UTF-8)\n\ \n\ --output-ignored-statements:\n\ ${tab}afficher les informations sur les instructions DDL qu''apgdiff ignore\n\ ${tab}pour le moment (n''affichera aucune instruction SELECT, INSERT, UPDATE et/ou \n\ ${tab}DELETE)\n\ \n\ --ignore-slony-triggers:\n\ ${tab}ignorer les triggers Slony nommés _slony_logtrigger et _slony_denyaccess lors du parsing\n\ ${tab}des instructions\n\ \n\ --list-charsets\n\ ${tab}liste les charsets supportés Version=Version OriginalDatabaseIgnoredStatements=Instruction a ignorer sur la base d''origine NewDatabaseIgnoredStatements=Instruction a ignorer sur la nouvelle base ErrorUnknownOption=ERREUR: option inconnue WarningUnableToDetermineStorageType=WARNING: la colonne {0} de la nouvelle table n''a pas de STORAGE indiqué mais c''était le cas dans la table d'origine. Impossible de determiner le type de STORAGE TypeParameterChange=Changement de TYPE - table: {0} original: {1} nouveau: {2} UnsupportedEncoding=Encoding non supporté CannotReadFile=Impossible de lire le fichier FileNotFound=Fichier ''{0}'' non trouvé CannotFindColumnInTable=Impossible de trouver la colonne ''{0}'' de la table ''{1}'' CannotParseStringExpectedWord=Impossible de parser la chaine de caractère: {0}\nAttendait {1} a la position {2} ''{3}'' CannotParseStringExpectedInteger=Impossible de parser la chaine de caractère: {0}\nAttendait un entier a la position {1} ''{2}'' CannotParseStringExpectedString=Impossible de parser la chaine de caractère: {0}\nAttendait une chaine a la position {1} CannotParseStringExpectedExpression=Impossible de parser la chaine de caractère: {0}\nAttendait une expression a la position {1} ''{2}'' CannotParseStringUnsupportedCommand=Impossible de parser la chaine de caractère: {0}\nCommande non supportée a la position {1} ''{2}'' CannotParseStringExpectedDataType=Impossible de parser la chaine de caractère: {0}\nAttendait une définition de type a la position {1} ''{2}'' CannotFindSchema=Impossible de trouver le schema ''{0}'' pour l'instruction ''{1}''. Ne manque-t-il pas l''instruction CREATE SCHEMA ? CannotFindView=Impossible de trouver la view ''{0}'' pour l'instruction ''{1}''. Ne manque-t-il pas l''instruction CREATE VIEW? CannotFindObject=Impossible de trouver l''objet ''{0}'' pour l'instruction ''{1}''. CannotFindTableColumn=Impossible de trouver la colonne ''{0}'' de la table ''{1}'' pour l''instruction ''{2}''. CannotFindTable=Impossible de trouver la table ''{0}'' pour l'instruction ''{1}''. Ne manque-t-il pas l''instruction CREATE TABLE? CannotFindSequence=Impossible de trouver la sequence ''{0}'' pour l'instruction ''{1}''. Ne manque-t-il pas l''instruction CREATE SEQUENCE? EndOfStatementNotFound=Impossible de trouver le point-virgule: {0} apgdiff/src/test/000077500000000000000000000000001316501242600142245ustar00rootroot00000000000000apgdiff/src/test/java/000077500000000000000000000000001316501242600151455ustar00rootroot00000000000000apgdiff/src/test/java/cz/000077500000000000000000000000001316501242600155615ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/000077500000000000000000000000001316501242600174255ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/utils/000077500000000000000000000000001316501242600205655ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/utils/pgdiff/000077500000000000000000000000001316501242600220245ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java000066400000000000000000000515771316501242600247050ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collection; import java.util.Locale; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /** * Tests for PgDiff class. * * @author fordfrog */ @RunWith(value = Parameterized.class) public class PgDiffTest { /** * Provides parameters for running the tests. * * @return parameters for the tests */ @Parameters public static Collection parameters() { return Arrays.asList( new Object[][]{ // Tests scenario where COLUMN type is modified. {"modify_column_type", false, false, false, false}, // Tests scenario where CLUSTER is added to TABLE. {"add_cluster", false, false, false, false}, // Tests scenario where CLUSTER is dropped from TABLE. {"drop_cluster", false, false, false, false}, // Tests scenario where CLUSTER is changed on TABLE. {"modify_cluster", false, false, false, false}, // Tests scenario where EXTENSION is added to TABLE. {"add_extension", false, false, false, false}, // Tests scenario where EXTENSION is dropped from TABLE. {"drop_extension", false, false, false, false}, // Tests scenario where WITH OIDS is dropped from TABLE. {"drop_with_oids", false, false, false, false}, // Tests scenario where INDEX is added. {"add_index", false, false, false, false}, // Tests scenario where INDEX is dropped. {"drop_index", false, false, false, false}, // Tests scenario where INDEX that TABLE CLUSTER is based // on is dropped. {"drop_index_with_cluster", false, false, false, false}, // Tests scenario where INDEX definition is modified. {"modify_index", false, false, false, false}, // Tests scenario where STATISTICS information is added // to COLUMN. {"add_statistics", false, false, false, false}, // Tests scenario where STATISTICS information is modified. {"modify_statistics", false, false, false, false}, // Tests scenario where STATISTICS information is dropped. {"drop_statistics", false, false, false, false}, // Tests scenario where DEFAULT value is set on COLUMN. {"add_default_value", false, false, false, false}, // Tests scenario where DEFAULT value is modified. {"modify_default_value", false, false, false, false}, // Tests scenario where DEFAULT value is dropped from COLUMN. {"drop_default_value", false, false, false, false}, // Tests scenario where NOT NULL constraint is set on COLUMN. {"add_not_null", false, false, false, false}, // Tests scenario where NOT NULL constraint is dropped // from COLUMN.MATERIALIZED {"drop_not_null", false, false, false, false}, // Tests scenario where COLUMN is added to TABLE definition. {"add_column", false, false, false, false}, // Tests scenario where COLUMN is dropped from TABLE. {"drop_column", false, false, false, false}, // Tests scenario where new TABLE is added. {"add_table", false, false, false, false}, // Tests scenario where TABLE is dropped. {"drop_table", false, false, false, false}, // Tests scenario where TABLE CONSTRAINT is added. {"add_constraint", false, false, false, false}, // Tests scenario where TABLE CONSTRAINT is modified. {"modify_constraint", false, false, false, false}, // Tests scenario where TABLE CONSTRAINT is dropped. {"drop_constraint", false, false, false, false}, // Tests scenario where UNIQUE TABLE CONSTRAINT is added. {"add_unique_constraint", false, false, false, true}, // Tests reading of TABLE with INHERITS. {"read_inherits", false, false, false, false}, // Tests scenario where TABLE with INHERITS is added. {"add_inherits", false, false, false, false}, // Tests scenario where original and new TABLE contain //different INHERITS. {"modify_inherits", false, false, false, false}, // Add a table with a default value for a column that belongs to an inherited table {"add_inherits_default_column", false, false, false, false}, // Add a table with a default value for a column that belongs to an inherited table in a different schema {"add_inherits_schema_default_column", false, false, false, false}, // Tests when a default value is changed for a column that belongs to an inherited table {"modify_default_value_inherited_column", false, false, false, false}, // Tests scenario where SEQUENCE is added. {"add_sequence", false, false, false, false}, // Tests scenario where SEQUENCE is dropped. {"drop_sequence", false, false, false, false}, // Tests scenario where INCREMENT BY is modified on SEQUENCE. {"modify_sequence_increment", false, false, false, false}, // Tests scenario where START WITH is modified on SEQUENCE // (both with --ignore-start-with turned off and on). {"modify_sequence_start_ignore_off", false, false, false, false }, {"modify_sequence_start_ignore_on", false, false, false, true }, // Tests scenario where MINVALUE is modified on SEQUENCE // (both setting and unsetting the value). {"modify_sequence_minvalue_set", false, false, false, false}, {"modify_sequence_minvalue_unset", false, false, false, false }, // Tests scenario where MAXVALUE is modified on SEQUENCE // (both setting and unsetting the value). {"modify_sequence_maxvalue_set", false, false, false, false}, {"modify_sequence_maxvalue_unset", false, false, false, false }, // Tests scenario where CACHE is modified on SEQUENCE. {"modify_sequence_cache", false, false, false, false}, // Tests scenario where CYCLE is modified on SEQUENCE. {"modify_sequence_cycle_on", false, false, false, false}, {"modify_sequence_cycle_off", false, false, false, false}, // Tests correct finding of function end. {"modify_function_end_detection", false, false, false, false}, // Tests scenario where new FUNCTION without args is added. {"add_function_noargs", false, false, false, false}, // Tests scenario where FUNCTION without args is dropped. {"drop_function_noargs", false, false, false, false}, // Tests scenario where FUNCTION without args is modified. {"modify_function_noargs", false, false, false, false}, // Tests scenario where new FUNCTION with args is added. {"add_function_args", false, false, false, false}, // Tests scenario where FUNCTION with args is dropped. {"drop_function_args", false, false, false, false}, // Tests scenario where FUNCTION with args is modified. {"modify_function_args", false, false, false, false}, // Tests scenario where new FUNCTION with args is added. {"add_function_args2", false, false, false, false}, // Tests scenario where FUNCTION with args is dropped. {"drop_function_args2", false, false, false, false}, // Tests scenario where FUNCTION with args is modified. {"modify_function_args2", false, false, false, false}, // Tests scenario where FUNCTION with same name but // different args is added. {"add_function_similar", false, false, false, false}, // Tests scenario where FUNCTION with same name but // different args is dropped. {"drop_function_similar", false, false, false, false}, // Tests scenario where FUNCTION with same name but // different args is modified. {"modify_function_similar", false, false, false, false}, // Tests different whitespace formatting in functions {"function_equal_whitespace", false, false, true, false}, // Tests scenario where TRIGGER is added. {"add_trigger", false, false, false, false}, // Tests scenario where TRIGGER is dropped. {"drop_trigger", false, false, false, false}, // Tests scenario where TRIGGER is modified. {"modify_trigger", false, false, false, false}, // Tests scenario where VIEW is added. {"add_view", false, false, false, false}, // Tests scenario where VIEW is dropped. {"drop_view", false, false, false, false}, // Tests scenario where VIEW is modified. {"modify_view", false, false, false, false}, // Tests scenario where MATERIALIZED VIEW is added. {"add_materialized_view", false, false, false, false}, // Tests scenario where MATERIALIZED VIEW is dropped. {"drop_materialized_view", false, false, false, false}, // Tests scenario where MATERIALIZED VIEW is modified. {"modify_materialized_view", false, false, false, false}, // Tests scenario where --add-defaults is specified. {"add_defaults", true, false, false, false}, // Tests scenario where multiple schemas are in the dumps. {"multiple_schemas", false, false, false, false}, // Tests scenario where --add-transaction is specified. {"multiple_schemas", false, true, false, false}, // Tests dropping view default value {"alter_view_drop_default", false, true, false, false}, // Tests adding view default value {"alter_view_add_default", false, true, false, false}, // Tests adding of comments {"add_comments", false, true, false, false}, // Tests dropping of comments {"drop_comments", false, true, false, false}, // Tests altering of comments {"alter_comments", false, true, false, false}, // Tests changing view default value {"alter_view_change_default", false, true, false, false}, // Tests creation of sequence with bug in MINVALUE value {"add_sequence_bug2100013", false, true, false, false}, // Tests view with default value {"view_bug3080388", false, true, false, false}, // Tests function arguments beginning with in_ {"function_bug3084274", false, true, false, false}, // Tests addition of comment when new column has been added {"add_comment_new_column", false, true, false, false}, // Tests handling of quoted schemas in search_path {"quoted_schema", false, true, false, false}, // Tests adding new column with add defaults turned on {"add_column_add_defaults", true, true, false, false}, // Tests adding new sequence that is owned by table {"add_owned_sequence", false, true, false, false}, // Tests adding empty table {"add_empty_table", false, false, false, false}, // Tests view with column names whose query changes {"view_colnames", false, false, false, false}, // Tests objects with the $ sign in the name {"add_table_bug102", false, false, false, false}, // Tests scenario where new UNLOGGED TABLE is added. {"add_unlogged_table", false, false, false, false}, // Tests scenario where UNLOGGED TABLE is dropped. {"drop_unlogged_table", false, false, false, false}, // Test scenarios where /**/ comments. {"add_table_issue115", false, false, false, false}, {"add_column_issue134", false, false, false, false}, {"add_column_issue188", false, false, false, false}, {"add_column_issue188", false, false, false, false}, {"view_alias_with_quote", false, false, false, false}, // Tests view triggers (support for 'INSTEAD OF') //90 {"view_triggers", false, false, false, false}, // Tests privileges {"grant_on_table_sequence", false, false, false, false}, {"revoke_on_table_sequence", false, false, false, false}, {"grant_on_view", false, false, false, false}, {"revoke_on_view", false, false, false, false}, {"grant_on_columns", false, false, false, false} // Tests types , {"add_type", false, false, false, false} , {"drop_type", false, false, false, false} , {"alter_type", false, false, false, false} // Test Foreign Tables , {"foreign_create_table", false, false, false, false} , {"foreign_drop_table", false, false, false, false} //100 , {"foreign_alter_type", false, false, false, false} // Tests enable/force rls , {"enable_force_rls", false, false, false, false} , {"disable_no_force_rls", false, false, false, false} // Tests policies , {"create_policies", false, false, false, false} , {"drop_policies", false, false, false, false} , {"alter_policies", false, false, false, false} }); } /** * Template name for file names that should be used for the test. Testing * method adds _original.sql, _new.sql and _diff.sql to the file name * template. */ private final String fileNameTemplate; /** * Value for the same named command line argument. */ private final boolean addDefaults; /** * Value for the same named command line argument. */ private final boolean addTransaction; /** * Value for the same named command line argument. */ private final boolean ignoreFunctionWhitespace; /** * Value for the same named command line argument. */ private final boolean ignoreStartWith; /** * Creates a new PgDiffTest object. * * @param fileNameTemplate {@link #fileNameTemplate} * @param addDefaults {@link #addDefaults} * @param addTransaction {@link #addTransaction} * @param ignoreFunctionWhitespace {@link #ignoreFunctionWhitespace} * @param ignoreStartWith {@link #ignoreStartWith} */ public PgDiffTest(final String fileNameTemplate, final boolean addDefaults, final boolean addTransaction, final boolean ignoreFunctionWhitespace, final boolean ignoreStartWith) { super(); this.fileNameTemplate = fileNameTemplate; this.addDefaults = addDefaults; this.addTransaction = addTransaction; this.ignoreFunctionWhitespace = ignoreFunctionWhitespace; this.ignoreStartWith = ignoreStartWith; Locale.setDefault(Locale.ENGLISH); } /** * Runs single test on original schema. * * @throws FileNotFoundException Thrown if expected diff file was not found. * @throws IOException Thrown if problem occurred while reading * expected diff. */ @Test(timeout = 1000) public void runDiffSameOriginal() throws FileNotFoundException, IOException { final ByteArrayOutputStream diffInput = new ByteArrayOutputStream(); final PrintWriter writer = new PrintWriter(diffInput, true); final PgDiffArguments arguments = new PgDiffArguments(); PgDiff.createDiff(writer, arguments, PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_original.sql"), PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_original.sql")); writer.flush(); Assert.assertEquals("File name template: " + fileNameTemplate, "", diffInput.toString().trim()); } /** * Runs single test on new schema. * * @throws FileNotFoundException Thrown if expected diff file was not found. * @throws IOException Thrown if problem occurred while reading * expected diff. */ @Test(timeout = 1000) public void runDiffSameNew() throws FileNotFoundException, IOException { final ByteArrayOutputStream diffInput = new ByteArrayOutputStream(); final PrintWriter writer = new PrintWriter(diffInput, true); final PgDiffArguments arguments = new PgDiffArguments(); PgDiff.createDiff(writer, arguments, PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_new.sql"), PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_new.sql")); writer.flush(); Assert.assertEquals("File name template: " + fileNameTemplate, "", diffInput.toString().trim()); } /** * Runs single test using class member variables. * * @throws FileNotFoundException Thrown if expected diff file was not found. * @throws IOException Thrown if problem occurred while reading * expected diff. */ @Test(timeout = 1000) public void runDiff() throws FileNotFoundException, IOException { final ByteArrayOutputStream diffInput = new ByteArrayOutputStream(); final PrintWriter writer = new PrintWriter(diffInput, true); final PgDiffArguments arguments = new PgDiffArguments(); arguments.setAddDefaults(addDefaults); arguments.setIgnoreFunctionWhitespace(ignoreFunctionWhitespace); arguments.setIgnoreStartWith(ignoreStartWith); PgDiffUtils.setUseExists(true); PgDiff.createDiff(writer, arguments, PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_original.sql"), PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_new.sql")); writer.flush(); final BufferedReader reader = new BufferedReader(new InputStreamReader( PgDiffTest.class.getResourceAsStream( fileNameTemplate + "_diff.sql"))); final char[] part = new char[1024]; final StringBuilder sbExpDiff = new StringBuilder(1024); while (reader.read(part) != -1) { sbExpDiff.append(part); } reader.close(); Assert.assertEquals("File name template: " + fileNameTemplate, sbExpDiff.toString().trim(), diffInput.toString().trim()); } } apgdiff/src/test/java/cz/startnet/utils/pgdiff/loader/000077500000000000000000000000001316501242600232725ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/utils/pgdiff/loader/PgDumpLoaderTest.java000066400000000000000000000032561316501242600273260ustar00rootroot00000000000000/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.loader; import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /** * Tests for PgDiffLoader class. * * @author fordfrog */ @RunWith(value = Parameterized.class) public class PgDumpLoaderTest { /** * Provides parameters for running the tests. * * @return parameters for the tests */ @Parameters public static Collection parameters() { return Arrays.asList( new Object[][]{ {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16} }); } /** * Index of the file that should be tested. */ private final int fileIndex; /** * Creates a new instance of PgDumpLoaderTest. * * @param fileIndex {@link #fileIndex} */ public PgDumpLoaderTest(final int fileIndex) { this.fileIndex = fileIndex; } /** * Runs single test. */ @Test(timeout = 1000) public void loadSchema() { PgDumpLoader.loadDatabaseSchema( getClass().getResourceAsStream("schema_" + fileIndex + ".sql"), "UTF-8", false, false, false); } } apgdiff/src/test/java/cz/startnet/utils/pgdiff/parsers/000077500000000000000000000000001316501242600235035ustar00rootroot00000000000000apgdiff/src/test/java/cz/startnet/utils/pgdiff/parsers/ParserUtilsTest.java000066400000000000000000000071461316501242600274730ustar00rootroot00000000000000/** * Copyright 2010 StartNet s.r.o. */ package cz.startnet.utils.pgdiff.parsers; import cz.startnet.utils.pgdiff.schema.PgDatabase; import cz.startnet.utils.pgdiff.schema.PgSchema; import org.hamcrest.core.IsEqual; import org.junit.Assert; import org.junit.Test; /** * Tests {@link #ParserUtils}. * * @author fordfrog */ public class ParserUtilsTest { @Test(timeout = 1000) public void testParseSchemaBothQuoted() { final PgDatabase database = new PgDatabase(); final PgSchema schema = new PgSchema("juzz_system"); database.addSchema(schema); Assert.assertThat(ParserUtils.getSchemaName( "\"juzz_system\".\"f_obj_execute_node_select\"", database), IsEqual.equalTo("juzz_system")); } @Test(timeout = 1000) public void testParseSchemaFirstQuoted() { final PgDatabase database = new PgDatabase(); final PgSchema schema = new PgSchema("juzz_system"); database.addSchema(schema); Assert.assertThat(ParserUtils.getSchemaName( "\"juzz_system\".f_obj_execute_node_select", database), IsEqual.equalTo("juzz_system")); } @Test(timeout = 1000) public void testParseSchemaSecondQuoted() { final PgDatabase database = new PgDatabase(); final PgSchema schema = new PgSchema("juzz_system"); database.addSchema(schema); Assert.assertThat(ParserUtils.getSchemaName( "juzz_system.\"f_obj_execute_node_select\"", database), IsEqual.equalTo("juzz_system")); } @Test(timeout = 1000) public void testParseSchemaNoneQuoted() { final PgDatabase database = new PgDatabase(); final PgSchema schema = new PgSchema("juzz_system"); database.addSchema(schema); Assert.assertThat(ParserUtils.getSchemaName( "juzz_system.f_obj_execute_node_select", database), IsEqual.equalTo("juzz_system")); } @Test(timeout = 1000) public void testParseSchemaThreeQuoted() { final PgDatabase database = new PgDatabase(); final PgSchema schema = new PgSchema("juzz_system"); database.addSchema(schema); Assert.assertThat(ParserUtils.getSchemaName( "\"juzz_system\".\"f_obj_execute_node_select\".\"test\"", database), IsEqual.equalTo("juzz_system")); } @Test(timeout = 1000) public void testParseObjectBothQuoted() { Assert.assertThat(ParserUtils.getObjectName( "\"juzz_system\".\"f_obj_execute_node_select\""), IsEqual.equalTo("f_obj_execute_node_select")); } @Test(timeout = 1000) public void testParseObjectFirstQuoted() { Assert.assertThat(ParserUtils.getObjectName( "\"juzz_system\".f_obj_execute_node_select"), IsEqual.equalTo("f_obj_execute_node_select")); } @Test(timeout = 1000) public void testParseObjectSecondQuoted() { Assert.assertThat(ParserUtils.getObjectName( "juzz_system.\"f_obj_execute_node_select\""), IsEqual.equalTo("f_obj_execute_node_select")); } @Test(timeout = 1000) public void testParseObjectNoneQuoted() { Assert.assertThat(ParserUtils.getObjectName( "juzz_system.f_obj_execute_node_select"), IsEqual.equalTo("f_obj_execute_node_select")); } @Test(timeout = 1000) public void testParseObjectThreeQuoted() { Assert.assertThat(ParserUtils.getObjectName( "\"juzz_system\".\"f_obj_execute_node_select\".\"test\""), IsEqual.equalTo("test")); } } apgdiff/src/test/resources/000077500000000000000000000000001316501242600162365ustar00rootroot00000000000000apgdiff/src/test/resources/cz/000077500000000000000000000000001316501242600166525ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/000077500000000000000000000000001316501242600205165ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/000077500000000000000000000000001316501242600216565ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/000077500000000000000000000000001316501242600231155ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_diff.sql000066400000000000000000000011311316501242600271130ustar00rootroot00000000000000 CREATE SEQUENCE IF NOT EXISTS testtable2_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE IF NOT EXISTS testtable2 ( id integer DEFAULT nextval('testtable2_id_seq'::regclass) NOT NULL, col1 boolean NOT NULL ); ALTER TABLE testtable2 OWNER TO fordfrog; ALTER SEQUENCE testtable2_id_seq OWNED BY testtable2.id; CREATE INDEX IF NOT EXISTS testindex ON testtable USING btree (field1); CREATE INDEX IF NOT EXISTS testtable2_col1 ON testtable2 USING btree (col1); ALTER TABLE testtable CLUSTER ON testindex; ALTER TABLE testtable2 CLUSTER ON testtable2_col1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_new.sql000066400000000000000000000047301316501242600270040ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testtable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer NOT NULL, col1 boolean NOT NULL ); ALTER TABLE public.testtable2 OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable2_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable2_id_seq OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable2_id_seq OWNED BY testtable2.id; -- -- Name: testtable2_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable2_id_seq', 1, false); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable2 ALTER COLUMN id SET DEFAULT nextval('testtable2_id_seq'::regclass); -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Data for Name: testtable2; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); ALTER TABLE testtable CLUSTER ON testindex; -- -- Name: testtable2_col1; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testtable2_col1 ON testtable2 USING btree (col1); ALTER TABLE testtable2 CLUSTER ON testtable2_col1; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_original.sql000066400000000000000000000016521316501242600300170ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_diff.sql000066400000000000000000000002771316501242600314400ustar00rootroot00000000000000 ALTER TABLE table1 ADD COLUMN IF NOT EXISTS col2 integer DEFAULT 0 NOT NULL, ADD COLUMN IF NOT EXISTS col3 integer DEFAULT 5 NOT NULL; ALTER TABLE table1 ALTER COLUMN col2 DROP DEFAULT; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_new.sql000066400000000000000000000022611316501242600313140ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: table1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE table1 ( col1 integer, col2 integer NOT NULL, col3 integer DEFAULT 5 NOT NULL ); ALTER TABLE public.table1 OWNER TO fordfrog; -- -- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- COPY table1 (col1, col2, col3) FROM stdin; \. -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_original.sql000066400000000000000000000021451316501242600323300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: table1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE table1 ( col1 integer ); ALTER TABLE public.table1 OWNER TO fordfrog; -- -- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- COPY table1 (col1) FROM stdin; \. -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_diff.sql000066400000000000000000000001301316501242600267250ustar00rootroot00000000000000 ALTER TABLE testtable ADD COLUMN IF NOT EXISTS field5 boolean DEFAULT false NOT NULL; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue134_diff.sql000066400000000000000000000000721316501242600303720ustar00rootroot00000000000000ALTER TABLE test1 ADD COLUMN IF NOT EXISTS type SMALLINT;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue134_new.sql000066400000000000000000000001401316501242600302470ustar00rootroot00000000000000CREATE table "test1" ( "id" BIGINT, "type" SMALLINT /* 1: aaa, 2:bbb */, "value" VARCHAR(255) );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue134_original.sql000066400000000000000000000000731316501242600312670ustar00rootroot00000000000000CREATE table "test1" ( "id" BIGINT, "value" VARCHAR(255) );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue188_diff.sql000066400000000000000000000002671316501242600304110ustar00rootroot00000000000000ALTER TABLE test1 ADD COLUMN IF NOT EXISTS test2 TEXT DEFAULT '*/', ADD COLUMN IF NOT EXISTS test TEXT DEFAULT 'this /*is*/ test', ADD COLUMN IF NOT EXISTS test3 TEXT DEFAULT '*/';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue188_new.sql000066400000000000000000000002771316501242600302730ustar00rootroot00000000000000/* Test table */ CREATE table "test1" ( "id" BIGINT, "value" VARCHAR(255), test2 TEXT DEFAULT '*/', test TEXT DEFAULT 'this /*is*/ test' /* in /*line*/ comment */, test3 TEXT DEFAULT '*/' );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_issue188_original.sql000066400000000000000000000000731316501242600313000ustar00rootroot00000000000000CREATE table "test1" ( "id" BIGINT, "value" VARCHAR(255) );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_new.sql000066400000000000000000000021471316501242600266200ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, field5 boolean DEFAULT false NOT NULL ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_column_original.sql000066400000000000000000000020741316501242600276320ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_diff.sql000066400000000000000000000002041316501242600313220ustar00rootroot00000000000000ALTER TABLE agent ADD COLUMN IF NOT EXISTS abc BIGINT; COMMENT ON COLUMN agent.abc IS 'This agent supports credit system or not.';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_new.sql000066400000000000000000000002111316501242600312010ustar00rootroot00000000000000CREATE TABLE public."agent"( id BIGINT, abc BIGINT ); COMMENT ON COLUMN "agent"."abc" IS 'This agent supports credit system or not.';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_original.sql000066400000000000000000000000421316501242600322160ustar00rootroot00000000000000CREATE TABLE agent( id BIGINT );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comments_diff.sql000066400000000000000000000011661316501242600272670ustar00rootroot00000000000000COMMENT ON DATABASE current_database() IS 'comments database'; COMMENT ON SCHEMA "public" IS 'public schema'; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence'; COMMENT ON TABLE test IS 'test table'; COMMENT ON COLUMN test.id IS 'id column'; COMMENT ON COLUMN test.text IS 'text column'; COMMENT ON VIEW test_view IS 'test view'; COMMENT ON COLUMN test_view.id IS 'view id col'; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function'; COMMENT ON CONSTRAINT text_check ON test IS 'text check'; COMMENT ON INDEX test_pkey IS 'primary key'; COMMENT ON TRIGGER test_trigger ON test IS 'test trigger';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comments_new.sql000066400000000000000000000035331316501242600271500ustar00rootroot00000000000000COMMENT ON DATABASE comments IS 'comments database'; COMMENT ON SCHEMA public IS 'public schema'; CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function'; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; COMMENT ON TABLE test IS 'test table'; COMMENT ON COLUMN test.id IS 'id column'; COMMENT ON COLUMN test.text IS 'text column'; COMMENT ON CONSTRAINT text_check ON test IS 'text check'; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence'; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; COMMENT ON VIEW test_view IS 'test view'; COMMENT ON COLUMN test_view.id IS 'view id col'; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); COMMENT ON INDEX test_pkey IS 'primary key'; CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc(); COMMENT ON TRIGGER test_trigger ON test IS 'test trigger';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_comments_original.sql000066400000000000000000000023561316501242600301650ustar00rootroot00000000000000CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc();apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_diff.sql000066400000000000000000000002271316501242600276230ustar00rootroot00000000000000 ALTER TABLE testtable ADD CONSTRAINT IF NOT EXISTS field4check CHECK (((field4 > (-5.0)::double precision) AND (field4 < (5.0)::double precision))); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_new.sql000066400000000000000000000025311316501242600275040ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL, CONSTRAINT field4check CHECK (((field4 > (-5.0)::double precision) AND (field4 < (5.0)::double precision))) ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_original.sql000066400000000000000000000023501316501242600305160ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_diff.sql000066400000000000000000000000751316501242600302600ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field4 SET DEFAULT 0.0; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_new.sql000066400000000000000000000021101316501242600301310ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision DEFAULT 0.0 ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_original.sql000066400000000000000000000020741316501242600311550ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_diff.sql000066400000000000000000000006571316501242600272550ustar00rootroot00000000000000 ALTER TABLE testtable ADD COLUMN IF NOT EXISTS col3 boolean DEFAULT false NOT NULL, ADD COLUMN IF NOT EXISTS col4 character(10) DEFAULT '' NOT NULL, ADD COLUMN IF NOT EXISTS col5 text DEFAULT '' NOT NULL, ALTER COLUMN col1 SET DEFAULT 0, ALTER COLUMN col1 SET NOT NULL; ALTER TABLE testtable ALTER COLUMN col3 DROP DEFAULT, ALTER COLUMN col4 DROP DEFAULT, ALTER COLUMN col5 DROP DEFAULT, ALTER COLUMN col1 DROP DEFAULT; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_new.sql000066400000000000000000000034511316501242600271310ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id integer NOT NULL, col1 smallint NOT NULL, col2 character varying(20), col3 boolean NOT NULL, col4 character(10) NOT NULL, col5 text NOT NULL ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testtable_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable_id_seq OWNER TO fordfrog; -- -- Name: testtable_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable_id_seq OWNED BY testtable.id; -- -- Name: testtable_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable_id_seq', 1, false); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable ALTER COLUMN id SET DEFAULT nextval('testtable_id_seq'::regclass); -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_original.sql000066400000000000000000000033141316501242600301420ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id integer NOT NULL, col1 smallint, col2 character varying(20) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testtable_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable_id_seq OWNER TO fordfrog; -- -- Name: testtable_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable_id_seq OWNED BY testtable.id; -- -- Name: testtable_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable_id_seq', 1, false); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable ALTER COLUMN id SET DEFAULT nextval('testtable_id_seq'::regclass); -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_diff.sql000066400000000000000000000001301316501242600277350ustar00rootroot00000000000000CREATE TABLE IF NOT EXISTS empty_table ( ); ALTER TABLE empty_table OWNER TO fordfrog; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_new.sql000066400000000000000000000017501316501242600276270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: empty_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE empty_table ( ); ALTER TABLE public.empty_table OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_original.sql000066400000000000000000000013311316501242600306350ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_extension_diff.sql000066400000000000000000000000731316501242600274520ustar00rootroot00000000000000 CREATE EXTENSION IF NOT EXISTS plpgsql SCHEMA pg_catalog; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_extension_new.sql000066400000000000000000000013301316501242600273300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_extension_original.sql000066400000000000000000000007261316501242600303530ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_diff.sql000066400000000000000000000002511316501242600303570ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_new.sql000066400000000000000000000026731316501242600302520ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number1 integer, number2 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_original.sql000066400000000000000000000021341316501242600312550ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_diff.sql000066400000000000000000000002201316501242600302710ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION power_number("input" integer) RETURNS integer AS $$ begin return input * input; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_new.sql000066400000000000000000000026001316501242600301560ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: power_number(integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION power_number("input" integer) RETURNS integer AS $$ begin return input * input; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.power_number("input" integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_original.sql000066400000000000000000000021341316501242600311730ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_diff.sql000066400000000000000000000001631316501242600306340ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION return_one() RETURNS integer AS $$ begin return 1; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_new.sql000066400000000000000000000025111316501242600305140ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: return_one(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION return_one() RETURNS integer AS $$ begin return 1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.return_one() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_original.sql000066400000000000000000000021341316501242600315300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_diff.sql000066400000000000000000000002631316501242600310040ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION multiply_numbers(number2 smallint, number1 smallint) RETURNS smallint AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_new.sql000066400000000000000000000034571316501242600306750ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; -- -- Name: multiply_numbers(smallint, smallint); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 smallint, number1 smallint) RETURNS smallint AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 smallint, number1 smallint) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_original.sql000066400000000000000000000027021316501242600317000ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_index_diff.sql000066400000000000000000000001121316501242600265370ustar00rootroot00000000000000 CREATE INDEX IF NOT EXISTS testindex3 ON testtable USING btree (field3); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_index_new.sql000066400000000000000000000026221316501242600264300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: testindex3; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex3 ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_index_original.sql000066400000000000000000000023761316501242600274510ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_default_column_diff.sql000066400000000000000000000002141316501242600323410ustar00rootroot00000000000000 CREATE TABLE IF NOT EXISTS childtable ( ) INHERITS (parenttable); ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 0; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_default_column_new.sql000066400000000000000000000013611316501242600322260ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); -- -- Name: childtable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE childtable ( ) INHERITS (parenttable); -- -- Name: childtable; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 0; -- -- PostgreSQL database dump complete --apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_default_column_original.sql000066400000000000000000000007301316501242600332400ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); -- -- PostgreSQL database dump complete --apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_diff.sql000066400000000000000000000001741316501242600272650ustar00rootroot00000000000000 CREATE TABLE IF NOT EXISTS testtable ( field1 polygon ) INHERITS (parenttable); ALTER TABLE testtable OWNER TO fordfrog; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_new.sql000066400000000000000000000020201316501242600271360ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( id bigserial NOT NULL ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 polygon ) INHERITS (parenttable); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_original.sql000066400000000000000000000015011316501242600301540ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( id bigserial NOT NULL ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_schema_default_column_diff.sql000066400000000000000000000004071316501242600336650ustar00rootroot00000000000000 CREATE SCHEMA IF NOT EXISTS schema1; SET search_path = schema1, pg_catalog; CREATE TABLE IF NOT EXISTS childtable ( childtable_date timestamptz NOT NULL ) INHERITS (public.parenttable); ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 0; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_schema_default_column_new.sql000066400000000000000000000016471316501242600335550ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: schema1; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA schema1; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); SET search_path = schema1, pg_catalog; -- -- Name: childtable; Type: TABLE; Schema: schema1; Owner: admin; Tablespace: -- CREATE TABLE childtable ( childtable_date timestamptz NOT NULL ) INHERITS (public.parenttable); -- -- Name: parenttable_id; Type: DEFAULT; Schema: schema1; Owner: admin -- ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 0; -- -- PostgreSQL database dump complete --apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_schema_default_column_original.sql000066400000000000000000000007301316501242600345600ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); -- -- PostgreSQL database dump complete --apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_materialized_view_diff.sql000066400000000000000000000001321316501242600311360ustar00rootroot00000000000000 CREATE MATERIALIZED VIEW testview AS SELECT testtable.id, testtable.name FROM testtable;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_materialized_view_new.sql000066400000000000000000000023041316501242600310220ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE MATERIALIZED VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_materialized_view_original.sql000066400000000000000000000017571316501242600320500ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_diff.sql000066400000000000000000000000721316501242600272670ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field3 SET NOT NULL; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_new.sql000066400000000000000000000021051316501242600271470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying NOT NULL, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_original.sql000066400000000000000000000020741316501242600301670ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_diff.sql000066400000000000000000000004731316501242600304460ustar00rootroot00000000000000 CREATE SEQUENCE IF NOT EXISTS table2_col1_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE IF NOT EXISTS table2 ( col1 integer DEFAULT nextval('table2_col1_seq'::regclass) NOT NULL ); ALTER TABLE table2 OWNER TO fordfrog; ALTER SEQUENCE table2_col1_seq OWNED BY table2.col1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_new.sql000066400000000000000000000054251316501242600303310ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: table1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE table1 ( col1 integer NOT NULL ); ALTER TABLE public.table1 OWNER TO fordfrog; -- -- Name: table1_col1_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE table1_col1_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.table1_col1_seq OWNER TO fordfrog; -- -- Name: table1_col1_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE table1_col1_seq OWNED BY table1.col1; -- -- Name: table1_col1_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('table1_col1_seq', 1, false); -- -- Name: table2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE table2 ( col1 integer NOT NULL ); ALTER TABLE public.table2 OWNER TO fordfrog; -- -- Name: table2_col1_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE table2_col1_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.table2_col1_seq OWNER TO fordfrog; -- -- Name: table2_col1_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE table2_col1_seq OWNED BY table2.col1; -- -- Name: table2_col1_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('table2_col1_seq', 1, false); -- -- Name: col1; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE ONLY table1 ALTER COLUMN col1 SET DEFAULT nextval('table1_col1_seq'::regclass); -- -- Name: col1; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE ONLY table2 ALTER COLUMN col1 SET DEFAULT nextval('table2_col1_seq'::regclass); -- -- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- COPY table1 (col1) FROM stdin; \. -- -- Data for Name: table2; Type: TABLE DATA; Schema: public; Owner: fordfrog -- COPY table2 (col1) FROM stdin; \. -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_original.sql000066400000000000000000000034531316501242600313430ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: table1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE table1 ( col1 integer NOT NULL ); ALTER TABLE public.table1 OWNER TO fordfrog; -- -- Name: table1_col1_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE table1_col1_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.table1_col1_seq OWNER TO fordfrog; -- -- Name: table1_col1_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE table1_col1_seq OWNED BY table1.col1; -- -- Name: table1_col1_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('table1_col1_seq', 1, false); -- -- Name: col1; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE ONLY table1 ALTER COLUMN col1 SET DEFAULT nextval('table1_col1_seq'::regclass); -- -- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- COPY table1 (col1) FROM stdin; \. -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_diff.sql000066400000000000000000000001461316501242600306330ustar00rootroot00000000000000CREATE SEQUENCE IF NOT EXISTS test_id_seq INCREMENT BY 1 MAXVALUE 2147483647 NO MINVALUE CACHE 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_new.sql000066400000000000000000000001231316501242600305070ustar00rootroot00000000000000CREATE SEQUENCE test_id_seq INCREMENT BY 1 MAXVALUE 2147483647 NO MINVALUE CACHE 1;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_original.sql000066400000000000000000000000001316501242600315140ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_diff.sql000066400000000000000000000001511316501242600272430ustar00rootroot00000000000000 CREATE SEQUENCE IF NOT EXISTS testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_new.sql000066400000000000000000000024371316501242600271350ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_original.sql000066400000000000000000000020741316501242600301450ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_diff.sql000066400000000000000000000001041316501242600276230ustar00rootroot00000000000000 ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 100; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_new.sql000066400000000000000000000021771316501242600275200ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 100; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_original.sql000066400000000000000000000020741316501242600305270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_diff.sql000066400000000000000000000005431316501242600276070ustar00rootroot00000000000000CREATE TABLE IF NOT EXISTS "procedureresult$Operation" ( id bigint NOT NULL, name character varying(255), result_id bigint ); ALTER TABLE "procedureresult$Operation" OWNER TO fordfrog; ALTER TABLE "procedureresult$Operation" ADD CONSTRAINT IF NOT EXISTS $1 FOREIGN KEY (result_id) REFERENCES testtable(field1) ON UPDATE RESTRICT ON DELETE RESTRICT; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_new.sql000066400000000000000000000027771316501242600275030ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: procedureresult$operation; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE "procedureresult$Operation" ( id bigint NOT NULL, name character varying(255), result_id bigint ); ALTER TABLE public."procedureresult$Operation" OWNER TO fordfrog; ALTER TABLE ONLY "procedureresult$Operation" ADD CONSTRAINT "$1" FOREIGN KEY (result_id) REFERENCES testtable(field1) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_original.sql000066400000000000000000000020741316501242600305040ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_diff.sql000066400000000000000000000002121316501242600265200ustar00rootroot00000000000000 CREATE TABLE IF NOT EXISTS testtable2 ( id integer, name character varying(100) NOT NULL ); ALTER TABLE testtable2 OWNER TO fordfrog; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_issue115_diff.sql000066400000000000000000000000721316501242600301630ustar00rootroot00000000000000CREATE TABLE IF NOT EXISTS test2 ( id serial NOT NULL ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_issue115_new.sql000066400000000000000000000001061316501242600300420ustar00rootroot00000000000000/* create table begin */ create table "test2"( "id" serial NOT NULL );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_issue115_original.sql000066400000000000000000000000001316501242600310460ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_new.sql000066400000000000000000000024351316501242600264120ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testtable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer, name character varying(100) NOT NULL ); ALTER TABLE public.testtable2 OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_table_original.sql000066400000000000000000000020741316501242600274240ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_diff.sql000066400000000000000000000012001316501242600277540ustar00rootroot00000000000000START TRANSACTION; DROP SCHEMA testschema1 CASCADE; CREATE SCHEMA testschema2; SET search_path = public, pg_catalog; DROP SEQUENCE testtable2_id_seq; CREATE SEQUENCE testtable3_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; DROP TABLE testtable2; CREATE TABLE testtable3 ( id bigint DEFAULT nextval('testtable3_id_seq'::regclass) NOT NULL ); SET search_path = testschema2, pg_catalog; CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE testtable1 ( id integer DEFAULT nextval('testtable1_id_seq'::regclass) NOT NULL ); COMMIT TRANSACTION; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_new.sql000066400000000000000000000077651316501242600276630ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: testschema2; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA testschema2; ALTER SCHEMA testschema2 OWNER TO fordfrog; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id bigint NOT NULL ); ALTER TABLE public.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); -- -- Name: testtable3; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable3 ( id bigint NOT NULL ); ALTER TABLE public.testtable3 OWNER TO fordfrog; -- -- Name: testtable3_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable3_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable3_id_seq OWNER TO fordfrog; -- -- Name: testtable3_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable3_id_seq OWNED BY testtable3.id; -- -- Name: testtable3_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable3_id_seq', 1, false); SET search_path = testschema2, pg_catalog; -- -- Name: testtable1; Type: TABLE; Schema: testschema2; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id integer NOT NULL ); ALTER TABLE testschema2.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: testschema2; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE testschema2.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: testschema2; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: testschema2; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); SET search_path = public, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable3 ALTER COLUMN id SET DEFAULT nextval('testtable3_id_seq'::regclass); SET search_path = testschema2, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: testschema2; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); SET search_path = public, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Data for Name: testtable3; Type: TABLE DATA; Schema: public; Owner: fordfrog -- SET search_path = testschema2, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: testschema2; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_original.sql000066400000000000000000000077661316501242600306770ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: testschema1; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA testschema1; ALTER SCHEMA testschema1 OWNER TO fordfrog; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id bigint NOT NULL ); ALTER TABLE public.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); -- -- Name: testtable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer NOT NULL ); ALTER TABLE public.testtable2 OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable2_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable2_id_seq OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable2_id_seq OWNED BY testtable2.id; -- -- Name: testtable2_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable2_id_seq', 1, false); SET search_path = testschema1, pg_catalog; -- -- Name: testtable1; Type: TABLE; Schema: testschema1; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id integer NOT NULL ); ALTER TABLE testschema1.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: testschema1; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE testschema1.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: testschema1; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: testschema1; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); SET search_path = public, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable2 ALTER COLUMN id SET DEFAULT nextval('testtable2_id_seq'::regclass); SET search_path = testschema1, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: testschema1; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); SET search_path = public, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Data for Name: testtable2; Type: TABLE DATA; Schema: public; Owner: fordfrog -- SET search_path = testschema1, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: testschema1; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_diff.sql000066400000000000000000000003771316501242600271100ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE ON test_table FOR EACH ROW EXECUTE PROCEDURE test_table_trigger(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_new.sql000066400000000000000000000026171316501242600267700ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: test_table_trigger(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.test_table_trigger() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_trigger; Type: TRIGGER; Schema: public; Owner: fordfrog -- CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE ON test_table FOR EACH ROW EXECUTE PROCEDURE test_table_trigger(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_original.sql000066400000000000000000000014731316501242600300020ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_type_diff.sql000066400000000000000000000003331316501242600264160ustar00rootroot00000000000000CREATE TYPE bug_status AS ENUM ( 'new', 'open', 'closed' ); CREATE TYPE descr_type AS ( name text, amount integer ); CREATE TABLE IF NOT EXISTS t1 ( id integer, descr descr_type ); ALTER TABLE t1 OWNER TO dv; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_type_new.sql000066400000000000000000000033701316501242600263030ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:27:26 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; -- -- TOC entry 556 (class 1247 OID 16397) -- Name: bug_status; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE bug_status AS ENUM ( 'new', 'open', 'closed' ); ALTER TYPE bug_status OWNER TO dv; -- -- TOC entry 549 (class 1247 OID 16389) -- Name: descr_type; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE descr_type AS ( name text, amount integer ); ALTER TYPE descr_type OWNER TO dv; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 16390) -- Name: t1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE t1 ( id integer, descr descr_type ); ALTER TABLE t1 OWNER TO dv; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:27:26 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_type_original.sql000066400000000000000000000020641316501242600273150ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:14:40 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2134 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- TOC entry 2133 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:14:40 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_diff.sql000066400000000000000000000004051316501242600312070ustar00rootroot00000000000000 ALTER TABLE inventoryitemsupplier ADD CONSTRAINT IF NOT EXISTS inventoryitemsupplier_pkey PRIMARY KEY (id); ALTER TABLE inventoryitemsupplier ADD CONSTRAINT IF NOT EXISTS inventoryitemsupplier_5a808b9c_key UNIQUE (inventoryitemid, partneridentificationid); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_new.sql000066400000000000000000000034601316501242600310740ustar00rootroot00000000000000-- -- Name: inventoryitemsupplier; Type: TABLE; Schema: public; Owner: intranet; Tablespace: -- CREATE TABLE inventoryitemsupplier ( id integer NOT NULL, code character varying(20) NOT NULL, partneridentificationid integer NOT NULL, inventoryitemid integer NOT NULL, createdbyuserid smallint NOT NULL, datecreated timestamp without time zone NOT NULL, datedeleted timestamp without time zone, datelastmodified timestamp without time zone, deletedbyuserid smallint, lastmodifiedbyuserid smallint ); ALTER TABLE public.inventoryitemsupplier OWNER TO intranet; -- -- Name: inventoryitemsupplier_seq; Type: SEQUENCE; Schema: public; Owner: intranet -- CREATE SEQUENCE inventoryitemsupplier_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.inventoryitemsupplier_seq OWNER TO intranet; -- -- Name: inventoryitemsupplier_5a808b9c_key; Type: CONSTRAINT; Schema: public; Owner: intranet; Tablespace: -- ALTER TABLE ONLY inventoryitemsupplier ADD CONSTRAINT inventoryitemsupplier_5a808b9c_key UNIQUE (inventoryitemid, partneridentificationid); -- -- Name: inventoryitemsupplier_pkey; Type: CONSTRAINT; Schema: public; Owner: intranet; Tablespace: -- ALTER TABLE ONLY inventoryitemsupplier ADD CONSTRAINT inventoryitemsupplier_pkey PRIMARY KEY (id); -- -- Name: inventoryitemsupplier_inventoryitemid_key; Type: INDEX; Schema: public; Owner: intranet; Tablespace: -- CREATE INDEX inventoryitemsupplier_inventoryitemid_key ON inventoryitemsupplier USING btree (inventoryitemid); -- -- Name: inventoryitemsupplier_partneridentificationid_key; Type: INDEX; Schema: public; Owner: intranet; Tablespace: -- CREATE INDEX inventoryitemsupplier_partneridentificationid_key ON inventoryitemsupplier USING btree (partneridentificationid); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_original.sql000066400000000000000000000025061316501242600321070ustar00rootroot00000000000000-- -- Name: inventoryitemsupplier; Type: TABLE; Schema: public; Owner: intranet; Tablespace: -- CREATE TABLE inventoryitemsupplier ( id integer NOT NULL, code character varying(20) NOT NULL, partneridentificationid integer NOT NULL, inventoryitemid integer NOT NULL, createdbyuserid smallint NOT NULL, datecreated timestamp without time zone NOT NULL, datedeleted timestamp without time zone, datelastmodified timestamp without time zone, deletedbyuserid smallint, lastmodifiedbyuserid smallint ); ALTER TABLE public.inventoryitemsupplier OWNER TO intranet; -- -- Name: inventoryitemsupplier_seq; Type: SEQUENCE; Schema: public; Owner: intranet -- CREATE SEQUENCE inventoryitemsupplier_seq INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.inventoryitemsupplier_seq OWNER TO intranet; -- -- Name: inventoryitemsupplier_inventoryitemid_key; Type: INDEX; Schema: public; Owner: intranet; Tablespace: -- CREATE INDEX inventoryitemsupplier_inventoryitemid_key ON inventoryitemsupplier USING btree (inventoryitemid); -- -- Name: inventoryitemsupplier_partneridentificationid_key; Type: INDEX; Schema: public; Owner: intranet; Tablespace: -- CREATE INDEX inventoryitemsupplier_partneridentificationid_key ON inventoryitemsupplier USING btree (partneridentificationid); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_diff.sql000066400000000000000000000003771316501242600304200ustar00rootroot00000000000000SET search_path = radstg, pg_catalog; CREATE UNLOGGED TABLE IF NOT EXISTS asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_new.sql000066400000000000000000000016061316501242600302750ustar00rootroot00000000000000-- -- Name: rad; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA rad; ALTER SCHEMA rad OWNER TO asi; -- -- Name: radstg; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA radstg; ALTER SCHEMA radstg OWNER TO asi; SET search_path = rad, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: rad; Owner: asi; Tablespace: -- CREATE TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; SET search_path = radstg, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: radstg; Owner: asi; Tablespace: -- CREATE UNLOGGED TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_original.sql000066400000000000000000000010571316501242600313100ustar00rootroot00000000000000-- -- Name: rad; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA rad; ALTER SCHEMA rad OWNER TO asi; -- -- Name: radstg; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA radstg; ALTER SCHEMA radstg OWNER TO asi; SET search_path = rad, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: rad; Owner: asi; Tablespace: -- CREATE TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_view_diff.sql000066400000000000000000000001161316501242600264060ustar00rootroot00000000000000 CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_view_new.sql000066400000000000000000000022671316501242600263000ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/add_view_original.sql000066400000000000000000000017571316501242600273160ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_diff.sql000066400000000000000000000012161316501242600276420ustar00rootroot00000000000000COMMENT ON DATABASE current_database() IS 'comments database 2'; COMMENT ON SCHEMA "public" IS 'public schema 2'; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence 2'; COMMENT ON TABLE test IS 'test table 2'; COMMENT ON COLUMN test.id IS 'id column 2'; COMMENT ON COLUMN test.text IS 'text column 2'; COMMENT ON VIEW test_view IS 'test view 2'; COMMENT ON COLUMN test_view.id IS 'view id col 2'; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function 2'; COMMENT ON CONSTRAINT text_check ON test IS 'text check 2'; COMMENT ON INDEX test_pkey IS 'primary key 2'; COMMENT ON TRIGGER test_trigger ON test IS 'test trigger 2';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_new.sql000066400000000000000000000035631316501242600275320ustar00rootroot00000000000000COMMENT ON DATABASE comments IS 'comments database 2'; COMMENT ON SCHEMA public IS 'public schema 2'; CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function 2'; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; COMMENT ON TABLE test IS 'test table 2'; COMMENT ON COLUMN test.id IS 'id column 2'; COMMENT ON COLUMN test.text IS 'text column 2'; COMMENT ON CONSTRAINT text_check ON test IS 'text check 2'; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence 2'; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; COMMENT ON VIEW test_view IS 'test view 2'; COMMENT ON COLUMN test_view.id IS 'view id col 2'; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); COMMENT ON INDEX test_pkey IS 'primary key 2'; CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc(); COMMENT ON TRIGGER test_trigger ON test IS 'test trigger 2';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_original.sql000066400000000000000000000035331316501242600305420ustar00rootroot00000000000000COMMENT ON DATABASE comments IS 'comments database'; COMMENT ON SCHEMA public IS 'public schema'; CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function'; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; COMMENT ON TABLE test IS 'test table'; COMMENT ON COLUMN test.id IS 'id column'; COMMENT ON COLUMN test.text IS 'text column'; COMMENT ON CONSTRAINT text_check ON test IS 'text check'; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence'; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; COMMENT ON VIEW test_view IS 'test view'; COMMENT ON COLUMN test_view.id IS 'view id col'; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); COMMENT ON INDEX test_pkey IS 'primary key'; CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc(); COMMENT ON TRIGGER test_trigger ON test IS 'test trigger';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_policies_diff.sql000066400000000000000000000010251316501242600276220ustar00rootroot00000000000000DROP POLICY only_owners ON todos; CREATE POLICY only_owners ON todos FOR INSERT TO PUBLIC; ALTER POLICY only_admins ON todos TO admin, manager; ALTER POLICY only_evens ON todos TO PUBLIC USING ( (id % 2) = 0 ); ALTER POLICY only_evens_and_1 ON todos TO PUBLIC USING ( (id % 2) = 0 or id = 1 ); ALTER POLICY check_evens_and_1 ON todos TO PUBLIC WITH CHECK ( (id % 2) = 0 or id = 1 ); ALTER POLICY check_using_evens_and_1 ON todos TO PUBLIC USING ( (id % 2) = 0 or id = 1 ) WITH CHECK ( (id % 2) = 0 or id = 1 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_policies_new.sql000066400000000000000000000012301316501242600275010ustar00rootroot00000000000000create table todos ( id integer ); create policy only_owners on todos for INSERT; create policy no_private on todos for ALL TO anonymous; create policy only_admins on todos TO admin, manager; create policy only_managers on todos; create policy only_evens on todos using ( (id % 2) = 0); create policy only_evens_and_1 on todos using ( (id % 2) = 0 or id = 1 ); create policy only_evens_whitespace_comment on todos using ( (id % 2) = 0 ); create policy check_evens_and_1 on todos with check( (id % 2) = 0 or id = 1 ); create policy check_using_evens_and_1 on todos using ( (id % 2) = 0 or id = 1 ) with check( (id % 2) = 0 or id = 1 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_policies_original.sql000066400000000000000000000011571316501242600305240ustar00rootroot00000000000000create table todos ( id integer ); create policy only_owners on todos for SELECT; create policy no_private on todos for ALL TO anonymous; create policy only_admins on todos TO admin; create policy only_managers on todos TO PUBLIC; create policy only_evens on todos; create policy only_evens_and_1 on todos using ( (id % 2) = 0 ); create policy only_evens_whitespace_comment on todos using ( -- comment 1 (id % 2) = 0 -- comment 2 ); create policy check_evens_and_1 on todos with check( (id % 2) = 0 ); create policy check_using_evens_and_1 on todos using ( (id % 2) = 0 ) with check( (id % 2) = 0 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_type_diff.sql000066400000000000000000000001151316501242600267730ustar00rootroot00000000000000ALTER TYPE descr_type ADD ATTRIBUTE date_create timestamp without time zone;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_type_new.sql000066400000000000000000000034611316501242600266630ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:55:57 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; -- -- TOC entry 556 (class 1247 OID 16397) -- Name: bug_status; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE bug_status AS ENUM ( 'new', 'open', 'closed', 'deleted' ); ALTER TYPE bug_status OWNER TO dv; -- -- TOC entry 549 (class 1247 OID 16389) -- Name: descr_type; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE descr_type AS ( name text, amount integer, date_create timestamp without time zone ); ALTER TYPE descr_type OWNER TO dv; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 16390) -- Name: t1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE t1 ( id integer, descr descr_type ); ALTER TABLE t1 OWNER TO dv; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:55:57 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_type_original.sql000066400000000000000000000033701316501242600276750ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:27:26 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; -- -- TOC entry 556 (class 1247 OID 16397) -- Name: bug_status; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE bug_status AS ENUM ( 'new', 'open', 'closed' ); ALTER TYPE bug_status OWNER TO dv; -- -- TOC entry 549 (class 1247 OID 16389) -- Name: descr_type; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE descr_type AS ( name text, amount integer ); ALTER TYPE descr_type OWNER TO dv; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 16390) -- Name: t1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE t1 ( id integer, descr descr_type ); ALTER TABLE t1 OWNER TO dv; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:27:26 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_diff.sql000066400000000000000000000000721316501242600313020ustar00rootroot00000000000000ALTER TABLE test ALTER COLUMN test_col SET DEFAULT now(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_new.sql000066400000000000000000000001531316501242600311630ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_original.sql000066400000000000000000000000611316501242600321740ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_diff.sql000066400000000000000000000000661316501242600320020ustar00rootroot00000000000000ALTER TABLE test ALTER COLUMN test_col SET DEFAULT 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_new.sql000066400000000000000000000001471316501242600316630ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_original.sql000066400000000000000000000001531316501242600326730ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_diff.sql000066400000000000000000000000651316501242600315200ustar00rootroot00000000000000ALTER TABLE test ALTER COLUMN test_col DROP DEFAULT; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_new.sql000066400000000000000000000000611316501242600313750ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_original.sql000066400000000000000000000001531316501242600324120ustar00rootroot00000000000000CREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/create_policies_diff.sql000066400000000000000000000010311316501242600277530ustar00rootroot00000000000000SET search_path = public, pg_catalog; CREATE POLICY only_owners ON todos FOR ALL TO PUBLIC; CREATE POLICY check_evens ON todos FOR ALL TO PUBLIC WITH CHECK ( (id % 2) = 0 ); CREATE POLICY check_using_evens ON todos FOR ALL TO PUBLIC USING ( (id % 2) = 0 ) WITH CHECK ( (id % 2) = 0 ); SET search_path = data, pg_catalog; CREATE POLICY only_owners ON sub_tasks FOR ALL TO PUBLIC; CREATE POLICY no_private ON sub_tasks FOR ALL TO anonymous, webuser; CREATE POLICY only_evens ON sub_tasks FOR ALL TO PUBLIC USING ( (id % 2) = 0 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/create_policies_new.sql000066400000000000000000000007441316501242600276460ustar00rootroot00000000000000create table todos ( id integer ); create policy only_owners on todos; create schema data; create table data.sub_tasks ( id integer ); create policy only_owners on data.sub_tasks; create policy no_private on data.sub_tasks to anonymous, webuser; create policy only_evens on data.sub_tasks using ( (id % 2) = 0); create policy check_evens on todos with check( (id % 2) = 0 ); create policy check_using_evens on todos using ( (id % 2) = 0 ) with check( (id % 2) = 0 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/create_policies_original.sql000066400000000000000000000001501316501242600306500ustar00rootroot00000000000000create table todos ( id integer ); create schema data; create table data.sub_tasks ( id integer ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/disable_no_force_rls_diff.sql000066400000000000000000000001421316501242600307600ustar00rootroot00000000000000 ALTER TABLE items DISABLE ROW LEVEL SECURITY; ALTER TABLE projects NO FORCE ROW LEVEL SECURITY; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/disable_no_force_rls_new.sql000066400000000000000000000001141316501242600306400ustar00rootroot00000000000000create table items ( id integer ); create table projects ( id integer ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/disable_no_force_rls_original.sql000066400000000000000000000002541316501242600316600ustar00rootroot00000000000000create table items ( id integer ); alter table items enable row level security; create table projects ( id integer ); alter table projects force row level security; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_diff.sql000066400000000000000000000000541316501242600273320ustar00rootroot00000000000000 ALTER TABLE testtable SET WITHOUT CLUSTER; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_new.sql000066400000000000000000000020741316501242600272170ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_original.sql000066400000000000000000000021511316501242600302260ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); ALTER TABLE testtable CLUSTER ON testindex; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_column_diff.sql000066400000000000000000000000661316501242600271510ustar00rootroot00000000000000 ALTER TABLE testtable DROP COLUMN IF EXISTS field5; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_column_new.sql000066400000000000000000000020741316501242600270330ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_column_original.sql000066400000000000000000000021471316501242600300470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, field5 boolean DEFAULT false NOT NULL ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_diff.sql000066400000000000000000000007751316501242600275100ustar00rootroot00000000000000COMMENT ON DATABASE current_database() IS NULL; COMMENT ON SCHEMA "public" IS NULL; COMMENT ON SEQUENCE test_id_seq IS NULL; COMMENT ON TABLE test IS NULL; COMMENT ON COLUMN test.id IS NULL; COMMENT ON COLUMN test.text IS NULL; COMMENT ON VIEW test_view IS NULL; COMMENT ON COLUMN test_view.id IS NULL; COMMENT ON FUNCTION test_fnc(arg character varying) IS NULL; COMMENT ON CONSTRAINT text_check ON test IS NULL; COMMENT ON INDEX test_pkey IS NULL; COMMENT ON TRIGGER test_trigger ON test IS NULL;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_new.sql000066400000000000000000000023561316501242600273660ustar00rootroot00000000000000CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc();apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_original.sql000066400000000000000000000035331316501242600303770ustar00rootroot00000000000000COMMENT ON DATABASE comments IS 'comments database'; COMMENT ON SCHEMA public IS 'public schema'; CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function'; CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; COMMENT ON TABLE test IS 'test table'; COMMENT ON COLUMN test.id IS 'id column'; COMMENT ON COLUMN test.text IS 'text column'; COMMENT ON CONSTRAINT text_check ON test IS 'text check'; CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; ALTER SEQUENCE test_id_seq OWNED BY test.id; COMMENT ON SEQUENCE test_id_seq IS 'test table sequence'; CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; COMMENT ON VIEW test_view IS 'test view'; COMMENT ON COLUMN test_view.id IS 'view id col'; ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); COMMENT ON INDEX test_pkey IS 'primary key'; CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc(); COMMENT ON TRIGGER test_trigger ON test IS 'test trigger';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_diff.sql000066400000000000000000000000771316501242600300420ustar00rootroot00000000000000 ALTER TABLE testtable DROP CONSTRAINT IF EXISTS field4check; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_new.sql000066400000000000000000000023501316501242600277170ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_original.sql000066400000000000000000000024571316501242600307420ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL, CONSTRAINT field4check CHECK ((field4 > (0.0)::double precision)) ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_diff.sql000066400000000000000000000000721316501242600304710ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field4 DROP DEFAULT; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_new.sql000066400000000000000000000020741316501242600303560ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_original.sql000066400000000000000000000021101316501242600313600ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision DEFAULT 1.0 ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_extension_diff.sql000066400000000000000000000000531316501242600276640ustar00rootroot00000000000000 DROP EXTENSION IF EXISTS plpgsql CASCADE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_extension_new.sql000066400000000000000000000007261316501242600275540ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_extension_original.sql000066400000000000000000000013301316501242600305570ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_diff.sql000066400000000000000000000001151316501242600305720ustar00rootroot00000000000000 DROP FUNCTION IF EXISTS multiply_numbers(number1 integer, number2 integer); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_new.sql000066400000000000000000000021341316501242600304560ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_original.sql000066400000000000000000000026731316501242600315010ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number1 integer, number2 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_diff.sql000066400000000000000000000000701316501242600305100ustar00rootroot00000000000000 DROP FUNCTION IF EXISTS power_number("input" integer); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_new.sql000066400000000000000000000021341316501242600303740ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_original.sql000066400000000000000000000026001316501242600314050ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: power_number(integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION power_number("input" integer) RETURNS integer AS $$ begin return input * input; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.power_number("input" integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_diff.sql000066400000000000000000000000471316501242600310510ustar00rootroot00000000000000 DROP FUNCTION IF EXISTS return_one(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_new.sql000066400000000000000000000021341316501242600307310ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_original.sql000066400000000000000000000025111316501242600317430ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: return_one(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION return_one() RETURNS integer AS $$ begin return 1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.return_one() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_diff.sql000066400000000000000000000001171316501242600312160ustar00rootroot00000000000000 DROP FUNCTION IF EXISTS multiply_numbers(number2 smallint, number1 smallint); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_new.sql000066400000000000000000000027021316501242600311010ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_original.sql000066400000000000000000000034571316501242600321240ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; -- -- Name: multiply_numbers(smallint, smallint); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 smallint, number1 smallint) RETURNS smallint AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 smallint, number1 smallint) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_diff.sql000066400000000000000000000000421316501242600267550ustar00rootroot00000000000000 DROP INDEX IF EXISTS testindex3; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_new.sql000066400000000000000000000023761316501242600266520ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_original.sql000066400000000000000000000026221316501242600276570ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: testindex3; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex3 ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_diff.sql000066400000000000000000000000421316501242600315510ustar00rootroot00000000000000 DROP INDEX IF EXISTS testindex2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_new.sql000066400000000000000000000020741316501242600314410ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_original.sql000066400000000000000000000023761316501242600324610ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_materialized_view_diff.sql000066400000000000000000000000541316501242600313550ustar00rootroot00000000000000 DROP MATERIALIZED VIEW IF EXISTS testview; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_materialized_view_new.sql000066400000000000000000000017571316501242600312510ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_materialized_view_original.sql000066400000000000000000000023041316501242600322510ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE MATERIALIZED VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_diff.sql000066400000000000000000000000731316501242600275040ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field3 DROP NOT NULL; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_new.sql000066400000000000000000000020741316501242600273700ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_original.sql000066400000000000000000000021051316501242600303760ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying NOT NULL, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_policies_diff.sql000066400000000000000000000004471316501242600274660ustar00rootroot00000000000000SET search_path = public, pg_catalog; DROP POLICY only_owners ON todos; DROP POLICY check_evens ON todos; DROP POLICY check_using_evens ON todos; SET search_path = data, pg_catalog; DROP POLICY only_owners ON sub_tasks; DROP POLICY no_private ON sub_tasks; DROP POLICY only_evens ON sub_tasks; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_policies_new.sql000066400000000000000000000001501316501242600273360ustar00rootroot00000000000000create table todos ( id integer ); create schema data; create table data.sub_tasks ( id integer ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_policies_original.sql000066400000000000000000000007441316501242600303620ustar00rootroot00000000000000create table todos ( id integer ); create policy only_owners on todos; create schema data; create table data.sub_tasks ( id integer ); create policy only_owners on data.sub_tasks; create policy no_private on data.sub_tasks to anonymous, webuser; create policy only_evens on data.sub_tasks using ( (id % 2) = 0); create policy check_evens on todos with check( (id % 2) = 0 ); create policy check_using_evens on todos using ( (id % 2) = 0 ) with check( (id % 2) = 0 ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_diff.sql000066400000000000000000000000421316501242600274560ustar00rootroot00000000000000 DROP SEQUENCE IF EXISTS testseq; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_new.sql000066400000000000000000000020741316501242600273460ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_original.sql000066400000000000000000000024421316501242600303600ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_diff.sql000066400000000000000000000001031316501242600300360ustar00rootroot00000000000000 ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS -1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_new.sql000066400000000000000000000020741316501242600277300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_original.sql000066400000000000000000000021771316501242600307470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_table_diff.sql000066400000000000000000000000421316501242600267350ustar00rootroot00000000000000 DROP TABLE IF EXISTS testtable2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_table_new.sql000066400000000000000000000020741316501242600266250ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_table_original.sql000066400000000000000000000024351316501242600276410ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testtable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer, name character varying(100) NOT NULL ); ALTER TABLE public.testtable2 OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_diff.sql000066400000000000000000000000721316501242600273140ustar00rootroot00000000000000 DROP TRIGGER IF EXISTS test_table_trigger ON test_table; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_new.sql000066400000000000000000000022611316501242600271770ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: test_table_trigger(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.test_table_trigger() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_original.sql000066400000000000000000000026251316501242600302160ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: test_table_trigger(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.test_table_trigger() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_trigger; Type: TRIGGER; Schema: public; Owner: fordfrog -- CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE OF id ON test_table FOR EACH ROW EXECUTE PROCEDURE test_table_trigger(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_type_diff.sql000066400000000000000000000001331316501242600266300ustar00rootroot00000000000000DROP TABLE IF EXISTS t1; DROP TYPE IF EXISTS bug_status; DROP TYPE IF EXISTS descr_type; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_type_new.sql000066400000000000000000000020641316501242600265160ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:14:40 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2134 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- TOC entry 2133 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:14:40 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_type_original.sql000066400000000000000000000033701316501242600275320ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.2 -- Dumped by pg_dump version 9.5.2 -- Started on 2016-05-02 12:27:26 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; -- -- TOC entry 556 (class 1247 OID 16397) -- Name: bug_status; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE bug_status AS ENUM ( 'new', 'open', 'closed' ); ALTER TYPE bug_status OWNER TO dv; -- -- TOC entry 549 (class 1247 OID 16389) -- Name: descr_type; Type: TYPE; Schema: public; Owner: dv -- CREATE TYPE descr_type AS ( name text, amount integer ); ALTER TYPE descr_type OWNER TO dv; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 16390) -- Name: t1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE t1 ( id integer, descr descr_type ); ALTER TABLE t1 OWNER TO dv; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- Completed on 2016-05-02 12:27:26 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_unlogged_table_diff.sql000066400000000000000000000001221316501242600306200ustar00rootroot00000000000000SET search_path = radstg, pg_catalog; DROP TABLE IF EXISTS asset_country_weight; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_unlogged_table_new.sql000066400000000000000000000010571316501242600305110ustar00rootroot00000000000000-- -- Name: rad; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA rad; ALTER SCHEMA rad OWNER TO asi; -- -- Name: radstg; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA radstg; ALTER SCHEMA radstg OWNER TO asi; SET search_path = rad, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: rad; Owner: asi; Tablespace: -- CREATE TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_unlogged_table_original.sql000066400000000000000000000016061316501242600315240ustar00rootroot00000000000000-- -- Name: rad; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA rad; ALTER SCHEMA rad OWNER TO asi; -- -- Name: radstg; Type: SCHEMA; Schema: -; Owner: asi -- CREATE SCHEMA radstg; ALTER SCHEMA radstg OWNER TO asi; SET search_path = rad, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: rad; Owner: asi; Tablespace: -- CREATE TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; SET search_path = radstg, pg_catalog; -- -- Name: asset_country_weight; Type: TABLE; Schema: radstg; Owner: asi; Tablespace: -- CREATE UNLOGGED TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL ); ALTER TABLE asset_country_weight OWNER TO asi; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_view_diff.sql000066400000000000000000000000371316501242600266240ustar00rootroot00000000000000 DROP VIEW IF EXISTS testview; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_view_new.sql000066400000000000000000000017571316501242600265170ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_view_original.sql000066400000000000000000000022671316501242600275270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_diff.sql000066400000000000000000000000521316501242600276400ustar00rootroot00000000000000 ALTER TABLE testtable SET WITHOUT OIDS; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_new.sql000066400000000000000000000002441316501242600275240ustar00rootroot00000000000000CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_original.sql000066400000000000000000000002561316501242600305420ustar00rootroot00000000000000CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ) WITH OIDS;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/enable_force_rls_diff.sql000066400000000000000000000001361316501242600301120ustar00rootroot00000000000000 ALTER TABLE items ENABLE ROW LEVEL SECURITY; ALTER TABLE projects FORCE ROW LEVEL SECURITY; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/enable_force_rls_new.sql000066400000000000000000000002521316501242600277720ustar00rootroot00000000000000create table items ( id integer ); alter table items enable row level security; create table projects ( id integer ); alter table projects force row level security; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/enable_force_rls_original.sql000066400000000000000000000001141316501242600310020ustar00rootroot00000000000000create table items ( id integer ); create table projects ( id integer ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_alter_type_diff.sql000066400000000000000000000006571316501242600305170ustar00rootroot00000000000000ALTER FOREIGN TABLE foreign_to_alter ADD COLUMN IF NOT EXISTS country_code character varying(5), ALTER COLUMN ref2 TYPE character varying(20) USING ref2::character varying(20) /* TYPE change - table: foreign_to_alter original: character varying(60) new: character varying(20) */, ALTER COLUMN deleted TYPE numeric(1,0) USING deleted::numeric(1,0) /* TYPE change - table: foreign_to_alter original: boolean new: numeric(1,0) */; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_alter_type_new.sql000066400000000000000000000006461316501242600303760ustar00rootroot00000000000000CREATE FOREIGN TABLE foreign_to_alter ( id bigint, user_id bigint, ref1 character varying(60), ref2 character varying(20), inplay_stake_coef numeric, pre_match_stake_coef numeric, punter_limits character varying, name character varying(60), colour_cat character varying(30), deleted numeric(1,0), country_code character varying(5) ) SERVER ats OPTIONS ( updatable 'false' );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_alter_type_original.sql000066400000000000000000000005721316501242600314070ustar00rootroot00000000000000CREATE FOREIGN TABLE foreign_to_alter ( id bigint, user_id bigint, ref1 character varying(60), ref2 character varying(60), inplay_stake_coef numeric, pre_match_stake_coef numeric, punter_limits character varying, name character varying(60), colour_cat character varying(30), deleted boolean ) SERVER ats OPTIONS ( updatable 'false' );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_create_table_diff.sql000066400000000000000000000001621316501242600307500ustar00rootroot00000000000000 CREATE FOREIGN TABLE IF NOT EXISTS foreign_to_create ( id bigint )SERVER ats OPTIONS ( updatable 'false' ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_create_table_new.sql000066400000000000000000000001451316501242600306320ustar00rootroot00000000000000 CREATE FOREIGN TABLE foreign_to_create ( id bigint ) SERVER ats OPTIONS ( updatable 'false' ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_create_table_original.sql000066400000000000000000000000001316501242600316330ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_drop_table_diff.sql000066400000000000000000000000571316501242600304540ustar00rootroot00000000000000 DROP FOREIGN TABLE IF EXISTS foreign_to_drop; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_drop_table_new.sql000066400000000000000000000000001316501242600303210ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/foreign_drop_table_original.sql000066400000000000000000000001441316501242600313450ustar00rootroot00000000000000CREATE FOREIGN TABLE foreign_to_drop ( id bigint ) SERVER ats OPTIONS ( updatable 'false' );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_diff.sql000066400000000000000000000004001316501242600300560ustar00rootroot00000000000000CREATE OR REPLACE FUNCTION f_obj_execute_node_select(in_id_model bigint, in_id_object text, in_arr_val text, in_mode bigint) RETURNS bigint LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_ret bigint; BEGIN RETURN v_ret + 1; END; $$;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_new.sql000066400000000000000000000003651316501242600277510ustar00rootroot00000000000000CREATE FUNCTION f_obj_execute_node_select(in_id_model bigint, in_id_object text, in_arr_val text, in_mode bigint) RETURNS bigint LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_ret bigint; BEGIN RETURN v_ret + 1; END; $$;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_original.sql000066400000000000000000000003611316501242600307600ustar00rootroot00000000000000CREATE FUNCTION f_obj_execute_node_select(in_id_model bigint, in_id_object text, in_arr_val text, in_mode bigint) RETURNS bigint LANGUAGE plpgsql SECURITY DEFINER AS $$ DECLARE v_ret bigint; BEGIN RETURN v_ret; END; $$;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_diff.sql000066400000000000000000000000001316501242600320440ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_new.sql000066400000000000000000000006241316501242600317410ustar00rootroot00000000000000CREATE FUNCTION update_list_subscription_history() RETURNS "trigger" AS ' BEGIN INSERT INTO list_subscription_history (id, areaid, prefixid, msn, j4f_customer_id, subscriptiondate, seqid, refid, price, stopdate) VALUES (OLD.id, OLD.areaid, OLD.prefixid, OLD.msn, OLD.j4f_customer_id, OLD.subscriptiondate, OLD.seqid, OLD.refid, OLD.price, CURRENT_TIMESTAMP); RETURN OLD; END; ' LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_original.sql000066400000000000000000000006241316501242600327540ustar00rootroot00000000000000CREATE FUNCTION update_list_subscription_history() RETURNS "trigger" AS ' BEGIN INSERT INTO list_subscription_history (id, areaid, prefixid, msn, j4f_customer_id, subscriptiondate, seqid, refid, price, stopdate) VALUES (OLD.id, OLD.areaid, OLD.prefixid, OLD.msn, OLD.j4f_customer_id, OLD.subscriptiondate, OLD.seqid, OLD.refid, OLD.price, CURRENT_TIMESTAMP); RETURN OLD; END; ' LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_columns_diff.sql000066400000000000000000000007201316501242600301740ustar00rootroot00000000000000REVOKE ALL (id) ON TABLE todos FROM admin; GRANT ALL (id) ON TABLE todos TO admin; REVOKE ALL (name) ON TABLE todos FROM anonymous; REVOKE ALL (name) ON TABLE todos FROM admin; GRANT ALL (name) ON TABLE todos TO admin; REVOKE ALL (id) ON TABLE todos_view FROM admin; GRANT ALL (id) ON TABLE todos_view TO admin; REVOKE ALL (name) ON TABLE todos_view FROM anonymous; REVOKE ALL (name) ON TABLE todos_view FROM admin; GRANT ALL (name) ON TABLE todos_view TO admin; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_columns_new.sql000066400000000000000000000005331316501242600300570ustar00rootroot00000000000000create table todos ( id integer, name text ); grant select(id) on todos to anonymous; grant all (id, name) on todos to admin; create view todos_view as select id, name from todos; grant select(id) on todos_view to anonymous; grant all (id, name) on todos_view to admin; -- Just to make sure it gets ignored grant webuser to anonymous; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_columns_original.sql000066400000000000000000000004171316501242600310730ustar00rootroot00000000000000create table todos ( id integer, name text ); grant select(id, name) on todos to anonymous; create view todos_view as select id, name from todos; grant select(id, name) on todos_view to anonymous; -- Just to make sure it gets ignored grant webuser to anonymous; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_diff.sql000066400000000000000000000004361316501242600314770ustar00rootroot00000000000000 REVOKE ALL ON SEQUENCE table1_id_seq FROM public; GRANT SELECT, USAGE ON SEQUENCE table1_id_seq TO public; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; REVOKE ALL ON TABLE table1 FROM public; GRANT SELECT, UPDATE ON TABLE table1 TO public;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_new.sql000066400000000000000000000054431316501242600313630ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 20:51:36 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2144 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 2020 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2022 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2143 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; -- -- TOC entry 2147 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; -- Completed on 2016-03-28 20:51:36 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_original.sql000066400000000000000000000046641316501242600324020ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 20:49:16 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2144 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 2020 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2022 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2143 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- Completed on 2016-03-28 20:49:16 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_diff.sql000066400000000000000000000001271316501242600274670ustar00rootroot00000000000000 REVOKE ALL ON TABLE view1 FROM public; GRANT SELECT, INSERT ON TABLE view1 TO public; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_new.sql000066400000000000000000000062571316501242600273620ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 21:21:00 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 183 (class 1259 OID 17716) -- Name: view1; Type: VIEW; Schema: public; Owner: dv -- CREATE VIEW view1 AS SELECT table1.id, table1.msg, table1.date_create FROM table1; ALTER TABLE view1 OWNER TO dv; -- -- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- -- TOC entry 2152 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -- -- TOC entry 2153 (class 0 OID 0) -- Dependencies: 183 -- Name: view1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; GRANT SELECT,INSERT ON TABLE view1 TO PUBLIC; -- Completed on 2016-03-28 21:21:00 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_original.sql000066400000000000000000000062011316501242600303620ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 21:18:55 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 183 (class 1259 OID 17716) -- Name: view1; Type: VIEW; Schema: public; Owner: dv -- CREATE VIEW view1 AS SELECT table1.id, table1.msg, table1.date_create FROM table1; ALTER TABLE view1 OWNER TO dv; -- -- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- -- TOC entry 2152 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -- -- TOC entry 2153 (class 0 OID 0) -- Dependencies: 183 -- Name: view1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; -- Completed on 2016-03-28 21:18:55 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/inherited_tables_diff.sql000066400000000000000000000000001316501242600301210ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/000077500000000000000000000000001316501242600243635ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_1.sql000066400000000000000000000015021316501242600265620ustar00rootroot00000000000000CREATE TABLE fax_boxes ( fax_box_id serial NOT NULL, name text, CONSTRAINT fax_boxes_pkey PRIMARY KEY (fax_box_id) ); CREATE TABLE extensions (id serial NOT NULL); ALTER TABLE fax_boxes OWNER TO postgres; ALTER TABLE extensions ADD FOREIGN KEY (fax_box_id) REFERENCES fax_boxes (fax_box_id) ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE faxes ( fax_id serial NOT NULL, fax_box_id int4, from_name text, from_number text, status int4, -- 1=pending, 2=failed, 3=received pages int4, time_received timestamp DEFAULT now(), time_finished_received timestamp, "read" int2 DEFAULT 0, station_id text, CONSTRAINT faxes_pkey PRIMARY KEY (fax_id), CONSTRAINT faxes_fax_box_id_fkey FOREIGN KEY (fax_box_id) REFERENCES fax_boxes (fax_box_id) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE ); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_10.sql000066400000000000000000000016611316501242600266500ustar00rootroot00000000000000CREATE SCHEMA admin; ALTER SCHEMA admin OWNER TO postgres; SET search_path = admin, pg_catalog; CREATE TABLE acl_role ( id bigint NOT NULL ); ALTER TABLE admin.acl_role OWNER TO postgres; ALTER TABLE ONLY acl_role ADD CONSTRAINT acl_role_pkey PRIMARY KEY (id); CREATE TABLE "user" ( id bigint NOT NULL, email character varying(255) NOT NULL, name character varying(255) NOT NULL, password character varying(40) NOT NULL, is_active boolean DEFAULT false NOT NULL, updated timestamp without time zone DEFAULT now() NOT NULL, created timestamp without time zone DEFAULT now() NOT NULL, role_id bigint NOT NULL, last_visit timestamp without time zone DEFAULT now() NOT NULL ); ALTER TABLE admin."user" OWNER TO postgres; CREATE INDEX fki_user_role_id_fkey ON "user" USING btree (role_id); ALTER TABLE ONLY "user" ADD CONSTRAINT user_role_id_fkey FOREIGN KEY (role_id) REFERENCES acl_role(id);apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_11.sql000066400000000000000000000001411316501242600266410ustar00rootroot00000000000000CREATE FUNCTION curdate() RETURNS date LANGUAGE sql AS $$SELECT CAST('now' AS date); $$; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_12.sql000066400000000000000000000001251316501242600266440ustar00rootroot00000000000000COMMENT ON DATABASE testdb IS 'The status : ''E'' for enabled, ''D'' for disabled.'; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_13.sql000066400000000000000000000002401316501242600266430ustar00rootroot00000000000000CREATE FUNCTION drop_fk_except_for(tables_in character varying[]) RETURNS SETOF character varying LANGUAGE plpgsql AS $$ DECLARE BEGIN -- aaa END; $$;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_14.sql000066400000000000000000000076571316501242600266670ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: comments; Type: COMMENT; Schema: -; Owner: fordfrog -- COMMENT ON DATABASE comments IS 'comments database'; COMMENT ON SCHEMA public IS 'public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres -- CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql; ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; SET search_path = public, pg_catalog; -- -- Name: test_fnc(character varying); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_fnc(arg character varying) RETURNS boolean LANGUAGE plpgsql AS $$BEGIN RETURN true; END;$$; ALTER FUNCTION public.test_fnc(arg character varying) OWNER TO fordfrog; -- -- Name: FUNCTION test_fnc(arg character varying); Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON FUNCTION test_fnc(arg character varying) IS 'test function'; -- -- Name: trigger_fnc(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION trigger_fnc() RETURNS trigger LANGUAGE plpgsql AS $$begin end;$$; ALTER FUNCTION public.trigger_fnc() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test ( id integer NOT NULL, text character varying(20) NOT NULL, CONSTRAINT text_check CHECK ((length((text)::text) > 0)) ); ALTER TABLE public.test OWNER TO fordfrog; COMMENT ON TABLE test IS 'test table'; -- -- Name: COLUMN test.id; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON COLUMN test.id IS 'id column'; -- -- Name: COLUMN test.text; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON COLUMN test.text IS 'text column'; -- -- Name: CONSTRAINT text_check ON test; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON CONSTRAINT text_check ON test IS 'text check'; -- -- Name: test_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE test_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE public.test_id_seq OWNER TO fordfrog; -- -- Name: test_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE test_id_seq OWNED BY test.id; -- -- Name: SEQUENCE test_id_seq; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON SEQUENCE test_id_seq IS 'test table sequence'; -- -- Name: test_view; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW test_view AS SELECT test.id, test.text FROM test; ALTER TABLE public.test_view OWNER TO fordfrog; -- -- Name: VIEW test_view; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON VIEW test_view IS 'test view'; -- -- Name: COLUMN test_view.id; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON COLUMN test_view.id IS 'view id col'; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq'::regclass); -- -- Name: test_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test ADD CONSTRAINT test_pkey PRIMARY KEY (id); -- -- Name: INDEX test_pkey; Type: COMMENT; Schema: public; Owner: fordfrog -- COMMENT ON INDEX test_pkey IS 'primary key'; -- -- Name: test_trigger; Type: TRIGGER; Schema: public; Owner: fordfrog -- CREATE TRIGGER test_trigger BEFORE UPDATE ON test FOR EACH STATEMENT EXECUTE PROCEDURE trigger_fnc(); COMMENT ON TRIGGER test_trigger ON test IS 'test trigger'; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_15.sql000066400000000000000000000001161316501242600266470ustar00rootroot00000000000000CREATE TABLE test (id bigint); COMMENT ON TABLE test IS 'multiline comment ';apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_16.sql000066400000000000000000000027211316501242600266540ustar00rootroot00000000000000CREATE TABLE cities ( id bigint NOT NULL, regionid bigint DEFAULT 0, loc_region_id bigint DEFAULT 0, name character varying(255) DEFAULT NULL::character varying, name_genitive character varying(255), name_prepositional character varying(255) DEFAULT NULL::character varying, name_ukr character varying(255) DEFAULT NULL::character varying, name_ukr_genetive character varying(255), name_ukr_prepositional character varying(255) DEFAULT NULL::character varying, translit character varying(255) DEFAULT NULL::character varying, mainflag smallint DEFAULT 0 NOT NULL, importance smallint DEFAULT 0, size smallint DEFAULT 1, population numeric(7,0), map boolean DEFAULT false NOT NULL, domain character varying(255) DEFAULT NULL::character varying, renta_item_count bigint DEFAULT 0 NOT NULL, class_flat_count integer[] DEFAULT ARRAY[0, 0, 0, 0], class_room_count integer[] DEFAULT ARRAY[0, 0, 0, 0], class_house_count integer[] DEFAULT ARRAY[0, 0, 0, 0], class_area_count integer[] DEFAULT ARRAY[0, 0, 0, 0], class_commercial_count integer[] DEFAULT ARRAY[0, 0, 0, 0], pos integer DEFAULT 0, user_id bigint DEFAULT 0 NOT NULL, mod_user_id bigint DEFAULT 0 NOT NULL, name_vector tsvector, name_lower character varying(255), name_ukr_lower character varying(255), created timestamp without time zone, modified timestamp without time zone, tel_code character varying(8) );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_17.sql000066400000000000000000000000611316501242600266500ustar00rootroot00000000000000CREATE TABLE test ( test TEXT DEFAULT '*/' );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_2.sql000066400000000000000000000002271316501242600265660ustar00rootroot00000000000000CREATE TABLE contacts(id int PRIMARY KEY, number_pool_id int, name varchar(50)); CREATE INDEX contacts_number_pool_id_idx ON contacts(number_pool_id);apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_3.sql000066400000000000000000000017351316501242600265740ustar00rootroot00000000000000-- -- TOC Entry ID 2 (OID 605638) -- -- Name: admins_aid_seq Type: SEQUENCE Owner: xxxx -- CREATE SEQUENCE "admins_aid_seq" start 1 increment 1 maxvalue 1000000000 minvalue 1 cache 1; -- -- TOC Entry ID 108 (OID 605640) -- -- Name: admins Type: TABLE Owner: enki -- CREATE TABLE "admins" ( "aid" integer DEFAULT nextval('"admins_aid_seq"'::text) NOT NULL, "companyid" integer DEFAULT 0 NOT NULL, "groupid" integer DEFAULT 0 NOT NULL, "username" character varying NOT NULL, "password" character varying(40) NOT NULL, "superuser" boolean DEFAULT 'f'::bool NOT NULL, "name" character varying(40), "surname" character varying(40), "email" character varying(100) NOT NULL, "tel" character varying(40), "mobile" character varying(40), "enabled" boolean DEFAULT 't'::bool NOT NULL, "lastlogints" timestamp with time zone DEFAULT now() NOT NULL, "expirienced" boolean DEFAULT 'f'::bool, Constraint "admins_pkey" Primary Key ("aid") );apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_4.sql000066400000000000000000000002141316501242600265640ustar00rootroot00000000000000CREATE TABLE call_logs ( id bigint NOT NULL ); ALTER TABLE call_logs ALTER COLUMN id SET DEFAULT nextval('call_logs_id_seq'::regclass);apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_5.sql000066400000000000000000000013341316501242600265710ustar00rootroot00000000000000CREATE FUNCTION gtsq_in(cstring) RETURNS gtsq AS '$libdir/tsearch2', 'gtsq_in' LANGUAGE c STRICT; CREATE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql STRICT; CREATE FUNCTION select_something(number1 integer, number2 integer) RETURNS integer AS $_$SELECT number1 * number2$_$ LANGUAGE plpgsql; CREATE FUNCTION select_something2(number1 integer, number2 integer) RETURNS integer AS 'SELECT number1 * number2 || \'text\'' LANGUAGE plpgsql; CREATE FUNCTION select_something3(number1 integer, number2 integer) RETURNS integer AS ' SELECT number1 * number2 || \'text\' ' LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_6.sql000066400000000000000000000024441316501242600265750ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres -- CREATE PROCEDURAL LANGUAGE plpgsql; CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: postgres; Tablespace: -- CREATE TABLE test_table ( id bigint, date_deleted timestamp without time zone ); ALTER TABLE public.test_table OWNER TO postgres; -- -- Name: test_table_deleted; Type: INDEX; Schema: public; Owner: postgres; Tablespace: -- CREATE INDEX test_table_deleted ON test_table USING btree (date_deleted) WHERE (date_deleted IS NULL); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_7.sql000066400000000000000000000022411316501242600265710ustar00rootroot00000000000000-- -- Name: common; Type: SCHEMA; Schema: -; Owner: common -- CREATE SCHEMA common; SET search_path = common, pg_catalog; -- -- Name: t_common_casttotext(time with time zone); Type: FUNCTION; Schema: common; Owner: postgres -- CREATE FUNCTION t_common_casttotext(time with time zone) RETURNS text AS $_$SELECT textin(timetz_out($1));$_$ LANGUAGE sql IMMUTABLE STRICT; -- -- Name: t_common_casttotext(time without time zone); Type: FUNCTION; Schema: common; Owner: postgres -- CREATE FUNCTION t_common_casttotext(time without time zone) RETURNS text AS $_$SELECT textin(time_out($1));$_$ LANGUAGE sql IMMUTABLE STRICT; -- -- Name: t_common_casttotext(timestamp with time zone); Type: FUNCTION; Schema: common; Owner: postgres -- CREATE FUNCTION t_common_casttotext(timestamp with time zone) RETURNS text AS $_$SELECT textin(timestamptz_out($1));$_$ LANGUAGE sql IMMUTABLE STRICT; -- -- Name: t_common_casttotext(timestamp without time zone); Type: FUNCTION; Schema: common; Owner: postgres -- CREATE FUNCTION t_common_casttotext(timestamp without time zone) RETURNS text AS $_$SELECT textin(timestamp_out($1));$_$ LANGUAGE sql IMMUTABLE STRICT;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_8.sql000066400000000000000000000015711316501242600265770ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'LATIN2'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: testtt; Type: TYPE; Schema: public; Owner: madej -- CREATE TYPE testtt AS ( a integer, b text ); ALTER TYPE public.testtt OWNER TO madej; -- -- Name: .x(integer); Type: FUNCTION; Schema: public; Owner: madej -- CREATE FUNCTION ".x"(integer) RETURNS boolean AS $_$ declare begin raise notice 'inside: %', $1; return true; end; $_$ LANGUAGE plpgsql; ALTER FUNCTION public.".x"(integer) OWNER TO madej; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_9.sql000066400000000000000000000022551316501242600266000ustar00rootroot00000000000000CREATE TABLE user_data ( id bigint NOT NULL, email character varying(128) NOT NULL, created timestamp with time zone DEFAULT now() ); ALTER TABLE public.user_data OWNER TO postgres; CREATE SEQUENCE user_id_seq INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.user_id_seq OWNER TO postgres; ALTER SEQUENCE user_id_seq OWNED BY user_data.id; ALTER TABLE user_data ALTER COLUMN id SET DEFAULT nextval('user_id_seq'::regclass); CREATE VIEW "user" AS SELECT user_data.id, user_data.email, user_data.created FROM user_data; ALTER TABLE public."user" OWNER TO postgres; ALTER VIEW public."user" OWNER TO postgres; ALTER TABLE "user" ALTER COLUMN created SET DEFAULT now(); ALTER VIEW "user" ALTER COLUMN created SET DEFAULT now(); CREATE RULE on_delete AS ON DELETE TO "user" DO INSTEAD DELETE FROM user_data WHERE (user_data.id = old.id); CREATE RULE on_insert AS ON INSERT TO "user" DO INSTEAD (INSERT INTO user_data (id, email, created) VALUES (new.id, new.email, new.created)); CREATE RULE on_update AS ON UPDATE TO "user" DO INSTEAD (UPDATE user_data SET id = new.id, email = new.email, created = new.created WHERE (user_data.id = old.id));apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_diff.sql000066400000000000000000000001701316501242600276540ustar00rootroot00000000000000 CREATE INDEX IF NOT EXISTS testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_new.sql000066400000000000000000000023761316501242600275470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: testindex2; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_original.sql000066400000000000000000000021511316501242600305510ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); ALTER TABLE testtable CLUSTER ON testindex; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_diff.sql000066400000000000000000000005161316501242600305350ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field1 TYPE integer USING field1::integer /* TYPE change - table: testtable original: smallint new: integer */, ALTER COLUMN field3 TYPE character varying(150) USING field3::character varying(150) /* TYPE change - table: testtable original: character varying(100) new: character varying(150) */; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_new.sql000066400000000000000000000016521316501242600304200ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_original.sql000066400000000000000000000016531316501242600314340ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 smallint, field2 integer, field3 character varying(100) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_diff.sql000066400000000000000000000002541316501242600303620ustar00rootroot00000000000000 ALTER TABLE testtable DROP CONSTRAINT IF EXISTS field4check; ALTER TABLE testtable ADD CONSTRAINT IF NOT EXISTS field4check CHECK ((field4 > (0.0)::double precision)); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_new.sql000066400000000000000000000024571316501242600302520ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL, CONSTRAINT field4check CHECK ((field4 > (0.0)::double precision)) ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_original.sql000066400000000000000000000025311316501242600312560ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision, "full" timestamp with time zone DEFAULT '2006-11-10 00:00:00+01'::timestamp with time zone NOT NULL, CONSTRAINT field4check CHECK (((field4 > (-5.0)::double precision) AND (field4 < (5.0)::double precision))) ); ALTER TABLE ONLY testtable ALTER COLUMN "full" SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_diff.sql000066400000000000000000000000751316501242600310170ustar00rootroot00000000000000 ALTER TABLE testtable ALTER COLUMN field4 SET DEFAULT 1.0; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_inherited_column_diff.sql000066400000000000000000000001111316501242600344160ustar00rootroot00000000000000 ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_inherited_column_new.sql000066400000000000000000000013651316501242600343130ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); -- -- Name: childtable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE childtable ( ) INHERITS (parenttable); -- -- Name: parenttable_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 1; -- -- PostgreSQL database dump complete --modify_default_value_inherited_column_original.sql000066400000000000000000000013651316501242600352470ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE parenttable ( parenttable_id integer NOT NULL, parenttable_date timestamptz NOT NULL ); -- -- Name: childtable; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE childtable ( ) INHERITS (parenttable); -- -- Name: parenttable_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY childtable ALTER COLUMN parenttable_id SET DEFAULT 0; -- -- PostgreSQL database dump complete --apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_new.sql000066400000000000000000000021101316501242600306700ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision DEFAULT 1.0 ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_original.sql000066400000000000000000000021101316501242600317030ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision DEFAULT 0.0 ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_diff.sql000066400000000000000000000002601316501242600311160ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_new.sql000066400000000000000000000027021316501242600310020ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_original.sql000066400000000000000000000026731316501242600320240ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number1 integer, number2 integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_diff.sql000066400000000000000000000002211316501242600310310ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION power_number(number integer) RETURNS integer AS $$ begin return number * number; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_new.sql000066400000000000000000000026001316501242600307150ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: power_number(integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION power_number(number integer) RETURNS integer AS $$ begin return number * number; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.power_number(number integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_original.sql000066400000000000000000000026001316501242600317300ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: power_number(integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION power_number("input" integer) RETURNS integer AS $$ begin return input * input; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.power_number("input" integer) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_diff.sql000066400000000000000000000013301316501242600327030ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION afunction(text, text, numeric) RETURNS numeric AS ' DECLARE param1 ALIAS FOR $1; param2 ALIAS FOR $2; param3 ALIAS FOR $3; avg NUMERIC; BEGIN IF param1 = ''value1'' AND param2 = ''value2'' THEN IF param3 = 0 THEN RETURN -0.35; ELSE IF param3 > 60 THEN avg = 0; ELSE avg = 0.29; END IF; END IF; RETURN round(avg, 2); END IF; IF param1 = ''value1'' AND param2 = ''value2'' THEN IF param3 = 0 THEN RETURN -0.35; ELSE IF param3 > 60 THEN avg = 0; ELSE avg = 0.29; END IF; END IF; RETURN round(avg, 2); END IF; RAISE EXCEPTION ''No info''; END; ' LANGUAGE plpgsql IMMUTABLE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_new.sql000066400000000000000000000013131316501242600325650ustar00rootroot00000000000000CREATE FUNCTION afunction(text, text, numeric) RETURNS numeric AS ' DECLARE param1 ALIAS FOR $1; param2 ALIAS FOR $2; param3 ALIAS FOR $3; avg NUMERIC; BEGIN IF param1 = ''value1'' AND param2 = ''value2'' THEN IF param3 = 0 THEN RETURN -0.35; ELSE IF param3 > 60 THEN avg = 0; ELSE avg = 0.29; END IF; END IF; RETURN round(avg, 2); END IF; IF param1 = ''value1'' AND param2 = ''value2'' THEN IF param3 = 0 THEN RETURN -0.35; ELSE IF param3 > 60 THEN avg = 0; ELSE avg = 0.29; END IF; END IF; RETURN round(avg, 2); END IF; RAISE EXCEPTION ''No info''; END; ' LANGUAGE plpgsql IMMUTABLE;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_original.sql000066400000000000000000000007721316501242600336100ustar00rootroot00000000000000CREATE FUNCTION afunction(text, text, numeric) RETURNS numeric AS ' DECLARE param1 ALIAS FOR $1; param2 ALIAS FOR $2; param3 ALIAS FOR $3; avg NUMERIC; BEGIN IF param1 = ''value1'' AND param2 = ''value2'' THEN IF param3 = 0 THEN RETURN -0.35; ELSE IF param3 > 60 THEN avg = 0; ELSE avg = 0.29; END IF; END IF; RETURN round(avg, 2); END IF; RAISE EXCEPTION ''This is a very very different function''; END; ' LANGUAGE plpgsql IMMUTABLE;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_diff.sql000066400000000000000000000001701316501242600313710ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION return_one() RETURNS integer AS $$ begin return -1 + 2; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_new.sql000066400000000000000000000025161316501242600312600ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: return_one(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION return_one() RETURNS integer AS $$ begin return -1 + 2; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.return_one() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_original.sql000066400000000000000000000025111316501242600322660ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: return_one(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION return_one() RETURNS integer AS $$ begin return 1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.return_one() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_diff.sql000066400000000000000000000002631316501242600315430ustar00rootroot00000000000000 CREATE OR REPLACE FUNCTION multiply_numbers(number1 smallint, number2 smallint) RETURNS smallint AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_new.sql000066400000000000000000000034571316501242600314340ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; -- -- Name: multiply_numbers(smallint, smallint); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number1 smallint, number2 smallint) RETURNS smallint AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number1 smallint, number2 smallint) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_original.sql000066400000000000000000000034571316501242600324470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: multiply_numbers(integer, integer); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 integer, number1 integer) OWNER TO fordfrog; -- -- Name: multiply_numbers(smallint, smallint); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION multiply_numbers(number2 smallint, number1 smallint) RETURNS smallint AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.multiply_numbers(number2 smallint, number1 smallint) OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_pkey; Type: CONSTRAINT; Schema: public; Owner: fordfrog; Tablespace: -- ALTER TABLE ONLY test_table ADD CONSTRAINT test_table_pkey PRIMARY KEY (id); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_index_diff.sql000066400000000000000000000001521316501242600273020ustar00rootroot00000000000000 DROP INDEX IF EXISTS testindex; CREATE INDEX IF NOT EXISTS testindex ON testtable USING btree (field3); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_index_new.sql000066400000000000000000000020741316501242600271700ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_index_original.sql000066400000000000000000000020741316501242600302030ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field1); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_diff.sql000066400000000000000000000005111316501242600300170ustar00rootroot00000000000000 CREATE TABLE IF NOT EXISTS parenttable2 ( id bigserial NOT NULL ); ALTER TABLE parenttable2 OWNER TO fordfrog; ALTER TABLE parenttable DROP COLUMN IF EXISTS id, ADD COLUMN IF NOT EXISTS field3 information_schema.cardinal_number; ALTER TABLE testtable NO INHERIT parenttable; ALTER TABLE testtable INHERIT parenttable2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_new.sql000066400000000000000000000023551316501242600277100ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( field3 information_schema.cardinal_number ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: parenttable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable2 ( id bigserial NOT NULL ); ALTER TABLE public.parenttable2 OWNER TO fordfrog; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 polygon ) INHERITS (parenttable2); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_original.sql000066400000000000000000000020201316501242600307100ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( id bigserial NOT NULL ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 polygon ) INHERITS (parenttable); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_materialized_view_diff.sql000066400000000000000000000002071316501242600317000ustar00rootroot00000000000000 DROP MATERIALIZED VIEW IF EXISTS testview; CREATE MATERIALIZED VIEW testview AS SELECT testtable.name, testtable.id FROM testtable; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_materialized_view_new.sql000066400000000000000000000023041316501242600315610ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE MATERIALIZED VIEW testview AS SELECT testtable.name, testtable.id FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_materialized_view_original.sql000066400000000000000000000023041316501242600325740ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE MATERIALIZED VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_diff.sql000066400000000000000000000000431316501242600311250ustar00rootroot00000000000000 ALTER SEQUENCE testseq CACHE 10; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_new.sql000066400000000000000000000014421316501242600310120ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 10; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_original.sql000066400000000000000000000014411316501242600320240ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_diff.sql000066400000000000000000000000431316501242600320130ustar00rootroot00000000000000 ALTER SEQUENCE testseq NO CYCLE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_new.sql000066400000000000000000000014411316501242600316770ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_original.sql000066400000000000000000000014531316501242600327150ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1 CYCLE; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_diff.sql000066400000000000000000000000401316501242600316520ustar00rootroot00000000000000 ALTER SEQUENCE testseq CYCLE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_new.sql000066400000000000000000000014531316501242600315440ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1 CYCLE; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_original.sql000066400000000000000000000014411316501242600325540ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_diff.sql000066400000000000000000000000521316501242600320460ustar00rootroot00000000000000 ALTER SEQUENCE testseq INCREMENT BY 10; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_new.sql000066400000000000000000000014421316501242600317330ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 10 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_original.sql000066400000000000000000000014411316501242600327450ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_diff.sql000066400000000000000000000000731316501242600325620ustar00rootroot00000000000000 ALTER SEQUENCE testseq MAXVALUE 1000 RESTART WITH 1000; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_new.sql000066400000000000000000000014471316501242600324510ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 MAXVALUE 1000 NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_original.sql000066400000000000000000000014421316501242600334570ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 10 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_diff.sql000066400000000000000000000000461316501242600331250ustar00rootroot00000000000000 ALTER SEQUENCE testseq NO MAXVALUE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_new.sql000066400000000000000000000014451316501242600330120ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_original.sql000066400000000000000000000014471316501242600340270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 MAXVALUE 1000 NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_diff.sql000066400000000000000000000000731316501242600325600ustar00rootroot00000000000000 ALTER SEQUENCE testseq MINVALUE 1000 RESTART WITH 1000; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_new.sql000066400000000000000000000014471316501242600324470ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 NO MAXVALUE MINVALUE 1000 CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_original.sql000066400000000000000000000014421316501242600334550ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 10 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_diff.sql000066400000000000000000000000461316501242600331230ustar00rootroot00000000000000 ALTER SEQUENCE testseq NO MINVALUE; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_new.sql000066400000000000000000000014451316501242600330100ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_original.sql000066400000000000000000000014471316501242600340250ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 10 NO MAXVALUE MINVALUE 1000 CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_diff.sql000066400000000000000000000000541316501242600334160ustar00rootroot00000000000000 ALTER SEQUENCE testseq RESTART WITH 1000; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_new.sql000066400000000000000000000024421316501242600333020ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_original.sql000066400000000000000000000024371316501242600343210ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_diff.sql000066400000000000000000000000001316501242600332470ustar00rootroot00000000000000apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_new.sql000066400000000000000000000024421316501242600331440ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1000 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_original.sql000066400000000000000000000024371316501242600341630ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; -- -- Name: testseq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testseq OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_diff.sql000066400000000000000000000001041316501242600303620ustar00rootroot00000000000000 ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 200; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_new.sql000066400000000000000000000021771316501242600302570ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 200; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_original.sql000066400000000000000000000021771316501242600312720ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 100; ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testindex; Type: INDEX; Schema: public; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_diff.sql000066400000000000000000000003071316501242600276400ustar00rootroot00000000000000 DROP TRIGGER IF EXISTS test_table_trigger ON test_table; CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE OF id ON test_table FOR EACH STATEMENT EXECUTE PROCEDURE test_table_trigger(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_new.sql000066400000000000000000000026331316501242600275250ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: test_table_trigger(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.test_table_trigger() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_trigger; Type: TRIGGER; Schema: public; Owner: fordfrog -- CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE OF id ON test_table FOR EACH STATEMENT EXECUTE PROCEDURE test_table_trigger(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_original.sql000066400000000000000000000026171316501242600305420ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -- CREATE PROCEDURAL LANGUAGE plpgsql; SET search_path = public, pg_catalog; -- -- Name: test_table_trigger(); Type: FUNCTION; Schema: public; Owner: fordfrog -- CREATE FUNCTION test_table_trigger() RETURNS "trigger" AS $$ begin return NEW; end; $$ LANGUAGE plpgsql; ALTER FUNCTION public.test_table_trigger() OWNER TO fordfrog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test_table; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE test_table ( id serial NOT NULL ); ALTER TABLE public.test_table OWNER TO fordfrog; -- -- Name: test_table_trigger; Type: TRIGGER; Schema: public; Owner: fordfrog -- CREATE TRIGGER test_table_trigger BEFORE INSERT OR UPDATE ON test_table FOR EACH ROW EXECUTE PROCEDURE test_table_trigger(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_view_diff.sql000066400000000000000000000001551316501242600271500ustar00rootroot00000000000000 DROP VIEW IF EXISTS testview; CREATE VIEW testview AS SELECT testtable.name, testtable.id FROM testtable; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_view_new.sql000066400000000000000000000022671316501242600270370ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.name, testtable.id FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/modify_view_original.sql000066400000000000000000000022671316501242600300520ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_diff.sql000066400000000000000000000016101316501242600301620ustar00rootroot00000000000000 DROP SCHEMA IF EXISTS testschema1 CASCADE; CREATE SCHEMA IF NOT EXISTS testschema2; SET search_path = public, pg_catalog; DROP TABLE IF EXISTS testtable2; DROP SEQUENCE IF EXISTS testtable2_id_seq; CREATE SEQUENCE IF NOT EXISTS testtable3_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE IF NOT EXISTS testtable3 ( id bigint DEFAULT nextval('testtable3_id_seq'::regclass) NOT NULL ); ALTER TABLE testtable3 OWNER TO fordfrog; ALTER SEQUENCE testtable3_id_seq OWNED BY testtable3.id; SET search_path = testschema2, pg_catalog; CREATE SEQUENCE IF NOT EXISTS testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE IF NOT EXISTS testtable1 ( id integer DEFAULT nextval('testtable1_id_seq'::regclass) NOT NULL ); ALTER TABLE testtable1 OWNER TO fordfrog; ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_new.sql000066400000000000000000000077651316501242600300640ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: testschema2; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA testschema2; ALTER SCHEMA testschema2 OWNER TO fordfrog; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id bigint NOT NULL ); ALTER TABLE public.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); -- -- Name: testtable3; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable3 ( id bigint NOT NULL ); ALTER TABLE public.testtable3 OWNER TO fordfrog; -- -- Name: testtable3_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable3_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable3_id_seq OWNER TO fordfrog; -- -- Name: testtable3_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable3_id_seq OWNED BY testtable3.id; -- -- Name: testtable3_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable3_id_seq', 1, false); SET search_path = testschema2, pg_catalog; -- -- Name: testtable1; Type: TABLE; Schema: testschema2; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id integer NOT NULL ); ALTER TABLE testschema2.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: testschema2; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE testschema2.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: testschema2; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: testschema2; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); SET search_path = public, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable3 ALTER COLUMN id SET DEFAULT nextval('testtable3_id_seq'::regclass); SET search_path = testschema2, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: testschema2; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); SET search_path = public, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Data for Name: testtable3; Type: TABLE DATA; Schema: public; Owner: fordfrog -- SET search_path = testschema2, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: testschema2; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_original.sql000066400000000000000000000077661316501242600311000ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; -- -- Name: testschema1; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA testschema1; ALTER SCHEMA testschema1 OWNER TO fordfrog; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable1; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id bigint NOT NULL ); ALTER TABLE public.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); -- -- Name: testtable2; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer NOT NULL ); ALTER TABLE public.testtable2 OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE; Schema: public; Owner: fordfrog -- CREATE SEQUENCE testtable2_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE public.testtable2_id_seq OWNER TO fordfrog; -- -- Name: testtable2_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fordfrog -- ALTER SEQUENCE testtable2_id_seq OWNED BY testtable2.id; -- -- Name: testtable2_id_seq; Type: SEQUENCE SET; Schema: public; Owner: fordfrog -- SELECT pg_catalog.setval('testtable2_id_seq', 1, false); SET search_path = testschema1, pg_catalog; -- -- Name: testtable1; Type: TABLE; Schema: testschema1; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable1 ( id integer NOT NULL ); ALTER TABLE testschema1.testtable1 OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE; Schema: testschema1; Owner: fordfrog -- CREATE SEQUENCE testtable1_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; ALTER TABLE testschema1.testtable1_id_seq OWNER TO fordfrog; -- -- Name: testtable1_id_seq; Type: SEQUENCE OWNED BY; Schema: testschema1; Owner: fordfrog -- ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; -- -- Name: testtable1_id_seq; Type: SEQUENCE SET; Schema: testschema1; Owner: fordfrog -- SELECT pg_catalog.setval('testtable1_id_seq', 1, false); SET search_path = public, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); -- -- Name: id; Type: DEFAULT; Schema: public; Owner: fordfrog -- ALTER TABLE testtable2 ALTER COLUMN id SET DEFAULT nextval('testtable2_id_seq'::regclass); SET search_path = testschema1, pg_catalog; -- -- Name: id; Type: DEFAULT; Schema: testschema1; Owner: fordfrog -- ALTER TABLE testtable1 ALTER COLUMN id SET DEFAULT nextval('testtable1_id_seq'::regclass); SET search_path = public, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: public; Owner: fordfrog -- -- -- Data for Name: testtable2; Type: TABLE DATA; Schema: public; Owner: fordfrog -- SET search_path = testschema1, pg_catalog; -- -- Data for Name: testtable1; Type: TABLE DATA; Schema: testschema1; Owner: fordfrog -- -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_diff.sql000066400000000000000000000002601316501242600274450ustar00rootroot00000000000000 SET search_path = "ABC", pg_catalog; CREATE TABLE IF NOT EXISTS testtable2 ( id integer, name character varying(100) NOT NULL ); ALTER TABLE testtable2 OWNER TO fordfrog; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_new.sql000066400000000000000000000032041316501242600273270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: ABC; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA "ABC"; ALTER SCHEMA "ABC" OWNER TO fordfrog; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = "ABC", pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: ABC; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE "ABC".testtable OWNER TO fordfrog; -- -- Name: testtable2; Type: TABLE; Schema: ABC; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable2 ( id integer, name character varying(100) NOT NULL ); ALTER TABLE "ABC".testtable2 OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: ABC; Owner: fordfrog -- COPY testtable (field1, field2, field3, field4) FROM stdin; \. -- -- Data for Name: testtable2; Type: TABLE DATA; Schema: ABC; Owner: fordfrog -- COPY testtable2 (id, name) FROM stdin; \. -- -- Name: testindex; Type: INDEX; Schema: ABC; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_original.sql000066400000000000000000000024471316501242600303520ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: ABC; Type: SCHEMA; Schema: -; Owner: fordfrog -- CREATE SCHEMA "ABC"; ALTER SCHEMA "ABC" OWNER TO fordfrog; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = "ABC", pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: ABC; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ); ALTER TABLE "ABC".testtable OWNER TO fordfrog; -- -- Data for Name: testtable; Type: TABLE DATA; Schema: ABC; Owner: fordfrog -- COPY testtable (field1, field2, field3, field4) FROM stdin; \. -- -- Name: testindex; Type: INDEX; Schema: ABC; Owner: fordfrog; Tablespace: -- CREATE INDEX testindex ON testtable USING btree (field3); -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_diff.sql000066400000000000000000000001341316501242600274440ustar00rootroot00000000000000 ALTER TABLE testtable ADD COLUMN IF NOT EXISTS field2 information_schema.cardinal_number; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_new.sql000066400000000000000000000020761316501242600273340ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( id bigserial NOT NULL ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 bit(1), field2 information_schema.cardinal_number ) INHERITS (parenttable); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_original.sql000066400000000000000000000020171316501242600303420ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: parenttable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE parenttable ( id bigserial NOT NULL ); ALTER TABLE public.parenttable OWNER TO fordfrog; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( field1 bit(1) ) INHERITS (parenttable); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_diff.sql000066400000000000000000000001331316501242600316510ustar00rootroot00000000000000 REVOKE ALL ON SEQUENCE table1_id_seq FROM public; REVOKE ALL ON TABLE table1 FROM public;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_new.sql000066400000000000000000000060631316501242600315420ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 21:12:09 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2148 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 2020 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2138 (class 0 OID 17707) -- Dependencies: 182 -- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: dv -- COPY table1 (id, msg, date_create) FROM stdin; \. -- -- TOC entry 2150 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dv -- SELECT pg_catalog.setval('table1_id_seq', 1, false); -- -- TOC entry 2022 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2147 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- -- TOC entry 2149 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -- Completed on 2016-03-28 21:12:09 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_original.sql000066400000000000000000000054431316501242600325560ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 20:51:36 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2144 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2146 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 2020 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2022 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2143 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2145 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; -- -- TOC entry 2147 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; -- Completed on 2016-03-28 20:51:36 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_diff.sql000066400000000000000000000000461316501242600276470ustar00rootroot00000000000000REVOKE ALL ON TABLE view1 FROM public;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_new.sql000066400000000000000000000062011316501242600275270ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 21:18:55 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 183 (class 1259 OID 17716) -- Name: view1; Type: VIEW; Schema: public; Owner: dv -- CREATE VIEW view1 AS SELECT table1.id, table1.msg, table1.date_create FROM table1; ALTER TABLE view1 OWNER TO dv; -- -- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- -- TOC entry 2152 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -- -- TOC entry 2153 (class 0 OID 0) -- Dependencies: 183 -- Name: view1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; -- Completed on 2016-03-28 21:18:55 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_original.sql000066400000000000000000000062571316501242600305550ustar00rootroot00000000000000-- -- PostgreSQL database dump -- -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 -- Started on 2016-03-28 21:21:00 KRAT SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; -- -- TOC entry 1 (class 3079 OID 12395) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- TOC entry 182 (class 1259 OID 17707) -- Name: table1; Type: TABLE; Schema: public; Owner: dv -- CREATE TABLE table1 ( id integer NOT NULL, msg text, date_create timestamp without time zone ); ALTER TABLE table1 OWNER TO dv; -- -- TOC entry 181 (class 1259 OID 17705) -- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv -- CREATE SEQUENCE table1_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE table1_id_seq OWNER TO dv; -- -- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- -- TOC entry 183 (class 1259 OID 17716) -- Name: view1; Type: VIEW; Schema: public; Owner: dv -- CREATE VIEW view1 AS SELECT table1.id, table1.msg, table1.date_create FROM table1; ALTER TABLE view1 OWNER TO dv; -- -- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); -- -- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- ALTER TABLE ONLY table1 ADD CONSTRAINT table1_pkey PRIMARY KEY (id); -- -- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -- -- TOC entry 2152 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -- -- TOC entry 2153 (class 0 OID 0) -- Dependencies: 183 -- Name: view1; Type: ACL; Schema: public; Owner: dv -- REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; GRANT SELECT,INSERT ON TABLE view1 TO PUBLIC; -- Completed on 2016-03-28 21:21:00 KRAT -- -- PostgreSQL database dump complete -- apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_alias_with_quote_diff.sql000066400000000000000000000001301316501242600312130ustar00rootroot00000000000000DROP VIEW IF EXISTS foo; CREATE VIEW foo AS SELECT bar AS "Foo's bar" FROM tableName; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_alias_with_quote_new.sql000066400000000000000000000000741316501242600311030ustar00rootroot00000000000000CREATE VIEW foo AS SELECT bar AS "Foo's bar" FROM tableName;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_alias_with_quote_original.sql000066400000000000000000000001301316501242600321070ustar00rootroot00000000000000CREATE VIEW foo AS SELECT bar AS "Foo's bar", bar2 AS "Foo's second bar" FROM tableName;apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_diff.sql000066400000000000000000000000011316501242600272020ustar00rootroot00000000000000 apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_new.sql000066400000000000000000000002131316501242600270700ustar00rootroot00000000000000create table t ( pk serial primary key, t text default '' ); create view v as select * from t; alter view v alter column t set default ''; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_original.sql000066400000000000000000000002131316501242600301030ustar00rootroot00000000000000create table t ( pk serial primary key, t text default '' ); create view v as select * from t; alter view v alter column t set default ''; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_colnames_diff.sql000066400000000000000000000000721316501242600274600ustar00rootroot00000000000000DROP VIEW IF EXISTS vx; CREATE VIEW vx (x) AS select 2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_colnames_new.sql000066400000000000000000000000401316501242600273340ustar00rootroot00000000000000create view vx (x) as select 2; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_colnames_original.sql000066400000000000000000000000401316501242600303470ustar00rootroot00000000000000create view vx (x) as select 1; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_triggers_diff.sql000066400000000000000000000010041316501242600275010ustar00rootroot00000000000000DROP TRIGGER IF EXISTS trg_testview_instead_of_delete ON testview; DROP TRIGGER IF EXISTS trg_testview_instead_of_insert ON testview; CREATE TRIGGER trg_testview_instead_of_delete_new_name INSTEAD OF DELETE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_before_update BEFORE UPDATE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_after_insert AFTER INSERT ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_triggers_new.sql000066400000000000000000000036521316501242600273750ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; CREATE FUNCTION fn_trg_testview() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -- do nothing RETURN OLD; END; $$; ALTER FUNCTION public.fn_trg_testview() OWNER TO fordfrog; CREATE TRIGGER trg_testview_instead_of_delete_new_name INSTEAD OF DELETE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_instead_of_update INSTEAD OF UPDATE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_before_update before UPDATE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_after_insert after INSERT ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; REVOKE ALL ON FUNCTION fn_trg_testview() FROM PUBLIC; REVOKE ALL ON FUNCTION fn_trg_testview() FROM postgres; GRANT ALL ON FUNCTION fn_trg_testview() TO PUBLIC; GRANT ALL ON FUNCTION fn_trg_testview() TO postgres; apgdiff/src/test/resources/cz/startnet/utils/pgdiff/view_triggers_original.sql000066400000000000000000000034651316501242600304120ustar00rootroot00000000000000-- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; SET escape_string_warning = off; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: testtable; Type: TABLE; Schema: public; Owner: fordfrog; Tablespace: -- CREATE TABLE testtable ( id bigint, name character varying(30) ); ALTER TABLE public.testtable OWNER TO fordfrog; -- -- Name: testview; Type: VIEW; Schema: public; Owner: fordfrog -- CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; ALTER TABLE public.testview OWNER TO fordfrog; CREATE FUNCTION fn_trg_testview() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -- do nothing RETURN OLD; END; $$; ALTER FUNCTION public.fn_trg_testview() OWNER TO fordfrog; CREATE TRIGGER trg_testview_instead_of_delete INSTEAD OF DELETE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_instead_of_insert INSTEAD OF INSERT ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); CREATE TRIGGER trg_testview_instead_of_update INSTEAD OF UPDATE ON testview FOR EACH ROW EXECUTE PROCEDURE fn_trg_testview(); -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; REVOKE ALL ON FUNCTION fn_trg_testview() FROM PUBLIC; REVOKE ALL ON FUNCTION fn_trg_testview() FROM postgres; GRANT ALL ON FUNCTION fn_trg_testview() TO PUBLIC; GRANT ALL ON FUNCTION fn_trg_testview() TO postgres;