Commit Graph

7 Commits (04bcc0219dc3acf67f27e68decd6dffe97334779)

Author SHA1 Message Date
Jack Christensen 832b4f9771 Fix: prepared statement already exists
When a conn is going to execute a query, the first thing it does is to
deallocate any invalidated prepared statements from the statement cache.
However, the statements were removed from the cache regardless of
whether the deallocation succeeded. This would cause subsequent calls of
the same SQL to fail with "prepared statement already exists" error.

This problem is easy to trigger by running a query with a context that
is already canceled.

This commit changes the deallocate invalidated cached statements logic
so that the statements are only removed from the cache if the
deallocation was successful on the server.

https://github.com/jackc/pgx/issues/1847
2024-02-03 12:33:17 -06:00
Jack Christensen c08cc72306 Improve QueryExecModeCacheDescribe and clarify documentation
QueryExecModeCacheDescribe actually is safe even when the schema or
search_path is modified. It may return an error on the first execution
but it should never silently encode or decode a value incorrectly. Add a
test to demonstrate and ensure this behavior.

Update documentation of QueryExecModeCacheDescribe to remove warning of
undetected result decoding errors.

Update documentation of QueryExecModeCacheStatement and
QueryExecModeCacheDescribe to indicate that the first execution of an
invalidated statement may fail.
2023-09-23 10:35:42 -05:00
Jack Christensen 7de53a958b stmtcache: Use deterministic, stable statement names
Statement names are now a function of the SQL. This may make database
diagnostics, monitoring, and profiling easier.
2023-09-23 09:55:05 -05:00
Jack Christensen ca41a6a222 Update docs 2022-07-10 14:32:08 -05:00
Jack Christensen e7aa76ccf9 SendBatch now uses pipeline mode to prepare and describe statements
Previously, a batch with 10 unique parameterized statements executed
100 times would entail 11 network round trips. 1 for each prepare /
describe and 1 for executing them all. Now pipeline mode is used to
prepare / describe all statements in a single network round trip. So it
would only take 2 round trips.
2022-07-09 09:32:36 -05:00
Jack Christensen c323ab6662 Merge remote-tracking branch 'pgconn/master' into v5-dev 2022-04-23 10:48:44 -05:00
Jack Christensen f27178ba85 Initial privatization of stmtcache
ConnConfig.BuildStatementCache is pending removal once connections
always have separate caches for prepared and described statements.
2022-03-12 08:35:31 -06:00