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

Function pgwin32_CommandLine

src/bin/pg_ctl/pg_ctl.c:1531–1613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1529}
1530
1531static char *
1532pgwin32_CommandLine(bool registration)
1533{
1534 PQExpBuffer cmdLine = createPQExpBuffer();
1535 char cmdPath[MAXPGPATH];
1536 int ret;
1537
1538 if (registration)
1539 {
1540 ret = find_my_exec(argv0, cmdPath);
1541 if (ret != 0)
1542 {
1543 write_stderr(_("%s: could not find own program executable\n"), progname);
1544 exit(1);
1545 }
1546 }
1547 else
1548 {
1549 ret = find_other_exec(argv0, "postgres", PG_BACKEND_VERSIONSTR,
1550 cmdPath);
1551 if (ret != 0)
1552 {
1553 write_stderr(_("%s: could not find postgres program executable\n"), progname);
1554 exit(1);
1555 }
1556 }
1557
1558 /* if path does not end in .exe, append it */
1559 if (strlen(cmdPath) < 4 ||
1560 pg_strcasecmp(cmdPath + strlen(cmdPath) - 4, ".exe") != 0)
1561 snprintf(cmdPath + strlen(cmdPath), sizeof(cmdPath) - strlen(cmdPath),
1562 ".exe");
1563
1564 /* use backslashes in path to avoid problems with some third-party tools */
1565 make_native_path(cmdPath);
1566
1567 /* be sure to double-quote the executable's name in the command */
1568 appendPQExpBuffer(cmdLine, "\"%s\"", cmdPath);
1569
1570 /* append assorted switches to the command line, as needed */
1571
1572 if (registration)
1573 appendPQExpBuffer(cmdLine, " runservice -N \"%s\"",
1574 register_servicename);
1575
1576 if (pg_config)
1577 {
1578 /* We need the -D path to be absolute */
1579 char *dataDir;
1580
1581 if ((dataDir = make_absolute_path(pg_config)) == NULL)
1582 {
1583 /* make_absolute_path already reported the error */
1584 exit(1);
1585 }
1586 make_native_path(dataDir);
1587 appendPQExpBuffer(cmdLine, " -D \"%s\"", dataDir);
1588 free(dataDir);

Callers 2

pgwin32_doRegisterFunction · 0.85
pgwin32_ServiceMainFunction · 0.85

Calls 9

createPQExpBufferFunction · 0.85
find_my_execFunction · 0.85
find_other_execFunction · 0.85
pg_strcasecmpFunction · 0.85
make_native_pathFunction · 0.85
appendPQExpBufferFunction · 0.85
make_absolute_pathFunction · 0.85
appendPQExpBufferStrFunction · 0.85
write_stderrFunction · 0.70

Tested by

no test coverage detected