diff -ruN ../tmp/src/interfaces/libpq/fe-exec.c ./src/interfaces/libpq/fe-exec.c --- ../tmp/src/interfaces/libpq/fe-exec.c 2025-08-11 21:06:43.000000000 +0000 +++ ./src/interfaces/libpq/fe-exec.c 2026-02-06 13:03:06.060890335 +0000 @@ -4528,3 +4528,20 @@ *retbuflen = buflen; return tmpbuf; } + +/* + * PQgetResultFromPGconn + * Get error result from PGconn + */ +const PGresult * +PQgetResultFromPGconn(PGconn *conn) +{ + if (!conn) + return NULL; + + if (conn->asyncStatus != PGASYNC_IDLE) + return NULL; + + return conn->result; +} + diff -ruN ../tmp/src/interfaces/libpq/libpq-fe.h ./src/interfaces/libpq/libpq-fe.h --- ../tmp/src/interfaces/libpq/libpq-fe.h 2025-08-11 21:06:43.000000000 +0000 +++ ./src/interfaces/libpq/libpq-fe.h 2026-02-06 13:03:06.060890335 +0000 @@ -668,6 +668,9 @@ extern void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook); extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn); +/* Get PGresult directly from PGconn. WARNING: DO NOT RELEASE THIS RESULT */ +extern const PGresult *PQgetResultFromPGconn(PGconn *conn); + #ifdef __cplusplus } #endif