From 35ed1d71341f36f7bc29e0ec5fb3500a9619ecdc Mon Sep 17 00:00:00 2001 From: Anatoliy Basov Date: Mon, 28 Mar 2016 21:47:18 +0700 Subject: [PATCH] Add tests for pull request #129 Refactoring Update README --- README.md | 2 + .../java/cz/startnet/utils/pgdiff/Main.java | 42 ++---- .../java/cz/startnet/utils/pgdiff/PgDiff.java | 7 - .../startnet/utils/pgdiff/PgDiffTables.java | 12 +- .../cz/startnet/utils/pgdiff/PgDiffViews.java | 12 +- .../utils/pgdiff/loader/PgDumpLoader.java | 2 +- .../pgdiff/parsers/GrantRevokeParser.java | 11 +- .../utils/pgdiff/schema/PgColumn.java | 77 +++++----- .../pgdiff/schema/PgColumnPrivilege.java | 6 +- .../utils/pgdiff/schema/PgRelation.java | 48 +++++++ .../pgdiff/schema/PgRelationPrivilege.java | 2 +- .../utils/pgdiff/schema/PgSequence.java | 76 +++++----- .../pgdiff/schema/PgSequencePrivilege.java | 6 +- .../startnet/utils/pgdiff/schema/PgTable.java | 46 ------ .../startnet/utils/pgdiff/schema/PgView.java | 25 ---- .../cz/startnet/utils/pgdiff/PgDiffTest.java | 14 +- .../utils/pgdiff/add_table_bug102_diff.sql | 2 + .../utils/pgdiff/add_unlogged_table_diff.sql | 4 +- .../pgdiff/grant_on_table_sequence_diff.sql | 9 ++ .../pgdiff/grant_on_table_sequence_new.sql | 136 ++++++++++++++++++ .../utils/pgdiff/grant_on_view_diff.sql | 10 +- .../utils/pgdiff/grant_on_view_new.sql | 46 ++++-- .../utils/pgdiff/grant_on_view_original.sql | 52 +++++-- .../pgdiff/revoke_on_table_sequence_diff.sql | 7 +- .../pgdiff/revoke_on_table_sequence_new.sql | 35 +++-- .../revoke_on_table_sequence_original.sql | 17 ++- .../utils/pgdiff/revoke_on_view_diff.sql | 4 +- .../utils/pgdiff/revoke_on_view_new.sql | 5 +- .../utils/pgdiff/revoke_on_view_original.sql | 5 +- 29 files changed, 432 insertions(+), 288 deletions(-) diff --git a/README.md b/README.md index 3d42162d..c60f4250 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ fordfrog@fordfrog.com. * Added support for CREATE UNLOGGED TABLE (Anatoliy Basov) * Added support for /**/ comments (yulei) * Support of triggers for views + clause 'INSTEAD OF' (Sergej Bonich) +* Add support for GRANT and REVOKE on objects: table, view, sequence, column (serge-pouliquen-itf) +* Add support for ALTER TABLE ... OWNER TO (serge-pouliquen-itf) #### Fixes * Added hint to use "CREATE TABLE ... CONSTRAINT name PRIMARY KEY/UNIQUE ..." diff --git a/src/main/java/cz/startnet/utils/pgdiff/Main.java b/src/main/java/cz/startnet/utils/pgdiff/Main.java index c17f5fa4..9e40fcf1 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/Main.java +++ b/src/main/java/cz/startnet/utils/pgdiff/Main.java @@ -5,7 +5,6 @@ */ package cz.startnet.utils.pgdiff; -import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; @@ -13,19 +12,18 @@ /** * 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. + * + * @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 { @@ -34,39 +32,15 @@ public static void main(final String[] args) final PgDiffArguments arguments = new PgDiffArguments(); if (arguments.parse(writer, args)) { - // localvar in case of print @SuppressWarnings("UseOfSystemOutOrSystemErr") final PrintWriter encodedWriter = new PrintWriter( - new OutputStreamWriter(System.out, - arguments.getOutCharsetName()) { - @Override - public void write(int c) throws IOException { - PgDiff.hasPrint = true; - super.write(c); - } - - @Override - public void write(char cbuf[], int off, int len) - throws IOException { - PgDiff.hasPrint = true; - super.write(cbuf, off, len); - } - - @Override - public void write(String str, int off, int len) - throws IOException { - PgDiff.hasPrint = true; - super.write(str, off, len); - } - }); + new OutputStreamWriter( + System.out, arguments.getOutCharsetName())); PgDiff.createDiff(encodedWriter, arguments); encodedWriter.close(); } writer.close(); - if (PgDiff.isDifferent) { - System.exit(1); - } } /** diff --git a/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java b/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java index c024b09a..87514af5 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java +++ b/src/main/java/cz/startnet/utils/pgdiff/PgDiff.java @@ -110,9 +110,6 @@ private static void diffDatabaseSchemas(final PrintWriter writer, writer.println("START TRANSACTION;"); } - hasPrint = false; - isDifferent = false; - if (oldDatabase.getComment() == null && newDatabase.getComment() != null || oldDatabase.getComment() != null @@ -132,10 +129,6 @@ private static void diffDatabaseSchemas(final PrintWriter writer, createNewSchemas(writer, oldDatabase, newDatabase); updateSchemas(writer, arguments, oldDatabase, newDatabase); - if (hasPrint) { - isDifferent = true; - } - if (arguments.isAddTransaction()) { writer.println(); writer.println("COMMIT TRANSACTION;"); diff --git a/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java b/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java index c2825dde..a222e4c4 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java +++ b/src/main/java/cz/startnet/utils/pgdiff/PgDiffTables.java @@ -11,7 +11,7 @@ import cz.startnet.utils.pgdiff.schema.PgInheritedColumn; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgTable; -import cz.startnet.utils.pgdiff.schema.PgTablePrivilege; +import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; @@ -546,7 +546,7 @@ public static void createTables(final PrintWriter writer, + PgDiffUtils.getQuotedName(table.getName()) + " OWNER TO " + table.getOwnerTo() + ";"); } - for (PgTablePrivilege tablePrivilege : table.getPrivileges()) { + for (PgRelationPrivilege tablePrivilege : table.getPrivileges()) { writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(table.getName()) + " FROM " + tablePrivilege.getRoleName() + ";"); @@ -792,8 +792,8 @@ private static void alterPrivileges(final PrintWriter writer, final PgTable oldTable, final PgTable newTable, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; - for (PgTablePrivilege oldTablePrivilege : oldTable.getPrivileges()) { - PgTablePrivilege newTablePrivilege = newTable + for (PgRelationPrivilege oldTablePrivilege : oldTable.getPrivileges()) { + PgRelationPrivilege newTablePrivilege = newTable .getPrivilege(oldTablePrivilege.getRoleName()); if (newTablePrivilege == null) { if (!emptyLinePrinted) { @@ -828,8 +828,8 @@ private static void alterPrivileges(final PrintWriter writer, } } // else similar privilege will not be updated } - for (PgTablePrivilege newTablePrivilege : newTable.getPrivileges()) { - PgTablePrivilege oldTablePrivilege = oldTable + for (PgRelationPrivilege newTablePrivilege : newTable.getPrivileges()) { + PgRelationPrivilege oldTablePrivilege = oldTable .getPrivilege(newTablePrivilege.getRoleName()); if (oldTablePrivilege == null) { if (!emptyLinePrinted) { diff --git a/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java b/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java index ef3e1d36..8ef101c2 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java +++ b/src/main/java/cz/startnet/utils/pgdiff/PgDiffViews.java @@ -8,7 +8,7 @@ import cz.startnet.utils.pgdiff.schema.PgColumn; import cz.startnet.utils.pgdiff.schema.PgSchema; import cz.startnet.utils.pgdiff.schema.PgView; -import cz.startnet.utils.pgdiff.schema.PgViewPrivilege; +import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -40,7 +40,7 @@ public static void createViews(final PrintWriter writer, writer.println(); writer.println(newView.getCreationSQL()); - for (PgViewPrivilege viewPrivilege : newView.getPrivileges()) { + for (PgRelationPrivilege viewPrivilege : newView.getPrivileges()) { writer.println("REVOKE ALL ON TABLE " + PgDiffUtils.getQuotedName(newView.getName()) + " FROM " + viewPrivilege.getRoleName() + ";"); @@ -289,8 +289,8 @@ private static void alterPrivileges(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { boolean emptyLinePrinted = false; - for (PgViewPrivilege oldViewPrivilege : oldView.getPrivileges()) { - PgViewPrivilege newViewPrivilege = newView + for (PgRelationPrivilege oldViewPrivilege : oldView.getPrivileges()) { + PgRelationPrivilege newViewPrivilege = newView .getPrivilege(oldViewPrivilege.getRoleName()); if (newViewPrivilege == null) { if (!emptyLinePrinted) { @@ -323,8 +323,8 @@ private static void alterPrivileges(final PrintWriter writer, } } // else similar privilege will not be updated } - for (PgViewPrivilege newViewPrivilege : newView.getPrivileges()) { - PgViewPrivilege oldViewPrivilege = oldView + for (PgRelationPrivilege newViewPrivilege : newView.getPrivileges()) { + PgRelationPrivilege oldViewPrivilege = oldView .getPrivilege(newViewPrivilege.getRoleName()); if (oldViewPrivilege == null) { if (!emptyLinePrinted) { diff --git a/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java b/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java index e3a7986b..85f0e2c3 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java +++ b/src/main/java/cz/startnet/utils/pgdiff/loader/PgDumpLoader.java @@ -358,7 +358,7 @@ private static void stripComment(final StringBuilder sbStatement) { pos = sbStatement.indexOf("--", pos + 1); } - + int endPos = sbStatement.indexOf("*/"); if (endPos >= 0) { int startPos = sbStatement.indexOf("/*"); diff --git a/src/main/java/cz/startnet/utils/pgdiff/parsers/GrantRevokeParser.java b/src/main/java/cz/startnet/utils/pgdiff/parsers/GrantRevokeParser.java index 7724c566..fcb351f2 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/parsers/GrantRevokeParser.java +++ b/src/main/java/cz/startnet/utils/pgdiff/parsers/GrantRevokeParser.java @@ -18,9 +18,8 @@ import cz.startnet.utils.pgdiff.schema.PgSequence; import cz.startnet.utils.pgdiff.schema.PgSequencePrivilege; import cz.startnet.utils.pgdiff.schema.PgTable; -import cz.startnet.utils.pgdiff.schema.PgTablePrivilege; +import cz.startnet.utils.pgdiff.schema.PgRelationPrivilege; import cz.startnet.utils.pgdiff.schema.PgView; -import cz.startnet.utils.pgdiff.schema.PgViewPrivilege; /** * Parses GRANT statements. @@ -198,10 +197,10 @@ public static void parse(final PgDatabase database, final String statement, if (table != null) { for (String roleName : roles) { - PgTablePrivilege tablePrivilege = table + PgRelationPrivilege tablePrivilege = table .getPrivilege(roleName); if (tablePrivilege == null) { - tablePrivilege = new PgTablePrivilege(roleName); + tablePrivilege = new PgRelationPrivilege(roleName); table.addPrivilege(tablePrivilege); } for (String priv : privileges) { @@ -211,10 +210,10 @@ public static void parse(final PgDatabase database, final String statement, } } else if (view != null) { for (String roleName : roles) { - PgViewPrivilege viewPrivilege = view + PgRelationPrivilege viewPrivilege = view .getPrivilege(roleName); if (viewPrivilege == null) { - viewPrivilege = new PgViewPrivilege(roleName); + viewPrivilege = new PgRelationPrivilege(roleName); view.addPrivilege(viewPrivilege); } for (String priv : privileges) { diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java index c034dd43..fcceb48c 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.java @@ -5,17 +5,16 @@ */ package cz.startnet.utils.pgdiff.schema; +import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import cz.startnet.utils.pgdiff.PgDiffUtils; - /** * Stores column information. - * + * * @author fordfrog */ public class PgColumn { @@ -23,8 +22,8 @@ public class PgColumn { /** * Pattern for parsing NULL arguments. */ - private static final Pattern PATTERN_NULL = Pattern.compile( - "^(.+)[\\s]+NULL$", Pattern.CASE_INSENSITIVE); + private static final Pattern PATTERN_NULL = + Pattern.compile("^(.+)[\\s]+NULL$", Pattern.CASE_INSENSITIVE); /** * Pattern for parsing NOT NULL arguments. */ @@ -71,9 +70,8 @@ public class PgColumn { /** * Creates a new PgColumn object. - * - * @param name - * name of the column + * + * @param name name of the column */ public PgColumn(final String name) { this.name = name; @@ -81,7 +79,7 @@ public PgColumn(final String name) { /** * Getter for {@link #comment}. - * + * * @return {@link #comment} */ public String getComment() { @@ -90,9 +88,8 @@ public String getComment() { /** * Setter for {@link #comment}. - * - * @param comment - * {@link #comment} + * + * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; @@ -100,9 +97,8 @@ public void setComment(final String comment) { /** * Setter for {@link #defaultValue}. - * - * @param defaultValue - * {@link #defaultValue} + * + * @param defaultValue {@link #defaultValue} */ public void setDefaultValue(final String defaultValue) { this.defaultValue = defaultValue; @@ -110,7 +106,7 @@ public void setDefaultValue(final String defaultValue) { /** * Getter for {@link #defaultValue}. - * + * * @return {@link #defaultValue} */ public String getDefaultValue() { @@ -119,11 +115,10 @@ public String getDefaultValue() { /** * 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 - * + * + * @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) { @@ -153,9 +148,8 @@ public String getFullDefinition(final boolean addDefaults) { /** * Setter for {@link #name}. - * - * @param name - * {@link #name} + * + * @param name {@link #name} */ public void setName(final String name) { this.name = name; @@ -163,7 +157,7 @@ public void setName(final String name) { /** * Getter for {@link #name}. - * + * * @return {@link #name} */ public String getName() { @@ -172,9 +166,8 @@ public String getName() { /** * Setter for {@link #nullValue}. - * - * @param nullValue - * {@link #nullValue} + * + * @param nullValue {@link #nullValue} */ public void setNullValue(final boolean nullValue) { this.nullValue = nullValue; @@ -182,7 +175,7 @@ public void setNullValue(final boolean nullValue) { /** * Getter for {@link #nullValue}. - * + * * @return {@link #nullValue} */ public boolean getNullValue() { @@ -191,9 +184,8 @@ public boolean getNullValue() { /** * Setter for {@link #statistics}. - * - * @param statistics - * {@link #statistics} + * + * @param statistics {@link #statistics} */ public void setStatistics(final Integer statistics) { this.statistics = statistics; @@ -201,7 +193,7 @@ public void setStatistics(final Integer statistics) { /** * Getter for {@link #statistics}. - * + * * @return {@link #statistics} */ public Integer getStatistics() { @@ -210,7 +202,7 @@ public Integer getStatistics() { /** * Getter for {@link #storage}. - * + * * @return {@link #storage} */ public String getStorage() { @@ -219,9 +211,8 @@ public String getStorage() { /** * Setter for {@link #storage}. - * - * @param storage - * {@link #storage} + * + * @param storage {@link #storage} */ public void setStorage(final String storage) { this.storage = storage; @@ -229,9 +220,8 @@ public void setStorage(final String storage) { /** * Setter for {@link #type}. - * - * @param type - * {@link #type} + * + * @param type {@link #type} */ public void setType(final String type) { this.type = type; @@ -239,7 +229,7 @@ public void setType(final String type) { /** * Getter for {@link #type}. - * + * * @return {@link #type} */ public String getType() { @@ -265,9 +255,8 @@ public List getPrivileges() { /** * Parses definition of the column - * - * @param definition - * definition of the column + * + * @param definition definition of the column */ public void parseDefinition(final String definition) { String string = definition; diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnPrivilege.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnPrivilege.java index 216a9ff2..95240354 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnPrivilege.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgColumnPrivilege.java @@ -27,7 +27,7 @@ public class PgColumnPrivilege { /** * Creates a new PgTablePrivilege object. * - * @param name + * @param roleName * name of the role */ public PgColumnPrivilege(final String roleName) { @@ -104,8 +104,8 @@ public void setPrivileges(final String privilege, final boolean value, /** * true the privileges are the same (no matter of roleName). * - * @param name - * name of the column + * @param other + * privileges to compare */ public boolean isSimilar(final PgColumnPrivilege other) { if (other == null) { diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelation.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelation.java index 5404dc37..eaa29c00 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelation.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelation.java @@ -50,6 +50,16 @@ public abstract class PgRelation { */ String comment; + /** + * List of privileges defined on the table. + */ + @SuppressWarnings("CollectionWithoutInitialCapacity") + private final List privileges = new ArrayList(); + /** + * Column the table is owner to. + */ + private String ownerTo; + /** * Setter for {@link #clusterIndexName}. * @@ -340,4 +350,42 @@ public boolean containsIndex(final String name) { return false; } + + public List getPrivileges() { + return Collections.unmodifiableList(privileges); + } + + /** + * Getter for {@link #ownerTo}. + * + * @return {@link #ownerTo} + */ + public String getOwnerTo() { + return ownerTo; + } + + /** + * Setter for {@link #ownerTo}. + * + * @param ownerTo + * {@link #ownerTo} + */ + public void setOwnerTo(final String ownerTo) { + this.ownerTo = ownerTo; + } + + + public void addPrivilege(final PgRelationPrivilege privilege) { + privileges.add(privilege); + } + + + public PgRelationPrivilege getPrivilege(final String roleName) { + for (PgRelationPrivilege privilege : privileges) { + if (privilege.getRoleName().equals(roleName)) { + return privilege; + } + } + return null; + } } diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelationPrivilege.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelationPrivilege.java index de978a75..457464f5 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelationPrivilege.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgRelationPrivilege.java @@ -156,7 +156,7 @@ public void setPrivileges(final String privilege, final boolean value, * @param other * privileges to compare */ - public boolean isSimilar(final PgTablePrivilege other) { + public boolean isSimilar(final PgRelationPrivilege other) { if (other == null) { return false; } diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java index 1fe12cc3..0a26e121 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequence.java @@ -13,7 +13,7 @@ /** * Stores sequence information. - * + * * @author fordfrog */ public class PgSequence { @@ -62,9 +62,8 @@ public class PgSequence { /** * Creates a new PgSequence object. - * - * @param name - * name of the sequence + * + * @param name name of the sequence */ public PgSequence(final String name) { this.name = name; @@ -72,9 +71,8 @@ public PgSequence(final String name) { /** * Setter for {@link #cache}. - * - * @param cache - * {@link #cache} + * + * @param cache {@link #cache} */ public void setCache(final String cache) { this.cache = cache; @@ -82,7 +80,7 @@ public void setCache(final String cache) { /** * Getter for {@link #cache}. - * + * * @return {@link #cache} */ public String getCache() { @@ -91,7 +89,7 @@ public String getCache() { /** * Getter for {@link #comment}. - * + * * @return {@link #comment} */ public String getComment() { @@ -100,9 +98,8 @@ public String getComment() { /** * Setter for {@link #comment}. - * - * @param comment - * {@link #comment} + * + * @param comment {@link #comment} */ public void setComment(final String comment) { this.comment = comment; @@ -110,7 +107,7 @@ public void setComment(final String comment) { /** * Creates and returns SQL statement for creation of the sequence. - * + * * @return created SQL statement */ public String getCreationSQL() { @@ -178,7 +175,7 @@ public String getCreationSQL() { /** * Creates and returns SQL statement for modification "OWNED BY" parameter. - * + * * @return created SQL statement */ public String getOwnedBySQL() { @@ -200,9 +197,8 @@ public String getOwnedBySQL() { /** * Setter for {@link #cycle}. - * - * @param cycle - * {@link #cycle} + * + * @param cycle {@link #cycle} */ public void setCycle(final boolean cycle) { this.cycle = cycle; @@ -210,7 +206,7 @@ public void setCycle(final boolean cycle) { /** * Getter for {@link #cycle}. - * + * * @return {@link #cycle} */ public boolean isCycle() { @@ -219,7 +215,7 @@ public boolean isCycle() { /** * Creates and returns SQL statement for dropping the sequence. - * + * * @return created SQL */ public String getDropSQL() { @@ -228,9 +224,8 @@ public String getDropSQL() { /** * Setter for {@link #increment}. - * - * @param increment - * {@link #increment} + * + * @param increment {@link #increment} */ public void setIncrement(final String increment) { this.increment = increment; @@ -238,7 +233,7 @@ public void setIncrement(final String increment) { /** * Getter for {@link #increment}. - * + * * @return {@link #increment} */ public String getIncrement() { @@ -247,9 +242,8 @@ public String getIncrement() { /** * Setter for {@link #maxValue}. - * - * @param maxValue - * {@link #maxValue} + * + * @param maxValue {@link #maxValue} */ public void setMaxValue(final String maxValue) { this.maxValue = maxValue; @@ -257,7 +251,7 @@ public void setMaxValue(final String maxValue) { /** * Getter for {@link #maxValue}. - * + * * @return {@link #maxValue} */ public String getMaxValue() { @@ -266,9 +260,8 @@ public String getMaxValue() { /** * Setter for {@link #minValue}. - * - * @param minValue - * {@link #minValue} + * + * @param minValue {@link #minValue} */ public void setMinValue(final String minValue) { this.minValue = minValue; @@ -276,7 +269,7 @@ public void setMinValue(final String minValue) { /** * Getter for {@link #minValue}. - * + * * @return {@link #minValue} */ public String getMinValue() { @@ -285,9 +278,8 @@ public String getMinValue() { /** * Setter for {@link #name}. - * - * @param name - * {@link #name} + * + * @param name {@link #name} */ public void setName(final String name) { this.name = name; @@ -295,7 +287,7 @@ public void setName(final String name) { /** * Getter for {@link #name}. - * + * * @return {@link #name} */ public String getName() { @@ -304,9 +296,8 @@ public String getName() { /** * Setter for {@link #startWith}. - * - * @param startWith - * {@link #startWith} + * + * @param startWith {@link #startWith} */ public void setStartWith(final String startWith) { this.startWith = startWith; @@ -314,7 +305,7 @@ public void setStartWith(final String startWith) { /** * Getter for {@link #startWith}. - * + * * @return {@link #startWith} */ public String getStartWith() { @@ -323,7 +314,7 @@ public String getStartWith() { /** * Getter for {@link #ownedBy}. - * + * * @return {@link #ownedBy} */ public String getOwnedBy() { @@ -332,9 +323,8 @@ public String getOwnedBy() { /** * Setter for {@link #ownedBy}. - * - * @param ownedBy - * {@link #ownedBy} + * + * @param ownedBy {@link #ownedBy} */ public void setOwnedBy(final String ownedBy) { this.ownedBy = ownedBy; diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequencePrivilege.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequencePrivilege.java index 39fc9399..0f07560b 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequencePrivilege.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgSequencePrivilege.java @@ -25,7 +25,7 @@ public class PgSequencePrivilege { /** * Creates a new PgSequencePrivilege object. * - * @param name + * @param roleName * name of the role */ public PgSequencePrivilege(final String roleName) { @@ -88,8 +88,8 @@ public void setPrivileges(final String privilege, final boolean value, /** * true the privileges are the same (no matter of roleName). * - * @param name - * name of the column + * @param other + * privileges to compare */ public boolean isSimilar(final PgSequencePrivilege other) { if (other == null) { diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java index edd403f7..863f8a6a 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java @@ -54,15 +54,6 @@ public class PgTable extends PgRelation { * PgSchema */ private final PgSchema schema; - /** - * List of privileges defined on the table. - */ - @SuppressWarnings("CollectionWithoutInitialCapacity") - private final List privileges = new ArrayList(); - /** - * Column the table is owner to. - */ - private String ownerTo; /** * Creates a new PgTable object. @@ -75,10 +66,6 @@ public PgTable(final String name, final PgDatabase database, final PgSchema sche this.schema = schema; } - public List getPrivileges() { - return Collections.unmodifiableList(privileges); - } - /** * Finds constraint according to specified constraint {@code name}. * @@ -236,16 +223,6 @@ public String getCreationSQL(final PgSchema schema) { return sbSQL.toString(); } - - public PgTablePrivilege getPrivilege(final String roleName) { - for (PgTablePrivilege privilege : privileges) { - if (privilege.getRoleName().equals(roleName)) { - return privilege; - } - } - return null; - } - /** * Setter for {@link #inherits}. * @@ -305,25 +282,6 @@ public void setTablespace(final String tablespace) { this.tablespace = tablespace; } - /** - * Getter for {@link #ownerTo}. - * - * @return {@link #ownerTo} - */ - public String getOwnerTo() { - return ownerTo; - } - - /** - * Setter for {@link #ownerTo}. - * - * @param ownerTo - * {@link #ownerTo} - */ - public void setOwnerTo(final String ownerTo) { - this.ownerTo = ownerTo; - } - /** * Adds {@code column} to the list of columns. * @@ -399,10 +357,6 @@ public boolean containsInheritedColumn(final String name) { return false; } - public void addPrivilege(final PgTablePrivilege privilege) { - privileges.add(privilege); - } - /** * Returns true if table contains given constraint {@code name}, otherwise * false. diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java index e52b1530..043ee1b5 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java @@ -7,7 +7,6 @@ import cz.startnet.utils.pgdiff.PgDiffUtils; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -30,12 +29,6 @@ public class PgView extends PgRelation { */ private String query; - /** - * List of privileges defined on the view. - */ - @SuppressWarnings("CollectionWithoutInitialCapacity") - private final List privileges = new ArrayList(); - /** * Creates a new PgView object. * @@ -84,24 +77,6 @@ public List getDeclaredColumnNames() { return list; } - public List getPrivileges() { - return Collections.unmodifiableList(privileges); - } - - public PgViewPrivilege getPrivilege(final String roleName) { - for (PgViewPrivilege privilege : privileges) { - if (privilege.getRoleName().equals(roleName)) { - return privilege; - } - } - return null; - } - - public void addPrivilege(final PgViewPrivilege privilege) { - privileges.add(privilege); - } - - /** * Returns relation kind for CREATE/ALTER/DROP commands. * diff --git a/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java b/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java index 80153670..d3924d04 100644 --- a/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java +++ b/src/test/java/cz/startnet/utils/pgdiff/PgDiffTest.java @@ -231,16 +231,10 @@ public static Collection parameters() { // Tests view triggers (support for 'INSTEAD OF') {"view_triggers", false, false, false, false}, // Tests privileges - { "privileges_enhancement89_test1", false, false, - false, false }, - { "privileges_enhancement89_test1a", false, false, - false, false }, - { "privileges_enhancement89_test2", false, false, - false, false }, - { "privileges_enhancement89_test3", false, false, - false, false }, - { "privileges_enhancement89_test4", false, false, - false, false }, + {"grant_on_table_sequence", false, false, false, false}, + {"revoke_on_table_sequence", false, false, false, false}, + {"grant_on_view", false, false, false, false}, + {"revoke_on_view", false, false, false, false} }); } /** diff --git a/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_diff.sql index 38f5b7d8..3bd2bdea 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/add_table_bug102_diff.sql @@ -4,5 +4,7 @@ CREATE TABLE "procedureresult$Operation" ( result_id bigint ); +ALTER TABLE "procedureresult$Operation" OWNER TO fordfrog; + ALTER TABLE "procedureresult$Operation" ADD CONSTRAINT $1 FOREIGN KEY (result_id) REFERENCES testtable(field1) ON UPDATE RESTRICT ON DELETE RESTRICT; \ No newline at end of file diff --git a/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_diff.sql index 7481fc78..6ca68fa1 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/add_unlogged_table_diff.sql @@ -4,4 +4,6 @@ CREATE UNLOGGED TABLE asset_country_weight ( asset integer NOT NULL, country character varying(3) NOT NULL, scaled_weight double precision NOT NULL -); \ No newline at end of file +); + +ALTER TABLE asset_country_weight OWNER TO asi; \ No newline at end of file diff --git a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_diff.sql index e69de29b..fd6fe223 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_diff.sql @@ -0,0 +1,9 @@ + +REVOKE ALL ON SEQUENCE table1_id_seq FROM public; +GRANT SELECT, USAGE ON SEQUENCE table1_id_seq TO public; + +REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; +GRANT ALL ON SEQUENCE table1_id_seq TO dv; + +REVOKE ALL ON TABLE table1 FROM public; +GRANT SELECT, UPDATE ON TABLE table1 TO public; \ No newline at end of file diff --git a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_new.sql b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_new.sql index e69de29b..a8782566 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_new.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_table_sequence_new.sql @@ -0,0 +1,136 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.5.1 +-- Dumped by pg_dump version 9.5.1 + +-- Started on 2016-03-28 20:51:36 KRAT + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SET check_function_bodies = false; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- TOC entry 1 (class 3079 OID 12395) +-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: +-- + +CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; + + +-- +-- TOC entry 2144 (class 0 OID 0) +-- Dependencies: 1 +-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: +-- + +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; + + +SET search_path = public, pg_catalog; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- TOC entry 182 (class 1259 OID 17707) +-- Name: table1; Type: TABLE; Schema: public; Owner: dv +-- + +CREATE TABLE table1 ( + id integer NOT NULL, + msg text, + date_create timestamp without time zone +); + + +ALTER TABLE table1 OWNER TO dv; + +-- +-- TOC entry 181 (class 1259 OID 17705) +-- Name: table1_id_seq; Type: SEQUENCE; Schema: public; Owner: dv +-- + +CREATE SEQUENCE table1_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE table1_id_seq OWNER TO dv; + +-- +-- TOC entry 2146 (class 0 OID 0) +-- Dependencies: 181 +-- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv +-- + +ALTER SEQUENCE table1_id_seq OWNED BY table1.id; + + +-- +-- TOC entry 2020 (class 2604 OID 17710) +-- Name: id; Type: DEFAULT; Schema: public; Owner: dv +-- + +ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); + + +-- +-- TOC entry 2022 (class 2606 OID 17715) +-- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv +-- + +ALTER TABLE ONLY table1 + ADD CONSTRAINT table1_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 2143 (class 0 OID 0) +-- Dependencies: 6 +-- Name: public; Type: ACL; Schema: -; Owner: postgres +-- + +REVOKE ALL ON SCHEMA public FROM PUBLIC; +REVOKE ALL ON SCHEMA public FROM postgres; +GRANT ALL ON SCHEMA public TO postgres; +GRANT ALL ON SCHEMA public TO PUBLIC; + + +-- +-- TOC entry 2145 (class 0 OID 0) +-- Dependencies: 182 +-- Name: table1; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON TABLE table1 FROM PUBLIC; +REVOKE ALL ON TABLE table1 FROM dv; +GRANT ALL ON TABLE table1 TO dv; +GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; + + +-- +-- TOC entry 2147 (class 0 OID 0) +-- Dependencies: 181 +-- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; +GRANT ALL ON SEQUENCE table1_id_seq TO dv; +GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; + + +-- Completed on 2016-03-28 20:51:36 KRAT + +-- +-- PostgreSQL database dump complete +-- diff --git a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_diff.sql index fd6fe223..8a17fd40 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_diff.sql @@ -1,9 +1,3 @@ -REVOKE ALL ON SEQUENCE table1_id_seq FROM public; -GRANT SELECT, USAGE ON SEQUENCE table1_id_seq TO public; - -REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; -GRANT ALL ON SEQUENCE table1_id_seq TO dv; - -REVOKE ALL ON TABLE table1 FROM public; -GRANT SELECT, UPDATE ON TABLE table1 TO public; \ No newline at end of file +REVOKE ALL ON TABLE view1 FROM public; +GRANT SELECT, INSERT ON TABLE view1 TO public; diff --git a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_new.sql b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_new.sql index a8782566..2958f551 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_new.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_new.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 20:51:36 KRAT +-- Started on 2016-03-28 21:21:00 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -24,7 +24,7 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- --- TOC entry 2144 (class 0 OID 0) +-- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- @@ -68,7 +68,7 @@ CREATE SEQUENCE table1_id_seq ALTER TABLE table1_id_seq OWNER TO dv; -- --- TOC entry 2146 (class 0 OID 0) +-- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- @@ -77,7 +77,21 @@ ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- --- TOC entry 2020 (class 2604 OID 17710) +-- TOC entry 183 (class 1259 OID 17716) +-- Name: view1; Type: VIEW; Schema: public; Owner: dv +-- + +CREATE VIEW view1 AS + SELECT table1.id, + table1.msg, + table1.date_create + FROM table1; + + +ALTER TABLE view1 OWNER TO dv; + +-- +-- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- @@ -85,7 +99,7 @@ ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::reg -- --- TOC entry 2022 (class 2606 OID 17715) +-- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- @@ -94,7 +108,7 @@ ALTER TABLE ONLY table1 -- --- TOC entry 2143 (class 0 OID 0) +-- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- @@ -106,7 +120,7 @@ GRANT ALL ON SCHEMA public TO PUBLIC; -- --- TOC entry 2145 (class 0 OID 0) +-- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- @@ -114,11 +128,10 @@ GRANT ALL ON SCHEMA public TO PUBLIC; REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; -- --- TOC entry 2147 (class 0 OID 0) +-- TOC entry 2152 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- @@ -126,10 +139,21 @@ GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; --- Completed on 2016-03-28 20:51:36 KRAT +-- +-- TOC entry 2153 (class 0 OID 0) +-- Dependencies: 183 +-- Name: view1; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON TABLE view1 FROM PUBLIC; +REVOKE ALL ON TABLE view1 FROM dv; +GRANT ALL ON TABLE view1 TO dv; +GRANT SELECT,INSERT ON TABLE view1 TO PUBLIC; + + +-- Completed on 2016-03-28 21:21:00 KRAT -- -- PostgreSQL database dump complete diff --git a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_original.sql b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_original.sql index a1e7d30b..84ecdb02 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_original.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/grant_on_view_original.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 20:49:16 KRAT +-- Started on 2016-03-28 21:18:55 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -24,7 +24,7 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- --- TOC entry 2144 (class 0 OID 0) +-- TOC entry 2149 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- @@ -68,7 +68,7 @@ CREATE SEQUENCE table1_id_seq ALTER TABLE table1_id_seq OWNER TO dv; -- --- TOC entry 2146 (class 0 OID 0) +-- TOC entry 2151 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- @@ -77,7 +77,21 @@ ALTER SEQUENCE table1_id_seq OWNED BY table1.id; -- --- TOC entry 2020 (class 2604 OID 17710) +-- TOC entry 183 (class 1259 OID 17716) +-- Name: view1; Type: VIEW; Schema: public; Owner: dv +-- + +CREATE VIEW view1 AS + SELECT table1.id, + table1.msg, + table1.date_create + FROM table1; + + +ALTER TABLE view1 OWNER TO dv; + +-- +-- TOC entry 2024 (class 2604 OID 17710) -- Name: id; Type: DEFAULT; Schema: public; Owner: dv -- @@ -85,7 +99,7 @@ ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::reg -- --- TOC entry 2022 (class 2606 OID 17715) +-- TOC entry 2026 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv -- @@ -94,7 +108,7 @@ ALTER TABLE ONLY table1 -- --- TOC entry 2143 (class 0 OID 0) +-- TOC entry 2148 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- @@ -106,7 +120,7 @@ GRANT ALL ON SCHEMA public TO PUBLIC; -- --- TOC entry 2145 (class 0 OID 0) +-- TOC entry 2150 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- @@ -116,7 +130,29 @@ REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; --- Completed on 2016-03-28 20:49:16 KRAT +-- +-- TOC entry 2152 (class 0 OID 0) +-- Dependencies: 181 +-- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; +GRANT ALL ON SEQUENCE table1_id_seq TO dv; + + +-- +-- TOC entry 2153 (class 0 OID 0) +-- Dependencies: 183 +-- Name: view1; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON TABLE view1 FROM PUBLIC; +REVOKE ALL ON TABLE view1 FROM dv; +GRANT ALL ON TABLE view1 TO dv; + + +-- Completed on 2016-03-28 21:18:55 KRAT -- -- PostgreSQL database dump complete diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_diff.sql index fd6fe223..bc5841b4 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_diff.sql @@ -1,9 +1,4 @@ REVOKE ALL ON SEQUENCE table1_id_seq FROM public; -GRANT SELECT, USAGE ON SEQUENCE table1_id_seq TO public; -REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; -GRANT ALL ON SEQUENCE table1_id_seq TO dv; - -REVOKE ALL ON TABLE table1 FROM public; -GRANT SELECT, UPDATE ON TABLE table1 TO public; \ No newline at end of file +REVOKE ALL ON TABLE table1 FROM public; \ No newline at end of file diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_new.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_new.sql index a8782566..22020d12 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_new.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_new.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 20:51:36 KRAT +-- Started on 2016-03-28 21:12:09 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -24,7 +24,7 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- --- TOC entry 2144 (class 0 OID 0) +-- TOC entry 2146 (class 0 OID 0) -- Dependencies: 1 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- @@ -68,7 +68,7 @@ CREATE SEQUENCE table1_id_seq ALTER TABLE table1_id_seq OWNER TO dv; -- --- TOC entry 2146 (class 0 OID 0) +-- TOC entry 2148 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dv -- @@ -84,6 +84,25 @@ ALTER SEQUENCE table1_id_seq OWNED BY table1.id; ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass); +-- +-- TOC entry 2138 (class 0 OID 17707) +-- Dependencies: 182 +-- Data for Name: table1; Type: TABLE DATA; Schema: public; Owner: dv +-- + +COPY table1 (id, msg, date_create) FROM stdin; +\. + + +-- +-- TOC entry 2150 (class 0 OID 0) +-- Dependencies: 181 +-- Name: table1_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dv +-- + +SELECT pg_catalog.setval('table1_id_seq', 1, false); + + -- -- TOC entry 2022 (class 2606 OID 17715) -- Name: table1_pkey; Type: CONSTRAINT; Schema: public; Owner: dv @@ -94,7 +113,7 @@ ALTER TABLE ONLY table1 -- --- TOC entry 2143 (class 0 OID 0) +-- TOC entry 2145 (class 0 OID 0) -- Dependencies: 6 -- Name: public; Type: ACL; Schema: -; Owner: postgres -- @@ -106,7 +125,7 @@ GRANT ALL ON SCHEMA public TO PUBLIC; -- --- TOC entry 2145 (class 0 OID 0) +-- TOC entry 2147 (class 0 OID 0) -- Dependencies: 182 -- Name: table1; Type: ACL; Schema: public; Owner: dv -- @@ -114,11 +133,10 @@ GRANT ALL ON SCHEMA public TO PUBLIC; REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; -GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; -- --- TOC entry 2147 (class 0 OID 0) +-- TOC entry 2149 (class 0 OID 0) -- Dependencies: 181 -- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv -- @@ -126,10 +144,9 @@ GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; GRANT ALL ON SEQUENCE table1_id_seq TO dv; -GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; --- Completed on 2016-03-28 20:51:36 KRAT +-- Completed on 2016-03-28 21:12:09 KRAT -- -- PostgreSQL database dump complete diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_original.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_original.sql index a1e7d30b..a8782566 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_original.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_table_sequence_original.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 20:49:16 KRAT +-- Started on 2016-03-28 20:51:36 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -114,9 +114,22 @@ GRANT ALL ON SCHEMA public TO PUBLIC; REVOKE ALL ON TABLE table1 FROM PUBLIC; REVOKE ALL ON TABLE table1 FROM dv; GRANT ALL ON TABLE table1 TO dv; +GRANT SELECT,UPDATE ON TABLE table1 TO PUBLIC; --- Completed on 2016-03-28 20:49:16 KRAT +-- +-- TOC entry 2147 (class 0 OID 0) +-- Dependencies: 181 +-- Name: table1_id_seq; Type: ACL; Schema: public; Owner: dv +-- + +REVOKE ALL ON SEQUENCE table1_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE table1_id_seq FROM dv; +GRANT ALL ON SEQUENCE table1_id_seq TO dv; +GRANT SELECT,USAGE ON SEQUENCE table1_id_seq TO PUBLIC; + + +-- Completed on 2016-03-28 20:51:36 KRAT -- -- PostgreSQL database dump complete diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_diff.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_diff.sql index 8a17fd40..434c98d2 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_diff.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_diff.sql @@ -1,3 +1 @@ - -REVOKE ALL ON TABLE view1 FROM public; -GRANT SELECT, INSERT ON TABLE view1 TO public; +REVOKE ALL ON TABLE view1 FROM public; \ No newline at end of file diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_new.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_new.sql index 2958f551..84ecdb02 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_new.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_new.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 21:21:00 KRAT +-- Started on 2016-03-28 21:18:55 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -150,10 +150,9 @@ GRANT ALL ON SEQUENCE table1_id_seq TO dv; REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; -GRANT SELECT,INSERT ON TABLE view1 TO PUBLIC; --- Completed on 2016-03-28 21:21:00 KRAT +-- Completed on 2016-03-28 21:18:55 KRAT -- -- PostgreSQL database dump complete diff --git a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_original.sql b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_original.sql index 84ecdb02..2958f551 100644 --- a/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_original.sql +++ b/src/test/resources/cz/startnet/utils/pgdiff/revoke_on_view_original.sql @@ -5,7 +5,7 @@ -- Dumped from database version 9.5.1 -- Dumped by pg_dump version 9.5.1 --- Started on 2016-03-28 21:18:55 KRAT +-- Started on 2016-03-28 21:21:00 KRAT SET statement_timeout = 0; SET lock_timeout = 0; @@ -150,9 +150,10 @@ GRANT ALL ON SEQUENCE table1_id_seq TO dv; REVOKE ALL ON TABLE view1 FROM PUBLIC; REVOKE ALL ON TABLE view1 FROM dv; GRANT ALL ON TABLE view1 TO dv; +GRANT SELECT,INSERT ON TABLE view1 TO PUBLIC; --- Completed on 2016-03-28 21:18:55 KRAT +-- Completed on 2016-03-28 21:21:00 KRAT -- -- PostgreSQL database dump complete