xref: /PHP-8.0/ext/oci8/tests/bug68298.phpt (revision f8d79582)
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--EXPECT--
40array(1) {
41  ["COL1"]=>
42  array(2) {
43    [0]=>
44    string(19) "1152921504606846975"
45    [1]=>
46    string(20) "-1152921504606846975"
47  }
48}
49