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