Fix / implement GH-15287: add a lazy fetch to Pdo\PgSql

Make Pdo\PgSql accept Pdo::setAttribute(PDO::ATTR_PREFETCH, 0) to enter libpq's single row mode.
This avoids storing the whole result set in memory before being able to call the first fetch().

close GH-15750
This commit is contained in:
Guillaume Outters 2024-09-03 22:43:58 +02:00 committed by David Carlier
parent 6fb81d2360
commit 68537fd9f4
No known key found for this signature in database
GPG key ID: 8486F847B4B94EF1
6 changed files with 360 additions and 32 deletions

View file

@ -34,6 +34,8 @@ typedef struct {
char *errmsg;
} pdo_pgsql_error_info;
typedef struct pdo_pgsql_stmt pdo_pgsql_stmt;
/* stuff we use in a pgsql database handle */
typedef struct {
PGconn *server;
@ -49,13 +51,15 @@ typedef struct {
bool disable_prepares;
HashTable *lob_streams;
zend_fcall_info_cache *notice_callback;
bool default_fetching_laziness;
pdo_pgsql_stmt *running_stmt;
} pdo_pgsql_db_handle;
typedef struct {
Oid pgsql_type;
} pdo_pgsql_column;
typedef struct {
struct pdo_pgsql_stmt {
pdo_pgsql_db_handle *H;
PGresult *result;
pdo_pgsql_column *cols;
@ -68,7 +72,9 @@ typedef struct {
Oid *param_types;
int current_row;
bool is_prepared;
} pdo_pgsql_stmt;
bool is_unbuffered;
bool is_running_unbuffered;
};
typedef struct {
Oid oid;