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

Commita72d613

Browse files
committed
Fix pg_dumpall with in-place tablespaces
In-place tablespaces would be dumped with the path produced bypg_tablespace_location(), which is in this case a relative path built aspg_tblspc/OID, but this would fail to restore as such tablespaces needto use an empty string as location. In order to detect if an in-placetablespace is used, this commit checks if the path returned is relativeand adapts the dump contents in consequence.Like the other changes related to in-place tablespaces, no backpatch isdone as these are only intended for development purposes. Rui Zhao hasfixed the code, while the test is from me.Author: Rui Zhao, Michael PaquierDiscussion:https://postgr.es/m/80c80b4a-b87b-456f-bd46-1ae326601d79.xiyuan.zr@alibaba-inc.com
1 parentf05b1fa commita72d613

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,16 @@ dumpTablespaces(PGconn *conn)
12861286
appendPQExpBuffer(buf," OWNER %s",fmtId(spcowner));
12871287

12881288
appendPQExpBufferStr(buf," LOCATION ");
1289-
appendStringLiteralConn(buf,spclocation,conn);
1289+
1290+
/*
1291+
* In-place tablespaces use a relative path, and need to be dumped
1292+
* with an empty string as location.
1293+
*/
1294+
if (is_absolute_path(spclocation))
1295+
appendStringLiteralConn(buf,spclocation,conn);
1296+
else
1297+
appendStringLiteralConn(buf,"",conn);
1298+
12901299
appendPQExpBufferStr(buf,";\n");
12911300

12921301
if (spcoptions&&spcoptions[0]!='\0')

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,22 @@
19071907
},
19081908
},
19091909

1910+
'CREATE TABLESPACE regress_dump_tablespace'=> {
1911+
create_order=> 2,
1912+
create_sql=>q(
1913+
SET allow_in_place_tablespaces = on;
1914+
CREATE TABLESPACE regress_dump_tablespace
1915+
OWNER regress_dump_test_role LOCATION ''),
1916+
regexp=>
1917+
qr/^CREATE TABLESPACE regress_dump_tablespace OWNER regress_dump_test_role LOCATION '';/m,
1918+
like=> {
1919+
pg_dumpall_dbprivs=> 1,
1920+
pg_dumpall_exclude=> 1,
1921+
pg_dumpall_globals=> 1,
1922+
pg_dumpall_globals_clean=> 1,
1923+
},
1924+
},
1925+
19101926
'CREATE DATABASE regression_invalid...'=> {
19111927
create_order=> 1,
19121928
create_sql=>q(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp