This commit is contained in:
Oliver Lehmann 1989-06-27 12:18:36 +00:00
parent 145c6bff27
commit 369925f750
3 changed files with 536 additions and 0 deletions

View File

@ -0,0 +1,166 @@
/* see ovqp/interp.c */
/* see ovqp/interp.c */
# define AND 0 /* see ovqp/interp.c */
# define OR 1 /* see ovqp/interp.c */
# define UOP 2 /* UNARY OPERATORS */
/* see ovqp/interp.c */
enum UOP_VAL
{
/* 0*/ opPLUS, /* see ovqp/interp.c */
/* 1*/ opMINUS, /* see ovqp/interp.c */
/* 2*/ opNOT, /* see ovqp/interp.c */
/* 3*/ opATAN, /* see ovqp/interp.c */
/* 4*/ opCOS, /* see ovqp/interp.c */
/* 5*/ opGAMMA, /* see ovqp/interp.c */
/* 6*/ opLOG, /* see ovqp/interp.c */
/* 7*/ opASCII, /* see ovqp/interp.c */
/* 8*/ opSIN, /* see ovqp/interp.c */
/* 9*/ opSQRT, /* see ovqp/interp.c */
/*10*/ opABS, /* see ovqp/interp.c */
/*11*/ opEXP, /* see ovqp/interp.c */
/*12*/ opINT1, /* see ovqp/interp.c */
/*13*/ opINT2, /* see ovqp/interp.c */
/*14*/ opINT4, /* see ovqp/interp.c */
/*15*/ opFLT4, /* see ovqp/interp.c */
/*16*/ opFLT8 /* see ovqp/interp.c */
};
# define BOP 3 /* BINARY OPERATORS */
/* see decomp/reformat.c */
/* and ovqp/interp.c */
enum BOP_VAL
{
/* 0*/ opADD, /* see ovqp/interp.c */
/* 1*/ opSUB, /* see ovqp/interp.c */
/* 2*/ opMUL, /* see ovqp/interp.c */
/* 3*/ opDIV, /* see ovqp/interp.c */
/* 4*/ opPOW, /* see ovqp/interp.c */
/* 5*/ opEQ, /* see decomp/reformat.c */
/* and ovqp/interp.c */
/* 6*/ opNE, /* see ovqp/interp.c */
/* 7*/ opLT, /* see ovqp/interp.c */
/* 8*/ opLE, /* see ovqp/interp.c */
/* 9*/ opGT, /* see ovqp/interp.c */
/*10*/ opGE, /* see ovqp/interp.c */
/*11*/ opMOD, /* see ovqp/interp.c */
/*12*/ opCONCAT /* see ovqp/interp.c */
};
# define AOP 4 /* AGGREGATE OPERATORS */
/* see ovqp/interp.c */
enum AOP_VAL
{
/* 0*/ opCNT, /* see ovqp/interp.c */
/* 1*/ opCNTU, /* see ovqp/interp.c */
/* 2*/ opSUM, /* see ovqp/interp.c */
/* 3*/ opSUMU, /* see ovqp/interp.c */
/* 4*/ opAVG, /* see ovqp/interp.c */
/* 5*/ opAVGU, /* see ovqp/interp.c */
/* 6*/ opMIN, /* see ovqp/interp.c */
/* 7*/ opMAX, /* see ovqp/interp.c */
/* 8*/ opANY /* see ovqp/interp.c */
};
# define COP 5 /* CONSTANT OPERATORS */
/* see ovqp/interp.c */
enum COP_VAL
{
/* 0*/ opDBA, /* see ovqp/interp.c */
/* 1*/ opUSERCODE, /* see ovqp/interp.c */
/* 2*/ opDATE,
/* 3*/ opTIME
};
# define RESDOM 11 /* RESULT DOMAIN NUMBER */
/* see ovqp/interp.c */
/* and qrymod/d_prot.c */
# define VAR 12 /* VARIABLE */
/* see decomp/reformat.c */
/* and qrymod/d_prot.c */
# define S_VAR 13 /* variable for which */
/* a substitution has been done */
/* Only occurs in OVQP-DECOMP merged process. */
# define QMODE 16 /* QUERY MODE */
enum QMODE_VAL
{
/* 0*/ mdRETTERM, /* RETRIEVE to terminal, used by OVQP-DECOMP */
/* 1*/ mdRETR, /* RETRIEVE, into relation perhaps */
/* 2*/ mdAPP, /* APPEND to relation */
/* 3*/ mdREPL, /* REPLACE in relation */
/* see ovqp/interp.c */
/* 4*/ mdDEL, /* DELETE from relation */
/* see ovqp/interp.c */
/* 5*/ mdCOPY, /* COPY INTO/FROM relation */
/* 6*/ mdCREATE, /* CREATE new relation */
/* see decomp/reformat.c */
/* 7*/ mdDESTROY, /* DESTROY old relation */
/* 8*/ mdHELP, /* print info on relation */
/* 9*/ mdINDEX, /* create secondary INDEX */
/*10*/ mdMODIFY, /* change access structure of relation */
/* see decomp/reformat.c */
/*11*/ mdPRINT, /* PRINT relation on terminal */
/*12*/ mdRANGE, /* declare RANGE variable */
/*13*/ mdSAVE, /* SAVE relation date */
/*14*/ mdDEFINE, /* "here is a tree", to QRYMOD */
/* see qrymod/d_prot.c */
/*15*/ mdRET_UNI, /* RETRIEVE UNIQUE */
/*16*/ mdVIEW, /* extra info for VIEW definition, to QRYMOD */
/* see support/restore.c */
/*17*/ mdUPDATE, /* update processor */
/*18*/ mdRESETREL, /* modify to truncated */
/*19*/ mdDISPLAY, /* dump QRYMOD declaration */
/*20*/ mdNETQRY, /* reserved for distributed DBS */
/*21*/ mdMOVEREL, /* reserved for distributed DBS */
/*22*/ mdPROT, /* extra info for PERMIT definition, to QRYMOD */
/* see qrymod/d_prot.c */
/* and support/restore.c */
/*23*/ mdINTEG, /* extra info for INTEGRITY def, to QRYMOD */
/* see support/restore.c */
/*24*/ mdDCREATE, /* reserved for distributed DBS */
/*25*/ mdWAITQRY, /* reserved for distributed DBS */
/*26*/ mdREMQM, /* remove PERMIT INTEGRITY definition */
/*27*/ mdDISTRIB /* reserved for distributed DBS */
};
# define ROOT 20 /* ROOT of QUERY TREE */
# define QLEND 21 /* NULL branch at end of QUAL */
/* see decomp/reformat.c */
/* and qrymod/d_prot.c */
# define BYHEAD 22 /* BY LIST HEAD */
# define AGHEAD 23 /* AGGREGATE HEAD */
# define TREE 25 /* SIGNALS BEGINNING of TREE */
/* see decomp/reformat.c */
/* and qrymod/d_prot.c */
# define SITE 26 /* reserved for distributed DBS */
/*define CID 29 ** FOR INTEGRITY CONSTRAINTS */
/*define INT 30 ** INTEGER CONSTANT */
/*define FLOAT 31 ** FLOATING POINT CONSTANT */
/*define CHAR 32 ** CHARACTER CONSTANT */
# define BINARY 33 /* BINARY CONST used in AAprtup */
# define RESULTVAR 40 /* RESULT RELATION VAR NO. */
# define SOURCEID 41 /* SOURCE RELATION NAME(S) */
# define RESULTID 42 /* RESULT RELATION NAME */
# define CHANGESTRAT 50 /* DEVISE OVQP NEW STRATEGY */
# define USERQRY 51 /* tells OVQP that the result */
/* relation is a user relation */
# define EXIT 52 /* tells OVQP that qry is done */
# define ACK 1 /* OVQP should write an */
/* acknowledging EOP */
# define NOACK 2 /* OVQP should not acknowledge */
# define RUBACK 3 /* internal mode for DECOMP */
# define REOPENRES 54 /* OVQP should reopen resrel */
# define RETVAL 55 /* RETURN FROM OVQP */
# define UPDATE -3 /* tells DECOMP to call update */
# define NOUPDATE -2 /* dito, not to call update */
# define EMPTY -1
# define NONEMPTY 0
# define EOTUP 56 /* end of tuple, OVQP to EQL */
/* The following are pattern matching symbols used by OVQP */
# define PAT_ANY 1 /* matches 0 or more char */
# define PAT_ONE 2 /* matches any one char */
# define PAT_LBRAC 3 /* left bracket for chargroups */
# define PAT_RBRAC 4 /* right bracket for chargroups */

