Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql extension is compiled with a too old libpq version #123

Closed
xleliberty opened this issue Jul 20, 2014 · 3 comments
Closed

postgresql extension is compiled with a too old libpq version #123

xleliberty opened this issue Jul 20, 2014 · 3 comments

Comments

@xleliberty
Copy link

Hi,
i've just track down a nasty problem with libpq used in this php build.
today, libpq is version is 8.2.23

if we use this version with postgresql 9.3.x , bytea decoding is returned as escaped version.

It seems that this old libpq version doesn't handle cleanly bytea conversions .
here is a quick test that show the problem and a solution.

CREATE TABLE bintest
(
  id serial NOT NULL,
  data bytea,
  CONSTRAINT pkok PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);

<?php

//DATA insertion
$dbh = new PDO("pgsql:dbname=cmf;host=localhost", 'xav');
$thebytes = file_get_contents('source.jpg');

$sth = $dbh->prepare("INSERT INTO bintest ( data ) VALUES (:content)");
$sth->bindParam(':content', $thebytes, PDO::PARAM_LOB);
$sth->execute();


//DATA Reading

//If we use this line, everything is ok
$dbh->query("SET bytea_output=escape");

$sth = $dbh->prepare("SELECT data FROM bintest WHERE id = 1");
$sth->execute();

$content = $sth->fetchColumn();
file_put_contents('test.jpg', $content);

thanks
Xavier

@chregu
Copy link
Member

chregu commented Aug 9, 2014

Thanks for the hint, the postgres library is now updated to 9.3.5, hope that solves the issue

@chregu chregu closed this as completed Aug 9, 2014
@xleliberty
Copy link
Author

Awesome,
thanks you for the update, because using brew php version is really boring...

Cheers
Xavier

@deatharse
Copy link

Any chance we can now bump the library to the most recent PostgreSQL stable version (10.1) as this is still using 9.3.5.

This will allow support for SCRAM authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants