1: # include   "../ingres.h"
   2: # include   "../aux.h"
   3: # include   "../pipes.h"
   4: # include   "../tree.h"
   5: # include   "../symbol.h"
   6: # include   "../catalog.h"
   7: # include   "qrymod.h"
   8: 
   9: 
  10: 
  11: /*
  12: **  D_VIEW -- define view
  13: **
  14: **	This procedure connects the tree in with the relation catalog
  15: **	and inserts the view tree into the tree catalog.
  16: **
  17: **	The information in the pipe is expected to come as follows:
  18: **		create for view, with S_VIEW bit set so that a
  19: **			physical relation is not created.
  20: **		define tree, which will put the translation tree
  21: **			into the 'tree' catalog.
  22: **		define view, which will connect the two together.
  23: **			The first two absolutely must be done before
  24: **			this step can be called.
  25: **
  26: **	Parameters:
  27: **		none
  28: **
  29: **	Returns:
  30: **		none
  31: **
  32: **	Side Effects:
  33: **		I/O in 'tree' catalog.
  34: **
  35: **	Requires:
  36: **		rdpipe -- to get parameters.
  37: **		Treeroot -- a ptr to the defintion tree.
  38: **		Pipe -- R_up pipe block.
  39: **		puttree -- to output the tree to the tree catalog.
  40: **		Rangev, Qmode, Resultvar -- for parameter validation.
  41: **
  42: **	Called By:
  43: **		define
  44: **
  45: **	Trace Flags:
  46: **		39
  47: **
  48: **	Diagnostics:
  49: **		none
  50: **
  51: **	Syserrs:
  52: **		On inconsistancies in system catalogs.
  53: **
  54: **	History:
  55: **		2/19/79 (eric) -- split from define.c.
  56: */
  57: 
  58: extern QTREE            *Treeroot;
  59: extern struct descriptor    Reldes;
  60: extern struct pipfrmt       Pipe;
  61: 
  62: 
  63: 
  64: 
  65: d_view()
  66: {
  67:     char        viewid[MAXNAME + 1];
  68:     struct relation relkey, reltup;
  69:     register QTREE  *t;
  70:     register int    i;
  71:     struct tup_id   tid;
  72:     int     treeid;
  73: 
  74:     /*
  75: 	**  Read parameters.
  76: 	**	Only parameter is view name (which must match the
  77: 	**	name of the Resultvar).
  78: 	*/
  79: 
  80:     if (rdpipe(P_NORM, &Pipe, R_up, viewid, 0) > MAXNAME + 1)
  81:         syserr("d_view: rdpipe");
  82:     pad(viewid, MAXNAME);
  83: 
  84:     /* done with pipe... */
  85:     rdpipe(P_SYNC, &Pipe, R_up);
  86: 
  87: #	ifdef xQTR3
  88:     /* do some extra validation */
  89:     if (Treeroot == NULL)
  90:         syserr("d_view: NULL Treeroot");
  91:     if (Qmode != mdDEFINE)
  92:         syserr("d_view: Qmode %d", Qmode);
  93:     if (Resultvar < 0)
  94:         syserr("d_view: Rv %d", Resultvar);
  95:     if (!Rangev[Resultvar].rused || !bequal(Rangev[Resultvar].relid, viewid, MAXNAME))
  96:         syserr("d_view: rangev %d %.14s", Rangev[Resultvar].rused,
  97:             Rangev[Resultvar].relid);
  98: #	endif
  99: 
 100:     Rangev[Resultvar].rused = FALSE;
 101:     Resultvar = -1;
 102:     Qmode = -1;
 103: 
 104:     /* output tree to tree catalog */
 105:     treeid = puttree(Treeroot, viewid, Usercode, mdVIEW);
 106: 
 107:     /* clear Treeroot to detect some errors */
 108:     Treeroot = NULL;
 109: }

Defined functions

d_view defined in line 65; used 1 times
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2789
Valid CSS Valid XHTML 1.0 Strict