|
|
1.1 root 1: # include <ingres.h>
2: # include <symbol.h>
3: # include <tree.h>
4: # include <sccs.h>
5:
6: SCCSID(@(#)mapvars.c 7.1 2/5/81)
7:
8: /*
9: ** MAPVARS -- remap varno's to be unique in 'tree' tree
10: **
11: ** A tree is scanned for VAR nodes; when found, the
12: ** mapping defined in Qt.qt_remap[] is applied. This is done so that
13: ** varno's as defined in trees in the 'tree' catalog will be
14: ** unique with respect to varno's in the user's query tree. For
15: ** example, if the view definition uses variable 1 and the user's
16: ** query also uses variable 1, the routine 'readqry' will (after
17: ** calling 'declare' to assign a new slot), put the index of this
18: ** new slot into the corresponding entry of Qt.qt_remap;
19: ** in this example, Qt.qt_remap[1] == 3. This routine does the actual
20: ** mapping in the tree.
21: **
22: ** Parameters:
23: ** tree -- pointer to tree to be remapped.
24: **
25: ** Returns:
26: ** none
27: **
28: ** Side Effects:
29: ** the tree pointed to by 'tree' is modified according
30: ** to Qt.qt_remap[].
31: **
32: ** Trace Flags:
33: ** 7.4-7.7
34: */
35:
36: mapvars(tree)
37: QTREE *tree;
38: {
39: register QTREE *t;
40: register int i;
41:
42: t = tree;
43: # ifdef xQTR3
44: if (tTf(7, 4) && t != NULL && t->sym.type == ROOT)
45: {
46: printf("mapvars:");
47: treepr(t);
48: for (i = 0; i < MAXVAR + 1; i++)
49: if (Qt.qt_rangev[i].rngvdesc != NULL && Qt.qt_remap[i] >= 0)
50: printf("\t%d => %d\n", i, Qt.qt_remap[i]);
51: }
52: # endif
53:
54: while (t != NULL)
55: {
56: /* map right subtree */
57: mapvars(t->right);
58:
59: /* check this node */
60: if (t->sym.type == VAR)
61: t->sym.value.sym_var.varno = Qt.qt_remap[t->sym.value.sym_var.varno];
62:
63: /* map left subtree (iteratively) */
64: t = t->left;
65: }
66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.