mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Scanner performance improvements
Use flex flags -CF. Pass the to-be-scanned string around as StringInfo type, to avoid querying the length repeatedly. Clean up some code and remove lex-compatibility cruft. Escape backslash sequences inline. Use flex-provided yy_scan_buffer() function to set up input, rather than using myinput().
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.261 2002/04/18 20:01:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.262 2002/04/20 21:56:15 petere Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -120,7 +120,7 @@ int XfuncMode = 0;
|
||||
static int InteractiveBackend(StringInfo inBuf);
|
||||
static int SocketBackend(StringInfo inBuf);
|
||||
static int ReadCommand(StringInfo inBuf);
|
||||
static List *pg_parse_query(char *query_string, Oid *typev, int nargs);
|
||||
static List *pg_parse_query(StringInfo query_string, Oid *typev, int nargs);
|
||||
static List *pg_analyze_and_rewrite(Node *parsetree);
|
||||
static void start_xact_command(void);
|
||||
static void finish_xact_command(void);
|
||||
@ -330,11 +330,15 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */
|
||||
List *raw_parsetree_list;
|
||||
List *querytree_list;
|
||||
List *list_item;
|
||||
StringInfoData stri;
|
||||
|
||||
initStringInfo(&stri);
|
||||
appendStringInfo(&stri, "%s", query_string);
|
||||
|
||||
/*
|
||||
* (1) parse the request string into a list of raw parse trees.
|
||||
*/
|
||||
raw_parsetree_list = pg_parse_query(query_string, typev, nargs);
|
||||
raw_parsetree_list = pg_parse_query(&stri, typev, nargs);
|
||||
|
||||
/*
|
||||
* (2) Do parse analysis and rule rewrite.
|
||||
@ -365,12 +369,12 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */
|
||||
* commands are not processed any further than the raw parse stage.
|
||||
*/
|
||||
static List *
|
||||
pg_parse_query(char *query_string, Oid *typev, int nargs)
|
||||
pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
|
||||
{
|
||||
List *raw_parsetree_list;
|
||||
|
||||
if (Debug_print_query)
|
||||
elog(LOG, "query: %s", query_string);
|
||||
elog(LOG, "query: %s", query_string->data);
|
||||
|
||||
if (Show_parser_stats)
|
||||
ResetUsage();
|
||||
@ -549,7 +553,7 @@ pg_plan_query(Query *querytree)
|
||||
*/
|
||||
|
||||
void
|
||||
pg_exec_query_string(char *query_string, /* string to execute */
|
||||
pg_exec_query_string(StringInfo query_string, /* string to execute */
|
||||
CommandDest dest, /* where results should go */
|
||||
MemoryContext parse_context) /* context for
|
||||
* parsetrees */
|
||||
@ -559,7 +563,7 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
List *parsetree_list,
|
||||
*parsetree_item;
|
||||
|
||||
debug_query_string = query_string; /* used by pgmonitor */
|
||||
debug_query_string = query_string->data; /* used by pgmonitor */
|
||||
|
||||
/*
|
||||
* Start up a transaction command. All queries generated by the
|
||||
@ -725,7 +729,7 @@ pg_exec_query_string(char *query_string, /* string to execute */
|
||||
* process utility functions (create, destroy, etc..)
|
||||
*/
|
||||
if (Debug_print_query)
|
||||
elog(LOG, "ProcessUtility: %s", query_string);
|
||||
elog(LOG, "ProcessUtility: %s", query_string->data);
|
||||
else elog(DEBUG2, "ProcessUtility");
|
||||
|
||||
if (querytree->originalQuery)
|
||||
@ -1688,7 +1692,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.261 $ $Date: 2002/04/18 20:01:09 $\n");
|
||||
puts("$Revision: 1.262 $ $Date: 2002/04/20 21:56:15 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1913,7 +1917,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
|
||||
pgstat_report_activity(parser_input->data);
|
||||
|
||||
pg_exec_query_string(parser_input->data,
|
||||
pg_exec_query_string(parser_input,
|
||||
whereToSendOutput,
|
||||
QueryContext);
|
||||
|
||||
|
Reference in New Issue
Block a user