Commit 297b2c1e authored by Tom Lane's avatar Tom Lane

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.
parent 0e7e355f
...@@ -434,17 +434,6 @@ RestoreArchive(Archive *AHX) ...@@ -434,17 +434,6 @@ RestoreArchive(Archive *AHX)
ahprintf(AH, "BEGIN;\n\n"); ahprintf(AH, "BEGIN;\n\n");
} }
/*
* 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. * Establish important parameter values right away.
*/ */
...@@ -2804,6 +2793,12 @@ _doSetFixedOutputState(ArchiveHandle *AH) ...@@ -2804,6 +2793,12 @@ _doSetFixedOutputState(ArchiveHandle *AH)
if (!AH->public.std_strings) if (!AH->public.std_strings)
ahprintf(AH, "SET escape_string_warning = off;\n"); 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"); ahprintf(AH, "\n");
} }
......
...@@ -1005,6 +1005,17 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, ...@@ -1005,6 +1005,17 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
if (quote_all_identifiers && AH->remoteVersion >= 90100) if (quote_all_identifiers && AH->remoteVersion >= 90100)
ExecuteSqlStatement(AH, "SET quote_all_identifiers = true"); 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. * Start transaction-snapshot mode transaction to dump consistent data.
*/ */
...@@ -1058,14 +1069,6 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, ...@@ -1058,14 +1069,6 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
AH->remoteVersion >= 90200 && AH->remoteVersion >= 90200 &&
!dopt->no_synchronized_snapshots) !dopt->no_synchronized_snapshots)
AH->sync_snapshot_id = get_synchronized_snapshot(AH); 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 static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment