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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 13:01:23 2019 UTC