Postgres dollar quoting (Delphi6)
Posted: 14.10.2019, 07:46
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
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