Skip to content

Commit 81624db

Browse files
author
Michael Meskes
committed
Cursor names in the backend are not case-sensitve. This change makes sure that
ecpg also does not regard cursor names as case-sensitive. Thanks to Zoltan Boszormenyi for the patch.
1 parent 0b81c7c commit 81624db

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.19 2010/03/31 08:45:18 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.20 2010/09/10 10:13:20 meskes Exp $ */
22
ECPG: stmtClosePortalStmt block
33
{
44
if (INFORMIX_MODE)
@@ -302,10 +302,11 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
302302
struct cursor *ptr, *this;
303303
char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
304304
char *comment, *c1, *c2;
305+
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
305306

306307
for (ptr = cur; ptr != NULL; ptr = ptr->next)
307308
{
308-
if (strcmp($2, ptr->name) == 0)
309+
if (strcmp_fn($2, ptr->name) == 0)
309310
{
310311
if ($2[0] == ':')
311312
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);

src/interfaces/ecpg/preproc/ecpg.header

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.16 2010/05/25 14:32:55 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.17 2010/09/10 10:13:20 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -386,10 +386,11 @@ add_additional_variables(char *name, bool insert)
386386
{
387387
struct cursor *ptr;
388388
struct arguments *p;
389+
int (* strcmp_fn)(const char *, const char *) = (name[0] == ':' ? strcmp : pg_strcasecmp);
389390

390391
for (ptr = cur; ptr != NULL; ptr=ptr->next)
391392
{
392-
if (strcmp(ptr->name, name) == 0)
393+
if (strcmp_fn(ptr->name, name) == 0)
393394
break;
394395
}
395396

src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.26 2010/05/25 17:28:20 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.27 2010/09/10 10:13:20 meskes Exp $ */
22

33
statements: /*EMPTY*/
44
| statements statement
@@ -289,13 +289,14 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
289289
{
290290
struct cursor *ptr, *this;
291291
char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
292+
int (* strcmp_fn)(const char *, const char *) = ($2[0] == ':' ? strcmp : pg_strcasecmp);
292293
struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
293294
const char *con = connection ? connection : "NULL";
294295
char *comment;
295296

296297
for (ptr = cur; ptr != NULL; ptr = ptr->next)
297298
{
298-
if (strcmp($2, ptr->name) == 0)
299+
if (strcmp_fn($2, ptr->name) == 0)
299300
{
300301
/* re-definition is a bug */
301302
if ($2[0] == ':')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy