Re: I want to send comments to the backend!

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: I want to send comments to the backend!
Дата
Msg-id 200303210555.h2L5tKG10364@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: I want to send comments to the backend!  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: I want to send comments to the backend!  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-interfaces
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > 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().
>
> Seems like the hard way.  I had in mind a quick
>
>     if (parsetree_list == NIL)
>     {
>         NullCommand(dest);
>         return;
>     }
>
> before entering the main loop.  It'd take a small amount of reordering
> of the existing code to make this happen without adding any more code
> than that, but it looked doable.

The problem is that there is so much startup/shutdown in that function
that adding a quick exit point seems too error-prone for maintenance,
rather than keeping the existing structure.

I used your idea of testing just 'parsetree_list' and the patch is now
smaller.

--
  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
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:52:56 -0000
***************
*** 927,932 ****
--- 927,936 ----
          EndCommand(commandTag, dest);
      }                            /* end loop over parsetrees */

+     /* No parsetree - return empty result */
+     if (!parsetree_list && 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;

                  /*

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: I want to send comments to the backend!
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: I want to send comments to the backend!