Skip site navigation (1) Skip section navigation (2)

BUG #1057: psql sometimes does not flush its output

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1057: psql sometimes does not flush its output
Date: 2004-01-20 22:52:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      1057
Logged by:          Jon Sablatnig

Email address:      jhs(at)cs(dot)tu-berlin(dot)de

PostgreSQL version: 7.4

Operating system:   Linux 2.4

Description:        psql sometimes does not flush its output


The frontend psql will usually flush its output after
every command.

Since version 7.4, it will NOT flush after its FIRST
command, if the output is NOT a tty.

	$ psql template1 | more
Now type:
	\qecho hello

The text will NOT appear.
Try it again, both lines will appear.

This is rather annoying when trying to parse the output
automatically, so please revert to the old behaviour of
always flushing.

Analysis & fix:
The relevant files are
, and the same file in postgresql-7.3.4.

Specifically, the else{} block from line 161 on (both
files) changed so that the fflush(stdout) moved inside
the if (pset.cur_cmd_interactive).  Undoing this change
will fix the bug.

Another, perhaps slightly cleaner option is to add the
just before the end of the main while loop (line 499
in 7.4).  This also fixes the bug.


pgsql-bugs by date

Next:From: bsDate: 2004-01-21 09:51:13
Subject: 7.4.xx regression
Previous:From: Scott YeadonDate: 2004-01-20 22:37:55
Subject: connection handling in 7.4.1

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group