@@ -8,6 +8,16 @@ InterBase: misc sql types (may take a while)
8
8
require ("interbase.inc " );
9
9
ibase_connect ($ test_base );
10
10
11
+ /* To prevent unwanted roundings set PHP precision to 18 */
12
+ ini_set ('precision ' ,"18 " );
13
+
14
+ /* Check if PHP precision is set correctly */
15
+ if (ini_get ('precision ' ) < 18 ) {
16
+ echo "PHP precision check fail \n" ;
17
+ echo "Precision set in php.ini: " . ini_get ('precision ' ) . "\n" ;
18
+ echo "Precision required: 18 \n" ;
19
+ }
20
+
11
21
ibase_query (
12
22
"create table test3 (
13
23
iter integer not null,
@@ -18,6 +28,7 @@ InterBase: misc sql types (may take a while)
18
28
v_decimal7_2 decimal(7,2),
19
29
v_decimal7_0 decimal(7,0),
20
30
v_numeric15_15 numeric(15,15),
31
+ v_decimal18_3 decimal(18,3),
21
32
v_numeric15_0 numeric(15,0),
22
33
v_double double precision,
23
34
v_float float,
@@ -42,6 +53,7 @@ InterBase: misc sql types (may take a while)
42
53
$ v_decimal7_2 = rand_number (7 ,2 );
43
54
$ v_decimal7_0 = rand_number (7 ,0 );
44
55
$ v_numeric15_15 = rand_number (15 ,15 );
56
+ $ v_decimal18_3 = $ iter ? rand_number (18 ,3 ) : 0 ;
45
57
$ v_numeric15_0 = $ iter ? rand_number (15 ,0 ) : 0 ;
46
58
$ v_double = rand_number (18 );
47
59
$ v_float = rand_number (7 );
@@ -50,8 +62,8 @@ InterBase: misc sql types (may take a while)
50
62
$ v_varchar = rand_str (10000 );
51
63
52
64
ibase_query (
53
- "insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
54
- values ( $ iter, ' $ v_char',' $ v_date', $ v_decimal4_2, $ v_decimal4_0, $ v_decimal7_2, $ v_decimal7_0, $ v_numeric15_15, $ v_numeric15_0, $ v_double, $ v_float, $ v_integer, $ v_smallint,' $ v_varchar') " );
65
+ "insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_decimal18_3, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar)
66
+ values ( $ iter, ' $ v_char',' $ v_date', $ v_decimal4_2, $ v_decimal4_0, $ v_decimal7_2, $ v_decimal7_0, $ v_numeric15_15, $ v_decimal18_3 , $ v_numeric15_0, $ v_double, $ v_float, $ v_integer, $ v_smallint,' $ v_varchar') " );
55
67
$ sel = ibase_query ("select * from test3 where iter = $ iter " );
56
68
$ row = ibase_fetch_object ($ sel );
57
69
if (substr ($ row ->V_CHAR ,0 ,strlen ($ v_char )) != $ v_char ){
@@ -89,6 +101,11 @@ InterBase: misc sql types (may take a while)
89
101
echo " in: $ v_numeric15_15 \n" ;
90
102
echo " out: $ row ->V_NUMERIC15_15 \n" ;
91
103
}
104
+ if ($ row ->V_DECIMAL18_3 != $ v_decimal18_3 ){
105
+ echo " DECIMAL18_3 fail \n" ;
106
+ echo " in: $ v_decimal18_3 \n" ;
107
+ echo " out: $ row ->V_DECIMAL18_3 \n" ;
108
+ }
92
109
if ($ row ->V_NUMERIC15_0 != (string )$ v_numeric15_0 ){
93
110
echo " NUMERIC15_0 fail \n" ;
94
111
echo " in: $ v_numeric15_0 \n" ;
0 commit comments