Обсуждение: Bug #655: win32 client and bytea column

Поиск
Список
Период
Сортировка

Bug #655: win32 client and bytea column

От
pgsql-bugs@postgresql.org
Дата:
Krzysztof Stachlewski (stach@toya.net.pl) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
win32 client and bytea column

Long Description
I have a problem with using bytea column with PHP.
I am using Apache 1.3.24 on Windows 2000, PHP 4.2.0
installed as Apache module.
PostgreSQL 7.2.1 on Linux (Debian).
When trying to manipulate the bytea column I get the following error:
pg_exec() query failed: pqReadData() -- read() failed: errno=0 No error
The guys from PHP told me this is not a problem with their code, but
with postgresql. (I submitted a bug report to php.net)
The error message is shown only when the code is runned from PHP on
Windows system. Exactly the same code, runned on Linux version
of PHP 4.1.2 causes no
problems at all. The problem does not appear when the amount of
data in the bytea column or data to be inserted into bytea
column is small enough.
"Small enough" seems to be sth about few hundred bytes.
I thought this is a problem with the libpq.dll  - the version of
the one that shipped with PHP was 7.0.2.
I have downloaded the latest source code of Postgres and compiled
the 7.2.1 version of the dll. That didn't solve the problem.

Sample Code
create table bin(id int primary key, dat bytea not null);

php code below:
<?
$connection = pg_connect("your favourite connection string");
$data = base64_encode(str_repeat("example", 1000));
$query = "insert into bin values (1, decode('$data', 'base64'))");
pg_exec($connection, $query)
?>



No file was uploaded with this report

Re: Bug #655: win32 client and bytea column

От
Bruce Momjian
Дата:
Yes, this is certainly our error message:

    pg_exec() query failed: pqReadData() -- read() failed: errno=0 No error

Of course, the "0 No error" is odd.  I think that just means that read()
itself didn't set errno for the failure.

You are clearly base64 encoding the storage info, meaning it isn't some
strange character in the data.  Are you using 7.2 for the server and the
client?  My guess is that Win isn't handling some of the larger packets,
but I may be wrong.  If it fails reliably, could you find the exact
length where it fails.  That may help.

---------------------------------------------------------------------------

pgsql-bugs@postgresql.org wrote:
> Krzysztof Stachlewski (stach@toya.net.pl) reports a bug with a severity of 1
> The lower the number the more severe it is.
>
> Short Description
> win32 client and bytea column
>
> Long Description
> I have a problem with using bytea column with PHP.
> I am using Apache 1.3.24 on Windows 2000, PHP 4.2.0
> installed as Apache module.
> PostgreSQL 7.2.1 on Linux (Debian).
> When trying to manipulate the bytea column I get the following error:
> pg_exec() query failed: pqReadData() -- read() failed: errno=0 No error
> The guys from PHP told me this is not a problem with their code, but
> with postgresql. (I submitted a bug report to php.net)
> The error message is shown only when the code is runned from PHP on
> Windows system. Exactly the same code, runned on Linux version
> of PHP 4.1.2 causes no
> problems at all. The problem does not appear when the amount of
> data in the bytea column or data to be inserted into bytea
> column is small enough.
> "Small enough" seems to be sth about few hundred bytes.
> I thought this is a problem with the libpq.dll  - the version of
> the one that shipped with PHP was 7.0.2.
> I have downloaded the latest source code of Postgres and compiled
> the 7.2.1 version of the dll. That didn't solve the problem.
>
> Sample Code
> create table bin(id int primary key, dat bytea not null);
>
> php code below:
> <?
> $connection = pg_connect("your favourite connection string");
> $data = base64_encode(str_repeat("example", 1000));
> $query = "insert into bin values (1, decode('$data', 'base64'))");
> pg_exec($connection, $query)
> ?>
>
>
>
> No file was uploaded with this report
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026