From 20ab467d76d78271006818d2baf4c9c8658d1f38 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 14 Mar 2006 22:48:25 +0000 Subject: Improve parser so that we can show an error cursor position for errors during parse analysis, not only errors detected in the flex/bison stages. This is per my earlier proposal. This commit includes all the basic infrastructure, but locations are only tracked and reported for errors involving column references, function calls, and operators. More could be done later but this seems like a good set to start with. I've also moved the ReportSyntaxErrorPosition logic out of psql and into libpq, which should make it available to more people --- even within psql this is an improvement because warnings weren't handled by ReportSyntaxErrorPosition. --- src/backend/tcop/postgres.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index a94d2691e88..78cb8c3f811 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.481 2006/03/05 15:58:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.482 2006/03/14 22:48:21 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -501,6 +501,7 @@ pg_parse_and_rewrite(const char *query_string, /* string to execute */ querytree_list = list_concat(querytree_list, pg_analyze_and_rewrite(parsetree, + query_string, paramTypes, numParams)); } @@ -625,7 +626,8 @@ log_after_parse(List *raw_parsetree_list, const char *query_string, * NOTE: for reasons mentioned above, this must be separate from raw parsing. */ List * -pg_analyze_and_rewrite(Node *parsetree, Oid *paramTypes, int numParams) +pg_analyze_and_rewrite(Node *parsetree, const char *query_string, + Oid *paramTypes, int numParams) { List *querytree_list; @@ -635,7 +637,8 @@ pg_analyze_and_rewrite(Node *parsetree, Oid *paramTypes, int numParams) if (log_parser_stats) ResetUsage(); - querytree_list = parse_analyze(parsetree, paramTypes, numParams); + querytree_list = parse_analyze(parsetree, query_string, + paramTypes, numParams); if (log_parser_stats) ShowUsage("PARSE ANALYSIS STATISTICS"); @@ -946,7 +949,8 @@ exec_simple_query(const char *query_string) */ oldcontext = MemoryContextSwitchTo(MessageContext); - querytree_list = pg_analyze_and_rewrite(parsetree, NULL, 0); + querytree_list = pg_analyze_and_rewrite(parsetree, query_string, + NULL, 0); plantree_list = pg_plan_queries(querytree_list, NULL, true); @@ -1257,6 +1261,7 @@ exec_parse_message(const char *query_string, /* string to execute */ ResetUsage(); querytree_list = parse_analyze_varparams(parsetree, + query_string, ¶mTypes, &numParams); -- cgit v1.2.3