From 574f262941c13b38d873fe6e034f8a6adf623348 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Mon, 3 Apr 1989 20:43:02 +0000 Subject: [PATCH] ING_DB --- WEGA/contrib/ingres/dbs/src/eql/comment.c | 62 +++++++++++++ WEGA/contrib/ingres/dbs/src/libq/IIflushtup.c | 46 ++++++++++ WEGA/contrib/ingres/dbs/src/libq/IIgettup.c | 91 +++++++++++++++++++ WEGA/contrib/ingres/dbs/src/libq/IIn_get.c | 66 ++++++++++++++ WEGA/contrib/ingres/dbs/src/libq/IIsetup.c | 22 +++++ WEGA/contrib/ingres/dbs/src/libq/IIsync.c | 37 ++++++++ 6 files changed, 324 insertions(+) create mode 100644 WEGA/contrib/ingres/dbs/src/eql/comment.c create mode 100644 WEGA/contrib/ingres/dbs/src/libq/IIflushtup.c create mode 100644 WEGA/contrib/ingres/dbs/src/libq/IIgettup.c create mode 100644 WEGA/contrib/ingres/dbs/src/libq/IIn_get.c create mode 100644 WEGA/contrib/ingres/dbs/src/libq/IIsetup.c create mode 100644 WEGA/contrib/ingres/dbs/src/libq/IIsync.c diff --git a/WEGA/contrib/ingres/dbs/src/eql/comment.c b/WEGA/contrib/ingres/dbs/src/eql/comment.c new file mode 100644 index 0000000..cce43ab --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/eql/comment.c @@ -0,0 +1,62 @@ +# include +# include "gen.h" +# include "constants.h" +# include "globals.h" + +/* +** COMMENT.C -- routine to scan comments inside an EQL statement +** +** Uses the endcmnt token code to find the endcmnt +** terminal string, then reads the input until it sees this +** terminal (must be <= 2 characters), returning EOF_TOK and +** giving an error diagnostic if end-of-file is encountered. +** +** Returns: +** CONTINUE -- valid comment +** EOF_TOK -- EOF in comment +** +** Side Effects: +** deletes comments from within an EQL statement +** +*/ +comment() +{ + register int i; + register int l; + register struct optab *op; + char buf[3]; + + /* find end of comment operator */ + for (op = Optab; op->op_term; op++) + if (op->op_token == Tokens.sp_endcmnt) + break; + + if (!op->op_term) + AAsyserr(13000); + /* scan for the end of comment */ + l = AAlength(op->op_term); + if (l > sizeof buf - 1) + AAsyserr(13001, l, op->op_term, sizeof buf -1); + + /* fill buffer to length of endmnt terminal */ + for (i = 0; i < l; i++) + { + if ((buf[i] = getch()) == EOF_TOK) + { +nontermcom : + /* non-terminated comment */ + yysemerr("premature EOF encountered in comment", (char *) 0); + return (EOF_TOK); + } + } + + /* shift on input until endcmnt */ + while (!AAbequal(buf, op->op_term, l)) + { + for (i = 0; i < l - 1; i++) + buf[i] = buf[i + 1]; + if ((buf[l - 1] = getch()) == EOF_TOK) + goto nontermcom; + } + return (CONTINUE); +} diff --git a/WEGA/contrib/ingres/dbs/src/libq/IIflushtup.c b/WEGA/contrib/ingres/dbs/src/libq/IIflushtup.c new file mode 100644 index 0000000..54923d2 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/libq/IIflushtup.c @@ -0,0 +1,46 @@ +# include +# include "gen.h" +# include "../h/dbs.h" +# include "../h/aux.h" +# include "../h/symbol.h" +# include "../h/tree.h" +# include "../h/pipes.h" +# include "IIglobals.h" + +/* +** IIflushtup is called to syncronize the data pipe +** after a retrieve. +*/ +IIflushtup(file_name, line_no) +register char *file_name; +register int line_no; +{ + struct retcode ret; + + if (IIproc_name = file_name) + IIline_no = line_no; + +# ifdef xETR1 + if (IIdebug) + printf("FLUSHTUP: IIerrflag %d\n", IIerrflag); +# endif + + if (IIerrflag < 2000) + { + /* flush the data pipe */ + IIrdpipe(P_SYNC, &IIeinpipe, IIr_front); + IIrdpipe(P_PRIME, &IIeinpipe); + + /* flush the control pipe */ + if (IIrdpipe(P_NORM, &IIinpipe, IIr_down, &ret, sizeof (ret)) == sizeof (ret)) + { + /* there was a tuple count field */ + IItupcnt = ret.rc_tupcount; + } + IIrdpipe(P_SYNC, &IIinpipe, IIr_down); + IIrdpipe(P_PRIME, &IIinpipe); + } + IIin_retrieve = 0; + IIndoms = 0; + IIdoms = 0; +} diff --git a/WEGA/contrib/ingres/dbs/src/libq/IIgettup.c b/WEGA/contrib/ingres/dbs/src/libq/IIgettup.c new file mode 100644 index 0000000..f807f86 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/libq/IIgettup.c @@ -0,0 +1,91 @@ +# include +# include "gen.h" +# include "../h/dbs.h" +# include "../h/aux.h" +# include "../h/symbol.h" +# include "../h/tree.h" +# include "../h/pipes.h" +# include "IIglobals.h" + +/* +** IIgettup is called to retrieve one instance +** of the target list into the c-variables. +** +** Integers and Floating point numbers can be converted +** to other numbers. +** +** Characters fields must match other character fields. +*/ +IIgettup(file_name, line_no) +char *file_name; +int line_no; +{ + register int length; + register int domain; + register struct retsym *ret; + char *s; + struct retsym sym; + char temp[MAXFIELD + 1]; + extern char *IIitos(); + + + + if (IIproc_name = file_name) + IIline_no = line_no; + + if (IIerrflag) + return (0); /* error. no data will be coming */ + + ret = IIretsym; + domain = 0; + + for ( ; ; ) + { + if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, &sym, TYP_LEN_SIZ) != TYP_LEN_SIZ) + IIsyserr("GETTUP: READ TYP_LEN"); + if (length = ctou(sym.len)) + if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, temp, length) != length) + IIsyserr("GETTUP: READ VALUE len=%d", length); +# ifdef xETR1 + if (IIdebug) + printf("GETTUP: typ %d len %d\n", sym.type, length); +# endif + domain++; + switch (sym.type) + { + + case INT: + case FLOAT: + if (ret->type == CHAR) + { + s = IIitos(domain); + IIerror(1000, 1, &s); + return (0); + } + if (IIconvert(temp, ret->addr, sym.type, length, ret->type, ctou(ret->len)) < 0) + { + s = IIitos(domain); + IIerror(1001, 1, &s); + } + break; + + case CHAR: + if (ret->type != CHAR) + { + s = IIitos(domain); + IIerror(1002, 1, &s); + return (0); + } + IIbmove(temp, ret->addr, length); + ret->addr[length] = '\0'; /* null terminate string */ + break; + + case EOTUP: + return (1); + + case EXIT: + return (0); + } + ret++; + } +} diff --git a/WEGA/contrib/ingres/dbs/src/libq/IIn_get.c b/WEGA/contrib/ingres/dbs/src/libq/IIn_get.c new file mode 100644 index 0000000..2211e3a --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/libq/IIn_get.c @@ -0,0 +1,66 @@ +# include +# include "gen.h" +# include "../h/dbs.h" +# include "../h/symbol.h" +# include "../h/tree.h" +# include "../h/pipes.h" +# include "IIglobals.h" + +/* +** IIN_GET -- Routine to check if there is a next +** tuple coming up the data pipe in a retrieve. +** Loads IIr_sym with the length and type of +** the next domain. +** +** Returns: +** 0 -- on error or end of tuple +** 1 -- otherwise +*/ +IIn_get(file_name, line_no) +register char *file_name; +register int line_no; +{ + register struct retsym *ret; + + if (IIproc_name = file_name) + IIline_no = line_no; + +# ifdef xETR1 + if (IIdebug) + printf("N_GET: IIdoms %d IIr_sym (typ %d len %d) IIerrflag %d\n", + IIdoms, IIr_sym.type, IIr_sym.len, IIerrflag); +# endif + + IIdoms = 0; + /* in case of overflow error, a tuple has been skipped */ + if (IIerrflag == 1001) + IIerrflag = 0; + if (IIerrflag) + return (0); + + ret = &IIr_sym; + if (ret->type && ret->type != EOTUP) + IIsyserr("N_GET: Unbekannter Typ %d", ret->type); + + /* read next type, length pair */ + if (IIrdpipe(P_NORM, &IIeinpipe, IIr_front, ret, TYP_LEN_SIZ) != TYP_LEN_SIZ) + IIsyserr("N_GET: READ TYP_LEN"); + + if (ret->type == EXIT) + return (0); + + return (1); +} + + +/* +** IIERRTEST -- Test if an error occurred within a retrieve. +** +** Returns: +** 1 -- if so +** 0 -- if not +*/ +IIerrtest() +{ + return (IIerrflag? 1: 0); +} diff --git a/WEGA/contrib/ingres/dbs/src/libq/IIsetup.c b/WEGA/contrib/ingres/dbs/src/libq/IIsetup.c new file mode 100644 index 0000000..3eaac68 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/libq/IIsetup.c @@ -0,0 +1,22 @@ +# include +# include "gen.h" +# include "../h/dbs.h" +# include "../h/symbol.h" +# include "../h/pipes.h" +# include "IIglobals.h" + +/* +** IIsetup is called to mark the start of a retrieve. +*/ +IIsetup() +{ +# ifdef xETR1 + if (IIdebug) + printf("SETUP\n"); +# endif + + IIin_retrieve = 1; + IIr_sym.type = 0; + IIr_sym.len = 0; + IIdoms = 0; +} diff --git a/WEGA/contrib/ingres/dbs/src/libq/IIsync.c b/WEGA/contrib/ingres/dbs/src/libq/IIsync.c new file mode 100644 index 0000000..1397067 --- /dev/null +++ b/WEGA/contrib/ingres/dbs/src/libq/IIsync.c @@ -0,0 +1,37 @@ +# include +# include "gen.h" +# include "../h/dbs.h" +# include "../h/symbol.h" +# include "../h/pipes.h" +# include "IIglobals.h" + +/* +** IIsync is called to syncronize the running +** of a query with the running of the EQL process. +** +** The query is flushed and an EOP is written +** to the QL parser. +** +** The QL parser will write an end-of-pipe when +** an operation is complete. +*/ +IIsync(file_name, line_no) +register char *file_name; +register int line_no; +{ + if (IIproc_name = file_name) + IIline_no = line_no; + +# ifdef xETR1 + if (IIdebug) + printf("SYNC\n"); +# endif + + IIwrpipe(P_END, &IIoutpipe, IIw_down); + IIwrpipe(P_PRIME, &IIoutpipe, IIw_down); + + IIerrflag = 0; /* reset error flag. If an error occures, */ + /* IIerrflag will get set in IIerror */ + IIrdpipe(P_SYNC, &IIinpipe, IIr_down); + IIrdpipe(P_PRIME, &IIinpipe); +}