php.net |  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
Votes:2
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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:

<?php
  $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: ';
  var_dump(pg_lo_tell($handle));
  echo 'seek to begin: ';
  var_dump(pg_lo_seek($handle, 0, PGSQL_SEEK_SET));
  echo 'tell: ';
  var_dump(pg_lo_tell($handle));
  pg_exec($database,  'commit');
  pg_close($database);
?>

outputs:

  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)

Patches

Pull Requests

History

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 )) {
        RETURN_TRUE;
    } else {
        RETURN_FALSE;
    }

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] sniper@php.net
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 http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net 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: Sat Nov 23 11:01:28 2024 UTC