]> granicus.if.org Git - postgresql/commitdiff
- Removed debug message from preproc.y.
authorMichael Meskes <meskes@postgresql.org>
Thu, 6 Dec 2001 14:46:20 +0000 (14:46 +0000)
committerMichael Meskes <meskes@postgresql.org>
Thu, 6 Dec 2001 14:46:20 +0000 (14:46 +0000)
        - Fixed some bugs in exec sql var and exec sql type command.

src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/test/test2.pgc
src/interfaces/ecpg/test/test3.pgc
src/interfaces/ecpg/test/test_text.pgc [deleted file]

index 9fca8d3c305a078733e31fd825a5b2ef34814ef3..86bb78735362dd2aafd7ab3f0a529dac7fc7e4ef 100644 (file)
@@ -1160,6 +1160,11 @@ Wed Dec  5 12:27:25 CET 2001
        - Fixed variable handling in AT statement.
        - Fixed bug that caused segfault when given incorrect DB name.
        - Fixed bug in ecpglib causing indicator to list the size of the
-         variable instead of the size of the data.
+         variable instead of the size of the data
+
+Thu Dec  6 14:02:56 CET 2001
+
+       - Removed debug message from preproc.y.
+       - Fixed some bugs in exec sql var and exec sql type command.
        - Set ecpg version to 2.9.0.
         - Set library version to 3.3.0.
index 7241770fd553ee5d0731c8bc2835b5abe1511971..7afe02d1619c6d798621c7663dab19c286fee6f6 100644 (file)
@@ -3886,7 +3886,6 @@ connection_target: database_name opt_server opt_port
         |  db_prefix ':' server opt_port '/' database_name opt_options
                 {
                  /* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
-                       printf("%s\n", $1);
                  if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
                  {
                    sprintf(errortext, "only protocols 'tcp' and 'unix' and database type 'postgresql' are supported");
@@ -4271,10 +4270,6 @@ s_struct: SQL_STRUCT opt_symbol
             if (struct_level >= STRUCT_DEPTH)
                  mmerror(ET_ERROR, "Too many levels in nested structure definition");
 
-           /* reset this variable so we see if there was */
-           /* an initializer specified */
-           initializer = 0;
-
            $$ = cat2_str(make_str("struct"), $2);
        };
 
@@ -4284,10 +4279,6 @@ s_union: UNION opt_symbol
             if (struct_level >= STRUCT_DEPTH)
                  mmerror(ET_ERROR, "Too many levels in nested structure definition");
 
-           /* reset this variable so we see if there was */
-           /* an initializer specified */
-           initializer = 0;
-
            $$ = cat2_str(make_str("union"), $2);
        };
 
@@ -4661,52 +4652,62 @@ ECPGSetConnection:  SET SQL_CONNECTION to_equal connection_object
 /*
  * define a new type for embedded SQL
  */
