diff options
Diffstat (limited to 'src/bin/scripts/reindexdb.c')
-rw-r--r-- | src/bin/scripts/reindexdb.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index 5b4cbc79f5..b1cdb47ae3 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.3 2005/09/30 09:56:26 petere Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.4 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,19 +15,19 @@ static void reindex_one_database(const char *name, const char *dbname, - const char *type, const char *host, - const char *port, const char *username, - bool password, const char *progname, - bool echo, bool quiet); + const char *type, const char *host, + const char *port, const char *username, + bool password, const char *progname, + bool echo, bool quiet); static void reindex_all_databases(const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, - bool quiet); + const char *username, bool password, + const char *progname, bool echo, + bool quiet); static void reindex_system_catalogs(const char *dbname, - const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, - bool quiet); + const char *host, const char *port, + const char *username, bool password, + const char *progname, bool echo, + bool quiet); static void help(const char *progname); int @@ -48,22 +48,22 @@ main(int argc, char *argv[]) {NULL, 0, NULL, 0} }; - const char *progname; - int optindex; - int c; + const char *progname; + int optindex; + int c; - const char *dbname = NULL; - const char *host = NULL; - const char *port = NULL; - const char *username = NULL; + const char *dbname = NULL; + const char *host = NULL; + const char *port = NULL; + const char *username = NULL; bool password = false; bool syscatalog = false; bool alldb = false; bool echo = false; bool quiet = false; - const char *table = NULL; - const char *index = NULL; - + const char *table = NULL; + const char *index = NULL; + progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], "pgscripts"); @@ -150,7 +150,7 @@ main(int argc, char *argv[]) } reindex_all_databases(host, port, username, password, - progname, echo, quiet); + progname, echo, quiet); } else if (syscatalog) { @@ -176,7 +176,7 @@ main(int argc, char *argv[]) } reindex_system_catalogs(dbname, host, port, username, password, - progname, echo, quiet); + progname, echo, quiet); } else { @@ -192,14 +192,14 @@ main(int argc, char *argv[]) if (index) reindex_one_database(index, dbname, "INDEX", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); if (table) reindex_one_database(table, dbname, "TABLE", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); /* reindex database only if index or table is not specified */ if (index == NULL && table == NULL) reindex_one_database(dbname, dbname, "DATABASE", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); } exit(0); @@ -207,14 +207,14 @@ main(int argc, char *argv[]) static void reindex_one_database(const char *name, const char *dbname, const char *type, - const char *host, const char *port, const char *username, - bool password, const char *progname, bool echo, - bool quiet) + const char *host, const char *port, const char *username, + bool password, const char *progname, bool echo, + bool quiet) { - PQExpBufferData sql; + PQExpBufferData sql; - PGconn *conn; - PGresult *result; + PGconn *conn; + PGresult *result; initPQExpBuffer(&sql); @@ -228,7 +228,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type, appendPQExpBuffer(&sql, ";\n"); conn = connectDatabase(dbname, host, port, username, password, progname); - + if (echo) printf("%s", sql.data); result = PQexec(conn, sql.data); @@ -261,12 +261,12 @@ reindex_one_database(const char *name, const char *dbname, const char *type, static void reindex_all_databases(const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, bool quiet) + const char *username, bool password, + const char *progname, bool echo, bool quiet) { - PGconn *conn; - PGresult *result; - int i; + PGconn *conn; + PGresult *result; + int i; conn = connectDatabase("postgres", host, port, username, password, progname); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo); @@ -274,13 +274,13 @@ reindex_all_databases(const char *host, const char *port, for (i = 0; i < PQntuples(result); i++) { - char *dbname = PQgetvalue(result, i, 0); + char *dbname = PQgetvalue(result, i, 0); if (!quiet) fprintf(stderr, _("%s: reindexing database \"%s\"\n"), progname, dbname); reindex_one_database(dbname, dbname, "DATABASE", host, port, username, - password, progname, echo, quiet); + password, progname, echo, quiet); } PQclear(result); @@ -288,20 +288,20 @@ reindex_all_databases(const char *host, const char *port, static void reindex_system_catalogs(const char *dbname, const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, bool quiet) + const char *username, bool password, + const char *progname, bool echo, bool quiet) { - PQExpBufferData sql; + PQExpBufferData sql; - PGconn *conn; - PGresult *result; + PGconn *conn; + PGresult *result; initPQExpBuffer(&sql); appendPQExpBuffer(&sql, "REINDEX SYSTEM %s;\n", dbname); conn = connectDatabase(dbname, host, port, username, password, progname); - + if (echo) printf("%s", sql.data); result = PQexec(conn, sql.data); @@ -309,7 +309,7 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port, if (PQresultStatus(result) != PGRES_COMMAND_OK) { fprintf(stderr, _("%s: reindexing of system catalogs failed: %s"), - progname, PQerrorMessage(conn)); + progname, PQerrorMessage(conn)); PQfinish(conn); exit(1); } |