Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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: error_pos_fix.patch
Description: text/plain (9.8 KB)

Responses

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group