xref: /PHP-7.4/ext/oci8/tests/bug68298.phpt (revision 26dfce7f)
1--TEST--
2Bug #68298 (OCI int overflow)
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die ("skip no oci8 extension");
6if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
7?>
8--FILE--
9<?php
10
11require(__DIR__.'/connect.inc');
12
13$stmtarray = array(
14	"DROP TABLE BUG68298",
15	"CREATE TABLE BUG68298 (COL1 NUMBER(20))"
16);
17
18oci8_test_sql_execute($c, $stmtarray);
19
20$s = oci_parse($c, "INSERT INTO BUG68298 VALUES (:INTVALUE)");
21$intvalue = 1152921504606846975;
22oci_bind_by_name($s, ":INTVALUE", $intvalue, -1, SQLT_INT);
23oci_execute($s);
24
25$s = oci_parse($c, "INSERT INTO BUG68298 VALUES (:INTVALUE)");
26$intvalue = -1152921504606846975;
27oci_bind_by_name($s, ":INTVALUE", $intvalue, -1, SQLT_INT);
28oci_execute($s);
29
30
31$s = oci_parse($c, "SELECT COL1 FROM BUG68298");
32oci_execute($s);
33oci_fetch_all($s, $r);
34var_dump($r);
35
36$stmtarray = array("DROP TABLE BUG68298");
37oci8_test_sql_execute($c, $stmtarray);
38?>
39===DONE===
40<?php exit(0); ?>
41--EXPECT--
42array(1) {
43  ["COL1"]=>
44  array(2) {
45    [0]=>
46    string(19) "1152921504606846975"
47    [1]=>
48    string(20) "-1152921504606846975"
49  }
50}
51===DONE===
52