Skip to content

Commit b16463a

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
2 parents be07f81 + 99d087e commit b16463a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

ext/sqlite3/sqlite3.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
730730

731731
switch (sqlite3_value_type(argv[i])) {
732732
case SQLITE_INTEGER:
733+
#if LONG_MAX > 2147483647
734+
ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int64(argv[i]));
735+
#else
733736
ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int(argv[i]));
737+
#endif
734738
break;
735739

736740
case SQLITE_FLOAT:
@@ -774,7 +778,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s
774778
if (retval) {
775779
switch (Z_TYPE_P(retval)) {
776780
case IS_LONG:
781+
#if LONG_MAX > 2147483647
782+
sqlite3_result_int64(context, Z_LVAL_P(retval));
783+
#else
777784
sqlite3_result_int(context, Z_LVAL_P(retval));
785+
#endif
778786
break;
779787

780788
case IS_NULL:
@@ -1493,7 +1501,11 @@ PHP_METHOD(sqlite3stmt, execute)
14931501
switch (param->type) {
14941502
case SQLITE_INTEGER:
14951503
convert_to_long(param->parameter);
1504+
#if LONG_MAX > 2147483647
1505+
sqlite3_bind_int64(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter));
1506+
#else
14961507
sqlite3_bind_int(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter));
1508+
#endif
14971509
break;
14981510

14991511
case SQLITE_FLOAT:

ext/sqlite3/tests/bug63921-32bit.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sqlite3')) die('skip');
6+
if (PHP_INT_SIZE > 4) die('skip'); // skip for 64bit builds - there is another test for that
7+
?>
8+
--FILE--
9+
<?php
10+
$num = PHP_INT_MAX; // 32 bits
11+
$conn = new sqlite3(':memory:');
12+
$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))');
13+
14+
$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
15+
$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
16+
$stmt->bindValue(':num', $num, SQLITE3_INTEGER);
17+
$stmt->execute();
18+
19+
$stmt = $conn->query('SELECT num FROM users');
20+
$result = $stmt->fetchArray();
21+
22+
var_dump($num,$result[0]);
23+
24+
?>
25+
--EXPECT--
26+
int(2147483647)
27+
string(10) "2147483647"

ext/sqlite3/tests/bug63921-64bit.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sqlite3')) die('skip');
6+
if (PHP_INT_SIZE < 8) die('skip'); // skip for 32bit builds - there is another test for that
7+
?>
8+
--FILE--
9+
<?php
10+
$num = 100004313234244; // notice this exceeds 32 bits
11+
$conn = new sqlite3(':memory:');
12+
$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))');
13+
14+
$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
15+
$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
16+
$stmt->bindValue(':num', $num, SQLITE3_INTEGER);
17+
$stmt->execute();
18+
19+
$stmt = $conn->query('SELECT num FROM users');
20+
$result = $stmt->fetchArray();
21+
22+
var_dump($num,$result[0]);
23+
24+
?>
25+
--EXPECT--
26+
int(100004313234244)
27+
string(15) "100004313234244"

0 commit comments

Comments
 (0)