summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2015-02-18 17:23:40 +0000
committerTom Lane2015-02-18 17:23:40 +0000
commit297b2c1ef9878f84a9951beadf831ef390227238 (patch)
tree2713533d2598eb62bb0410d3086c9a4b0ca19c6f /src
parent0e7e355f27302b62af3e1add93853ccd45678443 (diff)
Fix placement of "SET row_security" command issuance in pg_dump.
Somebody apparently threw darts at the code to decide where to insert these. They certainly didn't proceed by adding them where other similar SETs were handled. This at least broke pg_restore, and perhaps other use-cases too.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c17
-rw-r--r--src/bin/pg_dump/pg_dump.c19
2 files changed, 17 insertions, 19 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index f461393dc25..ca427de7ae9 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -435,17 +435,6 @@ RestoreArchive(Archive *AHX)
}
/*
- * Enable row-security if necessary.
- */
- if (PQserverVersion(AH->connection) >= 90500)
- {
- if (!ropt->enable_row_security)
- ahprintf(AH, "SET row_security = off;\n");
- else
- ahprintf(AH, "SET row_security = on;\n");
- }
-
- /*
* Establish important parameter values right away.
*/
_doSetFixedOutputState(AH);
@@ -2804,6 +2793,12 @@ _doSetFixedOutputState(ArchiveHandle *AH)
if (!AH->public.std_strings)
ahprintf(AH, "SET escape_string_warning = off;\n");
+ /* Adjust row-security state */
+ if (AH->ropt && AH->ropt->enable_row_security)
+ ahprintf(AH, "SET row_security = on;\n");
+ else
+ ahprintf(AH, "SET row_security = off;\n");
+
ahprintf(AH, "\n");
}
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7e92b74916a..2b53c7218fe 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1006,6 +1006,17 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
ExecuteSqlStatement(AH, "SET quote_all_identifiers = true");
/*
+ * Adjust row-security mode, if supported.
+ */
+ if (AH->remoteVersion >= 90500)
+ {
+ if (dopt->enable_row_security)
+ ExecuteSqlStatement(AH, "SET row_security = on");
+ else
+ ExecuteSqlStatement(AH, "SET row_security = off");
+ }
+
+ /*
* Start transaction-snapshot mode transaction to dump consistent data.
*/
ExecuteSqlStatement(AH, "BEGIN");
@@ -1058,14 +1069,6 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
AH->remoteVersion >= 90200 &&
!dopt->no_synchronized_snapshots)
AH->sync_snapshot_id = get_synchronized_snapshot(AH);
-
- if (AH->remoteVersion >= 90500)
- {
- if (dopt->enable_row_security)
- ExecuteSqlStatement(AH, "SET row_security TO ON");
- else
- ExecuteSqlStatement(AH, "SET row_security TO OFF");
- }
}
static void