Commit 7500a961 authored by Marc G. Fournier's avatar Marc G. Fournier

From: Michael Meskes <meskes@topsystem.de>

+ Thu Apr 23 09:27:16 CEST 1998
+
+       - Also allow call in whenever statement with the same functionality
+         as do.
+
+ Thu Apr 23 12:29:28 CEST 1998
+
+       - Also rewrote variable declaration part. It is now possible to
+         declare more than one variable per line.
+       - Set version to 2.1.0
+
+ Fri Apr 24 13:50:15 CEST 1998
+
+       - Fixed some bugs.
+       - Set version to 2.1.1
parent f2b64d35
......@@ -121,8 +121,24 @@ Mon Apr 20 16:13:25 CEST 1998
Mon Apr 20 16:39:23 CEST 1998
- Cursor is opened when the open command is issued, not at declare time.
- Set version to 2.0.0
Tue Apr 21 12:53:49 CEST 1998
- Set indicator to amount of data really written (truncation).
Thu Apr 23 09:27:16 CEST 1998
- Also allow call in whenever statement with the same functionality
as do.
Thu Apr 23 12:29:28 CEST 1998
- Also rewrote variable declaration part. It is now possible to
declare more than one variable per line.
- Set version to 2.1.0
Fri Apr 24 13:50:15 CEST 1998
- Fixed some bugs.
- Set version to 2.1.1
......@@ -35,8 +35,6 @@ There is no exec sql prepare statement.
The complete structure definition has to be listed inside the declare
section for ecpg to be able to understand it.
Each variable has to be defined on a line on its own.
There is no way yet to fill a complete array with one call except arrays of
[unsigned] char which are considered strings.
......@@ -54,4 +52,7 @@ exec sql disconnect {current|default|all|connectionname|connection_hostvar};
| CURRENT
commit release|commit work release auch disconnect
It is not neccessary to check for sql not found after all commands.
It is not neccessary to check for "not found" after all commands.
It would be nice to be able to specify parts of a structure like :foo.bar or
:foo->bar.
......@@ -21,7 +21,6 @@ ifeq ($(PORTNAME), linux)
install-shlib-dep := install-shlib
shlib := libecpg.so.$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
LDFLAGS_SL = -shared -soname libecpg.so.$(SO_MAJOR_VERSION)
CFLAGS += $(CFLAGS_SL)
endif
endif
ifeq ($(PORTNAME), bsd)
......@@ -47,12 +46,12 @@ endif
all: libecpg.a $(shlib)
$(shlib): ecpglib.o typename.o
$(LD) $(LDFLAGS_SL) -o $@ ecpglib.o typename.o
$(shlib): ecpglib.sho typename.sho
$(LD) $(LDFLAGS_SL) -o $@ ecpglib.sho typename.sho
ln -sf $@ libecpg.so
clean:
rm -f *.o *.a core a.out *~ $(shlib) libecpg.so
rm -f *.o *.sho *.a core a.out *~ $(shlib) libecpg.so
dep depend:
......@@ -70,6 +69,11 @@ uninstall::
libecpg.a : libecpg.a(ecpglib.o) libecpg.a(typename.o)
ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c ecpglib.c
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
typename.o : typename.c ../include/ecpgtype.h
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c typename.c
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
ecpglib.sho : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
$(CC) $(CFLAGS) $(CFLAGS_SL) -I../include $(PQ_INCLUDE) -c $< -o $@
typename.sho : typename.c ../include/ecpgtype.h
$(CC) $(CFLAGS) $(CFLAGS_SL) -I../include $(PQ_INCLUDE) -c $< -o $@
......@@ -2,8 +2,8 @@ SRCDIR= ../../..
include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2
MINOR_VERSION=0
PATCHLEVEL=0
MINOR_VERSION=1
PATCHLEVEL=1
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......
......@@ -27,7 +27,7 @@ static void
usage(char *progname)
{
fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
fprintf(stderr, "Usage: %s: [-v] [-d] [-I include path] [ -o output file name] file1 [file2] ...\n", progname);
fprintf(stderr, "Usage: %s: [-v] [-I include path] [ -o output file name] file1 [file2] ...\n", progname);
}
static void
......@@ -51,7 +51,7 @@ main(int argc, char *const argv[])
add_include_path("/usr/local/include");
add_include_path(".");
while ((c = getopt(argc, argv, "vdo:I:")) != EOF)
while ((c = getopt(argc, argv, "vo:I:")) != EOF)
{
switch (c)
{
......@@ -62,9 +62,6 @@ main(int argc, char *const argv[])
else
out_option = 1;
break;
case 'd':
debugging = 1;
break;
case 'I':
add_include_path(optarg);
break;
......
......@@ -21,6 +21,7 @@
*/
static ScanKeyword ScanKeywords[] = {
/* name value */
{"call", SQL_CALL},
{"connect", SQL_CONNECT},
{"continue", SQL_CONTINUE},
{"found", SQL_FOUND},
......
......@@ -2,8 +2,7 @@
/* variables */
extern int debugging,
braces_open;
extern int braces_open;
extern char *yytext;
extern int yylineno,
yyleng;
......@@ -23,6 +22,18 @@ struct cursor { char *name;
extern struct cursor *cur;
/* This is a linked list of the variable names and types. */
struct variable
{
char * name;
struct ECPGtype * type;
int brace_level;
struct variable * next;
};
extern struct ECPGtype ecpg_no_indicator;
extern struct variable no_indicator;
/* functions */
extern void lex_init(void);
......
......@@ -70,6 +70,7 @@ struct _yy_buffer { YY_BUFFER_STATE buffer;
%x xb
%x xc
%x xd
%x xdc
%x xh
%x xm
%x xq
......@@ -261,7 +262,7 @@ sql [sS][qQ][lL]
<xd>{xdstop} {
BEGIN(SQL);
yylval.str = strdup(literal);
return (IDENT);
return (CSTRING);
}
<xd>{xdinside} {
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
......@@ -269,7 +270,22 @@ sql [sS][qQ][lL]
memcpy(literal+llen, yytext, yyleng+1);
llen += yyleng;
}
<C>{xdstart} {
BEGIN(xdc);
llen = 0;
*literal = '\0';
}
<xdc>{xdstop} {
BEGIN(C);
yylval.str = strdup(literal);
return (CSTRING);
}
<xdc>{xdinside} {
if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
yyerror("ERROR: quoted string parse buffer exceeded");
memcpy(literal+llen, yytext, yyleng+1);
llen += yyleng;
}
<xm>{space}* { /* ignore */ }
<xm>{xmstop} {
......@@ -283,7 +299,7 @@ sql [sS][qQ][lL]
<SQL>{self}/-[\.0-9] {
return (yytext[0]);
}
<SQL>{self} { return (yytext[0]); }
<SQL>{self} { return (yytext[0]); }
<SQL>{operator}/-[\.0-9] {
yylval.str = strdup((char*)yytext);
return (Op);
......@@ -379,6 +395,10 @@ sql [sS][qQ][lL]
return (FCONST);
}
<SQL>:{identifier} {
yylval.str = strdup((char*)yytext+1);
return(CVARIABLE);
}
<SQL>{identifier} {
int i;
ScanKeyword *keyword;
......@@ -423,12 +443,14 @@ sql [sS][qQ][lL]
}
}
<C>";" { return(';'); }
<C>"," { return(','); }
<C>"*" { return('*'); }
<C>{space} { ECHO; }
\{ { return('{'); }
\} { return('}'); }
\[ { return('['); }
\] { return(']'); }
\= { return('='); }
<C>\{ { return('{'); }
<C>\} { return('}'); }
<C>\[ { return('['); }
<C>\] { return(']'); }
<C>\= { return('='); }
<C>{other} { return (S_ANYTHING); }
<C>{exec}{space}{sql}{space}{include} { BEGIN(incl); }
<incl>{space} /* eat the whitespace */
......
This diff is collapsed.
......@@ -130,6 +130,12 @@ ECPGdump_a_record(FILE *o, const char *name, const char *ind_name, long arrsiz,
void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix)
{
if (ind_typ == NULL)
{
ind_typ = &ecpg_no_indicator;
ind_name = "no_indicator";
}
if (IS_SIMPLE_TYPE(typ->typ))
{
ECPGdump_a_simple(o, name, typ->typ, typ->size, 0, 0, prefix);
......@@ -267,7 +273,7 @@ ECPGdump_a_record(FILE *o, const char *name, const char * ind_name, long arrsiz,
* then we are in a record in a record and the offset is used as
* offset.
*/
struct ECPGrecord_member *p, *ind_p;
struct ECPGrecord_member *p, *ind_p = NULL;
char obuf[BUFSIZ];
char pbuf[BUFSIZ], ind_pbuf[BUFSIZ];
const char *offset;
......@@ -288,9 +294,11 @@ ECPGdump_a_record(FILE *o, const char *name, const char * ind_name, long arrsiz,
sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
ind_prefix = ind_pbuf;
for (p = typ->u.members, ind_p = ind_typ->u.members; p; p = p->next, ind_p = ind_p->next)
if (ind_typ != NULL) ind_p = ind_typ->u.members;
for (p = typ->u.members; p; p = p->next)
{
ECPGdump_a_type(o, p->name, p->typ, ind_p->name, ind_p->typ, prefix, ind_prefix);
ECPGdump_a_type(o, p->name, p->typ, (ind_p != NULL) ? ind_p->name : NULL, (ind_p != NULL) ? ind_p->typ : NULL, prefix, ind_prefix);
if (ind_p != NULL) ind_p = ind_p->next;
}
}
......
......@@ -74,3 +74,9 @@ struct when
char *command;
char *str;
};
struct index
{
int ival;
char *str;
};
......@@ -119,5 +119,7 @@ exec sql end declare section;
exec sql drop table perftest1;
exec sql commit;
return (0);
}
......@@ -24,7 +24,7 @@ exec sql begin declare section;
} ind_birth;
} ind_personal;
long ind_married;
char married[9]="a";
char married[9];
exec sql end declare section;
char msg[128], command[128];
FILE *dbgs;
......@@ -60,7 +60,7 @@ exec sql end declare section;
while (not_found == 0) {
strcpy(msg, "fetch");
exec sql fetch cur into :personal:ind_personal, :married:ind_married;
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :personal.birth.born;
if (not_found == 0)
printf ("%8.8s was born %d (age = %d) %s%s\n", personal.name.arr, personal.birth.born, personal.birth.age, ind_married ? "" : "and married ", ind_married ? "" : married);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment