r-dbi / dbi3

DBI revisited
https://r-dbi.github.io/dbi3
37 stars 2 forks source link

libpq expects knowledge about data types for parametrized queries #10

Open krlmlr opened 6 years ago

krlmlr commented 6 years ago

Example:

$ psql -c 'PREPARE test AS SELECT ($1 IS NULL)'
ERROR:  could not determine data type of parameter $1
$ psql -c 'PREPARE test AS SELECT ($1::int4 IS NULL)'
PREPARE

For full support in DBI, this means that we must postpone sending the query to the database until we have received values for binding. On the other hand, currently the specs require that dbSendQuery() must reject invalid queries.

If we parse query parameters ourselves (r-dbi/DBI#52), we have more control and still can send non-parametrized queries right away (and fail in case of error). Proposed action:

krlmlr commented 6 years ago

Same for blobs in parametrized queries, found no way to pass them to the server without setting the data type for the parameter.

krlmlr commented 3 years ago

DBI is not responsible for parsing the queries.