Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/actions/freebsd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runs:
pkgconf \
webp \
libavif \
`#sqlite3` \
sqlite3 \
curl \
$OPCACHE_TLS_TESTS_DEPS

Expand All @@ -57,9 +57,7 @@ runs:
--enable-debug \
--enable-option-checking=fatal \
--enable-fpm \
`#--with-pdo-sqlite` \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pdo-sqlite \
--without-pear \
--with-bz2 \
--with-avif \
Expand Down
8 changes: 4 additions & 4 deletions ext/pdo_sqlite/tests/bug38334.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pdo_sqlite

$db = new PDO('sqlite::memory:');
$db->exec('CREATE TABLE test_38334 (i INTEGER , f DOUBLE, s VARCHAR(255))');
$db->exec('INSERT INTO test_38334 VALUES (42, 46.7, "test")');
$db->exec("INSERT INTO test_38334 VALUES (42, 46.7, 'test')");
var_dump($db->query('SELECT * FROM test_38334')->fetch(PDO::FETCH_ASSOC));

// Check handling of integers larger than 32-bit.
$db->exec('INSERT INTO test_38334 VALUES (10000000000, 0.0, "")');
$db->exec("INSERT INTO test_38334 VALUES (10000000000, 0.0, '')");
$i = $db->query('SELECT i FROM test_38334 WHERE f = 0.0')->fetchColumn(0);
if (PHP_INT_SIZE >= 8) {
var_dump($i === 10000000000);
Expand All @@ -20,8 +20,8 @@ if (PHP_INT_SIZE >= 8) {
}

// Check storing of strings into integer/float columns.
$db->exec('INSERT INTO test_38334 VALUES ("test", "test", "x")');
var_dump($db->query('SELECT * FROM test_38334 WHERE s = "x"')->fetch(PDO::FETCH_ASSOC));
$db->exec("INSERT INTO test_38334 VALUES ('test', 'test', 'x')");
var_dump($db->query("SELECT * FROM test_38334 WHERE s = 'x'")->fetch(PDO::FETCH_ASSOC));

?>
--EXPECT--
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/bug_42589.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(!in_array('ENABLE_COLUMN_METADATA', $options, true))
$db = new PDO("sqlite::memory:");

$db->exec('CREATE TABLE test_42589 (field1 VARCHAR(10))');
$db->exec('INSERT INTO test_42589 VALUES("test")');
$db->exec("INSERT INTO test_42589 VALUES('test')");

$result = $db->query('SELECT * FROM test_42589 t1 LEFT JOIN test_42589 t2 ON t1.field1 = t2.field1');
$meta1 = $result->getColumnMeta(0);
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createaggregate (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, 'PHP'), (NULL, 'PHP6')");

$db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }, function(&$v) { return $v; });

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$db->query('CREATE TABLE test_pdo_sqlite_createcollation (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, "1"), (NULL, "2"), (NULL, "10")');
$db->query("INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, '1'), (NULL, '2'), (NULL, '10')");

