18
18
*
19
19
*
20
20
* IDENTIFICATION
21
- * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.43 2008/01/01 19:45:51 momjian Exp $
21
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.44 2008/01/25 20:42:10 tgl Exp $
22
22
*
23
23
*-------------------------------------------------------------------------
24
24
*/
@@ -89,7 +89,7 @@ static bool pipe_eof_seen = false;
89
89
static FILE * syslogFile = NULL ;
90
90
static FILE * csvlogFile = NULL ;
91
91
static char * last_file_name = NULL ;
92
- static char * last_csvfile_name = NULL ;
92
+ static char * last_csv_file_name = NULL ;
93
93
94
94
/*
95
95
* Buffers for saving partial messages from different backends. We don't expect
@@ -345,12 +345,12 @@ SysLoggerMain(int argc, char *argv[])
345
345
rotation_requested = true;
346
346
size_rotation_for |= LOG_DESTINATION_STDERR ;
347
347
}
348
- if (csvlogFile != NULL && ftell (csvlogFile ) >= Log_RotationSize * 1024L )
348
+ if (csvlogFile != NULL &&
349
+ ftell (csvlogFile ) >= Log_RotationSize * 1024L )
349
350
{
350
351
rotation_requested = true;
351
352
size_rotation_for |= LOG_DESTINATION_CSVLOG ;
352
353
}
353
-
354
354
}
355
355
356
356
if (rotation_requested )
@@ -1056,7 +1056,8 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for)
1056
1056
if (time_based_rotation || (size_rotation_for & LOG_DESTINATION_STDERR ))
1057
1057
{
1058
1058
if (Log_truncate_on_rotation && time_based_rotation &&
1059
- last_file_name != NULL && strcmp (filename , last_file_name ) != 0 )
1059
+ last_file_name != NULL &&
1060
+ strcmp (filename , last_file_name ) != 0 )
1060
1061
fh = fopen (filename , "w" );
1061
1062
else
1062
1063
fh = fopen (filename , "a" );
@@ -1084,6 +1085,8 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for)
1084
1085
Log_RotationSize = 0 ;
1085
1086
}
1086
1087
pfree (filename );
1088
+ if (csvfilename )
1089
+ pfree (csvfilename );
1087
1090
return ;
1088
1091
}
1089
1092
@@ -1107,20 +1110,16 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for)
1107
1110
if (last_file_name != NULL )
1108
1111
pfree (last_file_name );
1109
1112
last_file_name = filename ;
1110
-
1111
-
1112
1113
}
1113
1114
1114
- /* same as above, but for csv file. */
1115
+ /* Same as above, but for csv file. */
1115
1116
1116
- if (csvlogFile != NULL && (
1117
- time_based_rotation ||
1118
- (size_rotation_for & LOG_DESTINATION_STDERR )))
1117
+ if (csvlogFile != NULL &&
1118
+ (time_based_rotation || (size_rotation_for & LOG_DESTINATION_CSVLOG )))
1119
1119
{
1120
1120
if (Log_truncate_on_rotation && time_based_rotation &&
1121
- last_csvfile_name != NULL &&
1122
- strcmp (csvfilename , last_csvfile_name ) != 0 )
1123
-
1121
+ last_csv_file_name != NULL &&
1122
+ strcmp (csvfilename , last_csv_file_name ) != 0 )
1124
1123
fh = fopen (csvfilename , "w" );
1125
1124
else
1126
1125
fh = fopen (csvfilename , "a" );
@@ -1168,13 +1167,12 @@ logfile_rotate(bool time_based_rotation, int size_rotation_for)
1168
1167
#endif
1169
1168
1170
1169
/* instead of pfree'ing filename, remember it for next time */
1171
- if (last_csvfile_name != NULL )
1172
- pfree (last_csvfile_name );
1173
- last_csvfile_name = filename ;
1170
+ if (last_csv_file_name != NULL )
1171
+ pfree (last_csv_file_name );
1172
+ last_csv_file_name = csvfilename ;
1174
1173
}
1175
1174
1176
1175
set_next_rotation_time ();
1177
-
1178
1176
}
1179
1177
1180
1178
0 commit comments