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