record statement boundaries

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: record statement boundaries
Date: 2006-02-17 04:21:50
Message-ID: 1140150110.31672.84.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Attached is a patch from Joachim Wieland that changes the parser to
optionally maintain a list of the source texts of the statements in the
input query string. Currently debug_query_string is used for that
purpose -- this is incorrect when multiple comma-separated statements
are concatenated together in a single query string.

The patch maintains the list by having the parser record when each
statement ends; the lexer's current position is used to determine the
source text that corresponds to the current statement. A new global
variable "current_statement" has been introduced to replace
"debug_query_string" (which has been removed).

Two issues/questions:

(1) Joachim's patch removes leading and trailing whitespace, and any
trailing semi-colon from the statement's text. Is this the right
behavior? I'm not sure, I can see an argument for both sides.

(2) Some of the logging code (e.g. log_after_parse(), the code for
log_min_duration_statement, etc.) needs to be updated to use
current_statement rather than the user-submitted query string. I'll do
that shortly.

Patch from Joachim Wieland, reviewed by Neil Conway.

-Neil

Attachment Content-Type Size
pg_debug_query_string.8.diff text/x-patch 15.1 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-02-17 06:15:22 Re: record statement boundaries
Previous Message Peter Eisentraut 2006-02-16 23:25:35 Re: memset using long instead of int32