doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.44k stars 1.33k forks source link

Oracle does not support streams for the CLOB columns #3290

Closed morozov closed 2 years ago

morozov commented 6 years ago

Bug Report

Q A
BC Break no
Version 2.8.0

Summary

See the build failure on ContinuousPHP. The Oracle driver handles ParameterType::LARGE_OBJECT (which represents both BLOB and CLOB parameters) by creating a OCI_TEMP_BLOB resource which doesn't work for CLOB columns:

https://github.com/doctrine/dbal/blob/3979efeedfda1eda12d30781344583b0ece0a644/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php#L304

Which results in the follwing error:

ORA-00932: inconsistent datatypes: expected CLOB got BLOB.

Apparently, the same issue (#57095) exits in pdo_oci since 2006.

morozov commented 6 years ago

Reproduction scenario:

use Doctrine\DBAL\ParameterType;

$conn->query(
    <<<SQL
CREATE TABLE test (
  id    NUMBER NOT NULL,
  value CLOB,
  PRIMARY KEY (id)
)
SQL
);

$stmt = $conn->prepare('INSERT INTO test VALUES(1, ?)');
$stmt->bindValue(1, 'foo', ParameterType::LARGE_OBJECT);
$stmt->execute();

// ORA-00932: inconsistent datatypes: expected CLOB got BLOB.

It's not critical right now since we don't support stream values of BLOBs either. But once we do, we won't be able to use stream for CLOBs.

morozov commented 2 years ago

I don't think it's fixable. OCI requires manual reading from and writing to the BLOB handle (i.e. start a transaction, query, read/write, commit). While the DBAL API is designed with the expectation that the drivers will do that automatically (all within a single API call).

It could be only accomplished if the DBAL owned the transaction boundaries (e.g. like the ORM does).

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.