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

Commit80e1282

Browse files
committed
+ Sat Feb 21 19:10:55 CET 1998
++ - use char[] as string not as array of bytes that is integers++ Sun Feb 22 16:37:36 CET 1998++ - use long for all size variables+ - added execute immediate statement++ Sun Feb 22 20:41:32 CET 1998++ - use varcharsize = 1 for all simple types, 0 means pointer, > 1+ means array if type is char resp. unsigned char++ Thu Feb 24 12:26:12 CET 1998++ - allow 'go to' in whenever statement as well as 'goto'+ - new argument 'stop' for whenever statementFrom: Michael Meskes <meskes@topsystem.de>
1 parent0227a4e commit80e1282

File tree

10 files changed

+247
-105
lines changed

10 files changed

+247
-105
lines changed

‎src/interfaces/ecpg/ChangeLog‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,21 @@ Thu Feb 19 12:48:14 CET 1998
3838

3939
- added do option to whenever statement
4040

41+
Sat Feb 21 19:10:55 CET 1998
42+
43+
- use char[] as string not as array of bytes that is integers
44+
45+
Sun Feb 22 16:37:36 CET 1998
46+
47+
- use long for all size variables
48+
- added execute immediate statement
49+
50+
Sun Feb 22 20:41:32 CET 1998
51+
52+
- use varcharsize = 1 for all simple types, 0 means pointer, > 1
53+
means array if type is char resp. unsigned char
54+
55+
Thu Feb 24 12:26:12 CET 1998
56+
57+
- allow 'go to' in whenever statement as well as 'goto'
58+
- new argument 'stop' for whenever statement

‎src/interfaces/ecpg/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
SUBDIRS = include lib preproc doc
2-
31
allinstalluninstallclean:
2+
$(MAKE) -C include$@
43
$(MAKE) -C lib$@
54
$(MAKE) -C preproc$@

‎src/interfaces/ecpg/TODO‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,22 @@ could be realised in a script.
4040

4141
Now comes my list (MM):
4242

43-
What do we do with enum data types?
43+
The return code is alway -1 in case of an error. You cannot see which error
44+
occured by examining the return code.
4445

45-
The cursor is opened when the declare statement is issued.
46+
The cursor is opened when the declare statement is issued.
47+
48+
ecpg does not understand enum datatypes.
4649