-ECPGTypedef: TYPE_P ColLabel IS type opt_type_array_bounds opt_reference
+ECPGTypedef: TYPE_P
+       {
+               /* reset this variable so we see if there was */
+               /* an initializer specified */
+               initializer = 0;
+       }
+       ColLabel IS type opt_type_array_bounds opt_reference
        {
                /* add entry to list */
                struct typedefs *ptr, *this;
-               int dimension = $5.index1;
-               int length = $5.index2;
+               int dimension = $6.index1;
+               int length = $6.index2;
 
-               if (($4.type_enum == ECPGt_struct ||
-                    $4.type_enum == ECPGt_union) &&
+               if (($5.type_enum == ECPGt_struct ||
+                    $5.type_enum == ECPGt_union) &&
                    initializer == 1)
+               {
                        mmerror(ET_ERROR, "Initializer not allowed in EXEC SQL VAR command");
-
-               for (ptr = types; ptr != NULL; ptr = ptr->next)
+               }
+               else
                {
-                       if (strcmp($2, ptr->name) == 0)
+                       for (ptr = types; ptr != NULL; ptr = ptr->next)
                        {
-                               /* re-definition is a bug */
-                               sprintf(errortext, "Type %s already defined", $2);
-                               mmerror(ET_ERROR, errortext);
-                       }
-               }
+                               if (strcmp($3, ptr->name) == 0)
+                               {
+                                       /* re-definition is a bug */
+                                       sprintf(errortext, "Type %s already defined", $3);
+                                       mmerror(ET_ERROR, errortext);
+                               }
+                       }
 
-               adjust_array($4.type_enum, &dimension, &length, $4.type_dimension, $4.type_index, *$6?1:0);
+                       adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
 
-               this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
+                               this = (struct typedefs *) mm_alloc(sizeof(struct typedefs));
 
-               /* initial definition */
-               this->next = types;
-               this->name = $2;
-               this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
-               this->type->type_enum = $4.type_enum;
-               this->type->type_str = mm_strdup($2);
-               this->type->type_dimension = dimension; /* dimension of array */
-               this->type->type_index = length;    /* lenght of string */
-               this->struct_member_list = ($4.type_enum == ECPGt_struct || $4.type_enum == ECPGt_union) ?
-                       struct_member_list[struct_level] : NULL;
+                       /* initial definition */
+                       this->next = types;
+                       this->name = $3;
+                       this->type = (struct this_type *) mm_alloc(sizeof(struct this_type));
+                       this->type->type_enum = $5.type_enum;
+                       this->type->type_str = mm_strdup($3);
+                       this->type->type_dimension = dimension; /* dimension of array */
+                       this->type->type_index = length;    /* lenght of string */
+                       this->struct_member_list = ($5.type_enum == ECPGt_struct || $5.type_enum == ECPGt_union) ?
+                               struct_member_list[struct_level] : NULL;
 
-               if ($4.type_enum != ECPGt_varchar &&
-                   $4.type_enum != ECPGt_char &&
-                   $4.type_enum != ECPGt_unsigned_char &&
-                   this->type->type_index >= 0)
-                            mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
+                       if ($5.type_enum != ECPGt_varchar &&
+                           $5.type_enum != ECPGt_char &&
+                           $5.type_enum != ECPGt_unsigned_char &&
+                           this->type->type_index >= 0)
+                                   mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
 
-               types = this;
+                       types = this;
+               }
 
-               $$ = cat_str(7, make_str("/* exec sql type"), mm_strdup($2), make_str("is"), mm_strdup($4.type_str), mm_strdup($5.str), $6, make_str("*/"));
+               $$ = cat_str(7, make_str("/* exec sql type"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str("*/"));
        };
 
 opt_type_array_bounds:  '[' ']' opt_type_array_bounds
@@ -4754,60 +4755,70 @@ opt_reference: SQL_REFERENCE { $$ = make_str("reference"); }
 /*
  * define the type of one variable for embedded SQL
  */
-ECPGVar: SQL_VAR ColLabel IS type opt_type_array_bounds opt_reference
+ECPGVar: SQL_VAR
        {
-               struct variable *p = find_variable($2);
-               int dimension = $5.index1;
-               int length = $5.index2;
+               /* reset this variable so we see if there was */
+               /* an initializer specified */
+               initializer = 0;
+       }
+       ColLabel IS type opt_type_array_bounds opt_reference
+       {
+               struct variable *p = find_variable($3);
+               int dimension = $6.index1;
+               int length = $6.index2;
                struct ECPGtype * type;
 
-               if (($4.type_enum == ECPGt_struct ||
-                    $4.type_enum == ECPGt_union) &&
+               if (($5.type_enum == ECPGt_struct ||
+                    $5.type_enum == ECPGt_union) &&
                    initializer == 1)
+               {
                        mmerror(ET_ERROR, "Initializer not allowed in EXEC SQL VAR command");
-
-               adjust_array($4.type_enum, &dimension, &length, $4.type_dimension, $4.type_index, *$6?1:0);
-
-               switch ($4.type_enum)
+               }
+               else
                {
-                  case ECPGt_struct:
-                  case ECPGt_union:
-                        if (dimension < 0)
-                            type = ECPGmake_struct_type(struct_member_list[struct_level], $4.type_enum);
-                        else
-                            type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $4.type_enum), dimension); 
-                        break;
-                   case ECPGt_varchar:
-                        if (dimension == -1)
-                            type = ECPGmake_simple_type($4.type_enum, length);
-                        else
-                            type = ECPGmake_array_type(ECPGmake_simple_type($4.type_enum, length), dimension);
-
-                       break;
-                   case ECPGt_char:
-                   case ECPGt_unsigned_char:
-                        if (dimension == -1)
-                            type = ECPGmake_simple_type($4.type_enum, length);
-                        else
-                            type = ECPGmake_array_type(ECPGmake_simple_type($4.type_enum, length), dimension);
-
-                       break;
-                  default:
-                       if (length >= 0)
-                           mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
+                       adjust_array($5.type_enum, &dimension, &length, $5.type_dimension, $5.type_index, *$7?1:0);
 
-                        if (dimension < 0)
-                            type = ECPGmake_simple_type($4.type_enum, 1);
-                        else
-                            type = ECPGmake_array_type(ECPGmake_simple_type($4.type_enum, 1), dimension);
-
-                       break;
-               }       
-
-               ECPGfree_type(p->type);
-               p->type = type;
+                       switch ($5.type_enum)
+                       {
+                          case ECPGt_struct:
+                          case ECPGt_union:
+                               if (dimension < 0)
+                                   type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum);
+                               else
+                                   type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum), dimension); 
+                               break;
+                          case ECPGt_varchar:
+                               if (dimension == -1)
+                                   type = ECPGmake_simple_type($5.type_enum, length);
+                               else
+                                   type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length), dimension);
+
+                               break;
+                          case ECPGt_char:
+                          case ECPGt_unsigned_char:
+                               if (dimension == -1)
+                                   type = ECPGmake_simple_type($5.type_enum, length);
+                               else
+                                   type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, length), dimension);
+
+                               break;
+                          default:
+                               if (length >= 0)
+                                   mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
+
+                               if (dimension < 0)
+                                   type = ECPGmake_simple_type($5.type_enum, 1);
+                               else
+                                   type = ECPGmake_array_type(ECPGmake_simple_type($5.type_enum, 1), dimension);
+
+                               break;
+                       }       
+
+                       ECPGfree_type(p->type);
+                       p->type = type;
+               }
 
