php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #23786 pg_put_line invalidates all active large object resources
Submitted: 2003-05-23 15:55 UTC Modified: 2004-09-22 11:05 UTC
From: dave at codewhore dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4CVS-2003-05-23 (stable) OS: Linux 2.4
Private report: No CVE-ID: None
 [2003-05-23 15:55 UTC] dave at codewhore dot org
Hi:

Use of the pg_put_line() function causes most large object operations, including pg_lo_read and pg_lo_tell, to subsequently fail. A test script demonstrates this:

<?php
  $c = pg_connect('dbname=database user=postgres');
  var_dump($c);
  var_dump(pg_query($c, 'begin transaction'));
  $fd = pg_lo_open($c, $lo_id_goes_here, 'r');
  var_dump($fd);

  var_dump(pg_query($c, 'copy table_name_goes_here from stdin'));
  var_dump(pg_put_line($c, "\\.\n"));
  var_dump(pg_end_copy($c));
  var_dump(pg_lo_tell($fd));

  var_dump(pg_lo_close($fd));
  var_dump(pg_query($c, 'commit'));
?>

I would expect to see:
  resource(4) of type (pgsql link)
  resource(5) of type (pgsql result)
  resource(6) of type (pgsql large object)
  resource(7) of type (pgsql result)
  bool(true)
  bool(true)
  int(0)
  bool(true)

Instead, I get:
  resource(4) of type (pgsql link)
  resource(5) of type (pgsql result)
  resource(6) of type (pgsql large object)
  resource(7) of type (pgsql result)
  bool(true)
  bool(true)
  int(-1)
  Warning: pg_lo_close(): Unable to close PostgreSQL large object descriptor 0. in /home/dave/test.php on line 14
  bool(false)

The pg_copy_from and pg_copy_to functions, strangely enough, don't exhibit this behavior.

If this is something intrinsic to the design of Postgres' wire protocol (e.g. not a PHP bug - I don't know if it is or not), it'd be worth leaving a nice big warning in the docs for pg_put_line/pg_lo_open.

Thanks in advance,
- Dave

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-24 00:54 UTC] dave at codewhore dot org
I'm moving this to the documentation category, since I haven't been able to prove that the invalidation of open large object handles is actually a ext/pgsql problem (and not just intrinsic to the Postgres server/protocol/client-library).
 [2004-09-22 11:02 UTC] vrana@php.net
"Use of the pg_put_line() causes most large object operations, including pg_lo_read() and pg_lo_tell(), to subsequently fail. You can use pg_copy_from() and pg_copy_to() instead."
 [2004-09-22 11:05 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 09:01:28 2024 UTC