|
11 | 11 | *
|
12 | 12 | *
|
13 | 13 | * IDENTIFICATION
|
14 |
| - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.150 2000/06/28 03:31:52 tgl Exp $ |
| 14 | + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.151 2000/07/02 15:20:48 petere Exp $ |
15 | 15 | *
|
16 | 16 | * NOTES
|
17 | 17 | *
|
|
84 | 84 | #include "access/xlog.h"
|
85 | 85 | #include "tcop/tcopprot.h"
|
86 | 86 | #include "utils/guc.h"
|
87 |
| -#include "version.h" |
88 | 87 |
|
89 | 88 | /*
|
90 | 89 | * "postmaster.opts" is a file containing options for postmaser.
|
@@ -300,68 +299,47 @@ int assert_enabled = 1;
|
300 | 299 | #endif
|
301 | 300 |
|
302 | 301 | static void
|
303 |
| -checkDataDir(const char *DataDir, bool *DataDirOK) |
| 302 | +checkDataDir(const char *DataDir) |
304 | 303 | {
|
| 304 | + char path[MAXPGPATH]; |
| 305 | + FILE *fp; |
| 306 | + |
305 | 307 | if (DataDir == NULL)
|
306 | 308 | {
|
307 | 309 | fprintf(stderr, "%s does not know where to find the database system "
|
308 | 310 | "data. You must specify the directory that contains the "
|
309 | 311 | "database system either by specifying the -D invocation "
|
310 | 312 | "option or by setting the PGDATA environment variable.\n\n",
|
311 | 313 | progname);
|
312 |
| - *DataDirOK = false; |
| 314 | + exit(2); |
313 | 315 | }
|
314 |
| - else |
315 |
| - { |
316 |
| - char path[MAXPGPATH]; |
317 |
| - FILE *fp; |
318 | 316 |
|
319 |
| - snprintf(path, sizeof(path), "%s%cbase%ctemplate1%cpg_class", |
320 |
| - DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR); |
321 |
| - fp = AllocateFile(path, PG_BINARY_R); |
322 |
| - if (fp == NULL) |
323 |
| - { |
324 |
| - fprintf(stderr, "%s does not find the database system. " |
325 |
| - "Expected to find it " |
326 |
| - "in the PGDATA directory \"%s\", but unable to open file " |
327 |
| - "with pathname \"%s\".\n\n", |
328 |
| - progname, DataDir, path); |
329 |
| - *DataDirOK = false; |
330 |
| - } |
331 |
| - else |
332 |
| - { |
333 |
| - char *reason; |
| 317 | + snprintf(path, sizeof(path), "%s%cbase%ctemplate1%cpg_class", |
| 318 | + DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR); |
334 | 319 |
|
335 |
| - /* reason ValidatePgVersion failed. NULL if didn't */ |
| 320 | + fp = AllocateFile(path, PG_BINARY_R); |
| 321 | + if (fp == NULL) |
| 322 | + { |
| 323 | + fprintf(stderr, "%s does not find the database system. " |
| 324 | + "Expected to find it " |
| 325 | + "in the PGDATA directory \"%s\", but unable to open file " |
| 326 | + "with pathname \"%s\".\n\n", |
| 327 | + progname, DataDir, path); |
| 328 | + exit(2); |
| 329 | + } |
336 | 330 |
|
337 |
| - FreeFile(fp); |
| 331 | + FreeFile(fp); |
338 | 332 |
|
339 |
| - ValidatePgVersion(DataDir, &reason); |
340 |
| - if (reason) |
341 |
| - { |
342 |
| - fprintf(stderr, |
343 |
| - "Database system in directory %s " |
344 |
| - "is not compatible with this version of " |
345 |
| - "Postgres, or we are unable to read the " |
346 |
| - "PG_VERSION file. " |
347 |
| - "Explanation from ValidatePgVersion: %s\n\n", |
348 |
| - DataDir, reason); |
349 |
| - free(reason); |
350 |
| - *DataDirOK = false; |
351 |
| - } |
352 |
| - else |
353 |
| - *DataDirOK = true; |
354 |
| - } |
355 |
| - } |
| 333 | + ValidatePgVersion(DataDir); |
356 | 334 | }
|
357 | 335 |
|
| 336 | + |
358 | 337 | int
|
359 | 338 | PostmasterMain(int argc, char *argv[])
|
360 | 339 | {
|
361 | 340 | int opt;
|
362 | 341 | int status;
|
363 | 342 | int silentflag = 0;
|
364 |
| - bool DataDirOK; /* We have a usable PGDATA value */ |
365 | 343 | char original_extraoptions[MAXPGPATH];
|
366 | 344 |
|
367 | 345 | IsUnderPostmaster = true; /* so that backends know this */
|
@@ -435,12 +413,7 @@ PostmasterMain(int argc, char *argv[])
|
435 | 413 | }
|
436 | 414 |
|
437 | 415 | optind = 1; /* start over */
|
438 |
| - checkDataDir(DataDir, &DataDirOK); /* issues error messages */ |
439 |
| - if (!DataDirOK) |
440 |
| - { |
441 |
| - fprintf(stderr, "No data directory -- can't proceed.\n"); |
442 |
| - exit(2); |
443 |
| - } |
| 416 | + checkDataDir(DataDir); /* issues error messages */ |
444 | 417 |
|
445 | 418 | ProcessConfigFile(PGC_POSTMASTER);
|
446 | 419 |
|
|
0 commit comments