From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gerhard Häring <lists@ghaering.de>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: I want to send comments to the backend!
Date: Fri, 21 Mar 2003 00:16:52 -0500 (EST)
Message-ID: <200303210516.h2L5Gq104398@candle.pha.pa.us> (raw)
In-Reply-To: <25200.1048186822@sss.pgh.pa.us>
OK, this patch fixes the comment passing bug. I remove the strspn() and
added a boolean to test if any parsetree had been generated --- if not,
I call NullCommand(). I also changed the call to use 'dest' rather than
a hardwired "Remote".
---------------------------------------------------------------------------
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> generalize it to understand about comments. Right now seems to be a
> >> fine time to think about this, in fact, given that we're hacking the
> >> protocol anyway.
>
> > Yes.
>
> On third thought, though, it would be really trivial for
> pg_exec_query_string to call NullCommand and fall out early if
> pg_parse_query returns an empty list; it'd take one extra test for NIL,
> which would be more than compensated for if we got rid of the strspn
> test. So maybe changing the backend is the best answer after all.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Attachments:/bjm/diff (text/plain, 2.9K) download
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.318
diff -c -c -r1.318 postgres.c
*** src/backend/tcop/postgres.c 20 Mar 2003 07:02:10 -0000 1.318
--- src/backend/tcop/postgres.c 21 Mar 2003 05:14:15 -0000
***************
*** 553,559 ****
MemoryContext parse_context) /* context for
* parsetrees */
{
! bool xact_started;
MemoryContext oldcontext;
List *parsetree_list,
*parsetree_item;
--- 553,559 ----
MemoryContext parse_context) /* context for
* parsetrees */
{
! bool xact_started, was_parsetree = false;
MemoryContext oldcontext;
List *parsetree_list,
*parsetree_item;
***************
*** 618,623 ****
--- 618,624 ----
List *querytree_list,
*querytree_item;
+ was_parsetree = true;
/*
* First we set the command-completion tag to the main query (as
* opposed to each of the others that may be generated by analyze
***************
*** 927,932 ****
--- 928,936 ----
EndCommand(commandTag, dest);
} /* end loop over parsetrees */
+ if (!was_parsetree && IsUnderPostmaster)
+ NullCommand(dest);
+
/*
* Close down transaction statement, if one is open. (Note that this
* will only happen if the querystring was empty.)
***************
*** 1995,2030 ****
* 'Q' indicates a user query
*/
case 'Q':
! if (strspn(parser_input->data, " \t\r\n") == parser_input->len)
! {
! /*
! * if there is nothing in the input buffer, don't
! * bother trying to parse and execute anything; just
! * send back a quick NullCommand response.
! */
! if (IsUnderPostmaster)
! NullCommand(Remote);
! }
! else
! {
! /*
! * otherwise, process the input string.
! *
! * Note: transaction command start/end is now done within
! * pg_exec_query_string(), not here.
! */
! if (log_statement_stats)
! ResetUsage();
! pgstat_report_activity(parser_input->data);
! pg_exec_query_string(parser_input,
! whereToSendOutput,
! QueryContext);
! if (log_statement_stats)
! ShowUsage("QUERY STATISTICS");
! }
break;
/*
--- 1999,2021 ----
* 'Q' indicates a user query
*/
case 'Q':
! /*
! * otherwise, process the input string.
! *
! * Note: transaction command start/end is now done within
! * pg_exec_query_string(), not here.
! */
! if (log_statement_stats)
! ResetUsage();
! pgstat_report_activity(parser_input->data);
! pg_exec_query_string(parser_input,
! whereToSendOutput,
! QueryContext);
! if (log_statement_stats)
! ShowUsage("QUERY STATISTICS");
break;
/*
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: pgman@candle.pha.pa.us, tgl@sss.pgh.pa.us, lists@ghaering.de
Subject: Re: I want to send comments to the backend!
In-Reply-To: <200303210516.h2L5Gq104398@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox