diff options
Diffstat (limited to 'src/bin/scripts')
-rw-r--r-- | src/bin/scripts/Makefile | 2 | ||||
-rw-r--r-- | src/bin/scripts/clusterdb.c | 9 | ||||
-rw-r--r-- | src/bin/scripts/reindexdb.c | 14 | ||||
-rw-r--r-- | src/bin/scripts/vacuumdb.c | 11 |
4 files changed, 30 insertions, 6 deletions
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile index 0c059665274..0fd21200eb5 100644 --- a/src/bin/scripts/Makefile +++ b/src/bin/scripts/Makefile @@ -32,7 +32,7 @@ dropdb: dropdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq droplang: droplang.o common.o print.o mbprint.o | submake-libpq dropuser: dropuser.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq clusterdb: clusterdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq -vacuumdb: vacuumdb.o common.o | submake-libpq +vacuumdb: vacuumdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq reindexdb: reindexdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/% diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c index 8ed839490c8..7088a6cae93 100644 --- a/src/bin/scripts/clusterdb.c +++ b/src/bin/scripts/clusterdb.c @@ -204,12 +204,14 @@ cluster_all_databases(bool verbose, const char *host, const char *port, { PGconn *conn; PGresult *result; + PQExpBufferData connstr; int i; conn = connectDatabase("postgres", host, port, username, prompt_password, progname); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;", progname, echo); PQfinish(conn); + initPQExpBuffer(&connstr); for (i = 0; i < PQntuples(result); i++) { char *dbname = PQgetvalue(result, i, 0); @@ -220,10 +222,15 @@ cluster_all_databases(bool verbose, const char *host, const char *port, fflush(stdout); } - cluster_one_database(dbname, verbose, NULL, + resetPQExpBuffer(&connstr); + appendPQExpBuffer(&connstr, "dbname="); + appendConnStrVal(&connstr, dbname); + + cluster_one_database(connstr.data, verbose, NULL, host, port, username, prompt_password, progname, echo); } + termPQExpBuffer(&connstr); PQclear(result); } diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index 6d7039f8575..4bcec082b99 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -258,12 +258,14 @@ reindex_all_databases(const char *host, const char *port, { PGconn *conn; PGresult *result; + PQExpBufferData connstr; int i; conn = connectDatabase("postgres", host, port, username, prompt_password, progname); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;", progname, echo); PQfinish(conn); + initPQExpBuffer(&connstr); for (i = 0; i < PQntuples(result); i++) { char *dbname = PQgetvalue(result, i, 0); @@ -274,9 +276,15 @@ reindex_all_databases(const char *host, const char *port, fflush(stdout); } - reindex_one_database(dbname, dbname, "DATABASE", host, port, username, - prompt_password, progname, echo); + resetPQExpBuffer(&connstr); + appendPQExpBuffer(&connstr, "dbname="); + appendConnStrVal(&connstr, dbname); + + reindex_one_database(NULL, connstr.data, "DATABASE", host, + port, username, prompt_password, + progname, echo); } + termPQExpBuffer(&connstr); PQclear(result); } @@ -293,7 +301,7 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port, initPQExpBuffer(&sql); - appendPQExpBuffer(&sql, "REINDEX SYSTEM %s;\n", PQdb(conn)); + appendPQExpBuffer(&sql, "REINDEX SYSTEM %s;\n", fmtId(PQdb(conn))); if (!executeMaintenanceCommand(conn, sql.data, echo)) { diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index 84a9dcd38e5..5dbc01ec0ac 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -12,6 +12,7 @@ #include "postgres_fe.h" #include "common.h" +#include "dumputils.h" static void vacuum_one_database(const char *dbname, bool full, bool verbose, @@ -296,12 +297,14 @@ vacuum_all_databases(bool full, bool verbose, bool and_analyze, bool analyze_onl { PGconn *conn; PGresult *result; + PQExpBufferData connstr; int i; conn = connectDatabase("postgres", host, port, username, prompt_password, progname); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;", progname, echo); PQfinish(conn); + initPQExpBuffer(&connstr); for (i = 0; i < PQntuples(result); i++) { char *dbname = PQgetvalue(result, i, 0); @@ -312,10 +315,16 @@ vacuum_all_databases(bool full, bool verbose, bool and_analyze, bool analyze_onl fflush(stdout); } - vacuum_one_database(dbname, full, verbose, and_analyze, analyze_only, + resetPQExpBuffer(&connstr); + appendPQExpBuffer(&connstr, "dbname="); + appendConnStrVal(&connstr, PQgetvalue(result, i, 0)); + + vacuum_one_database(connstr.data, full, verbose, and_analyze, + analyze_only, freeze, NULL, host, port, username, prompt_password, progname, echo); } + termPQExpBuffer(&connstr); PQclear(result); } |