You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pg_insert fails if one of the values has been passed by reference #8253
In a test postgresql database create a table like such:
create table foo ( bar text );
The following code:
<?phpfunctionfee(&$a){}
$a = ["bar"=>"testing"];
$db = pg_connect('dbname=test host=localhost');
pg_insert($db, 'foo', $a); //No error$res = pg_query($db, "select * from foo");
var_dump(pg_fetch_all($res)); // Output is a single tuple with the field foo is "testing"fee($a["bar"]);
pg_insert($db, 'foo', $a); //Error: pg_insert(): Expects NULL, string, long or double value for PostgreSQL 'text' (bar)
ext/pgsql/pgsql.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 70a78643fa..64bce7dda4 100644
--- a/ext/pgsql/pgsql.c+++ b/ext/pgsql/pgsql.c@@ -4595,6 +4595,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), field, val) {
skip_field = 0;
+ ZVAL_DEREF(val);
ZVAL_NULL(&new_val);
/* TODO: Check when meta data can be broken and see if can use assertions instead */
Activity
cmb69 commentedon Mar 26, 2022
I think we need to deref the value:
Fix phpGH-8253: pg_insert() fails for references
Merge branch 'PHP-8.0' into PHP-8.1
Merge branch 'PHP-8.1'
Bump version