Re: client side syntax error position (v3)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>, Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
Subject: Re: client side syntax error position (v3)
Date: 2004-03-14 04:33:04
Message-ID: 17103.1079238784@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> writes:
> New submission... after suggestions by Tom and others, the current result
> looks like the following:

> psql> CREATE foo;
> ERROR: syntax error at or near "foo" at character 8
> LINE 1: CREATE foo;
> ^
> psql>

I have applied this patch, after some considerable whacking around to
make it ready to cope with multicolumn Kanji characters. It does not
actually cope yet, since the necessary knowledge is not available
from the character encoding logic. But replacing the two places
that say

scroffset += 1; /* XXX fix me when we have screen width info */

with calls to a get-the-screen-width-of-this-character subroutine should
do the job.

I have temporarily fixed the problem shown in Fabien's original
regression tests:

CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
AS 'not even SQL';
ERROR: syntax error at or near "not" at character 1
+ LINE 1: CREATE FUNCTION test1 (int) RETURNS int LANGUAGE sql
+ ^

by having the backend output a CONTEXT field in this case, and causing
psql to ignore the cursor position if there's a CONTEXT field. This
is necessary AFAICS in the general case where a pre-existing function
gets an internal syntax error when called. It'd be nice to do better in
the case of CREATE FUNCTION for a SQL function, but I don't currently
see how we can account for the string literal's starting position and
possible internal quotes, backslashes, etc etc.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-03-14 05:05:33 Re: PSQLRC environment variable.
Previous Message Bruce Momjian 2004-03-14 04:15:07 Re: libpq thread safety