Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PgSQL large object resource is incorrectly closed #9411

Closed
Yurunsoft opened this issue Aug 24, 2022 · 1 comment
Closed

PgSQL large object resource is incorrectly closed #9411

Yurunsoft opened this issue Aug 24, 2022 · 1 comment

Comments

@Yurunsoft
Copy link
Contributor

Description

The following code:

<?php
$pdo = new PDO('pgsql:host=127.0.0.1;dbname=test', 'root', 'root');
$pdo->beginTransaction();
$oid = $pdo->pgsqlLOBCreate();
var_dump($lob = $pdo->pgsqlLOBOpen($oid, 'wb'));
fwrite($lob, 'test');
$pdo->commit();
$pdo->beginTransaction();
var_dump($lob = $pdo->pgsqlLOBOpen($oid, 'wb'));
var_dump(fgets($lob));

Resulted in this output:

resource(4) of type (stream)
resource(5) of type (stream)
bool(false)

But I expected this output instead:

resource(4) of type (stream)
resource(5) of type (stream)
string(4) "test"

PHP Version

PHP 8.0.21

Operating System

Ubuntu 20.04

@cmb69
Copy link
Contributor

cmb69 commented Aug 24, 2022

Indeed, the first LOB stream is only closed after the second transaction has been started.

@cmb69 cmb69 linked a pull request Sep 5, 2022 that will close this issue
cmb69 added a commit that referenced this issue Sep 5, 2022
* PHP-8.0:
  Fix GH-9411: PgSQL large object resource is incorrectly closed
@cmb69 cmb69 closed this as completed in 6ac3f7c Sep 5, 2022
cmb69 added a commit that referenced this issue Sep 5, 2022
* PHP-8.1:
  Fix GH-9411: PgSQL large object resource is incorrectly closed
cmb69 added a commit that referenced this issue Sep 5, 2022
* PHP-8.2:
  Fix GH-9411: PgSQL large object resource is incorrectly closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@cmb69 @Yurunsoft and others