[php-src] Issue #23697: PDO\SQLite does not return the length of a BLOB item correctly using SQL LENGTH
| From: | mnewnham | Date: | Wed, 16 Sep 2026 04:02:55 +0000 |
| Subject: | [php-src] Issue #23697: PDO\SQLite does not return the length of a BLOB item correctly using SQL LENGTH | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252741@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/23697
Author: mnewnham
### Description
Creating a table similar to this:
```sql
CREATE TABLE blob_storage_table (
id INTEGER PRIMARY KEY AUTOINCREMENT,
blob_field BLOB
);
```
Then inserting a file into the table of a size of say 345678 via the appropriate prepared statement
(assuming the process succeeds)
### SQLite3 driver
The following code:
```php
$blobSize = $db->querySingle("SELECT LENGTH(blob_field) FROM blob_storage_table");
```
Resulted in this output:
```
345678
```
### PDO\SQLite driver
The following code
```php
$blobSize = $db->querySingle("SELECT LENGTH(blob_field) FROM blob_storage_table");
```
Resulted in this output:
```
9
```
### Points of interest
- All PDO drivers return blobs as stream resource
- All other PDO drivers would return the correct field length using the same query
### PHP Version
```plain
PHP 8.5.8 (cli) (built: Jul 1 2026 04:03:04) (NTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Built by The PHP Group
Zend Engine v4.5.8, Copyright (c) Zend Technologies
with Zend OPcache v8.5.8, Copyright (c), by Zend Technologies
```
### Operating System
Windows 10