diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
| commit | 20ab467d76d78271006818d2baf4c9c8658d1f38 (patch) | |
| tree | 7a536111b5cc4e494ac75558aad5655dfc8ab964 /src/interfaces/libpq/fe-exec.c | |
| parent | 48fb696753e267447f99914c7968d0b4ffb5c5dc (diff) | |
| download | postgresql-20ab467d76d78271006818d2baf4c9c8658d1f38.tar.gz | |
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/interfaces/libpq/fe-exec.c')
| -rw-r--r-- | src/interfaces/libpq/fe-exec.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 26d2b58fd9..7f09ff6dd2 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.181 2006/03/05 15:59:09 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.182 2006/03/14 22:48:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -667,6 +667,12 @@ PQsendQuery(PGconn *conn, const char *query) /* remember we are using simple query protocol */ conn->queryclass = PGQUERY_SIMPLE; + /* and remember the query text too, if possible */ + /* if insufficient memory, last_query just winds up NULL */ + if (conn->last_query) + free(conn->last_query); + conn->last_query = strdup(query); + /* * Give the data a push. In nonblock mode, don't complain if we're unable * to send it all; PQgetResult() will do any additional flushing needed. @@ -788,6 +794,12 @@ PQsendPrepare(PGconn *conn, /* remember we are doing just a Parse */ conn->queryclass = PGQUERY_PREPARE; + /* and remember the query text too, if possible */ + /* if insufficient memory, last_query just winds up NULL */ + if (conn->last_query) + free(conn->last_query); + conn->last_query = strdup(query); + /* * Give the data a push. In nonblock mode, don't complain if we're unable * to send it all; PQgetResult() will do any additional flushing needed. @@ -1017,6 +1029,15 @@ PQsendQueryGuts(PGconn *conn, /* remember we are using extended query protocol */ conn->queryclass = PGQUERY_EXTENDED; + /* and remember the query text too, if possible */ + /* if insufficient memory, last_query just winds up NULL */ + if (conn->last_query) + free(conn->last_query); + if (command) + conn->last_query = strdup(command); + else + conn->last_query = NULL; + /* * Give the data a push. In nonblock mode, don't complain if we're unable * to send it all; PQgetResult() will do any additional flushing needed. |
