* Open a new database connection using the stored connection parameters and * optionally a given dbname if not null, execute the stored initial command if * any, and associate the new connection with the given slot. */
| 286 | * any, and associate the new connection with the given slot. |
| 287 | */ |
| 288 | static void |
| 289 | connect_slot(ParallelSlotArray *sa, int slotno, const char *dbname) |
| 290 | { |
| 291 | const char *old_override; |
| 292 | ParallelSlot *slot = &sa->slots[slotno]; |
| 293 | |
| 294 | old_override = sa->cparams->override_dbname; |
| 295 | if (dbname) |
| 296 | sa->cparams->override_dbname = dbname; |
| 297 | slot->connection = connectDatabase(sa->cparams, sa->progname, sa->echo, false, true); |
| 298 | sa->cparams->override_dbname = old_override; |
| 299 | |
| 300 | if (PQsocket(slot->connection) >= FD_SETSIZE) |
| 301 | { |
| 302 | pg_log_fatal("too many jobs for this platform"); |
| 303 | exit(1); |
| 304 | } |
| 305 | |
| 306 | /* Setup the connection using the supplied command, if any. */ |
| 307 | if (sa->initcmd) |
| 308 | executeCommand(slot->connection, sa->initcmd, sa->echo); |
| 309 | } |
| 310 | |
| 311 | /* |
| 312 | * ParallelSlotsGetIdle |
no test coverage detected