xref: /PHP-8.3/ext/oci8/tests/field_funcs2.phpt (revision a53e5617)
1--TEST--
2Bug #41917 (invalid scale and precision)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14$s = oci_parse($c, 'drop table field_funcs2_tab');
15@oci_execute($s);
16
17$t = array("C01" => "NUMBER",
18           "C02" => "NUMBER(*,1)",
19           "C03" => "NUMBER(9)",
20           "C04" => "NUMBER(9,2)",
21           "C05" => "NUMBER(9,1)",
22           "C06" => "NUMBER(7,-2)",
23           "C07" => "DECIMAL(4,9)",
24           "C08" => "NUMERIC(4,9)",
25           "C09" => "DECIMAL(4)",
26           "C10" => "INTEGER",
27           "C11" => "INT",
28           "C12" => "SMALLINT",
29           "C13" => "FLOAT",
30           "C14" => "FLOAT(9)",
31           "C15" => "DOUBLE PRECISION",
32           "C16" => "REAL",
33           );
34
35$stmt = "create table field_funcs2_tab (\n";
36foreach ($t as $colname => $type) {
37    $stmt .= "$colname $type,\n";
38}
39$stmt[strlen($stmt)-2] = ")";
40
41$s = oci_parse($c, $stmt);
42oci_execute($s);
43
44$s = oci_parse($c, "select * from field_funcs2_tab");
45oci_execute($s);
46
47for ($i = 1; $i <= oci_num_fields($s); $i++) {
48    $name = oci_field_name($s, $i);
49    $precision = oci_field_precision($s, $i);
50    $scale = oci_field_scale($s, $i);
51    echo "$name ".$t[$name] .": precision $precision, scale $scale\n";
52}
53
54echo "Done\n";
55?>
56--EXPECT--
57C01 NUMBER: precision 0, scale -127
58C02 NUMBER(*,1): precision 38, scale 1
59C03 NUMBER(9): precision 9, scale 0
60C04 NUMBER(9,2): precision 9, scale 2
61C05 NUMBER(9,1): precision 9, scale 1
62C06 NUMBER(7,-2): precision 7, scale -2
63C07 DECIMAL(4,9): precision 4, scale 9
64C08 NUMERIC(4,9): precision 4, scale 9
65C09 DECIMAL(4): precision 4, scale 0
66C10 INTEGER: precision 38, scale 0
67C11 INT: precision 38, scale 0
68C12 SMALLINT: precision 38, scale 0
69C13 FLOAT: precision 126, scale -127
70C14 FLOAT(9): precision 9, scale -127
71C15 DOUBLE PRECISION: precision 126, scale -127
72C16 REAL: precision 63, scale -127
73Done
74