Unix Technical Forum

patch to suppress psql timing output in quiet mode

This is a discussion on patch to suppress psql timing output in quiet mode within the Pgsql Patches forums, part of the PostgreSQL category; --> I noticed that when psql accepts input from stdin or -f (but not -c), and timing is set to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 10:55 AM
Merlin Moncure
 
Posts: n/a
Default patch to suppress psql timing output in quiet mode

I noticed that when psql accepts input from stdin or -f (but not -c),
and timing is set to on in .psqlrc, timing results are printed out to
stdout even when -q (quiet) is passed in.

This may not be the perfect solution, but it fixes the problem (I'm
having problems with bash scripts that are borking on time returned).

current behavior:
[root@mernix psql]# echo "select 0" | psql -tAq
0
Time: 1.155 ms
[root@mernix psql]# psql -tAqc"select 0"
0

merlin

Index: common.c
================================================== =================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/common.c,v
retrieving revision 1.133
diff -c -r1.133 common.c
*** common.c 8 Feb 2007 11:10:27 -0000 1.133
--- common.c 11 Apr 2007 17:20:21 -0000
***************
*** 918,924 ****
PQclear(results);

/* Possible microtiming output */
! if (OK && pset.timing)
printf(_("Time: %.3f ms\n"), elapsed_msec);

/* check for events that may occur during query execution */
--- 918,924 ----
PQclear(results);

/* Possible microtiming output */
! if (OK && pset.timing && !pset.quiet)
printf(_("Time: %.3f ms\n"), elapsed_msec);

/* check for events that may occur during query execution */

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 10:57 AM
Magnus Hagander
 
Posts: n/a
Default Re: patch to suppress psql timing output in quiet mode

Merlin Moncure wrote:
> I noticed that when psql accepts input from stdin or -f (but not -c),
> and timing is set to on in .psqlrc, timing results are printed out to
> stdout even when -q (quiet) is passed in.
>
> This may not be the perfect solution, but it fixes the problem (I'm
> having problems with bash scripts that are borking on time returned).
>
> current behavior:
> [root@mernix psql]# echo "select 0" | psql -tAq
> 0
> Time: 1.155 ms
> [root@mernix psql]# psql -tAqc"select 0"
> 0


Makes sense to me. Applied and backpatched, thanks!

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:58 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com