glaredb
glaredb copied to clipboard
improve out of the box psycopg2 support
Presently, when attempting to connect to glaredb over the postgres protocol with the psycopg2 python module, unless connection.autocommit = True, psycopg2 will attempt to wrap all cursor operations in a transaction, sending BEGIN TRANSACTION queries to glaredb. As a result, queries throw an exception and users see the PGRES_EMPTY_QUERY error. Setting autocommit to true, disables the "wrap in a transaction" behavior.
The solution to this is somewhat difficult. We could (and should) improve the error message so users know that they were sending a transaction when they didn't mean to. It is (probably) correct to error early when we see a transaction that we shouldn't.
Uncovered by the testing in #2258.
related to https://github.com/GlareDB/glaredb/issues/2402
@scsmithr and I discussed this today and we decided:
- we should document that the postgres protocol only does not support transactions.
- glaredb should send a notice on the pg protocol when someone uses a trasaction statement, but otherwise continue.
- cloud should print notices via the postgres protocol
- in local mode, and for RPC/flight sql, transaction statements should be errors.
Some further carve outs.
- we may also want to say that we may eventually provide transactions over the postgres protocol in the future.
- it may make sense to still reject write operations inside of transactions.
- it might make sense to reject some higher transaction levels too.