Exemple #1
0
DB_STATUS
qee_p2_dsh_ddb(
	QEF_RCB		*v_qer_p,
	QEE_DSH		*i_dsh_p)
{
    DB_STATUS	    status = E_DB_OK;
    QEF_CB	    *qecb_p = v_qer_p->qef_cb;
    QEF_QP_CB	    *qp_p = i_dsh_p->dsh_qp_ptr;    /* debugging aid */
    QEQ_DDQ_CB	    *ddq_p = & qp_p->qp_ddq_cb;
    QEE_DDB_CB	    *dde_p = i_dsh_p->dsh_ddb_cb;
    DD_TAB_NAME	    *tmptbl_p = (DD_TAB_NAME *) NULL;
    i4	    *sts_p = (i4 *) NULL;
    i4		    i;
    char	    namebuf[DB_TAB_MAXNAME + 1];
    char	    cur_name[DB_CURSOR_MAXNAME + 1];
    char	    *cbuf = v_qer_p->qef_cb->qef_trfmt;
    i4		    cbufsize = v_qer_p->qef_cb->qef_trsize;


    if (! (qecb_p->qef_c1_distrib & DB_3_DDB_SESS) )
	return(E_DB_OK);    /* NOT a DDB session */

    if (ddq_p->qeq_d3_elt_cnt == 0)
    {
	STprintf(cbuf, 
	    "%s %p: ...     0 temporary tables used by query\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    else
    {
	if (ddq_p->qeq_d3_elt_cnt == 1)
	{
	    STprintf(cbuf, 
		"%s %p: ...     1 temporary table ",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}
	else
	{
	    STprintf(cbuf, 
		"%s %p: ...     %d temporary tables ",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb,
		ddq_p->qeq_d3_elt_cnt);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}
	STprintf(cbuf, "used by query\n");
        qec_tprintf(v_qer_p, cbufsize, cbuf);

	/* print all the temporary table names */

	for (i = 1, tmptbl_p = dde_p->qee_d1_tmp_p,
		    sts_p = dde_p->qee_d2_sts_p;
		i <= ddq_p->qeq_d3_elt_cnt; 
		i++, tmptbl_p++, sts_p++)
	    if (*sts_p & QEE_01M_CREATED)
	    {
		qed_u0_trimtail((char *) tmptbl_p, DB_TAB_MAXNAME, namebuf);
		STprintf(cbuf, 
		    "%s %p: ...     %d) %s\n",
		    IIQE_61_qefsess,
		    (PTR) v_qer_p->qef_cb,
		    i,
		    namebuf);
        	qec_tprintf(v_qer_p, cbufsize, cbuf);
	    }
    }

    if (dde_p->qee_d3_status & QEE_01Q_CSR)
    {
        STprintf(cbuf, 
	    "%s %p: ...     query pertains to a CURSOR\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_02Q_RPT)
    {
        STprintf(cbuf, 
	    "%s %p: ...     this is a REPEAT query\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_03Q_DEF)
    {
        STprintf(cbuf, 
	    "%s %p: ...     query has been DEFINED to the LDB\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_04Q_EOD)
    {
	STprintf(cbuf, 
	    "%s %p: ...     query has NO more retrieved data coming back\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_05Q_CDB)
    {
        STprintf(cbuf, 
"%s %p: ...     retrieval REROUTED thru the CDB, to be committed when done\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_06Q_TDS)
    {
        STprintf(cbuf, 
	    "%s %p: ...     RQF returning a tuple descriptor to SCF\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_07Q_ATT)
    {
        STprintf(cbuf, 
	    "%s %p: ...     tuple descriptor contains attribute names\n",
	    IIQE_61_qefsess,
            (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d4_given_qid.db_cursor_id[0] != 0)
    {
	/* null-terminate name part for printing */

	qed_u0_trimtail( dde_p->qee_d4_given_qid.db_cur_name, DB_CURSOR_MAXNAME,
	    cur_name);

	STprintf(cbuf, 
	    "%s %p: ...     DDB query id: %x %x %s\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb,
	    dde_p->qee_d4_given_qid.db_cursor_id[0],
	    dde_p->qee_d4_given_qid.db_cursor_id[1],
	    cur_name);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }

    if (dde_p->qee_d5_local_qid.db_cursor_id[0] != 0)
    {
	/* null-terminate name part for printing */

	qed_u0_trimtail( dde_p->qee_d5_local_qid.db_cur_name, DB_CURSOR_MAXNAME,
	    cur_name);

	STprintf(cbuf, 
	    "%s %p: ...     LDB (sub)query id: %x %x %s\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb,
	    dde_p->qee_d5_local_qid.db_cursor_id[0],
	    dde_p->qee_d5_local_qid.db_cursor_id[1],
	    cur_name);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }

    if (dde_p->qee_d6_dynamic_cnt > 0)
    {
	if (dde_p->qee_d6_dynamic_cnt == 1)
	{
	    STprintf(cbuf, 
		"%s %p: ...     1 DB_DATA_VALUE ",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}
	else
	{
	    STprintf(cbuf, 
		"%s %p: ...     %d DB_DATA_VALUEs ",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb,
		dde_p->qee_d6_dynamic_cnt);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}
	STprintf(cbuf, "for query\n");
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    if (dde_p->qee_d3_status & QEE_01Q_CSR
	||
	dde_p->qee_d3_status & QEE_02Q_RPT)
    {
	if (dde_p->qee_d3_status & QEE_01Q_CSR)
	{
	    STprintf(cbuf, 
		"%s %p: ...     LDB for this CURSOR query:\n",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}
	else
	{
	    STprintf(cbuf, 
		"%s %p: ...     LDB for this REPEAT query:\n",
		IIQE_61_qefsess,
		(PTR) v_qer_p->qef_cb);
            qec_tprintf(v_qer_p, cbufsize, cbuf);
	}

	/* print the LDB's information */

	status = qed_w1_prt_ldbdesc(v_qer_p, & dde_p->qee_d11_ldbdesc);
    }

    return(E_DB_OK);
}
Exemple #2
0
DB_STATUS
qel_c0_cre_lnk(
QEF_RCB		*v_qer_p ) 
{
    DB_STATUS		status;
    QEF_CB		*qef_cb = v_qer_p->qef_cb;
    QES_DDB_SES		*dds_p = & v_qer_p->qef_cb->qef_c2_ddb_ses;
    QED_DDL_INFO	*ddl_p = & v_qer_p->qef_r3_ddb_req.qer_d7_ddl_info;
    DD_0LDB_PLUS	*plus_p = & ddl_p->qed_d6_tab_info_p->
			    dd_t9_ldb_p->dd_i2_ldb_plus;
    DD_CAPS		*caps_p = & plus_p->dd_p3_ldb_caps;
    DD_LDB_DESC		ldb,		    /* for replicating LDB desc */
			*ldb_p = & ldb,
			*cdb_p = & dds_p->qes_d4_ddb_p->
			    dd_d3_cdb_info.dd_i1_ldb_desc,
			*ddl_ldb_p = & ddl_p->qed_d6_tab_info_p->
			    dd_t9_ldb_p->dd_i1_ldb_desc;
    QEC_D9_TABLEINFO	tabinfo;	    /* used for table info of link */
    QEC_D2_LDBIDS	ldbids;		    /* used for internal LDB id info */
    QEC_D5_LONG_LDBNAMES
			longnames;	    /* used for excessively long LDB
					    ** name */
    QEC_L16_TABLES	tables;		    /* used for IITABLES-style info */
    QEC_D6_OBJECTS	objects;	    /* used for object info */
    QEC_L6_INDEXES	indexes;
    QEC_MIN_CAP_LVLS	pre_mins,
			aft_mins;
    QEC_LINK		link,		    /* used as global control block */
			*link_p = & link;
    QEQ_1CAN_QRY	del,
			ins,
			sel,
			upd,		    /* used for ordering canned query */
			*upd_p = & upd;
    u_i4		len;
    SYSTIME		now;
    bool		log_ddl_56 = FALSE,
			log_err_59 = FALSE;
    i4		i4_1,
			i4_2;
    QEC_INDEX_ID	ndx_ids[QEK_0MAX_NDX_COUNT + 1];
					    /* working space for index ids */
    RQB_BIND		rq_bind[QEC_CAT_COL_COUNT_MAX + 1];
    QEC_D7_OBJECT_BASE	obj_base,
			*base_p = & obj_base;
    i4			xact_mode;
    char		*cbuf = v_qer_p->qef_cb->qef_trfmt;
    i4			cbufsize = v_qer_p->qef_cb->qef_trsize;

    
    if (ult_check_macro(& qef_cb->qef_trace, QEF_TRACE_DDB_LOG_DDL_56,
	    & i4_1, & i4_2))
    {
        log_ddl_56 = TRUE;
    }
    
    if (ult_check_macro(& qef_cb->qef_trace, QEF_TRACE_DDB_LOG_ERR_59,
	    & i4_1, & i4_2))
    {
        log_err_59 = TRUE;
    }
    sel.qeq_c2_rqf_bind_p = rq_bind;		/* must set up */
    del.qeq_c2_rqf_bind_p = (RQB_BIND *) NULL;
    ins.qeq_c2_rqf_bind_p = (RQB_BIND *) NULL;
    upd.qeq_c2_rqf_bind_p = (RQB_BIND *) NULL;

    /* 1.  set up control block */

    if (dds_p->qes_d7_ses_state == QES_4ST_REFRESH)	
						/* REGISTER WITH REFRESH ? */
	STRUCT_ASSIGN_MACRO(ddl_p->qed_d7_obj_id, tabinfo.d9_1_obj_id);
						/* yes */
    else					/* no */
    {
	tabinfo.d9_1_obj_id.db_tab_base = 0;	/* unknown */
	tabinfo.d9_1_obj_id.db_tab_index = 0;	/* always 0 for non-index */
    }
    link_p->qec_1_ddl_info_p = ddl_p;
    link_p->qec_2_tableinfo_p = & tabinfo;
    link_p->qec_3_ldb_id = 0;			
    link_p->qec_4_col_cnt = 0;
    MEfill(DB_DB_MAXNAME, ' ', link_p->qec_5_ldb_alias);
    link_p->qec_6_select_p = & sel;
    link_p->qec_7_ldbids_p = & ldbids;
    link_p->qec_8_longnames_p = & longnames;
    link_p->qec_9_tables_p = & tables;
    link_p->qec_10_haves = QEC_07_CREATE;
    if (caps_p->dd_c6_name_case == DD_2CASE_UPPER)
	link_p->qec_10_haves |= QEC_06_UPPER_LDB;
    if (caps_p->dd_c1_ldb_caps & DD_7CAP_USE_PHYSICAL_SOURCE)
	link_p->qec_10_haves |= QEC_10_USE_PHY_SRC;
    if (caps_p->dd_c2_ldb_caps & DD_201CAP_DIFF_ARCH)
	link_p->qec_10_haves |= QEC_11_LDB_DIFF_ARCH;

    /* make a copy of the LDB descriptor for non-$ingrs access if necessary */

    if (ddl_ldb_p->dd_l1_ingres_b)
    {
	/* make a copy for non-$ingres access */

	STRUCT_ASSIGN_MACRO(*ddl_ldb_p, ldb);
	ldb_p->dd_l1_ingres_b = FALSE;
	ldb_p->dd_l5_ldb_id = DD_0_IS_UNASSIGNED;
    }
    else
    {	
	/* use provided LDB descriptor but determine if LDB has a long name */

	qed_u0_trimtail(
		ddl_ldb_p->dd_l3_ldb_name, 
		(u_i4) DD_256_MAXDBNAME,
		ldb_p->dd_l3_ldb_name);

	len = STlength(ldb_p->dd_l3_ldb_name);
	if (len > DB_DB_MAXNAME)
	    link_p->qec_10_haves |= QEC_04_LONG_LDBNAME;

	ldb_p = ddl_ldb_p;
    }
    link_p->qec_11_ldb_obj_cnt = 0;
    link_p->qec_12_indexes_p = & indexes;
    link_p->qec_13_objects_p = & objects;
    link_p->qec_15_ndx_cnt = 0;
    link_p->qec_16_ndx_ids_p = ndx_ids;
    link_p->qec_19_ldb_p = ldb_p;
    link_p->qec_20_rqf_bind_p = rq_bind;
    link_p->qec_21_delete_p = & del;
    link_p->qec_22_insert_p = & ins;
    link_p->qec_23_update_p = & upd;

    status = qed_u8_gmt_now(v_qer_p, link_p->qec_24_cur_time);
    if (status)
	return(status);

    link_p->qec_24_cur_time[DD_25_DATE_SIZE] = EOS;
    link_p->qec_25_pre_mins_p = & pre_mins;
    link_p->qec_26_aft_mins_p = & aft_mins;
    link_p->qec_27_select_cnt = 0;
    link_p->qec_28_iistats_cnt = 0;
    
    TMnow(& now);
    link_p->qec_17_ts1 = now.TM_secs;
    link_p->qec_18_ts2 = now.TM_msecs;
    
    /* 2.  inform TPF of update intention on CDB (note that only CREATE does
    **	   LDB retrievals */

    /* 2.1 2PC is required if DDL concurrency is off. */
    if (dds_p->qes_d9_ctl_info & QES_01CTL_DDL_CONCURRENCY_ON)
	xact_mode = QEK_4TPF_1PC;
    else
	xact_mode = QEK_3TPF_UPDATE;

    status = qet_t5_register(v_qer_p, cdb_p, DB_SQL, xact_mode);
    if (status)
	return(status);

    if (log_ddl_56)
    {
	/* display beginning, CDB and LDB info */

	STprintf(cbuf, "\n%s %p: %s REGISTRATION begins%s\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb,
	    IIQE_65_tracing,
	    IIQE_62_3dots);
        qec_tprintf(v_qer_p, cbufsize, cbuf);

	STprintf(cbuf, 
	    "%s %p: ...the CDB:\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
	qed_w1_prt_ldbdesc(v_qer_p, cdb_p);

	STprintf(cbuf, 
	    "%s %p: ...the LDB:\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
	qed_w1_prt_ldbdesc(v_qer_p, ldb_p);

	STprintf(cbuf, "\n");
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }
    /* 3.  update OBJECT_BASE in II_DD_DB_OBJECT_BASE */

    upd_p->qeq_c1_can_id = UPD_716_DD_DDB_OBJECT_BASE;
    upd_p->qeq_c3_ptr_u.d7_object_base_p = base_p;
    upd_p->qeq_c4_ldb_p = cdb_p;

    status = qel_u1_update(v_qer_p, link_p);
    if (status)
	goto END_TRACING;

    /* 4.  enter phase 1: set up necessary information */

    status = qel_c1_cre_p1(v_qer_p, link_p);
    if (status)
	goto END_TRACING;

    /* 2.  enter phase 2: promote information into STAR catalogs */

    status = qel_c2_cre_p2(v_qer_p, link_p);
    if (status)
	v_qer_p->qef_cb->qef_abort = TRUE;

END_TRACING:

    if (log_ddl_56)
    {
	/* display end tracing message */

	STprintf(cbuf, 
	    "%s %p: %s REGISTRATION ends\n\n",
	    IIQE_61_qefsess,
	    (PTR) v_qer_p->qef_cb,
	    IIQE_65_tracing);
        qec_tprintf(v_qer_p, cbufsize, cbuf);
    }

    return(status);
}