| 193 | |
| 194 | |
| 195 | static void |
| 196 | cluster_one_database(const ConnParams *cparams, const char *table, |
| 197 | const char *progname, bool verbose, bool echo) |
| 198 | { |
| 199 | PQExpBufferData sql; |
| 200 | |
| 201 | PGconn *conn; |
| 202 | |
| 203 | conn = connectDatabase(cparams, progname, echo, false, false); |
| 204 | |
| 205 | initPQExpBuffer(&sql); |
| 206 | |
| 207 | appendPQExpBufferStr(&sql, "CLUSTER"); |
| 208 | if (verbose) |
| 209 | appendPQExpBufferStr(&sql, " VERBOSE"); |
| 210 | if (table) |
| 211 | { |
| 212 | appendPQExpBufferChar(&sql, ' '); |
| 213 | appendQualifiedRelation(&sql, table, conn, echo); |
| 214 | } |
| 215 | appendPQExpBufferChar(&sql, ';'); |
| 216 | |
| 217 | if (!executeMaintenanceCommand(conn, sql.data, echo)) |
| 218 | { |
| 219 | if (table) |
| 220 | pg_log_error("clustering of table \"%s\" in database \"%s\" failed: %s", |
| 221 | table, PQdb(conn), PQerrorMessage(conn)); |
| 222 | else |
| 223 | pg_log_error("clustering of database \"%s\" failed: %s", |
| 224 | PQdb(conn), PQerrorMessage(conn)); |
| 225 | PQfinish(conn); |
| 226 | exit(1); |
| 227 | } |
| 228 | PQfinish(conn); |
| 229 | termPQExpBuffer(&sql); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | static void |
no test coverage detected