Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cbdca00

Browse files
committed
Fix missing dependency for pg_dump's ENABLE ROW LEVEL SECURITY items.
The archive should show a dependency on the item's table, but it failed to include one. This could cause failures in parallel restore due to emitting ALTER TABLE ... ENABLE ROW LEVEL SECURITY before restoring the table's data. In practice the odds of a problem seem low, since you would typically need to have set FORCE ROW LEVEL SECURITY as well, and you'd also need a very high --jobs count to have any chance of this happening. That probably explains the lack of field reports. Still, it's a bug, so back-patch to 9.5 where RLS was introduced. Discussion: https://postgr.es/m/19784.1535390902@sss.pgh.pa.us
1 parent 9b39b79 commit cbdca00

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/bin/pg_dump/pg_dump.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -3480,8 +3480,8 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
34803480

34813481
/*
34823482
* Get row security enabled information for the table. We represent
3483-
* RLS enabled on a table by creating PolicyInfo object with an empty
3484-
* policy.
3483+
* RLS being enabled on a table by creating a PolicyInfo object with
3484+
* null polname.
34853485
*/
34863486
if (tbinfo->rowsec)
34873487
{
@@ -3622,8 +3622,13 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
36223622
query = createPQExpBuffer();
36233623

36243624
appendPQExpBuffer(query, "ALTER TABLE %s ENABLE ROW LEVEL SECURITY;",
3625-
fmtQualifiedDumpable(polinfo));
3625+
fmtQualifiedDumpable(tbinfo));
36263626

3627+
/*
3628+
* We must emit the ROW SECURITY object's dependency on its table
3629+
* explicitly, because it will not match anything in pg_depend (unlike
3630+
* the case for other PolicyInfo objects).
3631+
*/
36273632
if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
36283633
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
36293634
polinfo->dobj.name,
@@ -3632,7 +3637,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
36323637
tbinfo->rolname, false,
36333638
"ROW SECURITY", SECTION_POST_DATA,
36343639
query->data, "", NULL,
3635-
NULL, 0,
3640+
&(tbinfo->dobj.dumpId), 1,
36363641
NULL, NULL);
36373642

36383643
destroyPQExpBuffer(query);

0 commit comments

Comments
 (0)