aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-22 19:09:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-22 19:09:32 +0000
commit5ad7d65da4499f82b9820c80fa12b6b9fe61d293 (patch)
treed7a708b9582fca626bee87e50a54b452881ad586 /src
parentfeaf66aa7271297ccabc7139e653149834f46b51 (diff)
downloadpostgresql-5ad7d65da4499f82b9820c80fa12b6b9fe61d293.tar.gz
postgresql-5ad7d65da4499f82b9820c80fa12b6b9fe61d293.zip
Fix incorrect dumping of database LOCATION from 7.0.* servers.
Per report from Mattias Kregert.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c11
-rw-r--r--src/bin/pg_dump/pg_dumpall.c12
2 files changed, 19 insertions, 4 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 81473bfa084..a6c8997c394 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.362 2004/01/07 00:44:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.363 2004/01/22 19:09:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1149,12 +1149,19 @@ dumpDatabase(Archive *AH)
}
else
{
+ /*
+ * In 7.0, datpath is either the same as datname, or the user-given
+ * location with "/" and the datname appended. We must strip this
+ * junk off to produce a correct LOCATION value.
+ */
appendPQExpBuffer(dbQry, "SELECT "
"(SELECT oid FROM pg_class WHERE relname = 'pg_database') AS tableoid, "
"oid, "
"(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
"pg_encoding_to_char(encoding) as encoding, "
- "datpath "
+ "CASE WHEN length(datpath) > length(datname) THEN "
+ "substr(datpath,1,length(datpath)-length(datname)-1) "
+ "ELSE '' END as datpath "
"FROM pg_database "
"WHERE datname = ");
appendStringLiteral(dbQry, datname, true);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 4ee77b844f2..f15ddc206dc 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.29 2003/11/29 19:52:05 pgsql Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.30 2004/01/22 19:09:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -430,6 +430,10 @@ dumpCreateDB(PGconn *conn)
else
{
/*
+ * In 7.0, datpath is either the same as datname, or the user-given
+ * location with "/" and the datname appended. We must strip this
+ * junk off to produce a correct LOCATION value.
+ *
* Note: 7.0 fails to cope with sub-select in COALESCE, so just
* deal with getting a NULL by not printing any OWNER clause.
*/
@@ -437,7 +441,11 @@ dumpCreateDB(PGconn *conn)
"SELECT datname, "
"(select usename from pg_shadow where usesysid=datdba), "
"pg_encoding_to_char(d.encoding), "
- "'f' as datistemplate, datpath, '' as datacl "
+ "'f' as datistemplate, "
+ "CASE WHEN length(datpath) > length(datname) THEN "
+ "substr(datpath,1,length(datpath)-length(datname)-1) "
+ "ELSE '' END as datpath, "
+ "'' as datacl "
"FROM pg_database d "
"ORDER BY 1");
}