View File

@ -0,0 +1,53 @@
/* Conditional compilation flags */
/* */
/* Some of these may be commented out to set them to "off". */
/* The comment should be removed to set them to "on". */
/* */
/* Form: xXTM = timing information (not supported) */
/* xXTR1 = trace level 1 */
/* xXTR2 = trace level 2, implies level 1 */
/* xXTR3 = trace level 3, implies level 1 and 2 */
/* where X = tracing object */
/* */
/* gutil, iutil and access methods compilation flags */
# define xATR1
# define xATR2
# define xATR3
/* decomposition compilation flags */
# define xDTR1
/* LIBQ.A compilation flags */
# define xETR1
# define xETR2
# define xETR3
/* monitor compilation flags */
# define xMTR1
# define xMTR2
# define xMTR3
/* # define xMTRM */ /* macro processor */
/* OVQP compilatiion flags */
# define xOTR1
/* parser compilation flags */
# define xPTR1
# define xPTR2
# define xPTR3
/* qrymod compilation flags */
# define xQTR1
# define xQTR2
# define xQTR3
/* support and sys compilation flags */
# define xSTR1
# define xSTR2
# define xSTR3
/* DBU compilation flags */
# define xZTR1
# define xZTR2
# define xZTR3

View File

@ -0,0 +1,317 @@
# include <stdio.h>
# include "gen.h"
# include "../h/dbs.h"
# include "../h/aux.h"
# include "../h/pipes.h"
# include "../h/tree.h"
# include "../h/symbol.h"
# include "parser.h"
# define BADCOP -1 /* error return on lookup */
int Eql; /* indicates EQL preprocessor on */
/*
** TREE
** FUNCTION TO ADD NODE TO QUERY TREE
** RETURN VALUE IS POINTER TO NODE JUST CREATED
*/
QTREE *tree(lptr, rptr, typ, len, valu1, attnum1)
QTREE *lptr;
QTREE *rptr;
char typ;
int len;
char *valu1;
struct atstash *attnum1;
{
register struct atstash *attnum;
register QTREE *tptr;
register char *valu;
extern char *need();
extern char *AAbmove();
extern QTREE *norm();
# ifdef xPTM
if (AAtTf(76, 2))
timtrace(5);
# endif
attnum = attnum1;
valu = valu1;
tptr = (QTREE *) need(Qbuf, len + QT_HDR_SIZ);
tptr->left = lptr;
tptr->right = rptr;
tptr->sym.type = typ;
tptr->sym.len = len;
switch (typ)
{
case VAR:
((VAR_NODE *) tptr)->varno = (short) valu;
((VAR_NODE *) tptr)->attno = attnum->atbid;
((VAR_NODE *)tptr )->frmt = attnum->atbfrmt;
((VAR_NODE *) tptr)->frml = attnum->atbfrml;
((VAR_NODE *) tptr)->valptr = (char *) 0;
break;
case ROOT:
case AGHEAD:
case BYHEAD:
case AND:
case OR:
case QLEND:
break;
case UOP:
case BOP:
((OP_NODE *) tptr)->opno = (short) valu;
format(tptr);
break;
case COP:
if ((((OP_NODE *) tptr)->opno = getcop(valu)) == BADCOP)
/* bad const operator */
yyerror(BADCONSTOP, valu, (char *) 0);
break;
case AOP:
format(tptr->right);
((AOP_NODE *) tptr)->agfrmt = Trfrmt;
((AOP_NODE *) tptr)->agfrml = Trfrml;
case RESDOM:
((RES_NODE *) tptr)->resno = (short) valu;
format(tptr);
((VAR_NODE *) tptr)->frmt = Trfrmt;
((VAR_NODE *) tptr)->frml = Trfrml;
break;
default:
/* INT, FLOAT, CHAR */
AAbmove(valu, tptr->sym.value, ctou(len));
break;
}
# ifdef xPTM
if (AAtTf(76, 2))
timtrace(6);
# endif
return (tptr);
}
/*
** TREEPR
** TREE PRINT ROUTINE
** CREATES STRING WHERE EACH TARGET LIST ELEMENT AND QUALIFICATION
** CLAUSE IS IN POLISH POSTFIX FORM BUT OVERALL LIST IS IN INFIX
** FORM
*/
treepr(p1)
QTREE *p1;
{
register QTREE *p;
register int l;
extern struct pipfrmt Pipebuf;
p = p1;
if (p->sym.type == ROOT || p->sym.type == BYHEAD)
{
writesym(TREE, 0, (char *) 0);
# ifdef xPTR2
AAtTfp(26, 8, "TREE node\n");
# endif
}
if (p->left)
treepr(p->left);
if (p->right)
treepr(p->right);
if (p->sym.type <= CHAR)
{
# ifdef xPTR2
if (AAtTf(26, 9))
nodewr(p);
# endif
wrpipe(P_NORM, &Pipebuf, W_down, &(p->sym), TYP_LEN_SIZ);
if (l = ctou(p->sym.len))
wrpipe(P_NORM, &Pipebuf, W_down, p->sym.value, l);
return;
}
AAsyserr(18023);
}
# ifdef xPTR1
/*
** NODEWR
** printf a tree node for debugging purposes
*/
nodewr(p1)
QTREE *p1;
{
register QTREE *p;
char str[MAXFIELD + 1];
register char *ptr;
extern char *AAbmove();
p = p1;
printf("addr=0%o, l=0%o, r=0%o, typ=%d, len=%d:\n",
p, p->left, p->right, p->sym.type, p->sym.len);
switch (p->sym.type)
{
case VAR:
printf("\t\tvarno=%d, attno=%d, frmt=%d, frml=%d\n", ((VAR_NODE *) p)->varno, ((VAR_NODE *) p)->attno, ((VAR_NODE *) p)->frmt, ((VAR_NODE *) p)->frml);
break;
case AOP:
printf("\t\taop=%d, frmt=%d, frml=%d\n", ((RES_NODE *) p)->resno, ((VAR_NODE *) p)->frmt, ((VAR_NODE *) p)->frml);
break;
case RESDOM:
printf("\t\trsdmno=%d, frmt=%d, frml=%d\n", ((RES_NODE *) p)->resno, ((VAR_NODE *) p)->frmt, ((VAR_NODE *) p)->frml);
break;
case CHAR:
ptr = AAbmove(p->sym.value, str, ctou(p->sym.len));
*ptr = 0;
printf("\t\tstring=%s\n", str);
break;
case INT:
ptr = (char *) p->sym.value;
switch (p->sym.len)
{
case sizeof (short):
printf("\t\tvalue=%d\n", ((I2TYPE *) ptr)->i2type);
break;
case sizeof (long):
printf("\t\tvalue=%ld\n", ((I4TYPE *) ptr)->i4type);
break;
}
break;
case FLOAT:
ptr = (char *) p->sym.value;
# ifndef NO_F4
switch (p->sym.len)
{
case sizeof (float):
printf("\t\tvalue=%f\n", ((F4TYPE *) ptr)->f4type);
break;
case sizeof (double):
# endif
printf("\t\tvalue=%f\n", ((F8TYPE *) ptr)->f8type);
# ifndef NO_F4
break;
}
# endif
break;
case UOP:
case BOP:
case COP:
printf("\t\top=%d\n", ((OP_NODE *) p)->opno);
break;
}
}
# endif
/*
** WINDUP
** assign resno's to resdoms of an agg fcn
*/
windup(ptr)
QTREE *ptr;
{
register int tot;
register int kk;
register QTREE *t;
/* COUNT THE RESDOM'S OF THIS TARGET LIST */
kk = 1;
for (t = ptr; t; t = t->left)
kk++;
tot = 1;
for (t=ptr; t;t = t->left)
((RES_NODE *) t)->resno = kk - tot++;
}
/*
** ADDRESDOM - makes a new entry for the target list
**
** Trname must contain the name of the resdom to
** use for the header, create and Rsdmno for append, replace
**
** the parameters are pointers to the subtrees to be
** suspended from the node
*/
QTREE *addresdom(lptr, rptr)
QTREE *lptr, *rptr;
{
extern QTREE *tree();
register QTREE *rtval;
register struct atstash *aptr;
char buf[10]; /* buffer type and length in ascii for dbu */
extern struct atstash *attlookup();
switch (Opflag)
{
case mdRETR:
case mdRET_UNI:
case mdVIEW:
Rsdmno++;
if (Rsdmno >= MAXDOM)
/* too many resdoms */
yyerror(RESXTRA, (char *) 0);
rtval = tree(lptr, rptr, RESDOM, RES_SIZ, CAST(Rsdmno));
if (!Eql || Resrng)
{
/* buffer info for header or CREATE */
setp(Trname);
buf[0] = ctou(Trfrmt);
AAsmove(AA_iocv(ctou(Trfrml)), &buf[1]);
setp(buf);
}
break;
default:
/*
** for append and replace, the result domain
** number is determined by the location of
** the attribute in the result relation
*/
if (AAsequal(Trname, "tid"))
/* attrib not found */
yyerror(NOATTRIN, Trname, Resrng->relnm, (char *) 0);
# ifdef DISTRIB
if (AAsequal(Trname, "sid"))
/* attrib not found */
yyerror(NOATTRIN, Trname, Resrng->relnm, (char *) 0);
# endif
aptr = attlookup(Resrng, Trname);
Rsdmno = aptr->atbid;
rtval = tree(lptr, rptr, RESDOM, RES_SIZ, CAST(Rsdmno));
if (Opflag != (int) mdPROT) /* INTEGRITY not possible here */
attcheck(aptr);
break;
}
return (rtval);
}
/*
** GETCOP
** routine to lookup 'string' in constant operators table
** constant table is declared in tables.y
** structure is defined in ../parser.h
*/
getcop(string)
char *string;
{
register struct constop *cpt;
register char *sptr;
extern struct constop Coptab[];
sptr = string;
for (cpt = Coptab; cpt->copname; cpt++)
if (AAsequal(sptr, cpt->copname))
return (cpt->copnum);
return (BADCOP);
}