Unix Technical Forum

change format of logging statements?

This is a discussion on change format of logging statements? within the Pgsql General forums, part of the PostgreSQL category; --> Postgres 8.2.0 is logging statements with variables like $1, $2, etc. and then on the next line saying: DETAIL: ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 03:11 PM
Matthew Hixson
 
Posts: n/a
Default change format of logging statements?

Postgres 8.2.0 is logging statements with variables like $1, $2, etc.
and then on the next line saying:

DETAIL: parameters: $1 = '100', $2 = '100', $3 = '1003'

Is it possible to get statements logged with the parameters placed
into the actual query statement so that its more convenient to copy
and paste them into psql while debugging? The reason for this is
that Hibernate is creating the queries and I'd like to see exactly
what those queries are returning.
Thanks,
-M@

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 03:11 PM
Alvaro Herrera
 
Posts: n/a
Default Re: change format of logging statements?

Matthew Hixson wrote:
> Postgres 8.2.0 is logging statements with variables like $1, $2, etc.
> and then on the next line saying:
>
> DETAIL: parameters: $1 = '100', $2 = '100', $3 = '1003'
>
> Is it possible to get statements logged with the parameters placed
> into the actual query statement so that its more convenient to copy
> and paste them into psql while debugging? The reason for this is
> that Hibernate is creating the queries and I'd like to see exactly
> what those queries are returning.


Not really. You could probably use PREPARE <the query as first logged>
and EXECUTE with the given paramters instead of interpolating the
parameters in the query itself. It might be easier.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 11:08 PM
Matthew Hixson
 
Posts: n/a
Default Re: change format of logging statements?

With 8.2.4 is it possible to get Postgres to log incoming SQL
statements the same as they look when written? Instead of:

DEBUG: insert into foo (name) values ($1);
DETAIL: parameters: $1 = 'stan'

I'd like to see:

DEBUG: insert into foo (name) values ('stan');

This would be extremely helpful when debugging complex Hibernate
generated queries. I could just copy&paste the query into a psql
session and begin playing with it.
Thanks,
-M@

---------------------------(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
  #4 (permalink)  
Old 04-09-2008, 11:08 PM
Tom Lane
 
Posts: n/a
Default Re: change format of logging statements?

Matthew Hixson <hixson@poindextrose.org> writes:
> Instead of:
> DEBUG: insert into foo (name) values ($1);
> DETAIL: parameters: $1 = 'stan'
> I'd like to see:
> DEBUG: insert into foo (name) values ('stan');


Don't hold your breath. That would require a great deal more smarts
in the logging code (and a great deal more cycles expended) than it
has now.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-09-2008, 11:08 PM
Alvaro Herrera
 
Posts: n/a
Default Re: change format of logging statements?

Tom Lane wrote:
> Matthew Hixson <hixson@poindextrose.org> writes:
> > Instead of:
> > DEBUG: insert into foo (name) values ($1);
> > DETAIL: parameters: $1 = 'stan'
> > I'd like to see:
> > DEBUG: insert into foo (name) values ('stan');

>
> Don't hold your breath. That would require a great deal more smarts
> in the logging code (and a great deal more cycles expended) than it
> has now.


That said, you can use explain on these things, though you must do a bit
more work:

alvherre=# prepare foo as insert into foo (name) values ($1);
PREPARE
alvherre=# explain execute foo('stan');
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.01 rows=1 width=0)
(1 ligne)

The benefit is that this will use the same plan that Hibernate would be
using, whereas simply expanding the literal in the query would possibly not.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(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
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 05:40 AM.


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