$db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); });

Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createfunction (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createfunction VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createfunction VALUES (NULL, 'PHP'), (NULL, 'PHP6')");


$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $db = new PDO('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createfunction_with_flags (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, 'PHP'), (NULL, 'PHP6')");


$db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC);
Expand Down
27 changes: 27 additions & 0 deletions ext/pdo_sqlite/tests/pdo_sqlite_dqs.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
PDO_sqlite: Testing DQS support
--EXTENSIONS--
pdo_sqlite
--SKIPIF--
<?php
$db = new PDO('sqlite::memory:');
try {
$db->exec('SELECT "test"');
} catch (\PDOException) {
die('skip SQLite is lacking DQS');
}
?>
--FILE--
<?php
$db = new PDO('sqlite::memory:');
$db->exec('CREATE TABLE test (s1 VARCHAR(255), s2 VARCHAR(255))');
$db->exec('INSERT INTO test VALUES (\'test\', "test")');
var_dump($db->query('SELECT * FROM test')->fetch(PDO::FETCH_ASSOC));
?>
--EXPECT--
array(2) {
["s1"]=>
string(4) "test"
["s2"]=>
string(4) "test"
}
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_lastinsertid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pdo_sqlite

$db = new PDO('sqlite::memory:');
$db->query('CREATE TABLE test_pdo_sqlite_lastinsertid (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO test_pdo_sqlite_lastinsertid VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_lastinsertid VALUES (NULL, 'PHP'), (NULL, 'PHP6')");
var_dump($db->query('SELECT * FROM test_pdo_sqlite_lastinsertid'));
var_dump($db->errorInfo());
var_dump($db->lastInsertId());
Expand Down
19 changes: 17 additions & 2 deletions ext/pdo_sqlite/tests/pdo_sqlite_parser.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ foreach ($queries as $k => $query) {
// One parameter
$queries = [
"SELECT * FROM {$table} WHERE '1' = ?",
"SELECT * FROM {$table} WHERE \"?\" IN (?, \"?\")",
"SELECT * FROM {$table} WHERE '?' IN (?, '?')",
"SELECT * FROM {$table} WHERE `a``?` = ?",
"SELECT * FROM {$table} WHERE \"a`?\" = ?",
"SELECT * FROM {$table} WHERE [a`?] = ?",
];

Expand All @@ -43,6 +42,22 @@ foreach ($queries as $k => $query) {
var_dump($stmt->fetch(PDO::FETCH_NUM) === [0 => 1]);
}

// Check if DQS are enabled.
$dqs = true;
try {
$db->exec('SELECT "test"');
} catch (\PDOException) {
$dqs = false;
}

if ($dqs) {
$stmt = $db->prepare("SELECT * FROM {$table} WHERE \"a`?\" = ?");
$stmt->execute([1]);
var_dump($stmt->fetch(PDO::FETCH_NUM) === [0 => 1]);
} else {
var_dump(true);
}

?>
--CLEAN--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $db->query('CREATE TABLE test_pdo_sqlite_transaction (id INT AUTO INCREMENT, nam
$db->commit();

$db->beginTransaction();
$db->query('INSERT INTO test_pdo_sqlite_transaction VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_transaction VALUES (NULL, 'PHP'), (NULL, 'PHP6')");
$db->rollback();

$r = $db->query('SELECT COUNT(*) FROM test_pdo_sqlite_transaction');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class TrampolineTest {

var_dump($db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper']));

foreach ($db->query('SELECT strtoupper("test")') as $row) {
foreach ($db->query("SELECT strtoupper('test')") as $row) {
var_dump($row);
}

foreach ($db->query('SELECT strtoupper("test")') as $row) {
foreach ($db->query("SELECT strtoupper('test')") as $row) {
var_dump($row);
}

Expand All @@ -33,14 +33,14 @@ foreach ($db->query('SELECT strtoupper("test")') as $row) {
bool(true)
Trampoline for strtoupper
array(2) {
["strtoupper("test")"]=>
["strtoupper('test')"]=>
string(4) "TEST"
[0]=>
string(4) "TEST"
}
Trampoline for strtoupper
array(2) {
["strtoupper("test")"]=>
["strtoupper('test')"]=>
string(4) "TEST"
[0]=>
string(4) "TEST"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $db = new Pdo\Sqlite('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createaggregate (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createaggregate VALUES (NULL, 'PHP'), (NULL, 'PHP6')");

$db->createAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }, function(&$v) { return $v; });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$db->query('CREATE TABLE test_pdo_sqlite_createcollation (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, "1"), (NULL, "2"), (NULL, "10")');
$db->query("INSERT INTO test_pdo_sqlite_createcollation VALUES (NULL, '1'), (NULL, '2'), (NULL, '10')");

$db->createCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $b); });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $db = new Pdo\Sqlite('sqlite::memory:');

$db->query('CREATE TABLE test_pdo_sqlite_createcollation_trampoline (s VARCHAR(4))');

$stmt = $db->query('INSERT INTO test_pdo_sqlite_createcollation_trampoline VALUES ("a1"), ("a10"), ("a2")');
$stmt = $db->query("INSERT INTO test_pdo_sqlite_createcollation_trampoline VALUES ('a1'), ('a10'), ('a2')");

class TrampolineTest {
public function __call(string $name, array $arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (!defined('Pdo\Sqlite::DETERMINISTIC')) die('skip system sqlite is too old');
// This test was copied from the pdo_sqlite test for sqliteCreateCollation
$db = new Pdo\Sqlite('sqlite::memory:');
$db->query('CREATE TABLE test_pdo_sqlite_createfunction_with_flags (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, "PHP"), (NULL, "PHP6")');
$db->query("INSERT INTO test_pdo_sqlite_createfunction_with_flags VALUES (NULL, 'PHP'), (NULL, 'PHP6')");

$db->createFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pdo_sqlite
$db = new Pdo\Sqlite('sqlite::memory:');

$db->query('CREATE TABLE test_busy (a string);');
$db->query('INSERT INTO test_busy VALUES ("interleaved"), ("statements")');
$db->query("INSERT INTO test_busy VALUES ('interleaved'), ('statements')");
$st = $db->prepare('SELECT a FROM test_busy');
var_dump($st->getAttribute(Pdo\Sqlite::ATTR_BUSY_STATEMENT));
$st->execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (!defined('Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN')) die('skip system sqlite does n
$db = new Pdo\Sqlite('sqlite::memory:');

$db->query('CREATE TABLE test_explain (a string);');
$stmt = $db->prepare('INSERT INTO test_explain VALUES ("first insert"), ("second_insert")');
$stmt = $db->prepare("INSERT INTO test_explain VALUES ('first insert'), ('second_insert')");
$stmt->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN);
var_dump($stmt->getAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT) == Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN);
$r = $stmt->execute();
Expand All @@ -24,7 +24,7 @@ var_dump($stmt->getAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT) == Pdo\Sqlite::
$r = $stmts->execute();
var_dump($stmts->fetchAll(PDO::FETCH_ASSOC));

$stmt = $db->prepare('INSERT INTO test_explain VALUES ("first insert"), ("second_insert")');
$stmt = $db->prepare("INSERT INTO test_explain VALUES ('first insert'), ('second_insert')");
$stmt->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, Pdo\Sqlite::EXPLAIN_MODE_PREPARED);
$stmt->execute();
$stmts->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, Pdo\Sqlite::EXPLAIN_MODE_PREPARED);
Expand Down Expand Up @@ -88,7 +88,7 @@ array(%d) {
["opcode"]=>
string(13) "InitCoroutine"
["p1"]=>
int(3)
int(%d)
["p2"]=>
int(%d)
["p3"]=>
Expand All @@ -109,7 +109,7 @@ array(%d) {
["p1"]=>
int(0)
["p2"]=>
int(2)
int(%d)
["p3"]=>
int(0)
["p4"]=>
Expand All @@ -126,7 +126,7 @@ array(%d) {
["opcode"]=>
string(5) "Yield"
["p1"]=>
int(3)
int(%d)
["p2"]=>
int(0)
["p3"]=>
Expand All @@ -147,7 +147,7 @@ array(%d) {
["p1"]=>
int(0)
["p2"]=>
int(2)
int(%d)
["p3"]=>
int(0)
["p4"]=>
Expand All @@ -164,7 +164,7 @@ array(%d) {
["opcode"]=>
string(5) "Yield"
["p1"]=>
int(3)
int(%d)
["p2"]=>
int(0)
["p3"]=>
Expand All @@ -183,7 +183,7 @@ array(%d) {
["opcode"]=>
string(12) "EndCoroutine"
["p1"]=>
int(3)
int(%d)
["p2"]=>
int(0)
["p3"]=>
Expand Down Expand Up @@ -221,7 +221,7 @@ array(%d) {
["opcode"]=>
string(5) "Yield"
["p1"]=>
int(3)
int(%d)
["p2"]=>
int(%d)
["p3"]=>
Expand All @@ -242,7 +242,7 @@ array(%d) {
["p1"]=>
int(0)
["p2"]=>
int(1)
int(%d)
["p3"]=>
int(0)
["p4"]=>
Expand All @@ -259,11 +259,11 @@ array(%d) {
["opcode"]=>
string(10) "MakeRecord"
["p1"]=>
int(2)
int(%d)
["p2"]=>
int(1)
["p3"]=>
int(4)
int(%d)
["p4"]=>
string(1) "C"
["p5"]=>
Expand All @@ -280,9 +280,9 @@ array(%d) {
["p1"]=>
int(0)
["p2"]=>
int(4)
int(%d)
["p3"]=>
int(1)
int(%d)
["p4"]=>
string(12) "test_explain"
["p5"]=>
Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/subclasses/pdosqlite_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ $db = new Pdo\Sqlite('sqlite::memory:');

$db->query('CREATE TABLE pdosqlite_001 (id INT AUTO INCREMENT, name TEXT)');

$db->query('INSERT INTO pdosqlite_001 VALUES (NULL, "PHP")');
$db->query('INSERT INTO pdosqlite_001 VALUES (NULL, "PHP6")');
$db->query("INSERT INTO pdosqlite_001 VALUES (NULL, 'PHP')");
$db->query("INSERT INTO pdosqlite_001 VALUES (NULL, 'PHP6')");

$db->createFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC);

Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/subclasses/pdosqlite_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if (!$db instanceof Pdo\Sqlite) {
}

$db->query('CREATE TABLE pdosqlite_002 (id INT AUTO INCREMENT, name TEXT)');
$db->query('INSERT INTO pdosqlite_002 VALUES (NULL, "PHP")');
$db->query('INSERT INTO pdosqlite_002 VALUES (NULL, "PHP6")');
$db->query("INSERT INTO pdosqlite_002 VALUES (NULL, 'PHP')");
$db->query("INSERT INTO pdosqlite_002 VALUES (NULL, 'PHP6')");

$db->createFunction('testing', function($v) { return strtolower($v); }, 1, Pdo\Sqlite::DETERMINISTIC);

Expand Down
Loading
Loading