php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73250 pg_convert doesn't support bytea
Submitted: 2016-10-05 09:35 UTC Modified: -
From: hans at xs4all dot nl Assigned:
Status: Open Package: PostgreSQL related
PHP Version: 5.6.26 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hans at xs4all dot nl
New email:
PHP Version: OS:

 

 [2016-10-05 09:35 UTC] hans at xs4all dot nl
Description:
------------
When a bytea value is passed to pg_convert, it returns the output of pg_escape_bytea (bytea hex format in PostgreSQL 9+, see https://www.postgresql.org/docs/9.3/static/datatype-binary.html#AEN5385 ) enclosed in single quotes with the letter E prepended (an escape string constant). But it does not convert the backslash at the beginning to a double backslash. It should either convert \ to \\, or it should not prepend the E (normal string constant).

(Tested using PostgreSQL 9.3.14)

Test script:
---------------
$db = pg_connect('dbname=foo');
pg_query($db, 'create table image (data bytea)');
$vals = ['data' => file_get_contents('image.png')];
print_r(pg_convert($db, 'image', $vals));


Expected result:
----------------
Array
(
    ["data"] => E'\\x89504e47........


or:


Array
(
    ["data"] => '\x89504e47........

Actual result:
--------------
Array
(
    ["data"] => E'\x89504e47........

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC