]> granicus.if.org Git - postgresql/commitdiff
- Made sure Informix style decimal vars are initialized. They use a
authorMichael Meskes <meskes@postgresql.org>
Sun, 29 Jun 2003 16:52:58 +0000 (16:52 +0000)
committerMichael Meskes <meskes@postgresql.org>
Sun, 29 Jun 2003 16:52:58 +0000 (16:52 +0000)
  fixed amount of digits and not an allocated one. So we have to work
  around. PostgreSQL numeric type remains the same.
- In INFORMIX_SE mode with autcommit set, make all cursors be "with
  hold". Is this really they way SE behaves?

src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/include/ecpgtype.h
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/test/num_test.pgc
src/interfaces/ecpg/test/test_informix.pgc

index 0185496fe06150a45ea47f7104157e9b8be17c0c..32cb6f40ec80e4dd80f72d73baa72e26d9a7cf4a 100644 (file)
@@ -1528,6 +1528,11 @@ Thu Jun 26 13:26:13 CEST 2003
 Sun Jun 29 11:22:48 CEST 2003
 
        - Just another sync.
+       - Made sure Informix style decimal vars are initialized. They use a
+         fixed amount of digits and not an allocated one. So we have to work
+         around. PostgreSQL numeric type remains the same.
+       - In INFORMIX_SE mode with autcommit set, make all cursors be "with
+         hold". Is this really they way SE behaves?
        - Set ecpg version to 3.0.0
        - Set ecpg library to 4.0.0
        - Set pgtypes library to 1.0.0
index bd1902a093e32cc1e8f9ec9c95ef93e7448bb7ed..94899413da5eec3581877da59b864b498808e2a5 100644 (file)
@@ -45,6 +45,7 @@ enum ECPGttype
        ECPGt_float, ECPGt_double,
        ECPGt_varchar, ECPGt_varchar2,
        ECPGt_numeric,
+       ECPGt_decimal,                  /* only used internally */
        ECPGt_date,
        ECPGt_timestamp,
        ECPGt_interval,
index 6c6006c175ecc22c1b1c320587fcbaba380dd75a..b82adfa7325e40b64bc423610da534bd6a7e7310 100644 (file)
@@ -1,4 +1,4 @@
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.242 2003/06/29 09:25:19 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.243 2003/06/29 16:52:58 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -2706,7 +2706,10 @@ cursor_options:  /* EMPTY */             { $$ = EMPTY; }
        | cursor_options NO SCROLL      { $$ = cat2_str($1, make_str("no scroll")); }
        ;
 
-opt_hold:      /* EMPTY */             { $$ = EMPTY; }
+opt_hold:      /* EMPTY */             { if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
+                                               $$ = make_str("with hold");
+                                         else
+                                                $$ = EMPTY; }
        | WITH HOLD                     { $$ = make_str("with hold"); }
        | WITHOUT HOLD                  { $$ = make_str("without hold"); }
        ;
@@ -4449,7 +4452,7 @@ single_vt_type: common_type
                        }
                        else if (strcmp($1, "decimal") == 0)
                        {
-                               $$.type_enum = ECPGt_numeric;
+                               $$.type_enum = ECPGt_decimal;
                                $$.type_str = make_str("Numeric");
                                $$.type_dimension = make_str("-1");
                                $$.type_index = make_str("-1");
@@ -4751,7 +4754,7 @@ common_type: simple_type
                        if (strcmp($1, "numeric") != 0 && strcmp($1, "decimal") != 0)
                                mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
                        
-                       $$.type_enum = ECPGt_numeric;
+                       $$.type_enum = (strcmp($1, "numeric") != 0) ? ECPGt_decimal : ECPGt_numeric;
                        $$.type_str = make_str("Numeric");
                        $$.type_dimension = make_str("-1");
                        $$.type_index = make_str("-1");
@@ -4803,7 +4806,7 @@ var_type: common_type
                        }
                        else if (strcmp($1, "decimal") == 0)
                        {
-                               $$.type_enum = ECPGt_numeric;
+                               $$.type_enum = ECPGt_decimal;
                                $$.type_str = make_str("Numeric");
                                $$.type_dimension = make_str("-1");
                                $$.type_index = make_str("-1");
@@ -5073,6 +5076,21 @@ variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
                                        $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
                                        break;
 
+                               case ECPGt_decimal: /* this is used by informix and need to be initialized */
+                                       if (atoi(dimension) < 0)
+                                               type = ECPGmake_simple_type(ECPGt_numeric, make_str("1"));
+                                       else
+                                               type = ECPGmake_array_type(ECPGmake_simple_type(ECPGt_numeric, make_str("1")), dimension);
+
+                                       if (strlen($4) == 0)
+                                       {
+                                               $4 = mm_alloc(sizeof(" = {0, 0, 0, 0, 0, NULL, NULL}"));
+                                               strcpy($4, " = {0, 0, 0, 0, 0, NULL, NULL}");
+                                       }
+                                       
+                                       $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
+                                       
+                                       break;
                                default:
                                        if (atoi(dimension) < 0)
                                                type = ECPGmake_simple_type(actual_type[struct_level].type_enum, make_str("1"));
index 4e921bb33e29c97944f56526aabb24d9c8628d32..5b83af5bd07d5d17973170b8029a1cec5be7bd53 100644 (file)
@@ -8,7 +8,7 @@ main()
        char *text="error\n";
        Numeric *value1, *value2, *res;
        exec sql begin declare section;
-               decimal(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
+               numeric(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
        exec sql end declare section;
        double d;
        FILE *dbgs;
index fdc9a97954fd6f47d394e4c2c9fc5560459854f9..0ca4c0647fc2d043993a79ad970bd3000e278a0b 100644 (file)
@@ -5,7 +5,7 @@ void openit(void);
 int main()
 {
        $int i = 14; 
-       $int j;
+       $decimal j;
        FILE *dbgs;
 
        if ((dbgs = fopen("log", "w")) != NULL)
@@ -15,24 +15,30 @@ int main()
 
        $create table test(i int primary key, j int);
 
-       rsetnull(CINTTYPE, (char *)&j);
+       rsetnull(CDECIMALTYPE, (char *)&j);
        $insert into test (i, j) values (7, :j);
        $insert into test (i, j) values (:i, 1);
 
        $declare c cursor for select * from test where i <= :i;
        openit();
 
-       j=0;
+       deccvint(0, &j);
+       
        while (1)
        {
                $fetch in c into :i, :j;
                if (sqlca.sqlcode == 100) break;
                else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
 
-               if (risnull(CINTTYPE, (char *)&j))
+               if (risnull(CDECIMALTYPE, (char *)&j))
                        printf("%d\n", i);
                else
-                       printf("%d %d\n", i, j);
+               {
+                       int a;
+                       
+                       dectoint(&j, &a);
+                       printf("%d %d\n", i, a);
+               }
        }
 
        $delete from test where i=87;