|  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
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.
Block user comment
Status: Assign to:
Bug Type:
From: php at codewhore dot org
New email:
PHP Version: OS:


 [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: Wed Feb 28 12:01:27 2024 UTC