4750
The is no exec sql prepare statement.
51+
52+
The complete structure definition has to be listed inside the declare
53+
section for ecpg to be able to understand it.
54+
55+
Each variable has to be defined on a line on its own.
56+
57+
There is no way yet to fill a complete array with one call except arrays of
58+
[unsigned] char which are considered strings.
59+
60+
ecpg cannot use pointer variables except [unsigned] char *
61+

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

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ ECPGdo(int lineno, char *query,...)
9696
while (type!=ECPGt_EOIT)
9797
{
9898
void*value=NULL;
99-
shortvarcharsize;
100-
shortsize;
101-
shortarrsize;
99+
longvarcharsize;
100+
longsize;
101+
longarrsize;
102102

103103
char*newcopy;
104104
char*mallocedval=NULL;
@@ -110,20 +110,18 @@ ECPGdo(int lineno, char *query,...)
110110
contents to arrive in a comma-separated list on insert (I think). */
111111

112112
value=va_arg(ap,void*);
113-
varcharsize=va_arg(ap,short);
114-
size=va_arg(ap,short);
115-
arrsize=va_arg(ap,short);
113+
varcharsize=va_arg(ap,long);
114+
size=va_arg(ap,long);
115+
arrsize=va_arg(ap,long);
116116

117117
switch (type)
118118
{
119-
caseECPGt_char:
120119
caseECPGt_short:
121120
caseECPGt_int:
122121
sprintf(buff,"%d",*(int*)value);
123122
tobeinserted=buff;
124123
break;
125124

126-
caseECPGt_unsigned_char:
127125
caseECPGt_unsigned_short:
128126
caseECPGt_unsigned_int:
129127
sprintf(buff,"%d",*(unsignedint*)value);
@@ -155,6 +153,27 @@ ECPGdo(int lineno, char *query,...)
155153
tobeinserted=buff;
156154
break;
157155

156+
caseECPGt_char:
157+
caseECPGt_unsigned_char:
158+
{
159+
/* set slen to string length if type is char * */
160+
intslen= (varcharsize==0) ?strlen((char*)value) :varcharsize;
161+
162+
newcopy= (char*)malloc(slen+1);
163+
strncpy(newcopy, (char*)value,slen);
164+
newcopy[slen]='\0';
165+
166+
mallocedval= (char*)malloc(2*strlen(newcopy)+3);
167+
strcpy(mallocedval,"'");
168+
strcat(mallocedval,quote_postgres(newcopy));
169+
strcat(mallocedval,"'");
170+
171+
free(newcopy);
172+
173+
tobeinserted=mallocedval;
174+
}
175+
break;
176+
158177
caseECPGt_varchar:
159178
caseECPGt_varchar2:
160179
{
@@ -274,7 +293,7 @@ ECPGdo(int lineno, char *query,...)
274293

275294
if (n<1)
276295
{
277-
ECPGlog("ECPGdolineno %d: Incorrect number of matches: %d\n",
296+
ECPGlog("ECPGdoline %d: Incorrect number of matches: %d\n",
278297
lineno,n);
279298
register_error(1,"Data not found line %d.",lineno);
280299
break;
@@ -293,9 +312,9 @@ ECPGdo(int lineno, char *query,...)
293312
for (x=0;x<m&&status;x++)
294313
{
295314
void*value=NULL;
296-
shortvarcharsize;
297-
shortsize;
298-
shortarrsize;
315+
longvarcharsize;
316+
longsize;
317+
longarrsize;
299318

300319
char*pval=PQgetvalue(results,0,x);
301320

@@ -311,17 +330,16 @@ ECPGdo(int lineno, char *query,...)
311330
/* We will have to decode the value */
312331
type=va_arg(ap,enumECPGttype);
313332
value=va_arg(ap,void*);
314-
varcharsize=va_arg(ap,short);
315-
size=va_arg(ap,short);
316-
arrsize=va_arg(ap,short);
333+
varcharsize=va_arg(ap,long);
334+
size=va_arg(ap,long);
335+
arrsize=va_arg(ap,long);
317336

318337
switch (type)
319338
{
320339
longres;
321340
unsigned longures;
322341
doubledres;
323342

324-
caseECPGt_char:
325343
caseECPGt_short:
326344
caseECPGt_int:
327345
caseECPGt_long:
@@ -342,9 +360,6 @@ ECPGdo(int lineno, char *query,...)
342360
/* Again?! Yes */
343361
switch (type)
344362
{
345-
caseECPGt_char:
346-
*(char*)value= (char)res;
347-
break;
348363
caseECPGt_short:
349364
*(short*)value= (short)res;
350365
break;
@@ -360,7 +375,6 @@ ECPGdo(int lineno, char *query,...)
360375
}
361376
break;
362377

363-
caseECPGt_unsigned_char:
364378
caseECPGt_unsigned_short:
365379
caseECPGt_unsigned_int:
366380
caseECPGt_unsigned_long:
@@ -381,9 +395,6 @@ ECPGdo(int lineno, char *query,...)
381395
/* Again?! Yes */
382396
switch (type)
383397
{
384-
caseECPGt_unsigned_char:
385-
*(unsignedchar*)value= (unsignedchar)ures;
386-
break;
387398
caseECPGt_unsigned_short:
388399
*(unsigned short*)value= (unsigned short)ures;
389400
break;
@@ -452,6 +463,20 @@ ECPGdo(int lineno, char *query,...)
452463
return false;
453464
break;
454465

466+
caseECPGt_char:
467+
caseECPGt_unsigned_char:
468+
{
469+
if (varcharsize==0)
470+
{
471+
/* char* */
472+
strncpy((char*)value,pval,strlen(pval));
473+
((char*)value)[strlen(pval)]='\0';
474+
}
475+
else
476+
strncpy((char*)value,pval,varcharsize);
477+
}
478+
break;
479+
455480
caseECPGt_varchar:
456481
{
457482
structECPGgeneric_varchar*var=

‎src/interfaces/ecpg/preproc/Makefile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ MAJOR_VERSION=1
55
MINOR_VERSION=0
66
PATCHLEVEL=0
77

8-
CFLAGS=-I$(SRCDIR)/include -I../include -Wall -DMAJOR_VERSION=$(MAJOR_VERSION) -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)
8+
CFLAGS+=-I$(SRCDIR)/include -I../include -Wall -DMAJOR_VERSION=$(MAJOR_VERSION) -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL)
99

1010
all:: ecpg
1111

1212
clean:
13-
rm -f*.o core a.out ecpg y.tab.h y.tab.c*~
13+
rm -f*.o core a.out ecpg y.tab.h y.tab.cpgc.c*~
1414

1515
install: all
16-
$(INSTALL)$(INSTLOPTS) ecpg$(DESTDIR)$(BINDIR)
16+
$(INSTALL)$(INSTL_EXE_OPTS) ecpg$(DESTDIR)$(BINDIR)
1717

1818
uninstall:
1919
rm -f$(DESTDIR)$(BINDIR)/ecpg
2020

2121
# Rule that really do something.
2222
ecpg: y.tab.o pgc.o type.o ecpg.o ../lib/typename.o
23-
$(CC) -Wall -o ecpg y.tab.o pgc.o type.o ecpg.o ../lib/typename.o$(LEXLIB)
23+
$(CC) -o ecpg y.tab.o pgc.o type.o ecpg.o ../lib/typename.o$(LEXLIB)
2424

2525
y.tab.hy.tab.c: preproc.y
2626
$(YACC)$(YFLAGS)$<

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end[eE][nN][dD]
2929
exec[eE][xX][eE][cC]
3030
execute[eE][xX][eE][cC][uU][tT][eE]
3131
found[fF][oO][uU][nN][dD]
32+
go[gG][oO]
3233
goto [gG][oO][tT][oO]
3334
immediate [iI][mM][mM][eE][dD][iI][aA][tT][eE]
3435
include [iI][nN][cC][lL][uU][dD][eE]
@@ -41,6 +42,8 @@ section[sS][eE][cC][tT][iI][oO][nN]
4142
sql[sS][qQ][lL]
4243
sqlerror [sS][qQ][lL][eE][rR][rR][oO][rR]
4344
sqlprint [sS][qQ][lL][pP][rR][iI][nN][tT]
45+
stop[sS][tT][oO][pP]
46+
to [tT][oO]
4447
varchar[vV][aA][rR][cC][hH][aA][rR]
4548
varchar2[vV][aA][rR][cC][hH][aA][rR]2
4649
whenever [wW][hH][eE][nN][eE][vV][eE][rR]
@@ -69,6 +72,8 @@ work [wW][oO][rR][kK]
6972
<SQL>{continue}{dbg(SQL_CONTINUE);return SQL_CONTINUE; }
7073
<SQL>{into}{dbg(SQL_INTO);return SQL_INTO; }
7174
<SQL>{goto}{dbg(SQL_GOTO);return SQL_GOTO; }
75+
<SQL>{go}{ws}{to}{dbg(SQL_GOTO);return SQL_GOTO; }
76+
<SQL>{stop}{dbg(SQL_STOP);return SQL_STOP; }
7277
<SQL>{do}{dbg(SQL_DO);return SQL_DO; }
7378

7479
{length}{dbg(S_LENGTH);return S_LENGTH; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp