apgdiff-2.4/0000777000401600037200000000000012027121624012071 5ustar cbecredativapgdiff-2.4/build.xml0000644000401600037200000001057412027104464013720 0ustar cbecredativ apgdiff-2.4/README.md0000644000401600037200000001256112027115134013350 0ustar cbecredativ# Another PostgreSQL Diff Tool (aka apgdiff) Ahother 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://apgdiff.startnet.biz/ ## Changelog ### 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. #### 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-2.4/pom.xml0000644000401600037200000002213112027102044013374 0ustar cbecredativ 4.0.0 cz.startnet apgdiff Another PostgreSQL Diff Tool 2.4 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://apgdiff.startnet.biz/ SouceForge Tracker http://sourceforge.net/tracker/?group_id=163508 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:hg:http://apgdiff.hg.sourceforge.net:8000/hgroot/apgdiff/apgdiff scm:hg:ssh://apgdiff.hg.sourceforge.net/hgroot/apgdiff/apgdiff http://apgdiff.hg.sourceforge.net/hgweb/apgdiff/ StartNet s.r.o. http://www.startnet.biz maven-compiler-plugin 1.6 1.6 org.apache.maven.plugins maven-surefire-plugin maven-surefire-report-plugin maven-jar-plugin true lib cz.startnet.utils.pgdiff.Main org.apache.maven.plugins maven-source-plugin attach-sources verify jar org.apache.maven.plugins maven-javadoc-plugin attach-javadoc verify jar private org.apache.maven.plugins maven-assembly-plugin ${basedir}/src/main/assembly/bin.xml ${basedir}/src/main/assembly/src.xml false codehaus-plugins codehaus-plugins http://repository.codehaus.org/ false codehaus-snapshot-plugins codehaus-shapshot-plugins http://snapshots.repository.codehaus.org/ unto.net http://repository.unto.net/maven/ daily warn daily warn stat-scm-sourceforge http://stat-scm.sourceforge.net/maven2 stat-scm-sourceforge-snapshot http://stat-scm.sourceforge.net/maven2-snapshots junit junit 4.8.1 test org.hamcrest hamcrest-all 1.1 test maven-project-info-reports-plugin maven-javadoc-plugin 128m 512 1.6 1.6 todo a To do something: net.sf stat-scm maven-pmd-plugin utf-8 1.6 org.codehaus.mojo taglist-maven-plugin maven-jxr-plugin UTF-8 UTF-8 org.codehaus.mojo findbugs-maven-plugin Ignore Max apgdiff-2.4/license.txt0000644000401600037200000000205612007023242014246 0ustar cbecredativCopyright (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-2.4/src/0000755000401600037200000000000012007023242012647 5ustar cbecredativapgdiff-2.4/src/main/0000755000401600037200000000000012007023242013573 5ustar cbecredativapgdiff-2.4/src/main/assembly/0000755000401600037200000000000012027106274015423 5ustar cbecredativapgdiff-2.4/src/main/assembly/src.xml0000644000401600037200000000127412027106274016740 0ustar cbecredativ src zip ${project.artifactId}-${project.version} ${basedir}/src src ${basedir} build.xml pom.xml README.md license.txt apgdiff-2.4/src/main/assembly/bin.xml0000644000401600037200000000120112027106274016707 0ustar cbecredativ bin zip ${project.artifactId}-${project.version} ${project.build.directory}/${project.build.finalName}.${project.packaging} ${basedir}/license.txt ${basedir}/README.md apgdiff-2.4/src/main/resources/0000755000401600037200000000000012007023242015605 5ustar cbecredativapgdiff-2.4/src/main/resources/cz/0000755000401600037200000000000012007023242016221 5ustar cbecredativapgdiff-2.4/src/main/resources/cz/startnet/0000755000401600037200000000000012007023242020065 5ustar cbecredativapgdiff-2.4/src/main/resources/cz/startnet/utils/0000755000401600037200000000000012007023242021225 5ustar cbecredativapgdiff-2.4/src/main/resources/cz/startnet/utils/pgdiff/0000755000401600037200000000000012027101706022470 5ustar cbecredativapgdiff-2.4/src/main/resources/cz/startnet/utils/pgdiff/Resources_cs.properties0000644000401600037200000001066512027101706027255 0ustar cbecredativUsageHelp=\ 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} apgdiff-2.4/src/main/resources/cz/startnet/utils/pgdiff/Resources.properties0000644000401600037200000000645312027121564026574 0ustar cbecredativVersionNumber=2.4 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 default\n\ ${tab}value (the default value is dropped later)\n\ \n\ --add-transaction:\n\ ${tab}adds START TRANSACTION and COMMIT TRANSACTION to the generated diff file\n\ \n\ --ignore-function-whitespace:\n\ ${tab}ignores multiple spaces and new lines when comparing content of functions\n\ ${tab}- WARNING: this may cause functions to appear to be same in cases they are\n\ ${tab}not, so use this feature only if you know what you are doing\n\ \n\ --ignore-start-with:\n\ ${tab}ignores START WITH modifications on SEQUENCEs (default is not to ignore\n\ ${tab}these changes)\n\ \n\ --in-charset-name :\n\ ${tab}charset that should be used for reading input files (standard charset name\n\ ${tab}supported by Java, 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 _slony_logtrigger\n\ ${tab}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} apgdiff-2.4/src/main/java/0000755000401600037200000000000012007023242014514 5ustar cbecredativapgdiff-2.4/src/main/java/cz/0000755000401600037200000000000012007023242015130 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/0000755000401600037200000000000012007023242016774 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/0000755000401600037200000000000012007023242020134 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/0000755000401600037200000000000012027101706021377 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffArguments.java0000644000401600037200000002371112027101706025273 0ustar cbecredativ/** * 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; /** * 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 ("--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 { 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; } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffIndexes.java0000644000401600037200000001507712027101706024733 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/SearchPathHelper.java0000644000401600037200000000175012027101706025427 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/0000755000401600037200000000000012027101706023056 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateViewParser.java0000644000401600037200000000402612027101706027136 0ustar cbecredativ/** * 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"); 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.setColumnNames(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.addView(view); } /** * Creates a new instance of CreateViewParser. */ private CreateViewParser() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/AlterSequenceParser.java0000644000401600037200000000440112027101706027635 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateIndexParser.java0000644000401600037200000000434012027101706027272 0ustar cbecredativ/** * 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.PgIndex; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; 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); if (table == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTable"), tableName, statement)); } final PgIndex index = new PgIndex(indexName); table.addIndex(index); schema.addIndex(index); index.setDefinition(definition.trim()); index.setTableName(table.getName()); index.setUnique(unique); } /** * Creates a new instance of CreateIndexParser. */ private CreateIndexParser() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CommentParser.java0000644000401600037200000002757412027101706026517 0ustar cbecredativ/** * Copyright 2010 StartNet s.r.o. */ 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.PgFunction; import cz.startnet.utils.pgdiff.schema.PgIndex; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgSequence; import cz.startnet.utils.pgdiff.schema.PgTable; import cz.startnet.utils.pgdiff.schema.PgTrigger; import cz.startnet.utils.pgdiff.schema.PgView; 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 tableName = ParserUtils.getSecondObjectName(columnName); final String schemaName = ParserUtils.getThirdObjectName(columnName); final PgSchema schema = database.getSchema(schemaName); final PgTable table = schema.getTable(tableName); if (table == null) { final PgView view = schema.getView(tableName); parser.expect("IS"); final String comment = getComment(parser); if (comment == null) { view.removeColumnComment(objectName); } else { view.addColumnComment(objectName, comment); } parser.expect(";"); } else { final PgColumn column = table.getColumn(objectName); if (column == null) { throw new ParserException(MessageFormat.format( Resources.getString("CannotFindColumnInTable"), columnName, table.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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/Parser.java0000644000401600037200000003521312027101706025161 0ustar cbecredativ/** * 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) == '[' || "(".equals(word) || ",".equals(word) || "[".equals(word) || "]".equals(word))) { position = wordEnd; skipWhitespace(); return true; } if (optional) { return false; } throw new ParserException(MessageFormat.format( Resources.getString("CannotParseStringExpectedWord"), string, word, position + 1, string.substring(position, position + 20))); } /** * 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 */ 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 == '(') { bracesCount++; } else if (chr == ')') { if (bracesCount == 0) { break; } else { bracesCount--; } } else if (chr == '\'') { 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, position + 20))); } /** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateSchemaParser.java0000644000401600037200000000340612027101706027425 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateSequenceParser.java0000644000401600037200000000622712027101706030001 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/ParserException.java0000644000401600037200000000177512027101706027046 0ustar cbecredativ/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.parsers; /** * Thrown if parsing problem occured. * * @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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/AlterTableParser.java0000644000401600037200000003700512027101706027122 0ustar cbecredativ/** * 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.PgSequence; import cz.startnet.utils.pgdiff.schema.PgTable; import cz.startnet.utils.pgdiff.schema.PgView; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; /** * Parses ALTER TABLE statements. * * @author fordfrog */ public class AlterTableParser { /** * 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", "TABLE"); parser.expectOptional("ONLY"); final String tableName = parser.parseIdentifier(); 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); if (table == null) { final PgView view = schema.getView(objectName); if (view != null) { parseView(parser, view, outputIgnoredStatements, tableName, database); return; } final PgSequence sequence = schema.getSequence(objectName); if (sequence != null) { parseSequence(parser, sequence, outputIgnoredStatements, tableName, database); return; } throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindObject"), tableName, statement)); } while (!parser.expectOptional(";")) { if (parser.expectOptional("ALTER")) { parseAlterColumn(parser, table); } else if (parser.expectOptional("CLUSTER", "ON")) { table.setClusterIndexName( ParserUtils.getObjectName(parser.parseIdentifier())); } else if (parser.expectOptional("OWNER", "TO")) { // we do not parse this one so we just consume the identifier if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + tableName + " OWNER TO " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else if (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 (parser.expectOptional("ENABLE")) { parseEnable( parser, outputIgnoredStatements, tableName, database); } else if (parser.expectOptional("DISABLE")) { parseDisable( parser, outputIgnoredStatements, tableName, 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 table pg table */ private static void parseAlterColumn(final Parser parser, final PgTable table) { parser.expectOptional("COLUMN"); final String columnName = ParserUtils.getObjectName(parser.parseIdentifier()); if (parser.expectOptional("SET")) { if (parser.expectOptional("STATISTICS")) { final PgColumn column = table.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, table.getName(), parser.getString())); } column.setStatistics(parser.parseInteger()); } else if (parser.expectOptional("DEFAULT")) { final String defaultValue = parser.getExpression(); 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())); } column.setDefaultValue(defaultValue); } else { throw new ParserException(MessageFormat.format( Resources.getString("CannotFindColumnInTable"), columnName, table.getName())); } } else if (parser.expectOptional("STORAGE")) { final PgColumn column = table.getColumn(columnName); if (column == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindTableColumn"), columnName, table.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 view. * * @param parser parser * @param view view * @param outputIgnoredStatements whether ignored statements should be * output in the diff * @param viewName view name as it was specified in the * statement * @param database database information */ private static void parseView(final Parser parser, final PgView view, final boolean outputIgnoredStatements, final String viewName, final PgDatabase database) { while (!parser.expectOptional(";")) { if (parser.expectOptional("ALTER")) { parser.expectOptional("COLUMN"); final String columnName = ParserUtils.getObjectName(parser.parseIdentifier()); if (parser.expectOptional("SET", "DEFAULT")) { final String expression = parser.getExpression(); view.addColumnDefaultValue(columnName, expression); } else if (parser.expectOptional("DROP", "DEFAULT")) { view.removeColumnDefaultValue(columnName); } else { parser.throwUnsupportedCommand(); } } else if (parser.expectOptional("OWNER", "TO")) { // we do not parse this one so we just consume the identifier if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + viewName + " OWNER TO " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } } /** * 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 AlterTableParser() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/ParserUtils.java0000644000401600037200000001121112027101706026172 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateFunctionParser.java0000644000401600037200000000705712027101706030020 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateTableParser.java0000644000401600037200000001046212027101706027254 0ustar cbecredativ/** * 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 */ public static void parse(final PgDatabase database, final String statement) { final Parser parser = new Parser(statement); parser.expect("CREATE", "TABLE"); // Optional IF NOT EXISTS, irrelevant for our purposes parser.expectOptional("IF", "NOT", "EXISTS"); final String tableName = parser.parseIdentifier(); final PgTable table = new PgTable(ParserUtils.getObjectName(tableName)); 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)); } schema.addTable(table); parser.expect("("); while (!parser.expectOptional(")")) { if (parser.expectOptional("CONSTRAINT")) { parseConstraint(parser, table); } else { parseColumn(parser, table); } if (parser.expectOptional(")")) { break; } else { parser.expect(","); } } while (!parser.expectOptional(";")) { if (parser.expectOptional("INHERITS")) { parseInherits(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 { parser.throwUnsupportedCommand(); } } } /** * Parses INHERITS. * * @param parser parser * @param table pg table */ private static void parseInherits(final Parser parser, final PgTable table) { parser.expect("("); while (!parser.expectOptional(")")) { table.addInherits( ParserUtils.getObjectName(parser.parseIdentifier())); 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-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/AlterViewParser.java0000644000401600037200000000574412027101706027012 0ustar cbecredativ/** * 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; /** * Parses ALTER VIEW statements. * * @author fordfrog */ public class AlterViewParser { /** * Parses ALTER VIEW statement. * * @param database database * @param statement ALTER VIEW 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", "VIEW"); final String viewName = parser.parseIdentifier(); 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)); } final String objectName = ParserUtils.getObjectName(viewName); final PgView view = schema.getView(objectName); if (view == null) { throw new RuntimeException(MessageFormat.format( Resources.getString("CannotFindView"), viewName, statement)); } while (!parser.expectOptional(";")) { if (parser.expectOptional("ALTER")) { parser.expectOptional("COLUMN"); final String columnName = ParserUtils.getObjectName(parser.parseIdentifier()); if (parser.expectOptional("SET", "DEFAULT")) { final String expression = parser.getExpression(); view.addColumnDefaultValue(columnName, expression); } else if (parser.expectOptional("DROP", "DEFAULT")) { view.removeColumnDefaultValue(columnName); } else { parser.throwUnsupportedCommand(); } } else if (parser.expectOptional("OWNER", "TO")) { // we do not parse this one so we just consume the identifier if (outputIgnoredStatements) { database.addIgnoredStatement("ALTER TABLE " + viewName + " OWNER TO " + parser.parseIdentifier() + ';'); } else { parser.parseIdentifier(); } } else { parser.throwUnsupportedCommand(); } } } /** * Creates new instance of AlterViewParser. */ private AlterViewParser() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/CreateTriggerParser.java0000644000401600037200000000677312027101706027642 0ustar cbecredativ/** * 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.setBefore(true); } else if (parser.expectOptional("AFTER")) { trigger.setBefore(false); } 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 tableName = parser.parseIdentifier(); trigger.setTableName(ParserUtils.getObjectName(tableName)); 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 tableSchema = database.getSchema( ParserUtils.getSchemaName(tableName, database)); tableSchema.getTable(trigger.getTableName()).addTrigger(trigger); } } /** * Creates a new CreateTableParser object. */ private CreateTriggerParser() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/parsers/package-info.java0000644000401600037200000000014512027101706026245 0ustar cbecredativ/** * Parsers for parsing DDLs from PostgreSQL dumps. */ package cz.startnet.utils.pgdiff.parsers; apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java0000644000401600037200000002626212027101706024427 0ustar cbecredativ/** * 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.PgView; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; 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()); } } } /** * 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) { final String[] oldViewColumnNames; if (oldView.getColumnNames() == null || oldView.getColumnNames().isEmpty()) { oldViewColumnNames = null; } else { oldViewColumnNames = oldView.getColumnNames().toArray( new String[oldView.getColumnNames().size()]); } final String[] newViewColumnNames; if (newView.getColumnNames() == null || newView.getColumnNames().isEmpty()) { newViewColumnNames = null; } else { newViewColumnNames = newView.getColumnNames().toArray( new String[newView.getColumnNames().size()]); } if (oldViewColumnNames == null && newViewColumnNames == null) { return !oldView.getQuery().trim().equals(newView.getQuery().trim()); } else { return !Arrays.equals(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.getColumnComments().size()); for (final PgView.ColumnComment columnComment : newView.getColumnComments()) { columnNames.add(columnComment.getColumnName()); } for (final PgView.ColumnComment columnComment : oldView.getColumnComments()) { if (!columnNames.contains(columnComment.getColumnName())) { columnNames.add(columnComment.getColumnName()); } } for (final String columnName : columnNames) { PgView.ColumnComment oldColumnComment = null; PgView.ColumnComment newColumnComment = null; for (final PgView.ColumnComment columnComment : oldView.getColumnComments()) { if (columnName.equals(columnComment.getColumnName())) { oldColumnComment = columnComment; break; } } for (final PgView.ColumnComment columnComment : newView.getColumnComments()) { if (columnName.equals(columnComment.getColumnName())) { newColumnComment = columnComment; break; } } if (oldColumnComment == null && newColumnComment != null || oldColumnComment != null && newColumnComment != null && !oldColumnComment.getComment().equals( newColumnComment.getComment())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName( newColumnComment.getColumnName())); writer.print(" IS "); writer.print(newColumnComment.getComment()); writer.println(';'); } else if (oldColumnComment != null && newColumnComment == null) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("COMMENT ON COLUMN "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print('.'); writer.print(PgDiffUtils.getQuotedName( oldColumnComment.getColumnName())); writer.println(" IS NULL;"); } } } } /** * 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) { final List oldValues = oldView.getDefaultValues(); final List newValues = newView.getDefaultValues(); // modify defaults that are in old view for (final PgView.DefaultValue oldValue : oldValues) { boolean found = false; for (final PgView.DefaultValue newValue : newValues) { if (oldValue.getColumnName().equals(newValue.getColumnName())) { found = true; if (!oldValue.getDefaultValue().equals( newValue.getDefaultValue())) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print( PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName( newValue.getColumnName())); writer.print(" SET DEFAULT "); writer.print(newValue.getDefaultValue()); writer.println(';'); } break; } } if (!found) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName( oldValue.getColumnName())); writer.println(" DROP DEFAULT;"); } } // add new defaults for (final PgView.DefaultValue newValue : newValues) { boolean found = false; for (final PgView.DefaultValue oldValue : oldValues) { if (newValue.getColumnName().equals(oldValue.getColumnName())) { found = true; break; } } if (found) { continue; } searchPathHelper.outputSearchPath(writer); writer.println(); writer.print("ALTER TABLE "); writer.print(PgDiffUtils.getQuotedName(newView.getName())); writer.print(" ALTER COLUMN "); writer.print(PgDiffUtils.getQuotedName(newValue.getColumnName())); writer.print(" SET DEFAULT "); writer.print(newValue.getDefaultValue()); writer.println(';'); } } /** * Creates a new instance of PgDiffViews. */ private PgDiffViews() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/0000755000401600037200000000000012027101706022637 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgConstraint.java0000644000401600037200000001154612027101706026124 0ustar cbecredativ/** * 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("\n\tADD CONSTRAINT "); sbSQL.append(PgDiffUtils.getQuotedName(getName())); sbSQL.append(' '); sbSQL.append(getDefinition()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT 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("\n\tDROP CONSTRAINT "); 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-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java0000644000401600037200000001365112027101706025234 0ustar cbecredativ/** * 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.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. */ 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; /** * 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; } /** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgSchema.java0000644000401600037200000002613212027101706025175 0ustar cbecredativ/** * 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 tables defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List tables = new ArrayList(); /** * List of views defined in the schema. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List views = 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.getQuotedName(getName())); if (getAuthorization() != null) { sbSQL.append(" AUTHORIZATION "); sbSQL.append(PgDiffUtils.getQuotedName(getAuthorization())); } sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT 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 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) { for (PgTable table : tables) { if (table.getName().equals(name)) { return table; } } return null; } /** * Getter for {@link #tables}. The list cannot be modified. * * @return {@link #tables} */ public List getTables() { return Collections.unmodifiableList(tables); } /** * 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) { for (PgView view : views) { if (view.getName().equals(name)) { return view; } } return null; } /** * Getter for {@link #views}. The list cannot be modified. * * @return {@link #views} */ public List getViews() { return Collections.unmodifiableList(views); } /** * 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 table} to the list of tables. * * @param table table */ public void addTable(final PgTable table) { tables.add(table); } /** * Adds {@code view} to the list of views. * * @param view view */ public void addView(final PgView view) { views.add(view); } /** * 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) { for (PgTable table : tables) { if (table.getName().equals(name)) { return true; } } return false; } /** * 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) { for (PgView view : views) { if (view.getName().equals(name)) { return true; } } return false; } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java0000644000401600037200000003126612027101706025030 0ustar cbecredativ/** * 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 PgTable { /** * List of columns defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List columns = new ArrayList(); /** * List of constraints defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List constraints = new ArrayList(); /** * List of indexes defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List indexes = new ArrayList(); /** * List of triggers defined on the table. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List triggers = new ArrayList(); /** * Name of the index on which the table is clustered */ private String clusterIndexName; /** * List of names of inherited tables. */ @SuppressWarnings("CollectionWithoutInitialCapacity") private final List inherits = new ArrayList(); /** * Name of the table. */ private String name; /** * 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; /** * Tablespace value. */ private String tablespace; /** * Comment. */ private String comment; /** * Creates a new PgTable object. * * @param name {@link #name} */ public PgTable(final String name) { this.name = name; } /** * 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); } /** * 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 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); } /** * 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 TABLE "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" (\n"); boolean first = true; if (columns.isEmpty()) { sbSQL.append(')'); } else { for (PgColumn column : columns) { if (first) { first = false; } else { sbSQL.append(",\n"); } sbSQL.append("\t"); sbSQL.append(column.getFullDefinition(false)); } sbSQL.append("\n)"); } if (inherits != null && !inherits.isEmpty()) { sbSQL.append("\nINHERITS ("); first = true; for (final String tableName : inherits) { if (first) { first = false; } else { sbSQL.append(", "); } sbSQL.append(tableName); } sbSQL.append(")"); } if (with != null && !with.isEmpty()) { sbSQL.append("\n"); 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 (tablespace != null && !tablespace.isEmpty()) { sbSQL.append("\nTABLESPACE "); sbSQL.append(tablespace); } sbSQL.append(';'); for (PgColumn column : getColumnsWithStatistics()) { sbSQL.append("\nALTER 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(';'); } if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT ON TABLE "); 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("\n\nCOMMENT 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(); } /** * Creates and returns SQL statement for dropping the table. * * @return created SQL statement */ public String getDropSQL() { return "DROP TABLE " + PgDiffUtils.getQuotedName(getName()) + ";"; } /** * 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 #inherits}. * * @param tableName name of inherited table */ public void addInherits(final String tableName) { inherits.add(tableName); } /** * Getter for {@link #inherits}. * * @return {@link #inherits} */ public List getInherits() { return Collections.unmodifiableList(inherits); } /** * 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); } /** * 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 constraint} to the list of constraints. * * @param constraint constraint */ public void addConstraint(final PgConstraint constraint) { constraints.add(constraint); } /** * 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 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 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 true if table contains given index {@code name}, otherwise false. * * @param name name of the index * * @return true if table 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; } /** * 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; } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java0000644000401600037200000001476212027101706025553 0ustar cbecredativ/** * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ package cz.startnet.utils.pgdiff.schema; 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; /** * 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.getQuotedName(name)); if (startWith != null) { sbSQL.append("\n\tSTART WITH "); sbSQL.append(startWith); } if (increment != null) { sbSQL.append("\n\tINCREMENT BY "); sbSQL.append(increment); } sbSQL.append("\n\t"); if (maxValue == null) { sbSQL.append("NO MAXVALUE"); } else { sbSQL.append("MAXVALUE "); sbSQL.append(maxValue); } sbSQL.append("\n\t"); if (minValue == null) { sbSQL.append("NO MINVALUE"); } else { sbSQL.append("MINVALUE "); sbSQL.append(minValue); } if (cache != null) { sbSQL.append("\n\tCACHE "); sbSQL.append(cache); } if (cycle) { sbSQL.append("\n\tCYCLE"); } sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT 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("\n\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.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; } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnUtils.java0000644000401600037200000000341212027101706026247 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgDatabase.java0000644000401600037200000000613412027101706025501 0ustar cbecredativ/** * 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; /** * 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); } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgIndex.java0000644000401600037200000001072312007023242025037 0ustar cbecredativ/** * 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.getQuotedName(getName())); sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(getTableName())); sbSQL.append(' '); sbSQL.append(getDefinition()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT 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.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-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgFunction.java0000644000401600037200000003020412027101706025555 0ustar cbecredativ/** * 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("\n\nCOMMENT 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(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-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java0000644000401600037200000002121612027101706024705 0ustar cbecredativ/** * 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 view information. * * @author fordfrog */ public class PgView { /** * List of column names. */ private List columnNames; /** * Name of the view. */ private final String name; /** * SQL query of the view. */ private String query; /** * List of optional column default values. */ private final List defaultValues = new ArrayList(0); /** * List of optional column comments. */ private final List columnComments = new ArrayList(0); /** * Comment. */ private String comment; /** * Creates a new PgView object. * * @param name {@link #name} */ public PgView(final String name) { this.name = name; } /** * Setter for {@link #columnNames}. * * @param columnNames {@link #columnNames} */ @SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter") public void setColumnNames(final List columnNames) { this.columnNames = columnNames; } /** * Getter for {@link #columnNames}. The list cannot be modified. * * @return {@link #columnNames} */ public List getColumnNames() { return Collections.unmodifiableList(columnNames); } /** * 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 view. * * @return created SQL statement */ public String getCreationSQL() { final StringBuilder sbSQL = new StringBuilder(query.length() * 2); sbSQL.append("CREATE VIEW "); sbSQL.append(PgDiffUtils.getQuotedName(name)); if (columnNames != null && !columnNames.isEmpty()) { sbSQL.append(" ("); for (int i = 0; i < columnNames.size(); i++) { if (i > 0) { sbSQL.append(", "); } sbSQL.append(PgDiffUtils.getQuotedName(columnNames.get(i))); } sbSQL.append(')'); } sbSQL.append(" AS\n\t"); sbSQL.append(query); sbSQL.append(';'); for (final DefaultValue defaultValue : defaultValues) { sbSQL.append("\n\nALTER VIEW "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ALTER COLUMN "); sbSQL.append( PgDiffUtils.getQuotedName(defaultValue.getColumnName())); sbSQL.append(" SET DEFAULT "); sbSQL.append(defaultValue.getDefaultValue()); sbSQL.append(';'); } if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT ON VIEW "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" IS "); sbSQL.append(comment); sbSQL.append(';'); } for (final ColumnComment columnComment : columnComments) { if (columnComment.getComment() != null && !columnComment.getComment().isEmpty()) { sbSQL.append("\n\nCOMMENT ON COLUMN "); sbSQL.append(PgDiffUtils.getQuotedName( columnComment.getColumnName())); sbSQL.append(" IS "); sbSQL.append(columnComment.getComment()); sbSQL.append(';'); } } return sbSQL.toString(); } /** * Creates and returns SQL statement for dropping the view. * * @return created SQL statement */ public String getDropSQL() { return "DROP VIEW " + PgDiffUtils.getQuotedName(getName()) + ";"; } /** * Getter for {@link #name}. * * @return {@link #name} */ public String getName() { return name; } /** * 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; } /** * Adds/replaces column default value specification. * * @param columnName column name * @param defaultValue default value */ public void addColumnDefaultValue(final String columnName, final String defaultValue) { removeColumnDefaultValue(columnName); defaultValues.add(new DefaultValue(columnName, defaultValue)); } /** * Removes column default value if present. * * @param columnName column name */ public void removeColumnDefaultValue(final String columnName) { for (final DefaultValue item : defaultValues) { if (item.getColumnName().equals(columnName)) { defaultValues.remove(item); return; } } } /** * Getter for {@link #defaultValues}. * * @return {@link #defaultValues} */ public List getDefaultValues() { return Collections.unmodifiableList(defaultValues); } /** * Adds/replaces column comment. * * @param columnName column name * @param comment comment */ public void addColumnComment(final String columnName, final String comment) { removeColumnDefaultValue(columnName); columnComments.add(new ColumnComment(columnName, comment)); } /** * Removes column comment if present. * * @param columnName column name */ public void removeColumnComment(final String columnName) { for (final ColumnComment item : columnComments) { if (item.getColumnName().equals(columnName)) { columnComments.remove(item); return; } } } /** * Getter for {@link #columnComments}. * * @return {@link #columnComments} */ public List getColumnComments() { return Collections.unmodifiableList(columnComments); } /** * Contains information about default value of column. */ @SuppressWarnings("PublicInnerClass") public class DefaultValue { /** * Column name. */ private final String columnName; /** * Default value. */ private final String defaultValue; /** * Creates new instance of DefaultValue. * * @param columnName {@link #columnName} * @param defaultValue {@link #defaultValue} */ DefaultValue(final String columnName, final String defaultValue) { this.columnName = columnName; this.defaultValue = defaultValue; } /** * Getter for {@link #columnName}. * * @return {@link #columnName} */ public String getColumnName() { return columnName; } /** * Getter for {@link #defaultValue}. * * @return {@link #defaultValue} */ public String getDefaultValue() { return defaultValue; } } /** * Contains information about column comment. */ @SuppressWarnings("PublicInnerClass") public class ColumnComment { /** * Column name. */ private final String columnName; /** * Comment. */ private final String comment; /** * Creates new instance of ColumnComment. * * @param columnName {@link #columnName} * @param comment {@link #comment} */ ColumnComment(final String columnName, final String comment) { this.columnName = columnName; this.comment = comment; } /** * Getter for {@link #columnName}. * * @return {@link #columnName} */ public String getColumnName() { return columnName; } /** * Getter for {@link #comment}. * * @return {@link #comment} */ public String getComment() { return comment; } } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/package-info.java0000644000401600037200000000013012027101706026020 0ustar cbecredativ/** * Contains PostgreSQL schema objects. */ package cz.startnet.utils.pgdiff.schema; apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/schema/PgTrigger.java0000644000401600037200000002366112027101706025404 0ustar cbecredativ/** * 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 trigger information. * * @author fordfrog */ public class PgTrigger { /** * Function name and arguments that should be fired on the trigger. */ private String function; /** * Name of the trigger. */ private String name; /** * Name of the table the trigger is defined on. */ private String tableName; /** * Whether the trigger should be fired BEFORE or AFTER action. Default is * before. */ private boolean before = true; /** * 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 #before}. * * @param before {@link #before} */ public void setBefore(final boolean before) { this.before = before; } /** * Getter for {@link #before}. * * @return {@link #before} */ public boolean isBefore() { return before; } /** * 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("\n\t"); sbSQL.append(isBefore() ? "BEFORE" : "AFTER"); 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(getTableName())); sbSQL.append("\n\tFOR EACH "); sbSQL.append(isForEachRow() ? "ROW" : "STATEMENT"); if (when != null && !when.isEmpty()) { sbSQL.append("\n\tWHEN ("); sbSQL.append(when); sbSQL.append(')'); } sbSQL.append("\n\tEXECUTE PROCEDURE "); sbSQL.append(getFunction()); sbSQL.append(';'); if (comment != null && !comment.isEmpty()) { sbSQL.append("\n\nCOMMENT ON TRIGGER "); sbSQL.append(PgDiffUtils.getQuotedName(name)); sbSQL.append(" ON "); sbSQL.append(PgDiffUtils.getQuotedName(tableName)); 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.getQuotedName(getName()) + " ON " + PgDiffUtils.getQuotedName(getTableName()) + ";"; } /** * 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 #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; } /** * 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 = (before == trigger.isBefore()) && (forEachRow == trigger.isForEachRow()) && function.equals(trigger.getFunction()) && name.equals(trigger.getName()) && (onDelete == trigger.isOnDelete()) && (onInsert == trigger.isOnInsert()) && (onUpdate == trigger.isOnUpdate()) && (onTruncate == trigger.isOnTruncate()) && tableName.equals(trigger.getTableName()); 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() + "|" + before + "|" + forEachRow + "|" + function + "|" + name + "|" + onDelete + "|" + onInsert + "|" + onUpdate + "|" + onTruncate + "|" + tableName).hashCode(); } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/Resources.java0000644000401600037200000000133312027101706024214 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/Main.java0000644000401600037200000000260012027101706023124 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffTriggers.java0000644000401600037200000001535712027101706025123 0ustar cbecredativ/** * 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.PgTable; 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 PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } // Add new triggers for (final PgTrigger trigger : getNewTriggers(oldTable, newTable)) { 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 PgTable newTable : newSchema.getTables()) { final PgTable oldTable; if (oldSchema == null) { oldTable = null; } else { oldTable = oldSchema.getTable(newTable.getName()); } // Drop triggers that no more exist or are modified for (final PgTrigger trigger : getDropTriggers(oldTable, newTable)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println(trigger.getDropSQL()); } } } /** * Returns list of triggers that should be dropped. * * @param oldTable original table * @param newTable new table * * @return list of triggers that should be dropped */ private static List getDropTriggers(final PgTable oldTable, final PgTable newTable) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null && oldTable != null) { final List newTriggers = newTable.getTriggers(); for (final PgTrigger oldTrigger : oldTable.getTriggers()) { if (!newTriggers.contains(oldTrigger)) { list.add(oldTrigger); } } } return list; } /** * Returns list of triggers that should be added. * * @param oldTable original table * @param newTable new table * * @return list of triggers that should be added */ private static List getNewTriggers(final PgTable oldTable, final PgTable newTable) { @SuppressWarnings("CollectionWithoutInitialCapacity") final List list = new ArrayList(); if (newTable != null) { if (oldTable == null) { list.addAll(newTable.getTriggers()); } else { for (final PgTrigger newTrigger : newTable.getTriggers()) { if (!oldTable.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 (PgTable oldTable : oldSchema.getTables()) { final PgTable newTable = newSchema.getTable(oldTable.getName()); if (newTable == null) { continue; } for (final PgTrigger oldTrigger : oldTable.getTriggers()) { final PgTrigger newTrigger = newTable.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.getTableName())); 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.getTableName())); writer.println(" IS NULL;"); } } } } /** * Creates a new instance of PgDiffTriggers. */ private PgDiffTriggers() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffSequences.java0000644000401600037200000001774012027101706025266 0ustar cbecredativ/** * 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 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()); } } } /** * 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("\n\tINCREMENT BY "); sbSQL.append(newIncrement); } final String oldMinValue = oldSequence.getMinValue(); final String newMinValue = newSequence.getMinValue(); if (newMinValue == null && oldMinValue != null) { sbSQL.append("\n\tNO MINVALUE"); } else if (newMinValue != null && !newMinValue.equals(oldMinValue)) { sbSQL.append("\n\tMINVALUE "); sbSQL.append(newMinValue); } final String oldMaxValue = oldSequence.getMaxValue(); final String newMaxValue = newSequence.getMaxValue(); if (newMaxValue == null && oldMaxValue != null) { sbSQL.append("\n\tNO MAXVALUE"); } else if (newMaxValue != null && !newMaxValue.equals(oldMaxValue)) { sbSQL.append("\n\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("\n\tRESTART WITH "); sbSQL.append(newStart); } } final String oldCache = oldSequence.getCache(); final String newCache = newSequence.getCache(); if (newCache != null && !newCache.equals(oldCache)) { sbSQL.append("\n\tCACHE "); sbSQL.append(newCache); } final boolean oldCycle = oldSequence.isCycle(); final boolean newCycle = newSequence.isCycle(); if (oldCycle && !newCycle) { sbSQL.append("\n\tNO CYCLE"); } else if (!oldCycle && newCycle) { sbSQL.append("\n\tCYCLE"); } final String oldOwnedBy = oldSequence.getOwnedBy(); final String newOwnedBy = newSequence.getOwnedBy(); if (newOwnedBy != null && !newOwnedBy.equals(oldOwnedBy)) { sbSQL.append("\n\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;"); } } } /** * Creates a new instance of PgDiffSequences. */ private PgDiffSequences() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/loader/0000755000401600037200000000000012027101706022645 5ustar cbecredativapgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java0000644000401600037200000003530112027101706026035 0ustar cbecredativ/** * 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.AlterTableParser; import cz.startnet.utils.pgdiff.parsers.AlterViewParser; import cz.startnet.utils.pgdiff.parsers.CommentParser; import cz.startnet.utils.pgdiff.parsers.CreateFunctionParser; 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.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]+TABLE[\\s]+.*$", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); /** * Pattern for testing whether it is CREATE VIEW statement. */ private static final Pattern PATTERN_CREATE_VIEW = Pattern.compile( "^CREATE[\\s]+(?:OR[\\s]+REPLACE[\\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]+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]+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); /** * 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 * * @return database schema from dump file */ public static PgDatabase loadDatabaseSchema(final InputStream inputStream, final String charsetName, final boolean outputIgnoredStatements, final boolean ignoreSlonyTriggers) { 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_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); } else if (PATTERN_ALTER_TABLE.matcher(statement).matches()) { AlterTableParser.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_ALTER_VIEW.matcher(statement).matches()) { AlterViewParser.parse( database, statement, outputIgnoredStatements); } 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_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()) { // 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 * * @return database schema from dump file */ public static PgDatabase loadDatabaseSchema(final String file, final String charsetName, final boolean outputIgnoredStatements, final boolean ignoreSlonyTriggers) { try { return loadDatabaseSchema(new FileInputStream(file), charsetName, outputIgnoredStatements, ignoreSlonyTriggers); } catch (final FileNotFoundException ex) { throw new FileException(MessageFormat.format( Resources.getString("FileNotFound"), file), 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('\n'); } 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); } } /** * 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; for (int curPos = 0; curPos < pos; curPos++) { 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 true; } final String tag = sbString.substring(curPos, endPos + 1); 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; } /** * Creates a new instance of PgDumpLoader. */ private PgDumpLoader() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/loader/FileException.java0000644000401600037200000000201712027101706026246 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/loader/package-info.java0000644000401600037200000000012512027101706026032 0ustar cbecredativ/** * Contains PostgreSQL dump loader. */ package cz.startnet.utils.pgdiff.loader; apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffUtils.java0000644000401600037200000002505012027101706024424 0ustar cbecredativ/** * 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"}; /** * 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); } /** * Creates a new PgDiffUtils object. */ private PgDiffUtils() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffFunctions.java0000644000401600037200000001256512027101706025303 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java0000644000401600037200000002731712027101706023413 0ustar cbecredativ/** * 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.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) { final PgDatabase oldDatabase = PgDumpLoader.loadDatabaseSchema( arguments.getOldDumpFile(), arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers()); final PgDatabase newDatabase = PgDumpLoader.loadDatabaseSchema( arguments.getNewDumpFile(), arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers()); 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()); final PgDatabase newDatabase = PgDumpLoader.loadDatabaseSchema( newInputStream, arguments.getInCharsetName(), arguments.isOutputIgnoredStatements(), arguments.isIgnoreSlonyTriggers()); 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 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); 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.getQuotedName(oldSchema.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); PgDiffSequences.createSequences( writer, oldSchema, newSchema, searchPathHelper); PgDiffSequences.alterSequences( writer, arguments, 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); 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-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java0000644000401600037200000006002212027101706024534 0ustar cbecredativ/** * 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.PgTable; 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, searchPathHelper); checkTablespace(writer, oldTable, newTable, searchPathHelper); addAlterStatistics(writer, oldTable, newTable, searchPathHelper); addAlterStorage(writer, oldTable, newTable, searchPathHelper); alterComments(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 " + 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.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() + " /* " + 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 searchPathHelper search path helper */ private static void checkInherits(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { for (final String tableName : oldTable.getInherits()) { if (!newTable.getInherits().contains(tableName)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); writer.println("\tNO INHERIT " + PgDiffUtils.getQuotedName(tableName) + ';'); } } for (final String tableName : newTable.getInherits()) { if (!oldTable.getInherits().contains(tableName)) { searchPathHelper.outputSearchPath(writer); writer.println(); writer.println("ALTER TABLE " + PgDiffUtils.getQuotedName(newTable.getName())); writer.println("\tINHERIT " + PgDiffUtils.getQuotedName(tableName) + ';'); } } } /** * 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()); } } } /** * 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 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 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() ? "," : ";"); } } } } /** * 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;"); } } } /** * Creates a new instance of PgDiffTables. */ private PgDiffTables() { } } apgdiff-2.4/src/main/java/cz/startnet/utils/pgdiff/PgDiffConstraints.java0000644000401600037200000002230312027101706025631 0ustar cbecredativ/** * 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-2.4/src/main/java/cz/startnet/utils/pgdiff/package-info.java0000644000401600037200000000016212027101706024565 0ustar cbecredativ/** * Contains tool that creates diff file from two PostgreSQL dump files. */ package cz.startnet.utils.pgdiff; apgdiff-2.4/src/test/0000755000401600037200000000000012007023242013626 5ustar cbecredativapgdiff-2.4/src/test/resources/0000755000401600037200000000000012007023242015640 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/0000755000401600037200000000000012007023242016254 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/0000755000401600037200000000000012007023242020120 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/0000755000401600037200000000000012007023242021260 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/0000755000401600037200000000000012027101706022523 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_new.sql0000644000401600037200000000006112007023242030777 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_diff.sql0000644000401600037200000000010412007023242027225 0ustar cbecredativ ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 100; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_original.sql0000644000401600037200000000331412007023242027544 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_new.sql0000644000401600037200000000346012007023242030476 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_diff.sql0000644000401600037200000000026312007023242031145 0ustar cbecredativ CREATE OR REPLACE FUNCTION multiply_numbers(number1 smallint, number2 smallint) RETURNS smallint AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_original.sql0000644000401600037200000000237612007023242032063 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_new.sql0000644000401600037200000000144712007023242032051 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_diff.sql0000644000401600037200000000005412007023242033020 0ustar cbecredativ ALTER SEQUENCE testseq RESTART WITH 1000; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_original.sql0000644000401600037200000000270212007023242031302 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_view_new.sql0000644000401600037200000000226712007023242026441 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_original.sql0000644000401600037200000000207412007023242030131 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_original.sql0000644000401600037200000000133112027101706030243 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_new.sql0000644000401600037200000000015312007023242030565 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_original.sql0000644000401600037200000000207412007023242027234 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_diff.sql0000644000401600037200000000007512007023242030421 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field4 SET DEFAULT 1.0; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_diff.sql0000644000401600037200000000026312007023242030406 0ustar cbecredativ CREATE OR REPLACE FUNCTION multiply_numbers(number2 smallint, number1 smallint) RETURNS smallint AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_new.sql0000644000401600037200000000776512007023242027265 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_new.sql0000644000401600037200000000207412007023242027760 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_original.sql0000644000401600037200000000165212007023242027421 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_original.sql0000644000401600037200000000217712007023242030674 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_new.sql0000644000401600037200000000235012007023242027321 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_new.sql0000644000401600037200000000014712007023242031265 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT 1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_diff.sql0000644000401600037200000000133012007023242032305 0ustar cbecredativ 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_diff.sql0000644000401600037200000000003012007023242026354 0ustar cbecredativ DROP INDEX testindex3; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_original.sql0000644000401600037200000000036112007023242030362 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_new.sql0000644000401600037200000000251612007023242030662 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_new.sql0000644000401600037200000000021112007023242030603 0ustar cbecredativCREATE TABLE public."agent"( id BIGINT, abc BIGINT ); COMMENT ON COLUMN "agent"."abc" IS 'This agent supports credit system or not.';apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_diff.sql0000644000401600037200000000060512007023242026650 0ustar cbecredativ ALTER TABLE testtable ADD COLUMN col3 boolean DEFAULT false NOT NULL, ADD COLUMN col4 character(10) DEFAULT '' NOT NULL, ADD COLUMN 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_new.sql0000644000401600037200000000211012007023242027533 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_diff.sql0000644000401600037200000000016612007023242030733 0ustar cbecredativALTER TABLE agent ADD COLUMN abc BIGINT; COMMENT ON COLUMN agent.abc IS 'This agent supports credit system or not.';apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_new.sql0000644000401600037200000000144112007023242031301 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_new.sql0000644000401600037200000000253112007023242027106 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comments_new.sql0000644000401600037200000000353312007023242026552 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_diff.sql0000644000401600037200000000017012007023242030773 0ustar cbecredativ CREATE OR REPLACE FUNCTION return_one() RETURNS integer AS $$ begin return -1 + 2; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_diff.sql0000644000401600037200000000016312007023242030236 0ustar cbecredativ CREATE OR REPLACE FUNCTION return_one() RETURNS integer AS $$ begin return 1; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_original.sql0000644000401600037200000000267312007023242031103 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_original.sql0000644000401600037200000000345312027101706030751 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_new.sql0000644000401600037200000000131312007023242032167 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_diff.sql0000644000401600037200000000010312007023242030171 0ustar cbecredativ DROP FUNCTION multiply_numbers(number1 integer, number2 integer); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_diff.sql0000644000401600037200000000007312007023242027106 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field3 DROP NOT NULL; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_diff.sql0000644000401600037200000000076612027101706026536 0ustar cbecredativ CREATE SEQUENCE testtable2_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE testtable2 ( id integer DEFAULT nextval('testtable2_id_seq'::regclass) NOT NULL, col1 boolean NOT NULL ); ALTER SEQUENCE testtable2_id_seq OWNED BY testtable2.id; CREATE INDEX testindex ON testtable USING btree (field1); CREATE INDEX testtable2_col1 ON testtable2 USING btree (col1); ALTER TABLE testtable CLUSTER ON testindex; ALTER TABLE testtable2 CLUSTER ON testtable2_col1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_index_original.sql0000644000401600037200000000237612007023242027053 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_diff.sql0000644000401600037200000000007312007023242032162 0ustar cbecredativ ALTER SEQUENCE testseq MINVALUE 1000 RESTART WITH 1000; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_original.sql0000644000401600037200000000244212007023242027762 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_original.sql0000644000401600037200000000214512027101706031736 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_new.sql0000644000401600037200000000213412007023242027776 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_new.sql0000644000401600037200000000267312007023242027654 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_new.sql0000644000401600037200000000345712007023242031036 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_diff.sql0000644000401600037200000000025112007023242027761 0ustar cbecredativ CREATE OR REPLACE FUNCTION multiply_numbers(number1 integer, number2 integer) RETURNS integer AS $$ begin return number1 * number2; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_new.sql0000644000401600037200000000251112007023242030116 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_index_new.sql0000644000401600037200000000207412007023242026572 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_diff.sql0000644000401600037200000000011612007023242027046 0ustar cbecredativ ALTER TABLE testtable ADD COLUMN field2 information_schema.cardinal_number; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_diff.sql0000644000401600037200000000022012007023242027673 0ustar cbecredativ CREATE OR REPLACE FUNCTION power_number("input" integer) RETURNS integer AS $$ begin return input * input; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_new.sql0000644000401600037200000000226112027101706030722 0ustar cbecredativ-- -- 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 -- ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_original.sqlapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_original.sq0000644000401600037200000000243712007023242033547 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_original.sql0000644000401600037200000000000012007023242031116 0ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_new.sql0000644000401600037200000000144212007023242031335 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_diff.sql0000644000401600037200000000121612007023242027244 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_new.sql0000644000401600037200000000036512007023242027353 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_original.sql0000644000401600037200000000250612007023242031511 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_diff.sql0000644000401600037200000000006512007023242031122 0ustar cbecredativALTER TABLE test ALTER COLUMN test_col DROP DEFAULT; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_new.sql0000644000401600037200000000356312007023242027134 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_diff.sql0000644000401600037200000000013012007023242030226 0ustar cbecredativCREATE SEQUENCE test_id_seq INCREMENT BY 1 MAXVALUE 2147483647 NO MINVALUE CACHE 1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_original.sql0000644000401600037200000000150112007023242027556 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_original.sql0000644000401600037200000000235012007023242030120 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_constraint_diff.sql0000644000401600037200000000021112007023242027216 0ustar cbecredativ ALTER TABLE testtable ADD CONSTRAINT field4check CHECK (((field4 > (-5.0)::double precision) AND (field4 < (5.0)::double precision))); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_diff.sql0000644000401600037200000000120012007023242027356 0ustar cbecredativSTART 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_new.sql0000644000401600037200000000145312007023242031146 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_original.sql0000644000401600037200000000144112007023242031426 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_new.sql0000644000401600037200000000260012007023242027560 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_diff.sql0000644000401600037200000000022112007023242030433 0ustar cbecredativ CREATE OR REPLACE FUNCTION power_number(number integer) RETURNS integer AS $$ begin return number * number; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_index_original.sql0000644000401600037200000000207412007023242027605 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_diff.sql0000644000401600037200000000000012007023242031446 0ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_diff.sql0000644000401600037200000000003512007023242030450 0ustar cbecredativ DROP FUNCTION return_one(); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_noargs_original.sql0000644000401600037200000000213412007023242031132 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_original.sql0000644000401600037200000000147312007023242027404 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_original.sql0000644000401600037200000000245712007023242030344 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_original.sql0000644000401600037200000000211012007023242030762 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_original.sql0000644000401600037200000000260012007023242031332 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_view_diff.sql0000644000401600037200000000002512007023242026223 0ustar cbecredativ DROP VIEW testview; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_new.sql0000644000401600037200000000217712007023242027661 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_new.sql0000644000401600037200000000261712007023242026372 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_view_original.sql0000644000401600037200000000226712007023242027131 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_noargs_original.sql0000644000401600037200000000251112007023242031670 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_set_original.sql0000644000401600037200000000144212007023242033057 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_diff.sql0000644000401600037200000000036612007023242027431 0ustar cbecredativ CREATE TABLE parenttable2 ( id bigserial NOT NULL ); ALTER TABLE parenttable DROP COLUMN id, ADD COLUMN field3 information_schema.cardinal_number; ALTER TABLE testtable NO INHERIT parenttable; ALTER TABLE testtable INHERIT parenttable2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_trigger_diff.sql0000644000401600037200000000037712027101706026516 0ustar cbecredativ 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_diff.sql0000644000401600037200000000026012007023242030520 0ustar cbecredativ CREATE OR REPLACE FUNCTION multiply_numbers(number2 integer, number1 integer) RETURNS integer AS $$ begin return number2 * number1; end; $$ LANGUAGE plpgsql; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_original.sql0000644000401600037200000000207412007023242030557 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_original.sql0000644000401600037200000000262212007023242027261 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_new.sql0000644000401600037200000000062412007023242031343 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_new.sql0000644000401600037200000000144512007023242032414 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_new.sql0000644000401600037200000000024412007023242027126 0ustar cbecredativCREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision );apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_original.sql0000644000401600037200000000215112007023242030153 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_diff.sql0000644000401600037200000000005212007023242031450 0ustar cbecredativ ALTER SEQUENCE testseq INCREMENT BY 10; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_table_new.sql0000644000401600037200000000243512007023242026014 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_new.sql0000644000401600037200000000144712007023242032053 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_view_new.sql0000644000401600037200000000175712007023242026121 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_original.sql0000644000401600037200000000021312007023242027505 0ustar cbecredativcreate 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_original.sql0000644000401600037200000000145312007023242032317 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args2_original.sql0000644000401600037200000000213412007023242030657 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_new.sql0000644000401600037200000000244212007023242032546 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_new.sql0000644000401600037200000000320412027101706026735 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_new.sql0000644000401600037200000000202012007023242026540 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_original.sql0000644000401600037200000000165312007023242031036 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_diff.sql0000644000401600037200000000000012007023242032651 0ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_column_original.sql0000644000401600037200000000214712007023242027451 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_original.sql0000644000401600037200000000217712007023242030351 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_diff.sql0000644000401600037200000000007212007023242026671 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field3 SET NOT NULL; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_new.sql0000644000401600037200000000270212007023242030503 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_new.sql0000644000401600037200000000175012027101706027235 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_off_diff.sql0000644000401600037200000000004312007023242031415 0ustar cbecredativ ALTER SEQUENCE testseq NO CYCLE; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_diff.sql0000644000401600037200000000003012007023242031150 0ustar cbecredativ DROP INDEX testindex2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_original.sql0000644000401600037200000000345712007023242031526 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_diff.sql0000644000401600037200000000005412007023242026734 0ustar cbecredativ ALTER TABLE testtable SET WITHOUT CLUSTER; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_similar_diff.sql0000644000401600037200000000010512007023242030615 0ustar cbecredativ DROP FUNCTION multiply_numbers(number2 smallint, number1 smallint); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_new.sql0000644000401600037200000000207412007023242026772 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_new.sql0000644000401600037200000000235612007023242026770 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_new.sql0000644000401600037200000000144212007023242030414 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_bug2100013_new.sql0000644000401600037200000000012312007023242030111 0ustar cbecredativCREATE SEQUENCE test_id_seq INCREMENT BY 1 MAXVALUE 2147483647 NO MINVALUE CACHE 1;apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_diff.sql0000644000401600037200000000006012007023242026713 0ustar cbecredativ DROP TRIGGER test_table_trigger ON test_table; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_comments_original.sql0000644000401600037200000000353312007023242030144 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_original.sql0000644000401600037200000000251112007023242031345 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_with_cluster_new.sql0000644000401600037200000000207412007023242031043 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_column_new.sql0000644000401600037200000000207412007023242026435 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_new.sql0000644000401600037200000000207412007023242026621 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_original.sql0000644000401600037200000000025612007023242030144 0ustar cbecredativCREATE TABLE testtable ( field1 integer, field2 integer, field3 character varying(150) DEFAULT 'none'::character varying, field4 double precision ) WITH OIDS;apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_diff.sql0000644000401600037200000000027512027101706027252 0ustar cbecredativ DROP TRIGGER 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_new.sql0000644000401600037200000000776512007023242027466 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_default_value_diff.sql0000644000401600037200000000007512007023242027662 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field4 SET DEFAULT 0.0; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_original.sql0000644000401600037200000000211012007023242031305 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_diff.sql0000644000401600037200000000005612007023242030116 0ustar cbecredativ DROP FUNCTION power_number("input" integer); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_statistics_diff.sql0000644000401600037200000000010412007023242027764 0ustar cbecredativ ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS 200; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_diff.sql0000644000401600037200000000037012027101706030050 0ustar cbecredativ CREATE SEQUENCE table2_col1_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE table2 ( col1 integer DEFAULT nextval('table2_col1_seq'::regclass) NOT NULL ); ALTER SEQUENCE table2_col1_seq OWNED BY table2.col1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_original.sql0000644000401600037200000000776612007023242030502 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_diff.sql0000644000401600037200000000004612007023242032527 0ustar cbecredativ ALTER SEQUENCE testseq NO MAXVALUE; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comment_new_column_original.sql0000644000401600037200000000004212007023242031620 0ustar cbecredativCREATE TABLE agent( id BIGINT );apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/multiple_schemas_diff.sql0000644000401600037200000000131612027101706027573 0ustar cbecredativ DROP SCHEMA testschema1 CASCADE; CREATE SCHEMA testschema2; SET search_path = public, pg_catalog; DROP TABLE testtable2; DROP SEQUENCE testtable2_id_seq; CREATE SEQUENCE testtable3_id_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; CREATE TABLE testtable3 ( id bigint DEFAULT nextval('testtable3_id_seq'::regclass) NOT NULL ); ALTER SEQUENCE testtable3_id_seq OWNED BY testtable3.id; 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 ); ALTER SEQUENCE testtable1_id_seq OWNED BY testtable1.id; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_original.sql0000644000401600037200000000207412007023242027547 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_diff.sql0000644000401600037200000000011212007023242026327 0ustar cbecredativ ALTER TABLE testtable ADD COLUMN field5 boolean DEFAULT false NOT NULL; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_unique_constraint_diff.sql0000644000401600037200000000035112007023242030611 0ustar cbecredativ ALTER TABLE inventoryitemsupplier ADD CONSTRAINT inventoryitemsupplier_pkey PRIMARY KEY (id); ALTER TABLE inventoryitemsupplier ADD CONSTRAINT inventoryitemsupplier_5a808b9c_key UNIQUE (inventoryitemid, partneridentificationid); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_table_diff.sql0000644000401600037200000000003012007023242026334 0ustar cbecredativ DROP TABLE testtable2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args_new.sql0000644000401600037200000000260012007023242030317 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_diff.sql0000644000401600037200000000007212007023242030704 0ustar cbecredativALTER TABLE test ALTER COLUMN test_col SET DEFAULT now(); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_statistics_new.sql0000644000401600037200000000217712007023242027122 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_diff.sql0000644000401600037200000000003012007023242027055 0ustar cbecredativ DROP SEQUENCE testseq; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_new.sql0000644000401600037200000000235512007023242027312 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_on_original.sql0000644000401600037200000000243712007023242033565 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_original.sql0000644000401600037200000000261712007023242030144 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_original.sql0000644000401600037200000000207412007023242027571 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_unset_original.sql0000644000401600037200000000144712007023242033431 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_similar_new.sql0000644000401600037200000000345712007023242030277 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_defaults_new.sql0000644000401600037200000000345112007023242026533 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_new.sql0000644000401600037200000000165212007023242030022 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_diff.sql0000644000401600037200000000015212007023242027256 0ustar cbecredativ CREATE INDEX testindex2 ON testtable USING btree (field2); ALTER TABLE testtable CLUSTER ON testindex2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_original.sql0000644000401600037200000000144712007023242033427 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_diff.sql0000644000401600037200000000016712027101706027061 0ustar cbecredativ SET search_path = "ABC", pg_catalog; CREATE TABLE testtable2 ( id integer, name character varying(100) NOT NULL ); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_index_new.sql0000644000401600037200000000237612007023242026254 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_equal_whitespace_original.sql0000644000401600037200000000062412007023242032356 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comments_original.sql0000644000401600037200000000235612007023242027567 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_original.sql0000644000401600037200000000201712007023242027744 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_diff.sql0000644000401600037200000000077512007023242027112 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_comments_diff.sql0000644000401600037200000000116612007023242026671 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_empty_table_diff.sql0000644000401600037200000000003512027101706027347 0ustar cbecredativCREATE TABLE empty_table ( );apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_view_diff.sql0000644000401600037200000000014312007023242026547 0ustar cbecredativ DROP VIEW testview; CREATE VIEW testview AS SELECT testtable.name, testtable.id FROM testtable; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_table_original.sql0000644000401600037200000000243512007023242027243 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cache_diff.sql0000644000401600037200000000004312007023242030527 0ustar cbecredativ ALTER SEQUENCE testseq CACHE 10; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_diff.sql0000644000401600037200000000004012007023242031254 0ustar cbecredativ ALTER SEQUENCE testseq CYCLE; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_comments_original.sql0000644000401600037200000000353312007023242030001 0ustar cbecredativCOMMENT 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_diff.sql0000644000401600037200000000004612007023242032525 0ustar cbecredativ ALTER SEQUENCE testseq NO MINVALUE; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_diff.sql0000644000401600037200000000007312007023242032164 0ustar cbecredativ ALTER SEQUENCE testseq MAXVALUE 1000 RESTART WITH 1000; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_increment_original.sql0000644000401600037200000000144112007023242032347 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_transaction_original.sql0000644000401600037200000000776612007023242030301 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/0000755000401600037200000000000012007023242023765 5ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_14.sql0000644000401600037200000000765712007023242026271 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_9.sql0000644000401600037200000000225512007023242026202 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_1.sql0000644000401600037200000000150212007023242026164 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_2.sql0000644000401600037200000000022712007023242026170 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_5.sql0000644000401600037200000000133412007023242026173 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_6.sql0000644000401600037200000000234512007023242026177 0ustar cbecredativ-- -- 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; 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_4.sql0000644000401600037200000000021412007023242026166 0ustar cbecredativCREATE TABLE call_logs ( id bigint NOT NULL ); ALTER TABLE call_logs ALTER COLUMN id SET DEFAULT nextval('call_logs_id_seq'::regclass);apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_8.sql0000644000401600037200000000157112007023242026201 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_11.sql0000644000401600037200000000014112007023242026243 0ustar cbecredativCREATE FUNCTION curdate() RETURNS date LANGUAGE sql AS $$SELECT CAST('now' AS date); $$; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_13.sql0000644000401600037200000000024012007023242026245 0ustar cbecredativCREATE FUNCTION drop_fk_except_for(tables_in character varying[]) RETURNS SETOF character varying LANGUAGE plpgsql AS $$ DECLARE BEGIN -- aaa END; $$;apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_15.sql0000644000401600037200000000011612007023242026251 0ustar cbecredativCREATE TABLE test (id bigint); COMMENT ON TABLE test IS 'multiline comment ';apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_7.sql0000644000401600037200000000224112007023242026173 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_12.sql0000644000401600037200000000012512007023242026246 0ustar cbecredativCOMMENT ON DATABASE testdb IS 'The status : ''E'' for enabled, ''D'' for disabled.'; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_3.sql0000644000401600037200000000173512007023242026176 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/loader/schema_10.sql0000644000401600037200000000166112007023242026252 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_diff.sql0000644000401600037200000000022412007023242027761 0ustar cbecredativ ALTER TABLE testtable DROP CONSTRAINT field4check; ALTER TABLE testtable ADD CONSTRAINT field4check CHECK ((field4 > (0.0)::double precision)); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_cluster_original.sql0000644000401600037200000000215112007023242027630 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_cycle_on_original.sql0000644000401600037200000000144112007023242032156 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args2_new.sql0000644000401600037200000000213412007023242030060 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_new.sql0000644000401600037200000000021312007023242026472 0ustar cbecredativcreate 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_new.sql0000644000401600037200000000243712007023242026537 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_new.sql0000644000401600037200000000270212007023242030404 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_view_diff.sql0000644000401600037200000000011612007023242026010 0ustar cbecredativ CREATE VIEW testview AS SELECT testtable.id, testtable.name FROM testtable; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_diff.sql0000644000401600037200000000010312007023242027440 0ustar cbecredativ ALTER TABLE ONLY testtable ALTER COLUMN field4 SET STATISTICS -1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_start_ignore_off_new.sql0000644000401600037200000000244212007023242032704 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_drop_default_original.sql0000644000401600037200000000015312007023242032014 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_new.sql0000644000401600037200000000245712007023242027654 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_function_args_original.sql0000644000401600037200000000213412007023242030575 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_original.sql0000644000401600037200000000015312007023242032275 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; ALTER VIEW test ALTER COLUMN test_col SET DEFAULT now(); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_default_value_new.sql0000644000401600037200000000211012007023242030272 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_new.sql0000644000401600037200000000214712007023242026222 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_table_diff.sql0000644000401600037200000000012112007023242026121 0ustar cbecredativ CREATE TABLE testtable2 ( id integer, name character varying(100) NOT NULL ); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_add_default_original.sql0000644000401600037200000000006112007023242031576 0ustar cbecredativCREATE VIEW test AS SELECT test_col FROM test2; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_statistics_new.sql0000644000401600037200000000207412007023242027332 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_view_original.sql0000644000401600037200000000175712007023242026720 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_table_original.sql0000644000401600037200000000207412007023242027026 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_similar_original.sql0000644000401600037200000000345712007023242032051 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_index_diff.sql0000644000401600037200000000012212007023242026701 0ustar cbecredativ DROP INDEX testindex; CREATE INDEX testindex ON testtable USING btree (field3); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_not_null_original.sql0000644000401600037200000000210512007023242030000 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_index_diff.sql0000644000401600037200000000007412007023242026150 0ustar cbecredativ CREATE INDEX testindex3 ON testtable USING btree (field3); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_sequence_new.sql0000644000401600037200000000207412007023242026750 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_args2_original.sql0000644000401600037200000000267312007023242031426 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_function_end_detection_original.sql0000644000401600037200000000077212007023242033212 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_view_new.sql0000644000401600037200000000226712007023242025702 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_not_null_new.sql0000644000401600037200000000210512007023242026551 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_maxvalue_set_original.sql0000644000401600037200000000144212007023242033061 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_column_type_diff.sql0000644000401600037200000000042312007023242030134 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field1 TYPE integer /* TYPE change - table: testtable original: smallint new: integer */, ALTER COLUMN field3 TYPE character varying(150) /* TYPE change - table: testtable original: character varying(100) new: character varying(150) */; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_args_original.sql0000644000401600037200000000260012007023242031007 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_sequence_diff.sql0000644000401600037200000000013312007023242026645 0ustar cbecredativ CREATE SEQUENCE testseq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_new.sql0000644000401600037200000000226112007023242026601 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_column_add_defaults_diff.sql0000644000401600037200000000024312027101706031037 0ustar cbecredativ ALTER TABLE table1 ADD COLUMN col2 integer DEFAULT 0 NOT NULL, ADD COLUMN col3 integer DEFAULT 5 NOT NULL; ALTER TABLE table1 ALTER COLUMN col2 DROP DEFAULT; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/view_bug3080388_diff.sql0000644000401600037200000000000112007023242026604 0ustar cbecredativ apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_trigger_new.sql0000644000401600037200000000263312027101706027133 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_view_original.sql0000644000401600037200000000226712007023242027454 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/read_inherits_new.sql0000644000401600037200000000207612007023242026736 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_owned_sequence_new.sql0000644000401600037200000000542512027101706027737 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_inherits_original.sql0000644000401600037200000000202012007023242030312 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_with_oids_diff.sql0000644000401600037200000000005212007023242027242 0ustar cbecredativ ALTER TABLE testtable SET WITHOUT OIDS; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_constraint_original.sql0000644000401600037200000000253112007023242030660 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_index_new.sql0000644000401600037200000000262212007023242026032 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_sequence_minvalue_unset_new.sql0000644000401600037200000000144512007023242032412 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_inherits_diff.sql0000644000401600037200000000010412007023242026660 0ustar cbecredativ CREATE TABLE testtable ( field1 polygon ) INHERITS (parenttable); apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/inherited_tables_diff.sql0000644000401600037200000000000012007023242027523 0ustar cbecredativapgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_function_noargs_new.sql0000644000401600037200000000213412007023242030333 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_trigger_original.sql0000644000401600037200000000262512027101706027624 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_constraint_diff.sql0000644000401600037200000000006512007023242027441 0ustar cbecredativ ALTER TABLE testtable DROP CONSTRAINT field4check; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/add_cluster_new.sql0000644000401600037200000000473012007023242026406 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_default_value_diff.sql0000644000401600037200000000007212007023242030073 0ustar cbecredativ ALTER TABLE testtable ALTER COLUMN field4 DROP DEFAULT; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/modify_cluster_new.sql0000644000401600037200000000237612007023242027151 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_table_new.sql0000644000401600037200000000207412007023242026227 0ustar cbecredativ-- -- 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/alter_view_change_default_diff.sql0000644000401600037200000000006612007023242031404 0ustar cbecredativALTER TABLE test ALTER COLUMN test_col SET DEFAULT 1; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/drop_column_diff.sql0000644000401600037200000000005412007023242026550 0ustar cbecredativ ALTER TABLE testtable DROP COLUMN field5; apgdiff-2.4/src/test/resources/cz/startnet/utils/pgdiff/function_bug3084274_diff.sql0000644000401600037200000000040012007023242027460 0ustar cbecredativCREATE 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-2.4/src/test/resources/cz/startnet/utils/pgdiff/quoted_schema_original.sql0000644000401600037200000000244712027101706027760 0ustar cbecredativ-- -- 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-2.4/src/test/java/0000755000401600037200000000000012007023242014547 5ustar cbecredativapgdiff-2.4/src/test/java/cz/0000755000401600037200000000000012007023242015163 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/0000755000401600037200000000000012007023242017027 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/utils/0000755000401600037200000000000012007023242020167 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/utils/pgdiff/0000755000401600037200000000000012027101706021432 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java0000644000401600037200000004214312027101706024300 0ustar cbecredativ/** * 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 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. {"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}, // 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 --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} }); } /** * 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); 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-2.4/src/test/java/cz/startnet/utils/pgdiff/parsers/0000755000401600037200000000000012007023242023105 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/utils/pgdiff/parsers/ParserUtilsTest.java0000644000401600037200000000714612007023242027075 0ustar cbecredativ/** * 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-2.4/src/test/java/cz/startnet/utils/pgdiff/loader/0000755000401600037200000000000012027101706022700 5ustar cbecredativapgdiff-2.4/src/test/java/cz/startnet/utils/pgdiff/loader/PgDumpLoaderTest.java0000644000401600037200000000321512027101706026727 0ustar cbecredativ/** * 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} }); } /** * 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); } }