1: # include "../ingres.h" 2: # include "../symbol.h" 3: # include "../tree.h" 4: # include "decomp.h" 5: 6: 7: mk_unique(root) 8: struct querytree *root; 9: 10: /* 11: ** create a result relation for a ret_unique 12: */ 13: 14: { 15: register int i, domcnt; 16: register struct querytree *r; 17: 18: r = root; 19: 20: /* verify that target list is within range */ 21: domcnt = r->left->sym.type != TREE ? ((struct qt_res *)r->left)->resno : 0; 22: if (findwid(r) > MAXTUP || domcnt > MAXDOM) 23: derror(4620); 24: i = MAXRANGE - 1; 25: Rangev[i].relnum = mak_t_rel(r, "u", -1); 26: Resultvar = i; 27: 28: /* don't count retrieve into portion as a user query */ 29: ((struct qt_root *)r)->rootuser = 0; 30: } 31: 32: 33: pr_unique(root1, var1) 34: struct querytree *root1; 35: int var1; 36: 37: /* 38: ** Retrieve all domains of the variable "var". 39: ** This routine is used for ret_unique to retrieve 40: ** the result relation. First duplicates are removed 41: ** then the original tree is converted to be a 42: ** retrieve of all domains of "var", and then 43: ** ovqp is called to retrieve the relation. 44: */ 45: 46: { 47: register struct querytree *root, *r; 48: register int var; 49: extern struct querytree *makavar(); 50: 51: root = root1; 52: var = var1; 53: 54: /* remove duplicates from the unopened relation */ 55: removedups(var); 56: 57: /* remove the qual from the tree */ 58: root->right = Qle; 59: 60: /* make all resdoms refer to the result relation */ 61: for (r = root->left; r->sym.type != TREE; r = r->left) 62: r->right = makavar(r, var, ((struct qt_res *)r)->resno); 63: 64: /* count as a user query */ 65: ((struct qt_root *)root)->rootuser = TRUE; 66: 67: /* run the retrieve */ 68: Sourcevar = var; 69: Newq = Newr = TRUE; 70: call_ovqp(root, mdRETR, NORESULT); 71: }