1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Refactor parallelization processing code in src/bin/scripts/

The existing facility of vacuumdb to handle parallel connections into a
given database with an authentication set is moved to a common file in
src/bin/scripts/, named scripts_parallel.c.  This introduces a set of
routines to initialize, wait and terminate a set of connections,
simplifying a bit the code of vacuumdb on the way.  More routines
related to result handling and database connection are moved to
common.c.

The initial plan is to use that for reindexdb, but it could be applied
to other tools like clusterdb.

While on it, clean up a set of variables "progname" which were defined
as routine arguments for error messages.  Since most of the callers have
switched to pg_log_error() and such there is no need for this variable.

Author: Julien Rouhaud
Reviewed-by: Michael Paquier, Álvaro Herrera
Discussion: https://postgr.es/m/CAOBaU_YrnH_Jqo46NhaJ7uRBiWWEcS40VNRQxgFbqYo9kApUsg@mail.gmail.com
This commit is contained in:
Michael Paquier
2019-07-19 09:31:58 +09:00
parent b538c90b1b
commit 5f3840370b
8 changed files with 446 additions and 383 deletions

View File

@ -206,7 +206,7 @@ cluster_one_database(const char *dbname, bool verbose, const char *table,
if (table)
{
appendPQExpBufferChar(&sql, ' ');
appendQualifiedRelation(&sql, table, conn, progname, echo);
appendQualifiedRelation(&sql, table, conn, echo);
}
appendPQExpBufferChar(&sql, ';');
@ -239,7 +239,7 @@ cluster_all_databases(bool verbose, const char *maintenance_db,
conn = connectMaintenanceDatabase(maintenance_db, host, port, username,
prompt_password, progname, echo);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;", progname, echo);
result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;", echo);
PQfinish(conn);
initPQExpBuffer(&connstr);