MCPcopy Create free account
hub / github.com/apache/cloudberry / connectMaintenanceDatabase

Function connectMaintenanceDatabase

src/fe_utils/connect_utils.c:138–157  ·  view source on GitHub ↗

* Try to connect to the appropriate maintenance database. * * This differs from connectDatabase only in that it has a rule for * inserting a default "dbname" if none was given (which is why cparams * is not const). Note that cparams->dbname should typically come from * a --maintenance-db command line parameter. */

Source from the content-addressed store, hash-verified

136 * a --maintenance-db command line parameter.
137 */
138PGconn *
139connectMaintenanceDatabase(ConnParams *cparams,
140 const char *progname, bool echo)
141{
142 PGconn *conn;
143
144 /* If a maintenance database name was specified, just connect to it. */
145 if (cparams->dbname)
146 return connectDatabase(cparams, progname, echo, false, false);
147
148 /* Otherwise, try postgres first and then template1. */
149 cparams->dbname = "postgres";
150 conn = connectDatabase(cparams, progname, echo, true, false);
151 if (!conn)
152 {
153 cparams->dbname = "template1";
154 conn = connectDatabase(cparams, progname, echo, false, false);
155 }
156 return conn;
157}
158
159/*
160 * Disconnect the given connection, canceling any statement if one is active.

Callers 8

mainFunction · 0.85
mainFunction · 0.85
vacuum_all_databasesFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cluster_all_databasesFunction · 0.85
reindex_all_databasesFunction · 0.85
mainFunction · 0.85

Calls 1

connectDatabaseFunction · 0.70

Tested by

no test coverage detected