1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Setting statistic options from SET PG_OPTIONS caused a backend crash

because StatFp never got set in that case.  Set it immediately before
use to eliminate such problems.
This commit is contained in:
Tom Lane
2000-04-28 05:07:34 +00:00
parent 45cc0e9b27
commit a90dc572ed

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.152 2000/04/23 00:13:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.153 2000/04/28 05:07:34 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
@ -129,7 +129,7 @@ extern int NBuffers;
static bool EchoQuery = false; /* default don't echo */ static bool EchoQuery = false; /* default don't echo */
time_t tim; time_t tim;
char pg_pathname[MAXPGPATH]; char pg_pathname[MAXPGPATH];
FILE *StatFp; FILE *StatFp = NULL;
/* ---------------- /* ----------------
* people who want to use EOF should #define DONTUSENEWLINE in * people who want to use EOF should #define DONTUSENEWLINE in
@ -1105,7 +1105,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* ---------------- * ----------------
*/ */
ShowStats = 1; ShowStats = 1;
StatFp = stderr;
break; break;
case 'T': case 'T':
@ -1127,7 +1126,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* caution: -s can not be used together with -t. * caution: -s can not be used together with -t.
* ---------------- * ----------------
*/ */
StatFp = stderr;
switch (optarg[0]) switch (optarg[0])
{ {
case 'p': case 'p':
@ -1455,7 +1453,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.152 $ $Date: 2000/04/23 00:13:16 $\n"); puts("$Revision: 1.153 $ $Date: 2000/04/28 05:07:34 $\n");
} }
/* /*
@ -1694,6 +1692,12 @@ ShowUsage(void)
r.ru_stime.tv_usec += 1000000; r.ru_stime.tv_usec += 1000000;
} }
/*
* Set output destination if not otherwise set
*/
if (StatFp == NULL)
StatFp = stderr;
/* /*
* the only stats we don't show here are for memory usage -- i can't * the only stats we don't show here are for memory usage -- i can't
* figure out how to interpret the relevant fields in the rusage * figure out how to interpret the relevant fields in the rusage