summaryrefslogtreecommitdiff
path: root/ext/sqlite3/tests
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-02-25 16:11:05 +0100
committerOndřej Surý <ondrej@sury.org>2013-02-25 16:11:05 +0100
commitc8013604b48675ec2b266aa186bb6c3126c47cca (patch)
treede627cca2457af7c3c0a6498906ff49b4d2f722d /ext/sqlite3/tests
parent28f17d3b49950d50f3900f84d74d7cc0822b123d (diff)
downloadphp-upstream/5.4.12.tar.gz
Imported Upstream version 5.4.12upstream/5.4.12
Diffstat (limited to 'ext/sqlite3/tests')
-rw-r--r--ext/sqlite3/tests/bug63921-32bit.phpt27
-rw-r--r--ext/sqlite3/tests/bug63921-64bit.phpt27
2 files changed, 54 insertions, 0 deletions
diff --git a/ext/sqlite3/tests/bug63921-32bit.phpt b/ext/sqlite3/tests/bug63921-32bit.phpt
new file mode 100644
index 000000000..8c1c6b941
--- /dev/null
+++ b/ext/sqlite3/tests/bug63921-32bit.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API
+--SKIPIF--
+<?php
+if (!extension_loaded('sqlite3')) die('skip');
+if (PHP_INT_SIZE > 4) die('skip'); // skip for 64bit builds - there is another test for that
+?>
+--FILE--
+<?php
+$num = PHP_INT_MAX; // 32 bits
+$conn = new sqlite3(':memory:');
+$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))');
+
+$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
+$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
+$stmt->bindValue(':num', $num, SQLITE3_INTEGER);
+$stmt->execute();
+
+$stmt = $conn->query('SELECT num FROM users');
+$result = $stmt->fetchArray();
+
+var_dump($num,$result[0]);
+
+?>
+--EXPECT--
+int(2147483647)
+string(10) "2147483647"
diff --git a/ext/sqlite3/tests/bug63921-64bit.phpt b/ext/sqlite3/tests/bug63921-64bit.phpt
new file mode 100644
index 000000000..8e821fd2d
--- /dev/null
+++ b/ext/sqlite3/tests/bug63921-64bit.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API
+--SKIPIF--
+<?php
+if (!extension_loaded('sqlite3')) die('skip');
+if (PHP_INT_SIZE < 8) die('skip'); // skip for 32bit builds - there is another test for that
+?>
+--FILE--
+<?php
+$num = 100004313234244; // notice this exceeds 32 bits
+$conn = new sqlite3(':memory:');
+$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))');
+
+$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
+$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
+$stmt->bindValue(':num', $num, SQLITE3_INTEGER);
+$stmt->execute();
+
+$stmt = $conn->query('SELECT num FROM users');
+$result = $stmt->fetchArray();
+
+var_dump($num,$result[0]);
+
+?>
+--EXPECT--
+int(100004313234244)
+string(15) "100004313234244"