Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10e705b

Browse files
committed
Fix omission of column-level privileges in selective pg_restore.
In a selective restore, ACLs for a table should be dumped if thetable is selected to be dumped. However, if the table has bothtable-level and column-level ACLs, only the table-level ACL wasrestored. This happened because _tocEntryRequired assumed thatan ACL could have only one dependency (the one on its table),and punted if there was more than one. But since commitea91253,column-level ACLs also depend on the table-level ACL if any, toensure correct ordering in parallel restores. To fix, adjust thelogic in _tocEntryRequired to ignore dependencies on ACLs.I extended a test case in 002_pg_dump.pl so that it purports totest for this; but in fact the test passes even without the fix.That's because this bug only manifests during a selective restore,while the scenarios 002_pg_dump.pl tests include only selective dumps.Perhaps somebody would like to extend the script so that it can testscenarios including selective restore, but I'm not touching that.Euler Taveira and Tom Lane, per report from Kong Man.Back-patch to all supported branches.Discussion:https://postgr.es/m/DM4PR11MB73976902DBBA10B1D652F9498B06A@DM4PR11MB7397.namprd11.prod.outlook.com
1 parent0684d19 commit10e705b

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,10 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
29162916
* TOC entry types only if their parent object is being restored.
29172917
* Without selectivity options, we let through everything in the
29182918
* archive. Note there may be such entries with no parent, eg
2919-
* non-default ACLs for built-in objects.
2919+
* non-default ACLs for built-in objects. Also, we make
2920+
* per-column ACLs additionally depend on the table's ACL if any
2921+
* to ensure correct restore order, so those dependencies should
2922+
* be ignored in this check.
29202923
*
29212924
* This code depends on the parent having been marked already,
29222925
* which should be the case; if it isn't, perhaps due to
@@ -2927,8 +2930,23 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
29272930
* But it's hard to tell which of their dependencies is the one to
29282931
* consult.
29292932
*/
2930-
if (te->nDeps!=1||
2931-
TocIDRequired(AH,te->dependencies[0])==0)
2933+
booldumpthis= false;
2934+
2935+
for (inti=0;i<te->nDeps;i++)
2936+
{
2937+
TocEntry*pte=getTocEntryByDumpId(AH,te->dependencies[i]);
2938+
2939+
if (!pte)
2940+
continue;/* probably shouldn't happen */
2941+
if (strcmp(pte->desc,"ACL")==0)
2942+
continue;/* ignore dependency on another ACL */
2943+
if (pte->reqs==0)
2944+
continue;/* this object isn't marked, so ignore it */
2945+
/* Found a parent to be dumped, so we want to dump this too */
2946+
dumpthis= true;
2947+
break;
2948+
}
2949+
if (!dumpthis)
29322950
return0;
29332951
}
29342952
}

‎src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,11 +3586,13 @@
35863586
35873587
'GRANT SELECT ON TABLE measurement' => {
35883588
create_order => 91,
3589-
create_sql => 'GRANT SELECT ON
3590-
TABLE dump_test.measurement
3591-
TO regress_dump_test_role;',
3589+
create_sql => 'GRANT SELECT ON TABLE dump_test.measurement
3590+
TO regress_dump_test_role;
3591+
GRANT SELECT(city_id) ON TABLE dump_test.measurement
3592+
TO "regress_quoted\"" role";',
35923593
regexp =>
3593-
qr/^\QGRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;\E/m,
3594+
qr/^\QGRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;\E\n.*
3595+
^\QGRANT SELECT(city_id) ON TABLE dump_test.measurement TO "regress_quoted\"" role";\E/xms,
35943596
like =>
35953597
{%full_runs,%dump_test_schema_runs, section_pre_data => 1, },
35963598
unlike => {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp