Skip to content

pg_insert fails if one of the values has been passed by reference #8253

Closed
@dansmill

Description

@dansmill

Description

In a test postgresql database create a table like such:

create table foo (  bar text );

The following code:

<?php

function fee(&$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)

I can reproduce on 7.1 and 8.0

There is no error on 5.6.

PHP Version

PHP 8.0.3

Operating System

Rocky Linux release 8.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions