]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
- Fixed DEALLOCATE PREPARE to use correct function call
authorMichael Meskes <meskes@postgresql.org>
Fri, 21 May 2004 13:50:12 +0000 (13:50 +0000)
committerMichael Meskes <meskes@postgresql.org>
Fri, 21 May 2004 13:50:12 +0000 (13:50 +0000)
- Made sure connect statement does not accept single char variable,
  but only strings.

src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/preproc/preproc.y

index 7226149853b7f6bfad0ae8c25cc6f76defd3ba60..f16bf08d820859346dfba2eca2a4b33f7befe8b6 100644 (file)
@@ -1795,6 +1795,12 @@ Mon May 10 15:38:58 CEST 2004
 
        - Argh, just another bug in adjust_informix.
        - Added "extern C" flags for C++ compiler.
+
+Fri May 21 15:17:35 CEST 2004
+       
+       - Fixed DEALLOCATE PREPARE to use correct function call
+       - Made sure connect statement does not accept single char variable,
+         but only strings.
        - Set pgtypes library version to 1.2.
        - Set ecpg version to 3.2.0.
        - Set compat library version to 1.2.
index 9de1b9bfd8bcceec5e3b33701744e77959fc95f4..f850b9c8f7f020b496404598c193e8cee16e46d9 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.11 2004/01/28 09:52:14 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.12 2004/05/21 13:50:12 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -116,7 +116,7 @@ ECPGdeallocate(int lineno, int c, char *name)
        {
                /*
                 * Just ignore all errors since we do not know the list of cursors
-                * we are allowed to free. We have to trust that the software.
+                * we are allowed to free. We have to trust the software.
                 */
                return true;
        }
index 572c0fca648ed91509c4ab00baf824622d0c5ac1..d12576f80358bceea15bdc87c89086bc0879e43f 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.282 2004/05/10 13:46:06 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.283 2004/05/21 13:50:12 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -714,7 +714,7 @@ stmt:  AlterDatabaseSetStmt         { output_statement($1, 0, connection); }
                {
                        if (connection)
                                mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n");
-                       fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
+                       fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s);", compat, $1);
                        whenever_action(2);
                        free($1);
                }
@@ -4249,27 +4249,17 @@ connection_target: database_name opt_server opt_port
 
                        $$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6),    $7, make_str("\"")));
                }
-               | StringConst
+               | Sconst
                {
                        if ($1[0] == '\"')
                                $$ = $1;
-                       else if (strcmp($1, " ?") == 0) /* variable */
-                       {
-                               enum ECPGttype type = argsinsert->variable->type->type;
-
-                               /* if array see what's inside */
-                               if (type == ECPGt_array)
-                                       type = argsinsert->variable->type->u.element->type;
-
-                               /* handle varchars */
-                               if (type == ECPGt_varchar)
-                                       $$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
-                               else
-                                       $$ = mm_strdup(argsinsert->variable->name);
-                       }
                        else
                                $$ = make3_str(make_str("\""), $1, make_str("\""));
                }
+               | char_variable
+               {
+                       $$ = $1;
+               }
                ;
 
 db_prefix: ident cvariable
@@ -4365,26 +4355,32 @@ user_name: UserId
 
 char_variable: cvariable
                {
-                       /* check if we have a char variable */
+                       /* check if we have a string variable */
                        struct variable *p = find_variable($1);
                        enum ECPGttype type = p->type->type;
 
-                       /* if array see what's inside */
-                       if (type == ECPGt_array)
-                               type = p->type->u.element->type;
-
-                       switch (type)
-                       {
-                               case ECPGt_char:
-                               case ECPGt_unsigned_char:
-                                       $$ = $1;
-                                       break;
-                               case ECPGt_varchar:
-                                       $$ = make2_str($1, make_str(".arr"));
-                                       break;
-                               default:
+                       /* If we have just one character this is not a string */
+                       if (atol(p->type->size) == 1)
                                        mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype");
-                                       break;
+                       else
+                       {
+                               /* if array see what's inside */
+                               if (type == ECPGt_array)
+                                       type = p->type->u.element->type;
+
+                               switch (type)
+                               {
+                                       case ECPGt_char:
+                                       case ECPGt_unsigned_char:
+                                               $$ = $1;
+                                               break;
+                                       case ECPGt_varchar:
+                                               $$ = make2_str($1, make_str(".arr"));
+                                               break;
+                                       default:
+                                               mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype");
+                                               break;
+                               }
                        }
                }
                ;