xref: /PHP-8.3/ext/oci8/tests/bug68298.phpt (revision a53e5617)
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");
8require_once 'skipifconnectfailure.inc';
9?>
10--FILE--
11<?php
12
13require __DIR__.'/connect.inc';
14
15$stmtarray = array(
16    "DROP TABLE BUG68298",
17    "CREATE TABLE BUG68298 (COL1 NUMBER(20))"
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22$s = oci_parse($c, "INSERT INTO BUG68298 VALUES (:INTVALUE)");
23$intvalue = 1152921504606846975;
24oci_bind_by_name($s, ":INTVALUE", $intvalue, -1, SQLT_INT);
25oci_execute($s);
26
27$s = oci_parse($c, "INSERT INTO BUG68298 VALUES (:INTVALUE)");
28$intvalue = -1152921504606846975;
29oci_bind_by_name($s, ":INTVALUE", $intvalue, -1, SQLT_INT);
30oci_execute($s);
31
32
33$s = oci_parse($c, "SELECT COL1 FROM BUG68298");
34oci_execute($s);
35oci_fetch_all($s, $r);
36var_dump($r);
37
38$stmtarray = array("DROP TABLE BUG68298");
39oci8_test_sql_execute($c, $stmtarray);
40?>
41--EXPECT--
42array(1) {
43  ["COL1"]=>
44  array(2) {
45    [0]=>
46    string(19) "1152921504606846975"
47    [1]=>
48    string(20) "-1152921504606846975"
49  }
50}
51