Re: TODO item: list prepared queries - Mailing list pgsql-patches

From Tom Lane
Subject Re: TODO item: list prepared queries
Date
Msg-id 12439.1136238019@sss.pgh.pa.us
Whole thread Raw
In response to Re: TODO item: list prepared queries  (Neil Conway <neilc@samurai.com>)
Responses Re: TODO item: list prepared queries  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> Well, it doesn't insert a deparse_query_list() into the processing of
> *every* Parse message -- it only does so for Parse messages that create
> named prepared statements. I don't see that there is a fundamental
> difference between a named Parse and an SQL-level PREPARE: if adding
> deparse_query_list() to one is too expensive, ISTM it is too expensive
> for either.

I quite agree ;-)

> One possibility would be to execute deparse_query_list() in the SRF
> (which is what Joachim's patch did originally), but that is fragile: if
> a table a prepared statement depends on is dropped, the view will be
> broken. We could workaround that by enclosing the deparse_query_list()
> call in a PG_TRY block (and displaying a NULL query string for broken
> prepared statements), but that doesn't prevent more subtle problems like
> the search_path changing.

Arguably, deparsing when the view is read is the only correct way to
handle search-path changes.  But I really think that storing the source
string is the most useful as well as fastest definition.  The average
application that wants to use this view at all will be looking to see
"did I already prepare FOO".  If it's using the query definition string
for this purpose, comparing source text is easy while comparing deparsed
text to source is a nightmare.

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: TODO item: list prepared queries
Next
From: Marko Kreen
Date:
Subject: pgcrypto: bug in gen_salt (md5/xdes)