Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 48272
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 2.15.0



Subject: Cannot determine which exec call will be used
Moved from bug 41565: As for using server-side prepare; one serious problem with the driver as it stands is that the application writer can find it _very_ hard to predict whether any given prepare()/bind_param()*/execute() sequence will lead to the driver using prepare/execPrepared, execParams, or plain exec when it comes to the execute call - and the handling of type information is VERY different between those cases, to the extent that many queries (especially ones involving function calls) will succeed or fail according to which choice the driver makes. (There's also a performance reason to prefer execParams (one roundtrip) over prepare/execPrepared (two roundtrips) for statements that are only going to be executed once.)
This should be fixed now - we only use PQexec when we really have to, e.g. when a statement is simply not preparable at all due to non-DML, or using a DEFAULT or CURRENT pseudo-constant. The basic rules now become: Use PQexecPrepared *unless*: - it's not DML - it has DEFAULT or CURRENT values - pg_direct is true - pg_server_prepare is false - "onetime" is true If we can't use PQexecPrepared, then we try to use PQexecParams *unless*: - it's not DML - it has DEFAULT or CURRENT values - it has no placeholders Thus, we are left with PQexec being called for the following circumstances: - it's not DML (e.g. ALTER, GRANT, SET) - the "pg_server_prepare" flag is false and no placeholders - the "pg_direct" flag is true and no placeholders - the "onetime" flag is true and no placeholders - it has DEFAULT or CURRENT values (and thus placeholders)