| 2646 | |
| 2647 | |
| 2648 | void |
| 2649 | setup_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 | |
| 2689 | void |
no test coverage detected