|  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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 12:01:30 2024 UTC