Bug #72124 [Opn->Ver]: pg_convert prefixes UUIDs with escape string constant

From: Date: Fri, 08 Jan 2021 14:43:29 +0000
Subject: Bug #72124 [Opn->Ver]: pg_convert prefixes UUIDs with escape string constant
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231449@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72124&edit=1

 ID:                 72124
 Updated by:         cmb@php.net
 Reported by:        me at nonrandom dot it
 Summary:            pg_convert prefixes UUIDs with escape string
                     constant
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   Centos 6.7
-PHP Version:        5.6.21RC1
+PHP Version:        7.4
 Block user comment: N
 Private report:     N

 New Comment:

The problem is that PHP doesn't explicitly support uuid[1], and as
such treats it as PG_UNKNOWN so that it is converted to an escape
string.

[1] <https://github.com/php/php-src/blob/8b2b8563ef2e9e42e4d03752556131abd501b3ae/ext/pgsql/php_pgsql.h#L203-L247>


Previous Comments:
------------------------------------------------------------------------
[2016-04-28 18:43:15] me at nonrandom dot it

Description:
------------
---
From manual page: http://www.php.net/function.pg-convert
---

Using pg_convert along with pg_query_params and having a value of UUID among the values being
converted generates an error:

Warning:  pg_query_params(): Query failed: ERROR:  invalid input syntax for uuid:
"E'7d9c76e4-0278-11e6-a626-000c2917e56a'"

It would seem that pg_convert is prefixing an escape string constant to UUIDs, and that is possibly
causing the issue.

I was using pg_convert to get around boolean falses becoming empty strings, but ended up using
something else when I ran across this.


Test script:
---------------
CREATE TABLE public.test_uuid(
	id uuid
);

$db = pg_connect('host=localhost port=5432 dbname=public user=postgres password=1234');

$sql = 'insert into public.test_uuid (id) values ($1)';

$values = array('id' => '7d9c76e4-0278-11e6-a626-000c2917e56a');

pg_covert($db, 'test_uuid', $values);

pg_query_params($db, $sql, $values);



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72124&edit=1


Thread (2 messages)

« previous php.bugs (#231449) next »