Annotation of 42BSD/ingres/source/decomp/qryproc.c, revision 1.1

1.1     ! root        1: # include      <ingres.h>
        !             2: # include      <aux.h>
        !             3: # include      <tree.h>
        !             4: # include      <symbol.h>
        !             5: # include      "globs.h"
        !             6: # include      <pv.h>
        !             7: # include      <lock.h>
        !             8: # include      <resp.h>
        !             9: # include      <sccs.h>
        !            10: 
        !            11: SCCSID(@(#)qryproc.c   7.1     2/5/81)
        !            12: 
        !            13: /* Control Module configuration information structure */
        !            14: 
        !            15: extern int de_init();
        !            16: extern int de_rubproc();
        !            17: extern int qryproc();
        !            18: 
        !            19: struct fn_def  DeOvqpFn =
        !            20: {
        !            21:        "DECOMP/OVQP",
        !            22:        qryproc,
        !            23:        de_init,
        !            24:        de_rubproc,
        !            25:        (char *) &De,
        !            26:        sizeof De,
        !            27:        tTdecomp,
        !            28:        100,
        !            29:        'D',
        !            30:        0,
        !            31: };
        !            32: 
        !            33: /*ARGSUSED*/
        !            34: qryproc(pc, pv)
        !            35: int    pc;
        !            36: PARM   *pv;
        !            37: {
        !            38:        register QTREE  *root, *q;
        !            39:        register int    i;
        !            40:        int             mode, result_num, retr_uniq;
        !            41:        extern long     Accuread, Accuwrite, Accusread;
        !            42:        extern int      derror();
        !            43:        char            loc_qbuf[QBUFSIZ];
        !            44: 
        !            45: #      ifdef xDTM
        !            46:        if (tTf(90, 1))
        !            47:                timtrace(23, 0);
        !            48: #      endif
        !            49: #      ifdef xDTR1
        !            50:        if (tTf(50, 0))
        !            51:        {
        !            52:                Accuread = 0;
        !            53:                Accusread = 0;
        !            54:                Accuwrite = 0;
        !            55:        }
        !            56: #      endif
        !            57: 
        !            58:        De.de_qbuf = loc_qbuf;
        !            59:        initbuf(loc_qbuf, QBUFSIZ, QBUFFULL, derror);
        !            60: 
        !            61:        /* init various variables in decomp for start of this query */
        !            62:        startdecomp();
        !            63: 
        !            64:        /* Read in query, range table and mode */
        !            65:        if (pv[0].pv_type != PV_QTREE)
        !            66:                syserr("qryproc: bad parameter");
        !            67:        root = pv[0].pv_val.pv_qtree;
        !            68:        /* a john fix (below)
        !            69:        root->sym.value.sym_root.rootuser = TRUE; */
        !            70: #      ifdef xDTR1
        !            71:        if (tTf(50, 4))
        !            72:        {
        !            73:                printf("qryproc\n");
        !            74:                treepr(root);
        !            75:        }
        !            76: #      endif
        !            77: 
        !            78:        /* initialize qt parameters */
        !            79:        mode = De.de_qmode = Qt.qt_qmode;
        !            80:        De.de_resultvar = Qt.qt_resvar;
        !            81: 
        !            82:        /*
        !            83:        ** Initialize range table. This code should eventually
        !            84:        ** be changed to take advantage of the fact that all
        !            85:        ** the openrs are already done by the control module.
        !            86:        */
        !            87: 
        !            88:        for (i = 0; i < MAXRANGE; i++)
        !            89:        {
        !            90:                if (Qt.qt_rangev[i].rngvdesc != NULL)
        !            91:                {
        !            92:                        De.de_rangev[i].relnum = rnum_assign(Qt.qt_rangev[i].rngvdesc->reldum.relid);
        !            93: 
        !            94:                }
        !            95:        }
        !            96:        /* Initialize relation descriptors */
        !            97:        initdesc(mode);
        !            98: 
        !            99:        /* locate pointers to QLEND and TREE nodes */
        !           100:        for (q = root->right; q->sym.type != QLEND; q = q->right)
        !           101:                continue;
        !           102:        De.de_qle = q;
        !           103: 
        !           104:        for (q = root->left; q->sym.type != TREE; q = q->left)
        !           105:                continue;
        !           106:        De.de_tr = q;
        !           107: 
        !           108: 
        !           109:        /* map the complete tree */
        !           110:        mapvar(root, 0);
        !           111: 
        !           112:        /* set logical locks */
        !           113:        if (Lockrel)
        !           114:                lockit(root, De.de_resultvar);
        !           115: 
        !           116:        /* If there is no result variable then this must be a retrieve to the terminal */
        !           117:        De.de_qry_mode = De.de_resultvar < 0 ? mdRETTERM : mode;
        !           118: 
        !           119:        /* if the mode is retrieve_unique, then make a result rel */
        !           120:        retr_uniq = mode == mdRET_UNI;
        !           121:        if (retr_uniq)
        !           122:        {
        !           123:                mk_unique(root);
        !           124:                mode = mdRETR;
        !           125:        }
        !           126: 
        !           127:        /* get id of result relation */
        !           128:        if (De.de_resultvar < 0)
        !           129:                result_num = NORESULT;
        !           130:        else
        !           131:                result_num = De.de_rangev[De.de_resultvar].relnum;
        !           132: 
        !           133:        /* evaluate aggregates in query */
        !           134:        aggregate(root);
        !           135: 
        !           136:        /* decompose and process aggregate free query */
        !           137:        decomp(root, mode, result_num);
        !           138: 
        !           139:        /* If this is a retrieve unique, then retrieve results */
        !           140:        if (retr_uniq)
        !           141:                pr_unique(root, De.de_resultvar);
        !           142: 
        !           143:        if (mode != mdRETR)
        !           144:                i = ACK;
        !           145:        else
        !           146:                i = NOACK;
        !           147:        i = endovqp(i);
        !           148: 
        !           149: #      ifdef xDTR1
        !           150:        if (tTf(50, 1))
        !           151:        {
        !           152:                printf("DECOMP read %ld pages,", Accuread);
        !           153:                printf("%ld catalog pages,", Accusread);
        !           154:                printf("wrote %ld pages\n", Accuwrite);
        !           155:        }
        !           156: #      endif
        !           157: 
        !           158:        /* call update processor if batch mode */
        !           159:        if (i == UPDATE)
        !           160:        {
        !           161:                initp();
        !           162:                call_dbu(mdUPDATE, -1);
        !           163:        }
        !           164: 
        !           165: #      ifdef xDTM
        !           166:        if (tTf(90, 1))
        !           167:                timtrace(24,0);
        !           168: #      endif
        !           169: 
        !           170:        /* clean decomp */
        !           171:        reinit();
        !           172: 
        !           173:        if (i != UPDATE)
        !           174:                Resp.resp_tups = De.ov_tupsfound;
        !           175: 
        !           176:        return (0);
        !           177: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.