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

Function process_postgres_switches

src/backend/tcop/postgres.c:4666–4943  ·  view source on GitHub ↗

---------------------------------------------------------------- * process_postgres_switches * Parse command line arguments for PostgresMain * * This is called twice, once for the "secure" options coming from the * postmaster or command line, and once for the "insecure" options coming * from the client's startup packet. The latter have the same syntax but * may be restricted in what the

Source from the content-addressed store, hash-verified

4664 * ----------------------------------------------------------------
4665 */
4666void
4667process_postgres_switches(int argc, char *argv[], GucContext ctx,
4668 const char **dbname)
4669{
4670 bool secure = (ctx == PGC_POSTMASTER);
4671 int errs = 0;
4672 GucSource gucsource;
4673 int flag;
4674
4675 if (secure)
4676 {
4677 gucsource = PGC_S_ARGV; /* switches came from command line */
4678
4679 /* Ignore the initial --single argument, if present */
4680 if (argc > 1 && strcmp(argv[1], "--single") == 0)
4681 {
4682 argv++;
4683 argc--;
4684 }
4685 }
4686 else
4687 {
4688 gucsource = PGC_S_CLIENT; /* switches came from client */
4689 }
4690
4691#ifdef HAVE_INT_OPTERR
4692
4693 /*
4694 * Turn this off because it's either printed to stderr and not the log
4695 * where we'd want it, or argv[0] is now "--single", which would make for
4696 * a weird error message. We print our own error message below.
4697 */
4698 opterr = 0;
4699#endif
4700
4701 /*
4702 * Parse command-line options. CAUTION: keep this in sync with
4703 * postmaster/postmaster.c (the option sets should not conflict) and with
4704 * the common help() function in main/main.c.
4705 */
4706 while ((flag = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lMm:N:nOPp:r:R:S:sTt:v:W:-:")) != -1)
4707 {
4708 switch (flag)
4709 {
4710 case 'B':
4711 SetConfigOption("shared_buffers", optarg, ctx, gucsource);
4712 break;
4713
4714 case 'b':
4715 /* Undocumented flag used for binary upgrades */
4716 if (secure)
4717 IsBinaryUpgrade = true;
4718 break;
4719
4720 case 'C':
4721 /* ignored for consistency with the postmaster */
4722 break;
4723

Callers 2

PostgresMainFunction · 0.85
process_startup_optionsFunction · 0.85

Calls 10

getoptFunction · 0.85
SetConfigOptionFunction · 0.85
set_debug_optionsFunction · 0.85
strlcpyFunction · 0.85
get_stats_option_nameFunction · 0.85
ParseLongOptionFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errhintFunction · 0.50

Tested by

no test coverage detected