From a90dc572ed4498e57381bdb7020ee453f4d20b57 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 28 Apr 2000 05:07:34 +0000 Subject: [PATCH] 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. --- src/backend/tcop/postgres.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index b84ae7b537..bcb63bb219 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * 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 * 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 */ time_t tim; char pg_pathname[MAXPGPATH]; -FILE *StatFp; +FILE *StatFp = NULL; /* ---------------- * 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; - StatFp = stderr; break; 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. * ---------------- */ - StatFp = stderr; switch (optarg[0]) { case 'p': @@ -1455,7 +1453,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { 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; } + /* + * 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 * figure out how to interpret the relevant fields in the rusage