88 *
99 *
1010 * 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 $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
6060
6161#include "pgstat.h"
6262
63+ extern int optind ;
64+ extern char * optarg ;
65+
6366
6467/* ----------------
6568 *global variables
6669 * ----------------
6770 */
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
7372 * log_min_error_statement */
7473
7574/* Note: whereToSendOutput is initialized for the bootstrap/standalone case */
@@ -339,22 +338,18 @@ ReadCommand(StringInfo inBuf)
339338 * but it is still needed for parsing of SQL function bodies.
340339 */
341340List *
342- pg_parse_and_rewrite (char * query_string ,/* string to execute */
341+ pg_parse_and_rewrite (const char * query_string ,/* string to execute */
343342Oid * typev ,/* parameter types */
344343int nargs )/* number of parameters */
345344{
346345List * raw_parsetree_list ;
347346List * querytree_list ;
348347List * list_item ;
349- StringInfoData stri ;
350-
351- initStringInfo (& stri );
352- appendStringInfoString (& stri ,query_string );
353348
354349/*
355350 * (1) parse the request string into a list of raw parse trees.
356351 */
357- raw_parsetree_list = pg_parse_query (& stri ,typev ,nargs );
352+ raw_parsetree_list = pg_parse_query (query_string ,typev ,nargs );
358353
359354/*
360355 * (2) Do parse analysis and rule rewrite.
@@ -385,12 +380,12 @@ pg_parse_and_rewrite(char *query_string,/* string to execute */
385380 * commands are not processed any further than the raw parse stage.
386381 */
387382List *
388- pg_parse_query (StringInfo query_string ,Oid * typev ,int nargs )
383+ pg_parse_query (const char * query_string ,Oid * typev ,int nargs )
389384{
390385List * raw_parsetree_list ;
391386
392387if (log_statement )
393- elog (LOG ,"query: %s" ,query_string -> data );
388+ elog (LOG ,"query: %s" ,query_string );
394389
395390if (log_parser_stats )
396391ResetUsage ();
@@ -569,7 +564,7 @@ pg_plan_query(Query *querytree)
569564 */
570565
571566void
572- pg_exec_query_string (StringInfo query_string ,/* string to execute */
567+ pg_exec_query_string (const char * query_string ,/* string to execute */
573568CommandDest dest ,/* where results should go */
574569MemoryContext parse_context )/* context for
575570 * parsetrees */
@@ -582,7 +577,7 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
582577stop_t ;
583578bool save_log_duration = log_duration ;
584579
585- debug_query_string = query_string -> data ;
580+ debug_query_string = query_string ;
586581
587582/*
588583 * We use save_log_duration so "SET log_duration = true" doesn't
@@ -1248,7 +1243,7 @@ PostgresMain(int argc, char *argv[], const char *username)
12481243GucSource gucsource ;
12491244char * tmp ;
12501245int firstchar ;
1251- StringInfo parser_input ;
1246+ StringInfo input_message ;
12521247bool send_rfq ;
12531248
12541249/*
@@ -1831,7 +1826,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18311826if (!IsUnderPostmaster )
18321827{
18331828puts ("\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" );
18351830}
18361831
18371832/*
@@ -1933,7 +1928,7 @@ PostgresMain(int argc, char *argv[], const char *username)
19331928MemoryContextSwitchTo (QueryContext );
19341929MemoryContextResetAndDeleteChildren (QueryContext );
19351930
1936- parser_input = makeStringInfo ();
1931+ input_message = makeStringInfo ();
19371932
19381933/*
19391934 * (1) tell the frontend we're ready for a new query.
@@ -1983,7 +1978,7 @@ PostgresMain(int argc, char *argv[], const char *username)
19831978/*
19841979 * (3) read a command (loop blocks here)
19851980 */
1986- firstchar = ReadCommand (parser_input );
1981+ firstchar = ReadCommand (input_message );
19871982
19881983/*
19891984 * (4) disable async signal conditions again.
@@ -2009,25 +2004,29 @@ PostgresMain(int argc, char *argv[], const char *username)
20092004switch (firstchar )
20102005{
20112006case '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 );
20202015
2021- pgstat_report_activity (parser_input -> data );
2016+ if (log_statement_stats )
2017+ ResetUsage ();
20222018
2023- pg_exec_query_string (parser_input ,
2024- whereToSendOutput ,
2025- QueryContext );
2019+ pgstat_report_activity (query_string );
20262020
2027- if (log_statement_stats )
2028- ShowUsage ("QUERY STATISTICS" );
2021+ pg_exec_query_string (query_string ,
2022+ whereToSendOutput ,
2023+ QueryContext );
20292024
2030- send_rfq = true;
2025+ if (log_statement_stats )
2026+ ShowUsage ("QUERY STATISTICS" );
2027+
2028+ send_rfq = true;
2029+ }
20312030break ;
20322031
20332032case 'F' :/* fastpath function call */
@@ -2037,7 +2036,7 @@ PostgresMain(int argc, char *argv[], const char *username)
20372036/* start an xact for this function invocation */
20382037start_xact_command ();
20392038
2040- if (HandleFunctionRequest (parser_input )== EOF )
2039+ if (HandleFunctionRequest (input_message )== EOF )
20412040{
20422041/* lost frontend connection during F message input */
20432042