Page 1 of 1

Postgres dollar quoting (Delphi6)

Posted: 14.10.2019, 07:46
by gmb
Hi

For reasons one of our projects is still stuck on Delphi6 - we're using the latest compatible ZEOSLIB (6.6_stable).
We're increasingly running into problems where this is raised:
>> Input parameter count is less then expected.

Further investigation showed that this is caused by the question marks not being handled correctly by ZEOS's parser code when using dollar quoting (see https://www.postgresql.org/docs/9.5/sql ... xical.html)
E.g. this Delphi code works fine:

ZQuery1.SQL.Text := 'INSERT INTO test_token VALUES (1, ''my second description ?'' ) returning * ; ';
ZQuery1.open;

But this raises the exception:

ZQuery1.SQL.Text := 'INSERT INTO test_token VALUES (1, $$ my second description ? $$ ) returning * ; ';
ZQuery1.open;

I found that the handling of quotes in "parsesql/ZPostgreSqlToken.pas" does not support the dollar quoting syntax and decided to port code from the latest version 7 source code in order to fix this. Basically I copied the TZPostgreSQLQuoteState class.

Can anybody see any problem with my approach ?

Regards

Re: Postgres dollar quoting (Delphi6)

Posted: 14.10.2019, 15:36
by marsupilami
Hello,

I don't know Zeos 6.6 good enough to tell you what is a good approach and what is a bad approach. I just have two suggestions. My first suggestion is to use the code from the SVN. There are some patches in there that never got released as a final Zeos 6.6 version. Some are relevant for PostgreSQL. My second suggestion is that you use the test suite. Run it before your changes to see which tests fail. Do your changes and then see if any new tests fail. This helps us a lot in preventing errors. If your patch works, we could check it into the Zeos 6.6 branch for others to use.

Best regards,

Jan

Re: Postgres dollar quoting (Delphi6)

Posted: 14.10.2019, 20:59
by gmb
Thanks Jan , I'll take a look at the svn repo. Will post here again if I need any more info.

Regards