|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22306 pg_lo_seek($h, 0, PGSQL_SEEK_SET) succeeds yet always returns false
Submitted: 2003-02-19 16:07 UTC Modified: 2003-02-20 01:23 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: php at codewhore dot org Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.3.0 OS: Linux 2.4
Private report: No CVE-ID: None
 [2003-02-19 16:07 UTC] php at codewhore dot org
Seeking back to the beginning of a file on a PostgreSQL large object handle returns false, even though the seek succeeds.

The following script:

  $database = pg_connect ('dbname=pile_dev user=postgres');
  pg_exec ($database, 'begin transaction');
  $oid = pg_lo_create($database);
  $handle = pg_lo_open($database, $oid,  "rw");
  echo 'write: ';
  var_dump(pg_lo_write($handle, 'foo'));
  echo 'tell: ';
  echo 'seek to begin: ';
  var_dump(pg_lo_seek($handle, 0, PGSQL_SEEK_SET));
  echo 'tell: ';
  pg_exec($database,  'commit');


  write: int(3)
  tell: int(3)
  seek to begin: bool(false)
  tell: int(0)

I expected:

  write: int(3)
  tell: int(3)
  seek to begin: bool(true)
  tell: int(0)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-19 16:51 UTC] php at codewhore dot org
From ext/pgsql/pgsql.c:

    if (lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, offset, whence )) {
    } else {

If lo_lseek() is anything like the POSIX lseek(), shouldn't the above return false when the return value is -1, not zero?
 [2003-02-20 01:23 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

Thanks for the excellent analysis. :)

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 03:01:30 2024 UTC