Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a90dc57

Browse files
committed
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.
1 parent 45cc0e9 commit a90dc57

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/tcop/postgres.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.152 2000/04/23 00:13:16 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.153 2000/04/28 05:07:34 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -129,7 +129,7 @@ extern int NBuffers;
129129
static bool EchoQuery = false; /* default don't echo */
130130
time_t tim;
131131
char pg_pathname[MAXPGPATH];
132-
FILE *StatFp;
132+
FILE *StatFp = NULL;
133133

134134
/* ----------------
135135
* 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[])
11051105
* ----------------
11061106
*/
11071107
ShowStats = 1;
1108-
StatFp = stderr;
11091108
break;
11101109

11111110
case 'T':
@@ -1127,7 +1126,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
11271126
* caution: -s can not be used together with -t.
11281127
* ----------------
11291128
*/
1130-
StatFp = stderr;
11311129
switch (optarg[0])
11321130
{
11331131
case 'p':
@@ -1455,7 +1453,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14551453
if (!IsUnderPostmaster)
14561454
{
14571455
puts("\nPOSTGRES backend interactive interface ");
1458-
puts("$Revision: 1.152 $ $Date: 2000/04/23 00:13:16 $\n");
1456+
puts("$Revision: 1.153 $ $Date: 2000/04/28 05:07:34 $\n");
14591457
}
14601458

14611459
/*
@@ -1694,6 +1692,12 @@ ShowUsage(void)
16941692
r.ru_stime.tv_usec += 1000000;
16951693
}
16961694

1695+
/*
1696+
* Set output destination if not otherwise set
1697+
*/
1698+
if (StatFp == NULL)
1699+
StatFp = stderr;
1700+
16971701
/*
16981702
* the only stats we don't show here are for memory usage -- i can't
16991703
* figure out how to interpret the relevant fields in the rusage

0 commit comments

Comments
 (0)