|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hans at xs4all dot nl
New email:
PHP Version: OS:


 [2016-10-05 09:35 UTC] hans at xs4all dot nl
When a bytea value is passed to pg_convert, it returns the output of pg_escape_bytea (bytea hex format in PostgreSQL 9+, see ) 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:
    ["data"] => E'\\x89504e47........


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

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


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 07:05:52 2022 UTC