ING_DB
This commit is contained in:
parent
a016ad1af3
commit
a717fcd00f
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* ALL DBS catalog names */
|
||||||
|
/* see gutil/gen.c */
|
||||||
|
|
||||||
|
char AA_ADMIN[] = "admin";
|
||||||
|
char AA_REL[] = "relation ";
|
||||||
|
char AA_ATT[] = "attribute ";
|
||||||
|
char AA_INDEX[] = "indexes ";
|
||||||
|
char AA_INTEG[] = "integrities ";
|
||||||
|
char AA_PROTECT[] = "protect ";
|
||||||
|
char AA_TREE[] = "tree ";
|
||||||
|
char AA_REF[] = "references ";
|
||||||
|
char AA_USERS[] = "/sys/etc/users";
|
||||||
|
char AA_DBS_LOCK[] = "/dev/db_lock";
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/symbol.h"
|
||||||
|
# include "../h/access.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Clr_tuple initializes all character domains
|
||||||
|
** to blank and all numeric domains to zero.
|
||||||
|
*/
|
||||||
|
clr_tuple(d, tuple)
|
||||||
|
register DESC *d;
|
||||||
|
char *tuple;
|
||||||
|
{
|
||||||
|
register char *tup;
|
||||||
|
register int i;
|
||||||
|
register int j;
|
||||||
|
register int pad;
|
||||||
|
|
||||||
|
for (i = 1; i <= d->reldum.relatts; i++)
|
||||||
|
{
|
||||||
|
pad = (d->relfrmt[i] == CHAR)? ' ': 0;
|
||||||
|
tup = &tuple[d->reloff[i]];
|
||||||
|
j = ctou(d->relfrml[i]);
|
||||||
|
|
||||||
|
while (j--)
|
||||||
|
*tup++ = pad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
# include <stdio.h>
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/aux.h"
|
||||||
|
# include "../h/pipes.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** DBS ERROR MESSAGE GENERATOR
|
||||||
|
**
|
||||||
|
** Error message `num' is sent up towards process 1 with param-
|
||||||
|
** eters `msg'. This routine may have any number of parameters,
|
||||||
|
** but the last one must be zero.
|
||||||
|
**
|
||||||
|
** In process one, the appropriate error file is scanned for the
|
||||||
|
** actual message. The parameters are then substituted into that
|
||||||
|
** message. If the error message doesn't exist, then the first
|
||||||
|
** parameter is printed as is.
|
||||||
|
*/
|
||||||
|
# ifdef P8000
|
||||||
|
error(num, msg1, msg2, msg3, msg4, msg5, msg6)
|
||||||
|
# else
|
||||||
|
error(num, msg1)
|
||||||
|
# endif
|
||||||
|
int num;
|
||||||
|
char *msg1;
|
||||||
|
# ifdef P8000
|
||||||
|
char *msg2;
|
||||||
|
char *msg3;
|
||||||
|
char *msg4;
|
||||||
|
char *msg5;
|
||||||
|
char *msg6;
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
register struct pipfrmt *pip;
|
||||||
|
register char **msg;
|
||||||
|
struct pipfrmt pip_buf;
|
||||||
|
extern int W_err;
|
||||||
|
# ifdef P8000
|
||||||
|
char *msg_buf[6];
|
||||||
|
|
||||||
|
msg = msg_buf;
|
||||||
|
*msg++ = msg1;
|
||||||
|
*msg++ = msg2;
|
||||||
|
*msg++ = msg3;
|
||||||
|
*msg++ = msg4;
|
||||||
|
*msg++ = msg5;
|
||||||
|
*msg = msg6;
|
||||||
|
msg = msg_buf;
|
||||||
|
# else
|
||||||
|
msg = &msg1;
|
||||||
|
# endif
|
||||||
|
pip = &pip_buf;
|
||||||
|
wrpipe(P_PRIME, pip, EXEC_ERROR, (char *) 0, 0);
|
||||||
|
pip->err_id = num;
|
||||||
|
|
||||||
|
if (W_err >= 0)
|
||||||
|
{
|
||||||
|
while (*msg)
|
||||||
|
wrpipe(P_NORM, pip, W_err, *msg++, 0);
|
||||||
|
wrpipe(P_END, pip, W_err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (num);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/bs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** GAMMA -- log gamma function
|
||||||
|
**
|
||||||
|
** Version seven does not define this routine, so here it
|
||||||
|
** is. Actually it just AAsyserr's.
|
||||||
|
*/
|
||||||
|
double gamma()
|
||||||
|
{
|
||||||
|
AAsyserr(15000);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
** GLOBALS -- DBS globals which belong everywhere
|
||||||
|
**
|
||||||
|
** Variables in this module should be included by everything
|
||||||
|
** DBS knows about. The real purpose of this module is
|
||||||
|
** so that actual definition of space can occur here (and
|
||||||
|
** everything can be 'extern' everywhere else).
|
||||||
|
**
|
||||||
|
** Defines:
|
||||||
|
** AAlockdes -- the lock descriptor for the concurrency
|
||||||
|
** device.
|
||||||
|
*/
|
||||||
|
int AAlockdes = -1; /* the concurrency device descriptor */
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/aux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** OUTPUT ARGUMENTS GLOBAL INITIALIZATION
|
||||||
|
*/
|
||||||
|
struct out_arg AAout_arg =
|
||||||
|
{
|
||||||
|
6, /* c0width */
|
||||||
|
6, /* i1width */
|
||||||
|
6, /* i2width */
|
||||||
|
13, /* i4width */
|
||||||
|
# ifndef NO_F4
|
||||||
|
10, /* f4width */
|
||||||
|
# endif
|
||||||
|
10, /* f8width */
|
||||||
|
# ifndef NO_F4
|
||||||
|
3, /* f4prec */
|
||||||
|
# endif
|
||||||
|
3, /* f8prec */
|
||||||
|
# ifndef NO_F4
|
||||||
|
'n', /* f4style */
|
||||||
|
# endif
|
||||||
|
'n', /* f8style */
|
||||||
|
66, /* linesperpage */
|
||||||
|
'|', /* coldelim */
|
||||||
|
'-', /* linedelim */
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/aux.h"
|
||||||
|
# include "../h/catalog.h"
|
||||||
|
# include "../h/access.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** get access parameters of a relation from its descriptor and return
|
||||||
|
** them in struct pointed to by "ap".
|
||||||
|
*/
|
||||||
|
AAdparam(d, ap)
|
||||||
|
register DESC *d;
|
||||||
|
register struct accessparam *ap;
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
register int p;
|
||||||
|
|
||||||
|
ap->mode = AAgetmode(ctoi(d->reldum.relspec));
|
||||||
|
ap->sec_index = FALSE; /* indicate that this isn't the index-rel */
|
||||||
|
|
||||||
|
for (i = 0; i < MAXDOM + 1; i++)
|
||||||
|
ap->keydno[i] = 0;
|
||||||
|
|
||||||
|
for (p = 1; p <= d->reldum.relatts; p++)
|
||||||
|
if (i = d->relxtra[p])
|
||||||
|
ap->keydno[i - 1] = p;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AAiparam(d, ap)
|
||||||
|
register struct index *d;
|
||||||
|
register struct accessparam *ap;
|
||||||
|
{
|
||||||
|
ap->mode = AAgetmode(ctoi(d->irelspeci));
|
||||||
|
ap->sec_index = TRUE; /* this is an index */
|
||||||
|
|
||||||
|
AAbmove(d->idom, ap->keydno, MAXKEYS);
|
||||||
|
ap->keydno[MAXKEYS] = 0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AAgetmode(spec)
|
||||||
|
register int spec;
|
||||||
|
{
|
||||||
|
switch (abs(spec))
|
||||||
|
{
|
||||||
|
case M_HEAP:
|
||||||
|
return (NOKEY);
|
||||||
|
|
||||||
|
case M_ISAM:
|
||||||
|
return (LRANGEKEY);
|
||||||
|
|
||||||
|
case M_HASH:
|
||||||
|
return (EXACTKEY);
|
||||||
|
|
||||||
|
default:
|
||||||
|
AAsyserr(15018, spec);
|
||||||
|
}
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** PRINT RELATION DESCRIPTOR (for debugging)
|
||||||
|
**
|
||||||
|
** A pointer of a file descriptor is passed. All pertinent
|
||||||
|
** info in that descriptor is printed on the standard output.
|
||||||
|
**
|
||||||
|
** For debugging purposes only
|
||||||
|
*/
|
||||||
|
|
||||||
|
AAprdesc(d)
|
||||||
|
register DESC *d;
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
register int end;
|
||||||
|
|
||||||
|
printf("Descriptor 0%o %.12s %.2s\n",
|
||||||
|
d, d->reldum.relid, d->reldum.relowner);
|
||||||
|
printf("\tspec %d, indxd %d, stat 0%o\n",
|
||||||
|
ctoi(d->reldum.relspec), ctoi(d->reldum.relindxd), d->reldum.relstat);
|
||||||
|
printf("\tsave %ld, tups %ld, atts %d, wid %d, prim %ld\n",
|
||||||
|
d->reldum.relsave, d->reldum.reltups, d->reldum.relatts,
|
||||||
|
d->reldum.relwid, d->reldum.relprim);
|
||||||
|
printf("\tfp %d, opn %d, tid %ld, adds %ld\n",
|
||||||
|
d->relfp, d->relopn, d->reltid, d->reladds);
|
||||||
|
|
||||||
|
end = d->reldum.relatts;
|
||||||
|
for (i = 0; i <= end; i++)
|
||||||
|
printf("\t[%2d] off %3d frmt %2d frml %3d, xtra %3d, given %04o\n",
|
||||||
|
i, d->reloff[i], d->relfrmt[i],
|
||||||
|
ctou(d->relfrml[i]), d->relxtra[i], d->relgiven[i]);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/tree.h"
|
||||||
|
# include "../h/symbol.h"
|
||||||
|
# include "../h/aux.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** TRBUILD -- Rebuild a tree in memory
|
||||||
|
**
|
||||||
|
** Trbuild is called with a pointer to the TREE node of
|
||||||
|
** a query already in memory. It rebuilds the pointer
|
||||||
|
** structure assuming the querytree is in postfix order.
|
||||||
|
**
|
||||||
|
** Parameters:
|
||||||
|
** p - a pointer to the TREE node
|
||||||
|
**
|
||||||
|
** Returns:
|
||||||
|
** (QTREE *) 0 - Internal stack overflow (STACKSIZ)
|
||||||
|
** pointer to the ROOT node
|
||||||
|
**
|
||||||
|
** Side Effects:
|
||||||
|
** All left & right pointers are rebuilt.
|
||||||
|
*/
|
||||||
|
QTREE *trbuild(p)
|
||||||
|
register char *p; /* really ptr to QTREE */
|
||||||
|
{
|
||||||
|
register QTREE **stackptr;
|
||||||
|
register SYMBOL *s;
|
||||||
|
QTREE *treestack[STACKSIZ];
|
||||||
|
|
||||||
|
stackptr = treestack;
|
||||||
|
|
||||||
|
for ( ; ; p += QT_HDR_SIZ + ctou(ALIGNMENT(ctou(s->len))))
|
||||||
|
{
|
||||||
|
s = &((QTREE *) p)->sym;
|
||||||
|
((QTREE *) p)->left = ((QTREE *) p)->right = (QTREE *) 0;
|
||||||
|
|
||||||
|
/* reunite p with left and right children on stack, if any*/
|
||||||
|
if (!leaf(p)) /* this node has children */
|
||||||
|
{
|
||||||
|
if (s->type != UOP)
|
||||||
|
if (stackptr <= treestack)
|
||||||
|
{
|
||||||
|
err:
|
||||||
|
AAsyserr(15038);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
((QTREE *) p)->right = *(--stackptr);
|
||||||
|
if (s->type != AOP)
|
||||||
|
if (stackptr <= treestack)
|
||||||
|
goto err;
|
||||||
|
else
|
||||||
|
((QTREE *) p)->left = *(--stackptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If this is a ROOT node then the tree is complete.
|
||||||
|
** verify that there are no extra nodes in the
|
||||||
|
** treestack.
|
||||||
|
*/
|
||||||
|
if (s->type == ROOT) /* root node */
|
||||||
|
{
|
||||||
|
if (stackptr != treestack)
|
||||||
|
AAsyserr(15039);
|
||||||
|
return ((QTREE *) p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stack p */
|
||||||
|
if (stackptr-treestack >= STACKSIZ)
|
||||||
|
return ((QTREE *) 0); /* error:stack full */
|
||||||
|
*(stackptr++) = (QTREE *) p;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
leaf(p)
|
||||||
|
register QTREE *p;
|
||||||
|
{
|
||||||
|
switch (p->sym.type)
|
||||||
|
{
|
||||||
|
case VAR:
|
||||||
|
case TREE:
|
||||||
|
case QLEND:
|
||||||
|
case INT:
|
||||||
|
case FLOAT:
|
||||||
|
case CHAR:
|
||||||
|
case COP:
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** TRIM_RELNAME -- trim blanks from relation name for printing
|
||||||
|
**
|
||||||
|
** A relation name (presumably in 'AAdbname' format: MAXNAME
|
||||||
|
** characters long with no terminating null byte) has the
|
||||||
|
** trailing blanks trimmed off of it into a local buffer, so
|
||||||
|
** that it can be printed neatly.
|
||||||
|
**
|
||||||
|
** Parameters:
|
||||||
|
** name -- a pointer to the relation name
|
||||||
|
**
|
||||||
|
** Returns:
|
||||||
|
** a pointer to the trimmed relation name.
|
||||||
|
*/
|
||||||
|
char *trim_relname(name)
|
||||||
|
register char *name;
|
||||||
|
{
|
||||||
|
static char trimname[MAXNAME + 1];
|
||||||
|
register char *new;
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
new = trimname;
|
||||||
|
i = MAXNAME;
|
||||||
|
|
||||||
|
while (i--)
|
||||||
|
if ((*new++ = *name++) == ' ')
|
||||||
|
{
|
||||||
|
new--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*new = '\0';
|
||||||
|
|
||||||
|
return (trimname);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
# include "gen.h"
|
||||||
|
# include "../h/dbs.h"
|
||||||
|
# include "../h/access.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** the buffer, PGSIZE
|
||||||
|
** place for one more tuple, MAXTUP - 1
|
||||||
|
** and the HASH-key, sizeof (long), see dbu/dbu___s.c
|
||||||
|
*/
|
||||||
|
char Tup_buf[TUP_BUF_SIZ];
|
||||||
|
char *Tup_ptr = Tup_buf; /* the actual buffer position */
|
||||||
|
short Tup_size = 0; /* the length of written tuple's */
|
||||||
|
int Tup_fd = -1; /* the write descriptor of the tuple file */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** tup_read -- read one tuple
|
||||||
|
**
|
||||||
|
** tup_fd is the file descriptor from which to read
|
||||||
|
** tup_ptr points to the actual tuple
|
||||||
|
** tup_end points to the first invalid byte
|
||||||
|
** tup_len is the size of tup_buf without the space
|
||||||
|
** for the additional tuple
|
||||||
|
** tup_no is untouched
|
||||||
|
*/
|
||||||
|
char *tup_read(hdr)
|
||||||
|
register struct tup_hdr *hdr;
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
register char *end;
|
||||||
|
extern char *AAbmove();
|
||||||
|
|
||||||
|
hdr->tup_ptr += Tup_size;
|
||||||
|
|
||||||
|
if ((i = (end = hdr->tup_end) - hdr->tup_ptr) < Tup_size)
|
||||||
|
{
|
||||||
|
end = (i > 0)? AAbmove(hdr->tup_ptr, hdr->tup_buf, i): hdr->tup_buf;
|
||||||
|
hdr->tup_ptr = hdr->tup_buf;
|
||||||
|
|
||||||
|
if ((i = read(hdr->tup_fd, end, hdr->tup_len)) < 0)
|
||||||
|
AAsyserr(15042);
|
||||||
|
|
||||||
|
end += i;
|
||||||
|
hdr->tup_end = end;
|
||||||
|
|
||||||
|
if (!(i = end - hdr->tup_ptr))
|
||||||
|
return ((char *) 0); /* EOF */
|
||||||
|
|
||||||
|
if (i < Tup_size)
|
||||||
|
AAsyserr(15043, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (hdr->tup_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** tup_write -- write one tuple
|
||||||
|
**
|
||||||
|
** there is always space for at least one tuple in the buffer
|
||||||
|
*/
|
||||||
|
tup_write(tup)
|
||||||
|
register char *tup;
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
register char *ptr;
|
||||||
|
extern char *AAbmove();
|
||||||
|
|
||||||
|
ptr = AAbmove(tup, Tup_ptr, Tup_size);
|
||||||
|
if ((i = ptr - &Tup_buf[PGSIZE]) >= 0)
|
||||||
|
{
|
||||||
|
if (write(Tup_fd, ptr = Tup_buf, PGSIZE) != PGSIZE)
|
||||||
|
AAsyserr(15044);
|
||||||
|
|
||||||
|
if (i)
|
||||||
|
ptr = AAbmove(&Tup_buf[PGSIZE], ptr, i);
|
||||||
|
}
|
||||||
|
Tup_ptr = ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** tup_close -- close the write descriptor of the tuple file
|
||||||
|
**
|
||||||
|
** flush's the buffer
|
||||||
|
*/
|
||||||
|
tup_close()
|
||||||
|
{
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
if ((i = Tup_ptr - Tup_buf) && write(Tup_fd, Tup_ptr = Tup_buf, i) != i)
|
||||||
|
AAsyserr(15045);
|
||||||
|
|
||||||
|
close(Tup_fd);
|
||||||
|
Tup_fd = -1;
|
||||||
|
Tup_ptr = Tup_buf;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue