Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpq expects knowledge about data types for parametrized queries #10

Open
krlmlr opened this issue Nov 21, 2017 · 2 comments
Open

libpq expects knowledge about data types for parametrized queries #10

krlmlr opened this issue Nov 21, 2017 · 2 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Nov 21, 2017

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:

  • Rewrite parametrized queries
    • Support everything that SQLite or PostgreSQL supports
    • Might require a helper in DBI
  • If query doesn't have parameters, send right away
  • If query has parameters, wait until types are known before sending, and use these types
@krlmlr
Copy link
Member Author

krlmlr commented Nov 28, 2017

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

@krlmlr
Copy link
Member Author

krlmlr commented Sep 6, 2021

DBI is not responsible for parsing the queries.

@krlmlr krlmlr closed this as completed Sep 6, 2021
@krlmlr krlmlr transferred this issue from r-dbi/RPostgres Oct 31, 2021
@krlmlr krlmlr reopened this Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant