mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
ext/pgsql: pg_fetch_all_columns/pg_copy_to arrays optimisations. (#18374)
changes to packed arrays for output userland values.
This commit is contained in:
parent
23e9d8bd88
commit
8f6bc97a36
1 changed files with 7 additions and 5 deletions
|
@ -2186,17 +2186,18 @@ PHP_FUNCTION(pg_fetch_all_columns)
|
|||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
if ((pg_numrows = PQntuples(pgsql_result)) <= 0) {
|
||||
return;
|
||||
RETURN_EMPTY_ARRAY();
|
||||
}
|
||||
|
||||
array_init_size(return_value, pg_numrows);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
|
||||
for (pg_row = 0; pg_row < pg_numrows; pg_row++) {
|
||||
if (PQgetisnull(pgsql_result, pg_row, (int)colno)) {
|
||||
add_next_index_null(return_value);
|
||||
add_index_null(return_value, pg_row);
|
||||
} else {
|
||||
add_next_index_string(return_value, PQgetvalue(pgsql_result, pg_row, (int)colno));
|
||||
add_index_string(return_value, pg_row, PQgetvalue(pgsql_result, pg_row, (int)colno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3363,6 +3364,7 @@ PHP_FUNCTION(pg_copy_to)
|
|||
|
||||
PQclear(pgsql_result);
|
||||
array_init(return_value);
|
||||
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
|
||||
while (!copydone)
|
||||
{
|
||||
int ret = PQgetCopyData(pgsql, &csv, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue