Commit 84bb600b authored by Heikki Linnakangas's avatar Heikki Linnakangas

Quote string literals correctly in the new CREATE SERVER statements

and binary upgrade UPDATE statements.
parent 71d119f8
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.534 2009/04/06 08:42:53 heikki Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.535 2009/04/08 19:02:37 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1734,8 +1734,10 @@ dumpDatabase(Archive *AH) ...@@ -1734,8 +1734,10 @@ dumpDatabase(Archive *AH)
appendPQExpBuffer(creaQry, "\n-- For binary upgrade, set datfrozenxid.\n"); appendPQExpBuffer(creaQry, "\n-- For binary upgrade, set datfrozenxid.\n");
appendPQExpBuffer(creaQry, "UPDATE pg_database\n" appendPQExpBuffer(creaQry, "UPDATE pg_database\n"
"SET datfrozenxid = '%u'\n" "SET datfrozenxid = '%u'\n"
"WHERE datname = '%s';\n", "WHERE datname = ",
frozenxid, datname); frozenxid);
appendStringLiteralAH(creaQry, datname, AH);
appendPQExpBuffer(creaQry, ";\n");
} }
appendPQExpBuffer(delQry, "DROP DATABASE %s;\n", appendPQExpBuffer(delQry, "DROP DATABASE %s;\n",
...@@ -9396,9 +9398,15 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) ...@@ -9396,9 +9398,15 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
appendPQExpBuffer(q, "CREATE SERVER %s", fmtId(srvinfo->dobj.name)); appendPQExpBuffer(q, "CREATE SERVER %s", fmtId(srvinfo->dobj.name));
if (srvinfo->srvtype && strlen(srvinfo->srvtype) > 0) if (srvinfo->srvtype && strlen(srvinfo->srvtype) > 0)
appendPQExpBuffer(q, " TYPE '%s'", srvinfo->srvtype); {
appendPQExpBuffer(q, " TYPE ");
appendStringLiteralAH(q, srvinfo->srvtype, fout);
}
if (srvinfo->srvversion && strlen(srvinfo->srvversion) > 0) if (srvinfo->srvversion && strlen(srvinfo->srvversion) > 0)
appendPQExpBuffer(q, " VERSION '%s'", srvinfo->srvversion); {
appendPQExpBuffer(q, " VERSION ");
appendStringLiteralAH(q, srvinfo->srvversion, fout);
}
appendPQExpBuffer(q, " FOREIGN DATA WRAPPER "); appendPQExpBuffer(q, " FOREIGN DATA WRAPPER ");
appendPQExpBuffer(q, "%s", fmtId(fdwname)); appendPQExpBuffer(q, "%s", fmtId(fdwname));
...@@ -9891,23 +9899,23 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -9891,23 +9899,23 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
" WHERE relnamespace = " " WHERE relnamespace = "
"(SELECT oid FROM pg_namespace " "(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA)\n" "WHERE nspname = CURRENT_SCHEMA)\n"
" AND relname = '%s'\n" " AND relname = ",
" );\n",
tbinfo->attlen[j], tbinfo->attlen[j],
tbinfo->attalign[j], tbinfo->attalign[j],
tbinfo->attnames[j], tbinfo->attnames[j]);
tbinfo->dobj.name); appendStringLiteralAH(q, tbinfo->dobj.name, fout);
appendPQExpBuffer(q, "\n );\n");
} }
} }
appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n"); appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n");
appendPQExpBuffer(q, "UPDATE pg_class\n" appendPQExpBuffer(q, "UPDATE pg_class\n"
"SET relfrozenxid = '%u'\n" "SET relfrozenxid = '%u'\n"
"WHERE relname = '%s'\n" "WHERE relname = ",
" AND relnamespace = " tbinfo->frozenxid);
appendStringLiteralAH(q, tbinfo->dobj.name, fout);
appendPQExpBuffer(q, "\n AND relnamespace = "
"(SELECT oid FROM pg_namespace " "(SELECT oid FROM pg_namespace "
"WHERE nspname = CURRENT_SCHEMA);\n", "WHERE nspname = CURRENT_SCHEMA);\n");
tbinfo->frozenxid,
tbinfo->dobj.name);
} }
/* Loop dumping statistics and storage statements */ /* Loop dumping statistics and storage statements */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* *
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.122 2009/04/06 08:42:53 heikki Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.123 2009/04/08 19:02:37 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1088,8 +1088,10 @@ dumpCreateDB(PGconn *conn) ...@@ -1088,8 +1088,10 @@ dumpCreateDB(PGconn *conn)
appendPQExpBuffer(buf, "\n-- For binary upgrade, set datfrozenxid.\n"); appendPQExpBuffer(buf, "\n-- For binary upgrade, set datfrozenxid.\n");
appendPQExpBuffer(buf, "UPDATE pg_database\n" appendPQExpBuffer(buf, "UPDATE pg_database\n"
"SET datfrozenxid = '%u'\n" "SET datfrozenxid = '%u'\n"
"WHERE datname = '%s';\n", "WHERE datname = ",
dbfrozenxid, fdbname); dbfrozenxid);
appendStringLiteralConn(buf, dbname, conn);
appendPQExpBuffer(buf, ";\n");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment