pg: Add prepared statement caching

The tests are not as thourough as I would like. There's many ways to
mess this up.

I was initially planning to drop the ref on the prepared statement
immediately after executing the query, so that the $st object can be
kept around for introspection without consuming excess resources.
Unfortunately, PQcopyResult does not copy over information about bind
parameters, so we need another way to keep that information alive. I
ended up going for the simple solution: keep the ref on the prepared
statement...
This commit is contained in:
Yorhel 2025-02-12 17:08:22 +01:00
parent 87d99e412b
commit 1f7e2de9a0
4 changed files with 190 additions and 10 deletions

6
FU.xs
View file

@ -116,6 +116,12 @@ void cache(fupg_conn *x, ...)
CODE:
FUPG_STFLAGS;
void cache_size(fupg_conn *c, unsigned int n)
CODE:
c->prep_max = n;
fupg_prepared_prune(c);
XSRETURN(1);
void disconnect(fupg_conn *c)
CODE:
fupg_conn_disconnect(c);