提交 c80ba6a1 编写于 作者: M Michael Meskes

*** empty log message ***

上级 4cd086ce
......@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999
Thu Jan 6 09:52:27 CET 2000
- 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.
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.
The error handling has to be improved by adding additional error-rules to
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
indicator-error?
Add a semantic check level, e.g. check if a table really exists.
How can one insert arrays from c variables?
Missing statements:
- exec sql ifdef
- exec sql allocate
......
......@@ -6,13 +6,13 @@
# Copyright (c) 1994, Regents of the University of California
#
# 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
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 1.0
SO_MINOR_VERSION= 0.10
SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global
......
......@@ -8,7 +8,7 @@ ECPGtype_name(enum ECPGttype typ)
{
switch (typ)
{
case ECPGt_char:
case ECPGt_char:
return "char";
case ECPGt_unsigned_char:
return "unsigned char";
......
......@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
MAJOR_VERSION=2
MINOR_VERSION=7
PATCHLEVEL=14
PATCHLEVEL=0
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
......
......@@ -17,12 +17,11 @@ struct cursor *cur = NULL;
struct typedefs *types = NULL;
struct _defines *defines = NULL;
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] [-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
......@@ -35,6 +34,18 @@ add_include_path(char *path)
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
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(".");
while ((c = getopt(argc, argv, "vo:I:t")) != EOF)
while ((c = getopt(argc, argv, "vo:I:tD:")) != EOF)
{
switch (c)
{
......@@ -73,6 +84,9 @@ main(int argc, char *const argv[])
case 'v':
verbose = true;
break;
case 'D':
add_preprocessor_define(optarg);
break;
default:
usage(argv[0]);
return ILLEGAL_OPTION;
......@@ -106,7 +120,10 @@ main(int argc, char *const argv[])
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? */
if (ptr2ext == NULL)
{
......@@ -120,7 +137,7 @@ main(int argc, char *const argv[])
ptr2ext[4] = '\0';
}
if (out_option == 0)/* calculate the output name */
if (out_option == 0) /* calculate the output name */
{
output_filename = strdup(input_filename);
......@@ -179,16 +196,29 @@ main(int argc, char *const argv[])
ptr = ptr->next;
free(this);
}
cur = NULL;
/* remove old defines as well */
for (defptr = defines; defptr != NULL;)
/* remove non-pertinent old defines as well */
while ( defines && !defines->pertinent ) {
defptr = defines;
defines = defines->next;
free(defptr->new);
free(defptr->old);
free(defptr);
}
for (defptr = defines; defptr != NULL; defptr = defptr->next )
{
struct _defines *this = defptr;
struct _defines *this = defptr->next;
if ( this && !this->pertinent ) {
defptr->next = this->next;
free(defptr->new);
free(defptr->old);
defptr = defptr->next;
free(this->new);
free(this->old);
free(this);
}
}
/* and old typedefs */
......@@ -197,17 +227,25 @@ main(int argc, char *const argv[])
struct typedefs *this = typeptr;
free(typeptr->name);
free(typeptr->type);
ECPGfree_struct_member(typeptr->struct_member_list);
free(typeptr->type);
typeptr = typeptr->next;
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 */
lex_init();
/* 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 */
yyparse();
......
......@@ -2,6 +2,10 @@
#include "type.h"
#include <errno.h>
/* defines */
#define STRUCT_DEPTH 128
/* variables */
extern int braces_open,
......@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator;
extern struct variable no_indicator;
extern struct arguments *argsinsert;
extern struct arguments *argsresult;
extern struct when when_error, when_nf, when_warn;
extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
/* functions */
......@@ -39,9 +45,9 @@ extern void yyerror(char *);
/* return codes */
#define OK 0
#define PARSE_ERROR -1
#define PARSE_ERROR -1
#define ILLEGAL_OPTION -2
#define INDICATOR_NOT_ARRAY -3
#define INDICATOR_NOT_ARRAY -3
#define NO_INCLUDE_FILE ENOENT
#define OUT_OF_MEMORY ENOMEM
#define NO_INCLUDE_FILE ENOENT
#define OUT_OF_MEMORY ENOMEM
......@@ -123,7 +123,7 @@ get_type(enum ECPGttype typ)
{
switch (typ)
{
case ECPGt_char:
case ECPGt_char:
return ("ECPGt_char");
break;
case ECPGt_unsigned_char:
......@@ -367,17 +367,17 @@ ECPGfree_type(struct ECPGtype * typ)
{
switch (typ->typ)
{
case ECPGt_array:
case ECPGt_array:
switch (typ->u.element->typ)
{
case ECPGt_array:
case ECPGt_array:
yyerror("internal error, found multi-dimensional array\n");
break;
case ECPGt_struct:
case ECPGt_union:
/* Array of structs. */
ECPGfree_struct_member(typ->u.element->u.members);
free(typ->u.members);
free(typ->u.element);
break;
default:
if (!IS_SIMPLE_TYPE(typ->u.element->typ))
......@@ -389,7 +389,6 @@ ECPGfree_type(struct ECPGtype * typ)
case ECPGt_struct:
case ECPGt_union:
ECPGfree_struct_member(typ->u.members);
free(typ->u.members);
break;
default:
sprintf(errortext, "illegal variable type %d\n", typ->typ);
......
exec sql include sqlca;
exec sql whenever sqlerror do PrintAndStop(msg);
exec sql whenever sqlwarning do warn();
void PrintAndStop(msg)
void Finish(msg)
{
fprintf(stderr, "Error in statement '%s':\n", msg);
sqlprint();
/* finish transaction */
exec sql rollback;
/* and remove test table */
exec sql drop table meskes;
exec sql commit;
exec sql disconnect;
exit(-1);
}
......@@ -14,3 +21,6 @@ void warn(void)
{
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;
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);
for (i = 0;i < 1407; i++)
......@@ -49,14 +55,16 @@ exec sql end declare section;
sprintf(text, "%ld", i);
exec sql insert into perftest1(number, ascii) values (:i, :text);
exec sql insert into perftest2(number, next_number) values (:i, :i+1);
exec sql commit;
}
exec sql commit;
gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert");
exec sql begin transaction;
gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++)
......@@ -66,14 +74,16 @@ exec sql end declare section;
exec sql end declare section;
exec sql select ascii into :text from perftest1 where number = :i;
exec sql commit;
}
exec sql commit;
gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection");
exec sql begin transaction;
gettimeofday(&tvs, NULL);
for (i = 0;i < 1407; i++)
......@@ -83,14 +93,16 @@ 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 commit;
}
exec sql commit;
gettimeofday(&tve, NULL);
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join");
exec sql begin transaction;
gettimeofday(&tvs, NULL);
exec sql update perftest2 set next_number = next_number + 1;
......@@ -101,6 +113,8 @@ exec sql end declare section;
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update");
exec sql begin transaction;
gettimeofday(&tvs, NULL);
exec sql delete from perftest2;
......@@ -111,6 +125,8 @@ exec sql end declare section;
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 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;
......
......@@ -62,7 +62,7 @@ exec sql end declare section;
while (1) {
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);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
......@@ -81,7 +81,7 @@ exec sql end declare section;
strcpy(msg, "close");
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 declare prep cursor for MM;
......
......@@ -54,7 +54,7 @@ exec sql end declare section;
while (1) {
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);
if (ind_personal.ind_birth.born >= 0)
printf(", born %d", personal.birth.born);
......@@ -73,7 +73,7 @@ exec sql end declare section;
strcpy(msg, "close");
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 declare prep cursor for MM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册