-               $$ = cat_str(7, make_str("/* exec sql var"), mm_strdup($2), make_str("is"), mm_strdup($4.type_str), mm_strdup($5.str), $6, make_str("*/"));
+               $$ = cat_str(7, make_str("/* exec sql var"), mm_strdup($3), make_str("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7, make_str("*/"));
        };
 
 /*
index 761f7bb725ce0239b609fd49c9ae969b5d05958f..ec2c790d2b4d430b60adc6b4a02066d7bc08c46e 100644 (file)
@@ -50,10 +50,10 @@ exec sql end declare section;
 
        strcpy(msg, "insert");
        exec sql insert into meskes(name, married, children) values ('Petra', '19900404', 3);
-       exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 34, '19900404', 3);
-       exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,9);
-       exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 6);
-       exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 2);
+       exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 35, '19900404', 3);
+       exec sql insert into meskes(name, born, age) values ('Carsten', 19910103,10);
+       exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 8);
+       exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 4);
 
        strcpy(msg, "commit");
        exec sql commit;
index fab3aeb6d37538ec6d2b822e09ccf1525b9f83f4..6f0afccc75bbe8c8407c776f8d77bb9fd1309320 100644 (file)
@@ -45,10 +45,10 @@ exec sql end declare section;
 
        strcpy(msg, "insert");
        exec sql insert into meskes(name, married, children) values (:wifesname, '19900404', 3);
-       exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 34, '19900404', 3);
-       exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 9);
-       exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 6);
-       exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 2);
+       exec sql insert into meskes(name, born, age, married, children) values ('Michael', 19660117, 35, '19900404', 3);
+       exec sql insert into meskes(name, born, age) values ('Carsten', 19910103, 10);
+       exec sql insert into meskes(name, born, age) values ('Marc', 19930907, 8);
+       exec sql insert into meskes(name, born, age) values ('Chris', 19970923, 4);
 
        strcpy(msg, "commit");
        exec sql commit;
diff --git a/src/interfaces/ecpg/test/test_text.pgc b/src/interfaces/ecpg/test/test_text.pgc
deleted file mode 100644 (file)
index 146b922..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// $Id: test_text.pgc,v 1.1 2001/01/31 16:12:34 meskes Exp $
-
-exec sql include sqlca;
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{  exec sql begin declare section;
-   int index;
-   char lab[15];
-   exec sql end declare section;
-
-   ECPGdebug(1,stdout);
-   
-   exec sql connect to mm;
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-
-   exec sql select 'a1234567890'::text into :lab;
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-
-   exec sql disconnect;
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   return 0;
-}