summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/tests
diff options
context:
space:
mode:
authorLars Strojny <lstrojny@php.net>2013-01-14 17:59:11 +0100
committerLars Strojny <lstrojny@php.net>2013-01-14 17:59:11 +0100
commit1e9a3ed234af443170d9ea8280a556d85299e301 (patch)
tree6f41889291d75d85d9c676b62cd3bb64cc11866b /ext/pdo_sqlite/tests
parent99d087e5d437023c55f96dcde4b5b784bd8b0ac8 (diff)
downloadphp-git-1e9a3ed234af443170d9ea8280a556d85299e301.tar.gz
Fix bug #63916: PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite
Diffstat (limited to 'ext/pdo_sqlite/tests')
-rw-r--r--ext/pdo_sqlite/tests/bug_63916-2.phpt27
-rw-r--r--ext/pdo_sqlite/tests/bug_63916.phpt27
2 files changed, 54 insertions, 0 deletions
diff --git a/ext/pdo_sqlite/tests/bug_63916-2.phpt b/ext/pdo_sqlite/tests/bug_63916-2.phpt
new file mode 100644
index 0000000000..bc9bfc9c98
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug_63916-2.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) die('skip');
+if (PHP_INT_SIZE > 4) die('skip');
+?>
+--FILE--
+<?php
+$num = PHP_INT_MAX; // 32 bits
+$conn = new PDO('sqlite::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, PDO::PARAM_INT);
+$stmt->bindValue(':num', $num, PDO::PARAM_INT);
+$stmt->execute();
+
+$stmt = $conn->query('SELECT num FROM users');
+$result = $stmt->fetchAll(PDO::FETCH_COLUMN);
+
+var_dump($num,$result[0]);
+
+?>
+--EXPECT--
+int(2147483647)
+string(10) "2147483647"
diff --git a/ext/pdo_sqlite/tests/bug_63916.phpt b/ext/pdo_sqlite/tests/bug_63916.phpt
new file mode 100644
index 0000000000..582413db4d
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug_63916.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #63916 PDO::PARAM_INT casts to 32bit int internally even on 64bit builds in pdo_sqlite
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) die('skip');
+if (PHP_INT_SIZE < 8) die('skip');
+?>
+--FILE--
+<?php
+$num = 100004313234244; // exceeds 32 bits
+$conn = new PDO('sqlite::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, PDO::PARAM_INT);
+$stmt->bindValue(':num', $num, PDO::PARAM_INT);
+$stmt->execute();
+
+$stmt = $conn->query('SELECT num FROM users');
+$result = $stmt->fetchAll(PDO::FETCH_COLUMN);
+
+var_dump($num,$result[0]);
+
+?>
+--EXPECT--
+int(100004313234244)
+string(15) "100004313234244"