Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit186aeb1

Browse files
committed
From: Dr. Michael Meskes <meskes@online-club.de>So this should finally get cursors working. There was an ugly bug in it.
1 parent1c9a125 commit186aeb1

File tree

12 files changed

+182
-118
lines changed

12 files changed

+182
-118
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,15 @@ Tue Jul 7 15:14:14 CEST 1998
258258

259259
- Fixed some bugs in preproc.y
260260
- Set version to 2.3.4
261+
262+
Mon Jul 27 17:13:11 CEST 1998
263+
264+
- Changed text of error message to make emacs happy
265+
266+
Mon Aug 3 17:23:18 CEST 1998
267+
268+
- Added latest changes from gram.y resp. scan.l to
269+
preproc.y resp. pgc.l
270+
- Fixed cursor handling
271+
- Set version to 2.3.5
272+
- Set library version to 2.4

‎src/interfaces/ecpg/TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
What happens to a cursor declaration with variables?
2+
13
The complete structure definition has to be listed inside the declare
24
section of the structure variable for ecpg to be able to understand it.
35

‎src/interfaces/ecpg/include/ecpgerrno.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#defineECPG_CONVERT_BOOL-207
2424
#defineECPG_EMPTY-208
2525
#defineECPG_NO_CONN-209
26+
#defineECPG_UNDECLARED_CURSOR-210
2627

2728
/* finally the backend error messages, they start at 300 */
2829
#defineECPG_PGSQL-300

‎src/interfaces/ecpg/include/ecpglib.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ boolECPGdisconnect(int, const char *);
1313

1414
voidECPGlog(constchar*format,...);
1515

16+
boolECPGdeclare(int,constchar*,char*);
17+
boolECPGopen(int,constchar*);
18+
1619
#ifdefLIBPQ_FE_H
1720
boolECPGsetdb(PGconn*);
1821

@@ -32,6 +35,11 @@ struct ECPGgeneric_varchar
3235
/* print an error message */
3336
voidsqlprint(void);
3437

38+
structcursor {constchar*name;
39+
char*command;
40+
structcursor*next;
41+
};
42+
3543
/* define this for simplicity as well as compatibility */
3644

3745
#defineSQLCODE sqlca.sqlcode

‎src/interfaces/ecpg/lib/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(SRCDIR)/Makefile.global
44
PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
55

66
SO_MAJOR_VERSION=2
7-
SO_MINOR_VERSION=3
7+
SO_MINOR_VERSION=4
88

99
PORTNAME=@PORTNAME@
1010

‎src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,3 +940,56 @@ sqlprint(void)
940940
sqlca.sqlerrm.sqlerrmc[sqlca.sqlerrm.sqlerrml]='\0';
941941
printf("sql error %s\n",sqlca.sqlerrm.sqlerrmc);
942942
}
943+
944+
/* keep a list of cursors */
945+
structcursor*cur=NULL;
946+
947+
boolECPGdeclare(intlineno,constchar*name,char*command)
948+
{
949+
structcursor*ptr;
950+
951+
for (ptr=cur;ptr!=NULL;ptr=ptr->next)
952+
{
953+
if (strcmp(name,ptr->name)==0)
954+
{
955+
/* re-definition */
956+
free(ptr->command);
957+
ptr->command=command;
958+
break;
959+
}
960+
}
961+
962+
if (ptr==NULL)
963+
{
964+
structcursor*this= (structcursor*)malloc(sizeof(structcursor));
965+
966+
if (!this)
967+
{
968+
ECPGlog("out of memory\n");
969+
register_error(ECPG_OUT_OF_MEMORY,"out of memory in line %d",lineno);
970+
return false;
971+
}
972+
/* initial definition */
973+
this->next=cur;
974+
this->name=name;
975+
this->command=command;
976+
cur=this;
977+
}
978+
979+
return(true);
980+
}
981+
982+
boolECPGopen(intlineno,constchar*name)
983+
{
984+
structcursor*ptr;
985+
986+
for (ptr=cur;ptr!=NULL;ptr=ptr->next)
987+
{
988+
if (strcmp(ptr->name,name)==0)
989+
return(ECPGdo(lineno,ptr->command,ECPGt_EOIT,ECPGt_EORT));
990+
}
991+
992+
ECPGlog("trying to open undeclared cursor %s\n",name);
993+
register_error(ECPG_UNDECLARED_CURSOR,"trying to open undeclared cursor %s in line %d",name,lineno);
994+
return(false);
995+
}

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ include $(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=2
55
MINOR_VERSION=3
6-
PATCHLEVEL=4
6+
PATCHLEVEL=5
77

88
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION)\
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)\
10-
-DINCLUDE_PATH=\"$(DESTDIR)$(HEADERDIR)\"
10+
-DINCLUDE_PATH=\"$(DESTDIR)$(HEADERDIR)\"
1111

1212
OBJ=y.tab.o pgc.o type.o ecpg.o ecpg_keywords.o ../../../backend/parser/scansup.o\
1313
keywords.o c_keywords.o ../lib/typename.o

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,6 @@ main(int argc, char *const argv[])
141141
/* initialize lex */
142142
lex_init();
143143

144-
/* initialize cursor list */
145-
for (ptr=cur;ptr!=NULL;)
146-
{
147-
structcursor*c;
148-
149-
free(ptr->name);
150-
free(ptr->command);
151-
c=ptr;
152-
ptr=ptr->next;
153-
free(c);
154-
}
155-
156-
cur=NULL;
157-
158144
/* we need two includes and a constant */
159145
fprintf(yyout,"/* Processed by ecpg (%d.%d.%d) */\n/*These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n\nconst int no_auto_trans = %d;\n\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL,no_auto_trans);
160146

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ struct _include_path { char * path;
1616

1717
externstruct_include_path*include_paths;
1818

19-
structcursor {char*name;
20-
char*command;
21-
structcursor*next;
22-
};
23-
24-
externstructcursor*cur;
25-
2619
/* This is a linked list of the variable names and types. */
2720
structvariable
2821
{

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
335335

336336
BEGIN(xm);
337337
for(i =0; yytext[i]; i++)
338-
if (isupper(yytext[i]))
338+
if (isascii((unsignedchar)yytext[i]) &&isupper(yytext[i]))
339339
yytext[i] =tolower(yytext[i]);
340340

341341
keyword =ScanKeywordLookup((char*)yytext);
@@ -417,7 +417,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
417417
ScanKeyword*keyword;
418418

419419
for(i =0; yytext[i]; i++)
420-
if (isupper(yytext[i]))
420+
if (isascii((unsignedchar)yytext[i]) &&isupper(yytext[i]))
421421
yytext[i] =tolower(yytext[i]);
422422

423423
keyword =ScanKeywordLookup((char*)yytext);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp