* Process any command-line switches and any additional GUC variable * settings passed in the startup packet. */
| 1501 | * settings passed in the startup packet. |
| 1502 | */ |
| 1503 | static void |
| 1504 | process_startup_options(Port *port, bool am_superuser) |
| 1505 | { |
| 1506 | GucContext gucctx; |
| 1507 | ListCell *gucopts; |
| 1508 | |
| 1509 | gucctx = am_superuser ? PGC_SU_BACKEND : PGC_BACKEND; |
| 1510 | |
| 1511 | /* |
| 1512 | * First process any command-line switches that were included in the |
| 1513 | * startup packet, if we are in a regular backend. |
| 1514 | */ |
| 1515 | if (port->cmdline_options != NULL) |
| 1516 | { |
| 1517 | /* |
| 1518 | * The maximum possible number of commandline arguments that could |
| 1519 | * come from port->cmdline_options is (strlen + 1) / 2; see |
| 1520 | * pg_split_opts(). |
| 1521 | */ |
| 1522 | char **av; |
| 1523 | int maxac; |
| 1524 | int ac; |
| 1525 | |
| 1526 | maxac = 2 + (strlen(port->cmdline_options) + 1) / 2; |
| 1527 | |
| 1528 | av = (char **) palloc(maxac * sizeof(char *)); |
| 1529 | ac = 0; |
| 1530 | |
| 1531 | av[ac++] = "postgres"; |
| 1532 | |
| 1533 | pg_split_opts(av, &ac, port->cmdline_options); |
| 1534 | |
| 1535 | av[ac] = NULL; |
| 1536 | |
| 1537 | Assert(ac < maxac); |
| 1538 | |
| 1539 | (void) process_postgres_switches(ac, av, gucctx, NULL); |
| 1540 | } |
| 1541 | |
| 1542 | /* |
| 1543 | * Process any additional GUC variable settings passed in startup packet. |
| 1544 | * These are handled exactly like command-line variables. |
| 1545 | */ |
| 1546 | gucopts = list_head(port->guc_options); |
| 1547 | while (gucopts) |
| 1548 | { |
| 1549 | char *name; |
| 1550 | char *value; |
| 1551 | |
| 1552 | name = lfirst(gucopts); |
| 1553 | gucopts = lnext(port->guc_options, gucopts); |
| 1554 | |
| 1555 | value = lfirst(gucopts); |
| 1556 | gucopts = lnext(port->guc_options, gucopts); |
| 1557 | |
| 1558 | SetConfigOption(name, value, gucctx, PGC_S_CLIENT); |
| 1559 | } |
| 1560 |
no test coverage detected