Postgres and other database interfaces

Denis F denis.feklushkin at gmail.com
Sun Feb 25 22:10:18 UTC 2018


On Sunday, 25 February 2018 at 19:29:59 UTC, kdevel wrote:
> On Sunday, 25 February 2018 at 11:46:26 UTC, Denis F wrote:
>> But it is impossible to convert text :names or '?' into 
>> Postgres's "$1": Postgres isn't knows fields names at start of 
>> a query processing and you can't replace '?' to "$<num>" by 
>> simple 'replace' call - it will need full syntax parsing of 
>> Posgres SQL query because queries can contain EXECUTE 
>> statement (whose purpose is executing dynamic commands).
>
> You don't have to parse the full syntax.

You must if you want to make a replacement correctly for all 
types of statements.

> Quote from another language (which also supports underscore in 
> integer literals):

"This language" just drops off supporting of dynamic commands by 
using prepared statements for requests with arguments:

"WARNING: DBD::Pg now (as of version 1.40) uses true prepared 
statements by sending them to the backend to be prepared by the 
Postgres server. Statements that were legal before may no longer 
work."

It is trivial to replace any placeholders if you use only 
prepared statements, yes. But if you after that try to call 
procedure which calls EXECUTE IMMEDIATE command inside it will 
fail! How many of your users will understand why this happens?

Also I see too high level of abstraction in DBD::Pg. I am isn't 
add prepared statement wrappers into dpq2 because its 
implementation depends from async queries handling implementation.

dpq2 is "middle-level" - C calls and classes wrappers over some 
of it.



More information about the Digitalmars-d mailing list