aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-01-22 19:09:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-01-22 19:09:48 +0000
commit6369ace2486651c53c8fdd502dd9b9f1f6f23839 (patch)
treeeaea3e71bcf103d45d606861196c7d4b3442799c /src
parent94db74f37071984c11ce5cc33a40285a5bfeec4c (diff)
downloadpostgresql-6369ace2486651c53c8fdd502dd9b9f1f6f23839.tar.gz
postgresql-6369ace2486651c53c8fdd502dd9b9f1f6f23839.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.c34
-rw-r--r--src/bin/pg_dump/pg_dumpall.c12
2 files changed, 38 insertions, 8 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 686102f8567..3b9133ed6ad 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -12,7 +12,7 @@
* by PostgreSQL
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.355.2.1 2003/12/19 14:21:43 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.355.2.2 2004/01/22 19:09:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1144,11 +1144,33 @@ dumpDatabase(Archive *AH)
selectSourceSchema("pg_catalog");
/* Get the database owner and parameters from pg_database */
- appendPQExpBuffer(dbQry, "select (select usename from pg_user where usesysid = datdba) as dba,"
- " pg_encoding_to_char(encoding) as encoding,"
- " datpath from pg_database"
- " where datname = ");
- appendStringLiteral(dbQry, datname, true);
+ if (g_fout->remoteVersion >= 70100)
+ {
+ appendPQExpBuffer(dbQry, "SELECT "
+ "(SELECT usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "pg_encoding_to_char(encoding) as encoding, "
+ "datpath "
+ "FROM pg_database "
+ "WHERE datname = ");
+ appendStringLiteral(dbQry, datname, true);
+ }
+ 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 usename FROM pg_user WHERE usesysid = datdba) as dba, "
+ "pg_encoding_to_char(encoding) as encoding, "
+ "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);
+ }
res = PQexec(g_conn, dbQry->data);
if (!res ||
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index e0853690f87..760db0ac4d8 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
*
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.28 2003/09/23 22:48:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.28.2.1 2004/01/22 19:09:48 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");
}