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

Commit5ad7d65

Browse files
committed
Fix incorrect dumping of database LOCATION from 7.0.* servers.
Per report from Mattias Kregert.
1 parentfeaf66a commit5ad7d65

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.362 2004/01/07 00:44:21 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.363 2004/01/22 19:09:32 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -1149,12 +1149,19 @@ dumpDatabase(Archive *AH)
11491149
}
11501150
else
11511151
{
1152+
/*
1153+
* In 7.0, datpath is either the same as datname, or the user-given
1154+
* location with "/" and the datname appended. We must strip this
1155+
* junk off to produce a correct LOCATION value.
1156+
*/
11521157
appendPQExpBuffer(dbQry,"SELECT "
11531158
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
11541159
"oid, "
11551160
"(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
11561161
"pg_encoding_to_char(encoding) as encoding, "
1157-
"datpath "
1162+
"CASE WHEN length(datpath) > length(datname) THEN "
1163+
"substr(datpath,1,length(datpath)-length(datname)-1) "
1164+
"ELSE '' END as datpath "
11581165
"FROM pg_database "
11591166
"WHERE datname = ");
11601167
appendStringLiteral(dbQry,datname, true);

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.29 2003/11/29 19:52:05 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.30 2004/01/22 19:09:32 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -430,14 +430,22 @@ dumpCreateDB(PGconn *conn)
430430
else
431431
{
432432
/*
433+
* In 7.0, datpath is either the same as datname, or the user-given
434+
* location with "/" and the datname appended. We must strip this
435+
* junk off to produce a correct LOCATION value.
436+
*
433437
* Note: 7.0 fails to cope with sub-select in COALESCE, so just
434438
* deal with getting a NULL by not printing any OWNER clause.
435439
*/
436440
res=executeQuery(conn,
437441
"SELECT datname, "
438442
"(select usename from pg_shadow where usesysid=datdba), "
439443
"pg_encoding_to_char(d.encoding), "
440-
"'f' as datistemplate, datpath, '' as datacl "
444+
"'f' as datistemplate, "
445+
"CASE WHEN length(datpath) > length(datname) THEN "
446+
"substr(datpath,1,length(datpath)-length(datname)-1) "
447+
"ELSE '' END as datpath, "
448+
"'' as datacl "
441449
"FROM pg_database d "
442450
"ORDER BY 1");
443451
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp