Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 79c3bf4

Browse files
author
Michael Meskes
committed
- Fixed DEALLOCATE PREPARE to use correct function call
- Made sure connect statement does not accept single char variable, but only strings.
1 parent 0a19fb4 commit 79c3bf4

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,12 @@ Mon May 10 15:38:58 CEST 2004
17951795

17961796
- Argh, just another bug in adjust_informix.
17971797
- Added "extern C" flags for C++ compiler.
1798+
1799+
Fri May 21 15:17:35 CEST 2004
1800+
1801+
- Fixed DEALLOCATE PREPARE to use correct function call
1802+
- Made sure connect statement does not accept single char variable,
1803+
but only strings.
17981804
- Set pgtypes library version to 1.2.
17991805
- Set ecpg version to 3.2.0.
18001806
- Set compat library version to 1.2.

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.11 2004/01/28 09:52:14 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.12 2004/05/21 13:50:12 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -116,7 +116,7 @@ ECPGdeallocate(int lineno, int c, char *name)
116116
{
117117
/*
118118
* Just ignore all errors since we do not know the list of cursors
119-
* we are allowed to free. We have to trust that the software.
119+
* we are allowed to free. We have to trust the software.
120120
*/
121121
return true;
122122
}

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.282 2004/05/10 13:46:06 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.283 2004/05/21 13:50:12 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -714,7 +714,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
714714
{
715715
if (connection)
716716
mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n");
717-
fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
717+
fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s);", compat, $1);
718718
whenever_action(2);
719719
free($1);
720720
}
@@ -4249,27 +4249,17 @@ connection_target: database_name opt_server opt_port
42494249

42504250
$$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6), $7, make_str("\"")));
42514251
}
4252-
| StringConst
4252+
| Sconst
42534253
{
42544254
if ($1[0] == '\"')
42554255
$$ = $1;
4256-
else if (strcmp($1, " ?") == 0) /* variable */
4257-
{
4258-
enum ECPGttype type = argsinsert->variable->type->type;
4259-
4260-
/* if array see what's inside */
4261-
if (type == ECPGt_array)
4262-
type = argsinsert->variable->type->u.element->type;
4263-
4264-
/* handle varchars */
4265-
if (type == ECPGt_varchar)
4266-
$$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr"));
4267-
else
4268-
$$ = mm_strdup(argsinsert->variable->name);
4269-
}
42704256
else
42714257
$$ = make3_str(make_str("\""), $1, make_str("\""));
42724258
}
4259+
| char_variable
4260+
{
4261+
$$ = $1;
4262+
}
42734263
;
42744264

42754265
db_prefix: ident cvariable
@@ -4365,26 +4355,32 @@ user_name: UserId
43654355

43664356
char_variable: cvariable
43674357
{
4368-
/* check if we have a char variable */
4358+
/* check if we have a string variable */
43694359
struct variable *p = find_variable($1);
43704360
enum ECPGttype type = p->type->type;
43714361

4372-
/* if array see what's inside */
4373-
if (type == ECPGt_array)
4374-
type = p->type->u.element->type;
4375-
4376-
switch (type)
4377-
{
4378-
case ECPGt_char:
4379-
case ECPGt_unsigned_char:
4380-
$$ = $1;
4381-
break;
4382-
case ECPGt_varchar:
4383-
$$ = make2_str($1, make_str(".arr"));
4384-
break;
4385-
default:
4362+
/* If we have just one character this is not a string */
4363+
if (atol(p->type->size) == 1)
43864364
mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype");
4387-
break;
4365+
else
4366+
{
4367+
/* if array see what's inside */
4368+
if (type == ECPGt_array)
4369+
type = p->type->u.element->type;
4370+
4371+
switch (type)
4372+
{
4373+
case ECPGt_char:
4374+
case ECPGt_unsigned_char:
4375+
$$ = $1;
4376+
break;
4377+
case ECPGt_varchar:
4378+
$$ = make2_str($1, make_str(".arr"));
4379+
break;
4380+
default:
4381+
mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype");
4382+
break;
4383+
}
43884384
}
43894385
}
43904386
;

0 commit comments

Comments
 (0)