Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cf615fba
Commit
cf615fba
authored
Apr 13, 2017
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pg_dump: Dump comments and security labels for publication and subscriptions
parent
d04eac11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
16 deletions
+128
-16
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+28
-0
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/pg_dump/t/002_pg_dump.pl
+100
-16
No files found.
src/bin/pg_dump/pg_dump.c
View file @
cf615fba
...
@@ -3456,12 +3456,14 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
...
@@ -3456,12 +3456,14 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
{
{
PQExpBuffer
delq
;
PQExpBuffer
delq
;
PQExpBuffer
query
;
PQExpBuffer
query
;
PQExpBuffer
labelq
;
if
(
!
(
pubinfo
->
dobj
.
dump
&
DUMP_COMPONENT_DEFINITION
))
if
(
!
(
pubinfo
->
dobj
.
dump
&
DUMP_COMPONENT_DEFINITION
))
return
;
return
;
delq
=
createPQExpBuffer
();
delq
=
createPQExpBuffer
();
query
=
createPQExpBuffer
();
query
=
createPQExpBuffer
();
labelq
=
createPQExpBuffer
();
appendPQExpBuffer
(
delq
,
"DROP PUBLICATION %s;
\n
"
,
appendPQExpBuffer
(
delq
,
"DROP PUBLICATION %s;
\n
"
,
fmtId
(
pubinfo
->
dobj
.
name
));
fmtId
(
pubinfo
->
dobj
.
name
));
...
@@ -3469,6 +3471,8 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
...
@@ -3469,6 +3471,8 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
appendPQExpBuffer
(
query
,
"CREATE PUBLICATION %s"
,
appendPQExpBuffer
(
query
,
"CREATE PUBLICATION %s"
,
fmtId
(
pubinfo
->
dobj
.
name
));
fmtId
(
pubinfo
->
dobj
.
name
));
appendPQExpBuffer
(
labelq
,
"PUBLICATION %s"
,
fmtId
(
pubinfo
->
dobj
.
name
));
if
(
pubinfo
->
puballtables
)
if
(
pubinfo
->
puballtables
)
appendPQExpBufferStr
(
query
,
" FOR ALL TABLES"
);
appendPQExpBufferStr
(
query
,
" FOR ALL TABLES"
);
...
@@ -3500,6 +3504,16 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
...
@@ -3500,6 +3504,16 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
NULL
,
0
,
NULL
,
0
,
NULL
,
NULL
);
NULL
,
NULL
);
if
(
pubinfo
->
dobj
.
dump
&
DUMP_COMPONENT_COMMENT
)
dumpComment
(
fout
,
labelq
->
data
,
NULL
,
pubinfo
->
rolname
,
pubinfo
->
dobj
.
catId
,
0
,
pubinfo
->
dobj
.
dumpId
);
if
(
pubinfo
->
dobj
.
dump
&
DUMP_COMPONENT_SECLABEL
)
dumpSecLabel
(
fout
,
labelq
->
data
,
NULL
,
pubinfo
->
rolname
,
pubinfo
->
dobj
.
catId
,
0
,
pubinfo
->
dobj
.
dumpId
);
destroyPQExpBuffer
(
delq
);
destroyPQExpBuffer
(
delq
);
destroyPQExpBuffer
(
query
);
destroyPQExpBuffer
(
query
);
}
}
...
@@ -3754,6 +3768,7 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
...
@@ -3754,6 +3768,7 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
{
{
PQExpBuffer
delq
;
PQExpBuffer
delq
;
PQExpBuffer
query
;
PQExpBuffer
query
;
PQExpBuffer
labelq
;
PQExpBuffer
publications
;
PQExpBuffer
publications
;
char
**
pubnames
=
NULL
;
char
**
pubnames
=
NULL
;
int
npubnames
=
0
;
int
npubnames
=
0
;
...
@@ -3764,6 +3779,7 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
...
@@ -3764,6 +3779,7 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
delq
=
createPQExpBuffer
();
delq
=
createPQExpBuffer
();
query
=
createPQExpBuffer
();
query
=
createPQExpBuffer
();
labelq
=
createPQExpBuffer
();
appendPQExpBuffer
(
delq
,
"DROP SUBSCRIPTION %s;
\n
"
,
appendPQExpBuffer
(
delq
,
"DROP SUBSCRIPTION %s;
\n
"
,
fmtId
(
subinfo
->
dobj
.
name
));
fmtId
(
subinfo
->
dobj
.
name
));
...
@@ -3796,6 +3812,8 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
...
@@ -3796,6 +3812,8 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
appendStringLiteralAH
(
query
,
subinfo
->
subslotname
,
fout
);
appendStringLiteralAH
(
query
,
subinfo
->
subslotname
,
fout
);
appendPQExpBufferStr
(
query
,
");
\n
"
);
appendPQExpBufferStr
(
query
,
");
\n
"
);
appendPQExpBuffer
(
labelq
,
"SUBSCRIPTION %s"
,
fmtId
(
subinfo
->
dobj
.
name
));
ArchiveEntry
(
fout
,
subinfo
->
dobj
.
catId
,
subinfo
->
dobj
.
dumpId
,
ArchiveEntry
(
fout
,
subinfo
->
dobj
.
catId
,
subinfo
->
dobj
.
dumpId
,
subinfo
->
dobj
.
name
,
subinfo
->
dobj
.
name
,
NULL
,
NULL
,
...
@@ -3806,6 +3824,16 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
...
@@ -3806,6 +3824,16 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
NULL
,
0
,
NULL
,
0
,
NULL
,
NULL
);
NULL
,
NULL
);
if
(
subinfo
->
dobj
.
dump
&
DUMP_COMPONENT_COMMENT
)
dumpComment
(
fout
,
labelq
->
data
,
NULL
,
subinfo
->
rolname
,
subinfo
->
dobj
.
catId
,
0
,
subinfo
->
dobj
.
dumpId
);
if
(
subinfo
->
dobj
.
dump
&
DUMP_COMPONENT_SECLABEL
)
dumpSecLabel
(
fout
,
labelq
->
data
,
NULL
,
subinfo
->
rolname
,
subinfo
->
dobj
.
catId
,
0
,
subinfo
->
dobj
.
dumpId
);
destroyPQExpBuffer
(
publications
);
destroyPQExpBuffer
(
publications
);
if
(
pubnames
)
if
(
pubnames
)
free
(
pubnames
);
free
(
pubnames
);
...
...
src/bin/pg_dump/t/002_pg_dump.pl
View file @
cf615fba
...
@@ -1517,6 +1517,7 @@ my %tests = (
...
@@ -1517,6 +1517,7 @@ my %tests = (
only_dump_test_schema
=>
1
,
only_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
role
=>
1
,
section_post_data
=>
1
,
test_schema_plus_blobs
=>
1
,
},
},
test_schema_plus_blobs
=>
1
,
},
},
'
COMMENT ON EXTENSION plpgsql
'
=>
{
'
COMMENT ON EXTENSION plpgsql
'
=>
{
...
@@ -1545,6 +1546,7 @@ my %tests = (
...
@@ -1545,6 +1546,7 @@ my %tests = (
only_dump_test_schema
=>
1
,
only_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
role
=>
1
,
section_post_data
=>
1
,
test_schema_plus_blobs
=>
1
,
},
},
test_schema_plus_blobs
=>
1
,
},
},
'
COMMENT ON TABLE dump_test.test_table
'
=>
{
'
COMMENT ON TABLE dump_test.test_table
'
=>
{
...
@@ -1576,7 +1578,8 @@ my %tests = (
...
@@ -1576,7 +1578,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_test_table
=>
1
,
exclude_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON COLUMN dump_test.test_table.col1
'
=>
{
'
COMMENT ON COLUMN dump_test.test_table.col1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1609,7 +1612,8 @@ my %tests = (
...
@@ -1609,7 +1612,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_test_table
=>
1
,
exclude_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON COLUMN dump_test.composite.f1
'
=>
{
'
COMMENT ON COLUMN dump_test.composite.f1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1642,7 +1646,8 @@ my %tests = (
...
@@ -1642,7 +1646,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON COLUMN dump_test.test_second_table.col1
'
=>
{
'
COMMENT ON COLUMN dump_test.test_second_table.col1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1675,7 +1680,8 @@ my %tests = (
...
@@ -1675,7 +1680,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON COLUMN dump_test.test_second_table.col2
'
=>
{
'
COMMENT ON COLUMN dump_test.test_second_table.col2
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1708,7 +1714,8 @@ my %tests = (
...
@@ -1708,7 +1714,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON CONVERSION dump_test.test_conversion
'
=>
{
'
COMMENT ON CONVERSION dump_test.test_conversion
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1739,7 +1746,8 @@ my %tests = (
...
@@ -1739,7 +1746,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON COLLATION test0
'
=>
{
'
COMMENT ON COLLATION test0
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1771,6 +1779,7 @@ my %tests = (
...
@@ -1771,6 +1779,7 @@ my %tests = (
only_dump_test_schema
=>
1
,
only_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
role
=>
1
,
section_post_data
=>
1
,
test_schema_plus_blobs
=>
1
,
},
},
test_schema_plus_blobs
=>
1
,
},
},
'
COMMENT ON LARGE OBJECT ...
'
=>
{
'
COMMENT ON LARGE OBJECT ...
'
=>
{
...
@@ -1814,6 +1823,74 @@ my %tests = (
...
@@ -1814,6 +1823,74 @@ my %tests = (
section_data
=>
1
,
section_data
=>
1
,
section_post_data
=>
1
,
},
},
section_post_data
=>
1
,
},
},
'
COMMENT ON PUBLICATION pub1
'
=>
{
all_runs
=>
1
,
create_order
=>
55
,
create_sql
=>
'
COMMENT ON PUBLICATION pub1
IS
\'
comment on publication
\'
;
',
regexp
=>
qr/^COMMENT ON PUBLICATION pub1 IS 'comment on publication';/
m,
like => {
binary_upgrade => 1,
clean
=>
1
,
clean_if_exists
=>
1
,
createdb
=>
1
,
defaults
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_test_table
=>
1
,
exclude_test_table_data
=>
1
,
no_blobs
=>
1
,
no_privs
=>
1
,
no_owner
=>
1
,
pg_dumpall_dbprivs
=>
1
,
schema_only
=>
1
,
section_post_data
=>
1
,
with_oids
=>
1
,
},
unlike
=>
{
column_inserts
=>
1
,
data_only
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_schema
=>
1
,
pg_dumpall_globals
=>
1
,
pg_dumpall_globals_clean
=>
1
,
role
=>
1
,
section_data
=>
1
,
section_pre_data
=>
1
,
test_schema_plus_blobs
=>
1
,
},
},
'
COMMENT ON SUBSCRIPTION sub1
'
=>
{
all_runs
=>
1
,
create_order
=>
55
,
create_sql
=>
'
COMMENT ON SUBSCRIPTION sub1
IS
\'
comment on subscription
\'
;
',
regexp
=>
qr/^COMMENT ON SUBSCRIPTION sub1 IS 'comment on subscription';/
m,
like => {
binary_upgrade => 1,
clean
=>
1
,
clean_if_exists
=>
1
,
createdb
=>
1
,
defaults
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_test_table
=>
1
,
exclude_test_table_data
=>
1
,
no_blobs
=>
1
,
no_privs
=>
1
,
no_owner
=>
1
,
pg_dumpall_dbprivs
=>
1
,
schema_only
=>
1
,
section_post_data
=>
1
,
with_oids
=>
1
,
},
unlike
=>
{
column_inserts
=>
1
,
data_only
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_schema
=>
1
,
pg_dumpall_globals
=>
1
,
pg_dumpall_globals_clean
=>
1
,
role
=>
1
,
section_data
=>
1
,
section_pre_data
=>
1
,
test_schema_plus_blobs
=>
1
,
},
},
'
COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1
'
=>
{
'
COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
catch_all
=>
'
COMMENT commands
',
catch_all
=>
'
COMMENT commands
',
...
@@ -1843,7 +1920,8 @@ my %tests = (
...
@@ -1843,7 +1920,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1
'
=>
{
'
COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1874,7 +1952,8 @@ my %tests = (
...
@@ -1874,7 +1952,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1
'
=>
{
'
COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1905,7 +1984,8 @@ my %tests = (
...
@@ -1905,7 +1984,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1
'
=>
{
'
COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1936,7 +2016,8 @@ my %tests = (
...
@@ -1936,7 +2016,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TYPE dump_test.planets - ENUM
'
=>
{
'
COMMENT ON TYPE dump_test.planets - ENUM
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1967,7 +2048,8 @@ my %tests = (
...
@@ -1967,7 +2048,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TYPE dump_test.textrange - RANGE
'
=>
{
'
COMMENT ON TYPE dump_test.textrange - RANGE
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -1998,7 +2080,8 @@ my %tests = (
...
@@ -1998,7 +2080,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TYPE dump_test.int42 - Regular
'
=>
{
'
COMMENT ON TYPE dump_test.int42 - Regular
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -2029,7 +2112,8 @@ my %tests = (
...
@@ -2029,7 +2112,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
'
COMMENT ON TYPE dump_test.undefined - Undefined
'
=>
{
'
COMMENT ON TYPE dump_test.undefined - Undefined
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
@@ -2060,7 +2144,8 @@ my %tests = (
...
@@ -2060,7 +2144,8 @@ my %tests = (
data_only
=>
1
,
data_only
=>
1
,
exclude_dump_test_schema
=>
1
,
exclude_dump_test_schema
=>
1
,
only_dump_test_table
=>
1
,
only_dump_test_table
=>
1
,
role
=>
1
,
},
},
role
=>
1
,
section_post_data
=>
1
,
},
},
# catch-all for COMMENTs
# catch-all for COMMENTs
'
COMMENT commands
'
=>
{
'
COMMENT commands
'
=>
{
...
@@ -2070,8 +2155,7 @@ my %tests = (
...
@@ -2070,8 +2155,7 @@ my %tests = (
unlike
=>
{
unlike
=>
{
pg_dumpall_globals
=>
1
,
pg_dumpall_globals
=>
1
,
pg_dumpall_globals_clean
=>
1
,
pg_dumpall_globals_clean
=>
1
,
section_data
=>
1
,
section_data
=>
1
,
},
},
section_post_data
=>
1
,
},
},
'
COPY test_table
'
=>
{
'
COPY test_table
'
=>
{
all_runs
=>
1
,
all_runs
=>
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment