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

Function setup_pgdata

src/bin/initdb/initdb.c:2648–2686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2646
2647
2648void
2649setup_pgdata(void)
2650{
2651 char *pgdata_get_env;
2652
2653 if (!pg_data)
2654 {
2655 pgdata_get_env = getenv("PGDATA");
2656 if (pgdata_get_env && strlen(pgdata_get_env))
2657 {
2658 /* PGDATA found */
2659 pg_data = pg_strdup(pgdata_get_env);
2660 }
2661 else
2662 {
2663 pg_log_error("no data directory specified");
2664 fprintf(stderr,
2665 _("You must identify the directory where the data for this database system\n"
2666 "will reside. Do this with either the invocation option -D or the\n"
2667 "environment variable PGDATA.\n"));
2668 exit(1);
2669 }
2670 }
2671
2672 pgdata_native = pg_strdup(pg_data);
2673 canonicalize_path(pg_data);
2674
2675 /*
2676 * we have to set PGDATA for postgres rather than pass it on the command
2677 * line to avoid dumb quoting problems on Windows, and we would especially
2678 * need quotes otherwise on Windows because paths there are most likely to
2679 * have embedded spaces.
2680 */
2681 if (setenv("PGDATA", pg_data, 1) != 0)
2682 {
2683 pg_log_error("could not set environment");
2684 exit(1);
2685 }
2686}
2687
2688
2689void

Callers 1

mainFunction · 0.85

Calls 3

pg_strdupFunction · 0.85
canonicalize_pathFunction · 0.85
setenvFunction · 0.85

Tested by

no test coverage detected