@@ -8,6 +8,16 @@ InterBase: misc sql types (may take a while)
88 require ("interbase.inc " );
99 ibase_connect ($ test_base );
1010
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+
1121 ibase_query (
1222 "create table test3 (
1323 iter integer not null,
@@ -18,6 +28,7 @@ InterBase: misc sql types (may take a while)
1828 v_decimal7_2 decimal(7,2),
1929 v_decimal7_0 decimal(7,0),
2030 v_numeric15_15 numeric(15,15),
31+ v_decimal18_3 decimal(18,3),
2132 v_numeric15_0 numeric(15,0),
2233 v_double double precision,
2334 v_float float,
@@ -42,6 +53,7 @@ InterBase: misc sql types (may take a while)
4253 $ v_decimal7_2 = rand_number (7 ,2 );
4354 $ v_decimal7_0 = rand_number (7 ,0 );
4455 $ v_numeric15_15 = rand_number (15 ,15 );
56+ $ v_decimal18_3 = $ iter ? rand_number (18 ,3 ) : 0 ;
4557 $ v_numeric15_0 = $ iter ? rand_number (15 ,0 ) : 0 ;
4658 $ v_double = rand_number (18 );
4759 $ v_float = rand_number (7 );
@@ -50,8 +62,8 @@ InterBase: misc sql types (may take a while)
5062 $ v_varchar = rand_str (10000 );
5163
5264 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') " );
5567 $ sel = ibase_query ("select * from test3 where iter = $ iter " );
5668 $ row = ibase_fetch_object ($ sel );
5769 if (substr ($ row ->V_CHAR ,0 ,strlen ($ v_char )) != $ v_char ){
@@ -89,6 +101,11 @@ InterBase: misc sql types (may take a while)
89101 echo " in: $ v_numeric15_15 \n" ;
90102 echo " out: $ row ->V_NUMERIC15_15 \n" ;
91103 }
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+ }
92109 if ($ row ->V_NUMERIC15_0 != (string )$ v_numeric15_0 ){
93110 echo " NUMERIC15_0 fail \n" ;
94111 echo " in: $ v_numeric15_0 \n" ;
0 commit comments