Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ec578e

Browse files
committed
Remove setvbuf() call from PQtrace()
It's misplaced there -- it's not libpq's output stream to tweak in thatway. In particular, POSIX says that it has to be called before anyother operation on the file, so if a stream previously used by thecalling application, bad things may happen.Put setvbuf() in libpq_pipeline for good measure.Also, reduce fopen(..., "w+") to just fopen(..., "w") inlibpq_pipeline.c. It's not clear that this fixes anything, but we don'tuse w+ anywhere.Per complaints from Tom Lane.Discussion:https://postgr.es/m/3337422.1617229905@sss.pgh.pa.us
1 parentaba24b5 commit6ec578e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

‎src/interfaces/libpq/fe-trace.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ PQtrace(PGconn *conn, FILE *debug_port)
4040
if (debug_port==NULL)
4141
return;
4242

43-
/* Make the trace stream line-buffered */
44-
setvbuf(debug_port,NULL,_IOLBF,0);
4543
conn->Pfdebug=debug_port;
4644
conn->traceFlags=0;
4745
}

‎src/test/modules/libpq_pipeline/libpq_pipeline.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,10 +1319,13 @@ main(int argc, char **argv)
13191319
/* Set the trace file, if requested */
13201320
if (tracefile!=NULL)
13211321
{
1322-
trace=fopen(tracefile,"w+");
1323-
1322+
trace=fopen(tracefile,"w");
13241323
if (trace==NULL)
13251324
pg_fatal("could not open file \"%s\": %m",tracefile);
1325+
1326+
/* Make it line-buffered */
1327+
setvbuf(trace,NULL,_IOLBF,0);
1328+
13261329
PQtrace(conn,trace);
13271330
PQtraceSetFlags(conn,
13281331
PQTRACE_SUPPRESS_TIMESTAMPS |PQTRACE_REGRESS_MODE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp