pg: Statement execution + better error reporting

This commit is contained in:
Yorhel 2025-02-06 09:05:05 +01:00
parent 922f19e39b
commit 711300b227
6 changed files with 124 additions and 26 deletions

View file

@ -40,10 +40,17 @@ okerr ERROR => prepare => qr/syntax error/;
is_deeply $st->params, [];
is_deeply $st->columns, [{ name => '?column?', oid => 23 }];
is $conn->exec('SELECT 1 FROM pg_prepared_statements'), 1;
is $st->exec, 1;
}
is $conn->exec('SELECT 1 FROM pg_prepared_statements'), 0;
ok !eval { $conn->q('SELECT 1', 1)->exec; 1 };
okerr ERROR => exec => qr/bind message supplies 1 parameters, but prepared statement/;
ok !eval { $conn->q('SELECT $1')->exec; 1 };
okerr ERROR => exec => qr/bind message supplies 0 parameters, but prepared statement/;
{
my $st = $conn->q("SELECT \$1::int AS a, \$2::char(5) AS \"\x{1F603}\"");
undef $conn; # statement keeps the connection alive