8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.324 2003/04/24 21:16:43 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.325 2003/04/27 20:09:44 tgl Exp $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
60
60
61
61
#include "pgstat.h"
62
62
63
+ extern int optind ;
64
+ extern char * optarg ;
65
+
63
66
64
67
/* ----------------
65
68
* global variables
66
69
* ----------------
67
70
*/
68
-
69
- extern int optind ;
70
- extern char * optarg ;
71
-
72
- char * debug_query_string ; /* for pgmonitor and
71
+ const char * debug_query_string ; /* for pgmonitor and
73
72
* log_min_error_statement */
74
73
75
74
/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
@@ -339,22 +338,18 @@ ReadCommand(StringInfo inBuf)
339
338
* but it is still needed for parsing of SQL function bodies.
340
339
*/
341
340
List *
342
- pg_parse_and_rewrite (char * query_string , /* string to execute */
341
+ pg_parse_and_rewrite (const char * query_string , /* string to execute */
343
342
Oid * typev , /* parameter types */
344
343
int nargs ) /* number of parameters */
345
344
{
346
345
List * raw_parsetree_list ;
347
346
List * querytree_list ;
348
347
List * list_item ;
349
- StringInfoData stri ;
350
-
351
- initStringInfo (& stri );
352
- appendStringInfoString (& stri , query_string );
353
348
354
349
/*
355
350
* (1) parse the request string into a list of raw parse trees.
356
351
*/
357
- raw_parsetree_list = pg_parse_query (& stri , typev , nargs );
352
+ raw_parsetree_list = pg_parse_query (query_string , typev , nargs );
358
353
359
354
/*
360
355
* (2) Do parse analysis and rule rewrite.
@@ -385,12 +380,12 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */
385
380
* commands are not processed any further than the raw parse stage.
386
381
*/
387
382
List *
388
- pg_parse_query (StringInfo query_string , Oid * typev , int nargs )
383
+ pg_parse_query (const char * query_string , Oid * typev , int nargs )
389
384
{
390
385
List * raw_parsetree_list ;
391
386
392
387
if (log_statement )
393
- elog (LOG , "query: %s" , query_string -> data );
388
+ elog (LOG , "query: %s" , query_string );
394
389
395
390
if (log_parser_stats )
396
391
ResetUsage ();
@@ -569,7 +564,7 @@ pg_plan_query(Query *querytree)
569
564
*/
570
565
571
566
void
572
- pg_exec_query_string (StringInfo query_string , /* string to execute */
567
+ pg_exec_query_string (const char * query_string , /* string to execute */
573
568
CommandDest dest , /* where results should go */
574
569
MemoryContext parse_context ) /* context for
575
570
* parsetrees */
@@ -582,7 +577,7 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
582
577
stop_t ;
583
578
bool save_log_duration = log_duration ;
584
579
585
- debug_query_string = query_string -> data ;
580
+ debug_query_string = query_string ;
586
581
587
582
/*
588
583
* We use save_log_duration so "SET log_duration = true" doesn't
@@ -1248,7 +1243,7 @@ PostgresMain(int argc, char *argv[], const char *username)
1248
1243
GucSource gucsource ;
1249
1244
char * tmp ;
1250
1245
int firstchar ;
1251
- StringInfo parser_input ;
1246
+ StringInfo input_message ;
1252
1247
bool send_rfq ;
1253
1248
1254
1249
/*
@@ -1831,7 +1826,7 @@ PostgresMain(int argc, char *argv[], const char *username)
1831
1826
if (!IsUnderPostmaster )
1832
1827
{
1833
1828
puts ("\nPOSTGRES backend interactive interface " );
1834
- puts ("$Revision: 1.324 $ $Date: 2003/04/24 21:16:43 $\n" );
1829
+ puts ("$Revision: 1.325 $ $Date: 2003/04/27 20:09:44 $\n" );
1835
1830
}
1836
1831
1837
1832
/*
@@ -1933,7 +1928,7 @@ PostgresMain(int argc, char *argv[], const char *username)
1933
1928
MemoryContextSwitchTo (QueryContext );
1934
1929
MemoryContextResetAndDeleteChildren (QueryContext );
1935
1930
1936
- parser_input = makeStringInfo ();
1931
+ input_message = makeStringInfo ();
1937
1932
1938
1933
/*
1939
1934
* (1) tell the frontend we're ready for a new query.
@@ -1983,7 +1978,7 @@ PostgresMain(int argc, char *argv[], const char *username)
1983
1978
/*
1984
1979
* (3) read a command (loop blocks here)
1985
1980
*/
1986
- firstchar = ReadCommand (parser_input );
1981
+ firstchar = ReadCommand (input_message );
1987
1982
1988
1983
/*
1989
1984
* (4) disable async signal conditions again.
@@ -2009,25 +2004,29 @@ PostgresMain(int argc, char *argv[], const char *username)
2009
2004
switch (firstchar )
2010
2005
{
2011
2006
case 'Q' : /* simple query */
2012
- /*
2013
- * Process the query string.
2014
- *
2015
- * Note: transaction command start/end is now done within
2016
- * pg_exec_query_string(), not here.
2017
- */
2018
- if ( log_statement_stats )
2019
- ResetUsage ( );
2007
+ {
2008
+ /*
2009
+ * Process the query string.
2010
+ *
2011
+ * Note: transaction command start/end is now done within
2012
+ * pg_exec_query_string(), not here.
2013
+ */
2014
+ const char * query_string = pq_getmsgstring ( input_message );
2020
2015
2021
- pgstat_report_activity (parser_input -> data );
2016
+ if (log_statement_stats )
2017
+ ResetUsage ();
2022
2018
2023
- pg_exec_query_string (parser_input ,
2024
- whereToSendOutput ,
2025
- QueryContext );
2019
+ pgstat_report_activity (query_string );
2026
2020
2027
- if (log_statement_stats )
2028
- ShowUsage ("QUERY STATISTICS" );
2021
+ pg_exec_query_string (query_string ,
2022
+ whereToSendOutput ,
2023
+ QueryContext );
2029
2024
2030
- send_rfq = true;
2025
+ if (log_statement_stats )
2026
+ ShowUsage ("QUERY STATISTICS" );
2027
+
2028
+ send_rfq = true;
2029
+ }
2031
2030
break ;
2032
2031
2033
2032
case 'F' : /* fastpath function call */
@@ -2037,7 +2036,7 @@ PostgresMain(int argc, char *argv[], const char *username)
2037
2036
/* start an xact for this function invocation */
2038
2037
start_xact_command ();
2039
2038
2040
- if (HandleFunctionRequest (parser_input ) == EOF )
2039
+ if (HandleFunctionRequest (input_message ) == EOF )
2041
2040
{
2042
2041
/* lost frontend connection during F message input */
2043
2042
0 commit comments