syntax error position "CREATE FUNCTION" bug fix

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: syntax error position "CREATE FUNCTION" bug fix
Date: 2004-03-18 09:51:36
Message-ID: Pine.LNX.4.58.0403181048580.24164@sablons.cri.ensmp.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Dear patchers,

Please find attached a patch to fix the "CREATE FUNCTION" syntax error
position bug I reported a few days ago.

As the exact query being processed in only known to the backend (it may be
the initial query, it may be a subset of the initial query, it may be some
generated query?), the offending string is returned with the error
position, which is expressed with respect to this query (that has always
been the case by the way).

In order to do that, I did the following:

1. appended a new "query" field into the ErrorData structure,
which is set with an added errquery function.

2. modified the error reporting part of the protocol (version 3).
As the protocol implementation in libpq is fuzzy enough, there is
not fix on the client reception part, only the server sending
part is modified with a new field for the query (Q). Thus this
addition should not harm old clients.

3. fixed yyerror to return the processed query on errors.
a copy of the buffer is needed as the scanner buffer is modified
and the convention about buffer termination are not the same.

4. fixed the psql position reporting code to use this reported query
instead of the one it sent. Tom's quick fix around the problem is removed.

5. updated comments where it seemd appropriate in the code.

6. finally updated the protocol documentation for the error reporting
part by adding the Q field and fixing the P field.

I dit it like that because I don't think it is elegantly feasible to
update the position to get back to the initial query, as escapes may have
been processed within the string, so a simple offset would not fix the
bug.

It validates for me.

Have a nice day,

--
Fabien Coelho - coelho(at)cri(dot)ensmp(dot)fr

Attachment Content-Type Size
error_pos_fix.patch text/plain 9.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2004-03-18 10:18:47 Re: Further thoughts about warning for costly FK checks
Previous Message Lee Kindness 2004-03-18 09:29:03 COPY formatting

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-03-18 16:07:28 Re: syntax error position "CREATE FUNCTION" bug fix
Previous Message Christopher Kings-Lynne 2004-03-18 08:19:36 Re: ALTER TABLE...SET WITHOUT CLUSTER