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@cri.ensmp.fr