summaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane2006-03-14 22:48:25 +0000
committerTom Lane2006-03-14 22:48:25 +0000
commit76319eaec81d541e2b466da30191e996e75d497d (patch)
tree254cc575a09ef98d0506d9e0716e36a9c4f5b6ca /src/backend/tcop/postgres.c
parent463d236de58c5a58f1bc69f09603116fc125942b (diff)
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.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index f922745d0c..afe9463e3b 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -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,
&paramTypes,
&numParams);