Commit c80ba6a1 authored by Michael Meskes's avatar Michael Meskes

*** empty log message ***

parent 4cd086ce
...@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999 ...@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999
Thu Jan 6 09:52:27 CET 2000 Thu Jan 6 09:52:27 CET 2000
- Synced preproc.y with gram.y. - Synced preproc.y with gram.y.
- Made sure Bruce's additions also make it into my source tree.
- Set ecpg version to 2.6.14. - Set ecpg version to 2.6.14.
Wed Jan 12 15:50:39 CET 2000
- Made sure Rene Hogendoorn's patches make it into ecpg completely
except for the FETCH syntax change.
Fri Jan 14 21:17:46 CET 2000
- Applied a minor patch to ecpglib.c.
- Fixed initialization bugs.
Mon Jan 17 21:55:40 CET 2000
- Synced preproc.y with gram.y.
- Changed FETCH syntax using Rene's final patch. Made it more
standard compliant.
- Set library version to 3.0.10.
- Set ecpg version to 2.7.0.
...@@ -13,19 +13,17 @@ stderr. Instead it should be listed as a warning. ...@@ -13,19 +13,17 @@ stderr. Instead it should be listed as a warning.
The error handling has to be improved by adding additional error-rules to The error handling has to be improved by adding additional error-rules to
the parser. the parser.
it would be nice to be able to use :var[:index] as cvariable it would be nice to be able to use :var[:index] as cvariable for an array var
support for dynamic SQL with unknown number of variables with DESCRIPTORS How can one insert arrays from c variables?
The line numbering is not exact. support for dynamic SQL with unknown number of variables with DESCRIPTORS
What happens to the output variable during read if there was an What happens to the output variable during read if there was an
indicator-error? indicator-error?
Add a semantic check level, e.g. check if a table really exists. Add a semantic check level, e.g. check if a table really exists.
How can one insert arrays from c variables?
Missing statements: Missing statements:
- exec sql ifdef - exec sql ifdef
- exec sql allocate - exec sql allocate
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.55 2000/01/10 15:41:27 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.56 2000/01/18 13:03:47 meskes Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
NAME= ecpg NAME= ecpg
SO_MAJOR_VERSION= 3 SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 1.0 SO_MINOR_VERSION= 0.10
SRCDIR= @top_srcdir@ SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global include $(SRCDIR)/Makefile.global
......
...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global ...@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2 MAJOR_VERSION=2
MINOR_VERSION=7 MINOR_VERSION=7
PATCHLEVEL=14 PATCHLEVEL=0
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \ CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \ -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......
...@@ -17,12 +17,11 @@ struct cursor *cur = NULL; ...@@ -17,12 +17,11 @@ struct cursor *cur = NULL;
struct typedefs *types = NULL; struct typedefs *types = NULL;
struct _defines *defines = NULL; struct _defines *defines = NULL;
static void static void
usage(char *progname) usage(char *progname)
{ {
fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] file1 [file2] ...\n", progname); fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] [-D define name] file1 [file2] ...\n", progname);
} }
static void static void
...@@ -35,6 +34,18 @@ add_include_path(char *path) ...@@ -35,6 +34,18 @@ add_include_path(char *path)
include_paths->next = ip; include_paths->next = ip;
} }
static void
add_preprocessor_define(char *define)
{
struct _defines *pd = defines;
defines = mm_alloc(sizeof(struct _defines));
defines->old = strdup(define);
defines->new = strdup("");
defines->pertinent = true;
defines->next = pd;
}
int int
main(int argc, char *const argv[]) main(int argc, char *const argv[])
{ {
...@@ -49,7 +60,7 @@ main(int argc, char *const argv[]) ...@@ -49,7 +60,7 @@ main(int argc, char *const argv[])
add_include_path("/usr/local/include"); add_include_path("/usr/local/include");
add_include_path("."); add_include_path(".");
while ((c = getopt(argc, argv, "vo:I:t")) != EOF) while ((c = getopt(argc, argv, "vo:I:tD:")) != EOF)
{ {
switch (c) switch (c)
{ {
...@@ -73,6 +84,9 @@ main(int argc, char *const argv[]) ...@@ -73,6 +84,9 @@ main(int argc, char *const argv[])
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
case 'D':
add_preprocessor_define(optarg);
break;
default: default:
usage(argv[0]); usage(argv[0]);
return ILLEGAL_OPTION; return ILLEGAL_OPTION;
...@@ -106,7 +120,10 @@ main(int argc, char *const argv[]) ...@@ -106,7 +120,10 @@ main(int argc, char *const argv[])
strcpy(input_filename, argv[fnr]); strcpy(input_filename, argv[fnr]);
ptr2ext = strrchr(input_filename, '.'); /* take care of relative paths */
ptr2ext = strrchr(input_filename, '/');
ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
/* no extension? */ /* no extension? */
if (ptr2ext == NULL) if (ptr2ext == NULL)
{ {
...@@ -120,7 +137,7 @@ main(int argc, char *const argv[]) ...@@ -120,7 +137,7 @@ main(int argc, char *const argv[])
ptr2ext[4] = '\0'; ptr2ext[4] = '\0';
} }
if (out_option == 0)/* calculate the output name */ if (out_option == 0) /* calculate the output name */
{ {
output_filename = strdup(input_filename); output_filename = strdup(input_filename);
...@@ -179,17 +196,30 @@ main(int argc, char *const argv[]) ...@@ -179,17 +196,30 @@ main(int argc, char *const argv[])
ptr = ptr->next; ptr = ptr->next;
free(this); free(this);
} }
cur = NULL;
/* remove old defines as well */ /* remove non-pertinent old defines as well */
for (defptr = defines; defptr != NULL;) while ( defines && !defines->pertinent ) {
{ defptr = defines;
struct _defines *this = defptr; defines = defines->next;
free(defptr->new); free(defptr->new);
free(defptr->old); free(defptr->old);
defptr = defptr->next; free(defptr);
}
for (defptr = defines; defptr != NULL; defptr = defptr->next )
{
struct _defines *this = defptr->next;
if ( this && !this->pertinent ) {
defptr->next = this->next;
free(this->new);
free(this->old);
free(this); free(this);
} }
}
/* and old typedefs */ /* and old typedefs */
for (typeptr = types; typeptr != NULL;) for (typeptr = types; typeptr != NULL;)
...@@ -197,17 +227,25 @@ main(int argc, char *const argv[]) ...@@ -197,17 +227,25 @@ main(int argc, char *const argv[])
struct typedefs *this = typeptr; struct typedefs *this = typeptr;
free(typeptr->name); free(typeptr->name);
free(typeptr->type);
ECPGfree_struct_member(typeptr->struct_member_list); ECPGfree_struct_member(typeptr->struct_member_list);
free(typeptr->type);
typeptr = typeptr->next; typeptr = typeptr->next;
free(this); free(this);
} }
types = NULL;
/* initialize whenever structures */
memset(&when_error, 0, sizeof(struct when));
memset(&when_nf, 0, sizeof(struct when));
memset(&when_warn, 0, sizeof(struct when));
/* and structure member lists */
memset(struct_member_list, 0, sizeof(struct_member_list));
/* initialize lex */ /* initialize lex */
lex_init(); lex_init();
/* we need two includes */ /* we need two includes */
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\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL); 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#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
/* and parse the source */ /* and parse the source */
yyparse(); yyparse();
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "type.h" #include "type.h"
#include <errno.h> #include <errno.h>
/* defines */
#define STRUCT_DEPTH 128
/* variables */ /* variables */
extern int braces_open, extern int braces_open,
...@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator; ...@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator;
extern struct variable no_indicator; extern struct variable no_indicator;
extern struct arguments *argsinsert; extern struct arguments *argsinsert;
extern struct arguments *argsresult; extern struct arguments *argsresult;
extern struct when when_error, when_nf, when_warn;
extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
/* functions */ /* functions */
......
This diff is collapsed.
...@@ -377,7 +377,7 @@ ECPGfree_type(struct ECPGtype * typ) ...@@ -377,7 +377,7 @@ ECPGfree_type(struct ECPGtype * typ)
case ECPGt_union: case ECPGt_union:
/* Array of structs. */ /* Array of structs. */
ECPGfree_struct_member(typ->u.element->u.members); ECPGfree_struct_member(typ->u.element->u.members);
free(typ->u.members); free(typ->u.element);
break; break;
default: default:
if (!IS_SIMPLE_TYPE(typ->u.element->typ)) if (!IS_SIMPLE_TYPE(typ->u.element->typ))
...@@ -389,7 +389,6 @@ ECPGfree_type(struct ECPGtype * typ) ...@@ -389,7 +389,6 @@ ECPGfree_type(struct ECPGtype * typ)
case ECPGt_struct: case ECPGt_struct:
case ECPGt_union: case ECPGt_union:
ECPGfree_struct_member(typ->u.members); ECPGfree_struct_member(typ->u.members);
free(typ->u.members);
break; break;
default: default:
sprintf(errortext, "illegal variable type %d\n", typ->typ); sprintf(errortext, "illegal variable type %d\n", typ->typ);
......
exec sql include sqlca; exec sql include sqlca;
exec sql whenever sqlerror do PrintAndStop(msg); void Finish(msg)
exec sql whenever sqlwarning do warn();
void PrintAndStop(msg)
{ {
fprintf(stderr, "Error in statement '%s':\n", msg); fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint(); sqlprint();
/* finish transaction */
exec sql rollback;
/* and remove test table */
exec sql drop table meskes;
exec sql commit;
exec sql disconnect;
exit(-1); exit(-1);
} }
...@@ -14,3 +21,6 @@ void warn(void) ...@@ -14,3 +21,6 @@ void warn(void)
{ {
fprintf(stderr, "Warning: At least one column was truncated\n"); fprintf(stderr, "Warning: At least one column was truncated\n");
} }
exec sql whenever sqlerror do Finish(msg);
exec sql whenever sqlwarning do warn();
...@@ -38,6 +38,12 @@ exec sql end declare section; ...@@ -38,6 +38,12 @@ exec sql end declare section;
exec sql create unique index number2 on perftest2(number); exec sql create unique index number2 on perftest2(number);
exec sql commit;
exec sql set autocommit to on;
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -49,14 +55,16 @@ exec sql end declare section; ...@@ -49,14 +55,16 @@ exec sql end declare section;
sprintf(text, "%ld", i); sprintf(text, "%ld", i);
exec sql insert into perftest1(number, ascii) values (:i, :text); exec sql insert into perftest1(number, ascii) values (:i, :text);
exec sql insert into perftest2(number, next_number) values (:i, :i+1); exec sql insert into perftest2(number, next_number) values (:i, :i+1);
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -66,14 +74,16 @@ exec sql end declare section; ...@@ -66,14 +74,16 @@ exec sql end declare section;
exec sql end declare section; exec sql end declare section;
exec sql select ascii into :text from perftest1 where number = :i; exec sql select ascii into :text from perftest1 where number = :i;
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++) for (i = 0;i < 1407; i++)
...@@ -83,14 +93,16 @@ exec sql end declare section; ...@@ -83,14 +93,16 @@ exec sql end declare section;
exec sql end declare section; exec sql end declare section;
exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i; exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i;
}
exec sql commit; exec sql commit;
}
gettimeofday(&tve, NULL); gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
exec sql update perftest2 set next_number = next_number + 1; exec sql update perftest2 set next_number = next_number + 1;
...@@ -101,6 +113,8 @@ exec sql end declare section; ...@@ -101,6 +113,8 @@ exec sql end declare section;
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update");
exec sql begin transaction;
gettimeofday(&tvs, NULL); gettimeofday(&tvs, NULL);
exec sql delete from perftest2; exec sql delete from perftest2;
...@@ -111,6 +125,8 @@ exec sql end declare section; ...@@ -111,6 +125,8 @@ exec sql end declare section;
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "delete"); print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "delete");
exec sql set autocommit = off;
exec sql drop index number2; exec sql drop index number2;
exec sql drop table perftest2; exec sql drop table perftest2;
......
exec sql include header_test; exec sql include sqlca;
exec sql whenever sqlerror do PrintAndStop(msg);
exec sql whenever sqlwarning do warn();
void PrintAndStop(msg)
{
fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint();
exit(-1);
}
void warn(void)
{
fprintf(stderr, "Warning: At least one column was truncated\n");
}
exec sql include sqlca; exec sql include sqlca;
......
...@@ -62,7 +62,7 @@ exec sql end declare section; ...@@ -62,7 +62,7 @@ exec sql end declare section;
while (1) { while (1) {
strcpy(msg, "fetch"); strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint; exec sql fetch from cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
printf("%8.8s", personal.name.arr); printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0) if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born); printf(", born %d", personal.birth.born);
...@@ -81,7 +81,7 @@ exec sql end declare section; ...@@ -81,7 +81,7 @@ exec sql end declare section;
strcpy(msg, "close"); strcpy(msg, "close");
exec sql close cur; exec sql close cur;
/* and now the same query with prepare */ /* and now a same query with prepare */
exec sql prepare MM from :query; exec sql prepare MM from :query;
exec sql declare prep cursor for MM; exec sql declare prep cursor for MM;
......
...@@ -54,7 +54,7 @@ exec sql end declare section; ...@@ -54,7 +54,7 @@ exec sql end declare section;
while (1) { while (1) {
strcpy(msg, "fetch"); strcpy(msg, "fetch");
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children; exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
printf("%8.8s", personal.name.arr); printf("%8.8s", personal.name.arr);
if (ind_personal.ind_birth.born >= 0) if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born); printf(", born %d", personal.birth.born);
...@@ -73,7 +73,7 @@ exec sql end declare section; ...@@ -73,7 +73,7 @@ exec sql end declare section;
strcpy(msg, "close"); strcpy(msg, "close");
exec sql close cur; exec sql close cur;
/* and now the same query with prepare */ /* and now a query with prepare */
exec sql prepare MM from "select name, born, age, married, children from meskes where name = ?"; exec sql prepare MM from "select name, born, age, married, children from meskes where name = ?";
exec sql declare prep cursor for MM; exec sql declare prep cursor for MM;
......
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