1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/sqlite3/tests/text_column_NUL_bytes.phpt
Niels Dossche 0d7e53535b Fix NUL byte truncation in sqlite3 TEXT column handling
As a bonus, this should probably also be a tad faster.

Closes GH-20704.
2025-12-15 22:47:41 +01:00

39 lines
652 B
PHP

--TEST--
Text column with NUL bytes
--EXTENSIONS--
sqlite3
--FILE--
<?php
$db = new SQLite3(':memory:');
$db->exec(
'CREATE TABLE messages (
content TEXT
)'
);
$insert = $db->prepare(
'INSERT INTO messages (content) VALUES (:content)'
);
$insert->bindValue(':content', "with\0null", SQLITE3_TEXT);
$insert->execute();
$insert->bindValue(':content', "\0", SQLITE3_TEXT);
$insert->execute();
$result = $db->query('SELECT * FROM messages');
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
var_dump($row);
}
?>
--EXPECTF--
array(1) {
["content"]=>
string(9) "with%0null"
}
array(1) {
["content"]=>
string(1) "%0"
}