Ejemplo n.º 1
0
DB_STATUS
qet_t5_register(
QEF_RCB         *v_qer_p,
DD_LDB_DESC	*i_ldb_p,
DB_LANG		i_lang,
i4		i_mode)
{
    DB_STATUS	    status;
    QES_DDB_SES	    *dds_p = & v_qer_p->qef_cb->qef_c2_ddb_ses;
    TPR_CB	    tpr_cb,
		    *tpr_p = & tpr_cb;
    i4		    tpf_opcode;


    if (! (i_lang == DB_SQL || i_lang == DB_QUEL))
    {
	status = qed_u1_gen_interr(& v_qer_p->error);
	return(status);
    }

    MEfill(sizeof(tpr_cb), '\0', (PTR) & tpr_cb);
    tpr_p->tpr_session = dds_p->qes_d2_tps_p;	/* TPF session cb ptr */
    tpr_p->tpr_rqf = dds_p->qes_d3_rqs_p;	/* RQF session cb ptr */
    tpr_p->tpr_site = i_ldb_p;
    tpr_p->tpr_lang_type = i_lang;

    switch (i_mode)
    {
    case QEK_2TPF_READ:
    case QEK_4TPF_1PC:
	tpf_opcode = TPF_READ_DML;
	break;
    case QEK_3TPF_UPDATE:
	tpf_opcode = TPF_WRITE_DML;
	break;
    default:
	status = qed_u1_gen_interr(& v_qer_p->error);
	return(status);
    }

    status = qed_u17_tpf_call(tpf_opcode, tpr_p, v_qer_p);

    return(status);
}
Ejemplo n.º 2
0
DB_STATUS
qel_31_std_cats(
QEF_RCB		*i_qer_p, 
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status;
    QED_DDL_INFO    *ddl_p = v_lnk_p->qec_1_ddl_info_p;


    if (v_lnk_p->qec_10_haves & QEC_08_NO_IITABLES)
    {
	/* must be index from non-ingres gateway */

	if (
		(! (v_lnk_p->qec_10_haves & QEC_03_INGRES))
		||
		(ddl_p->qed_d6_tab_info_p->dd_t3_tab_type != DD_4OBJ_INDEX)
	    )
	{
	    status = qed_u1_gen_interr(& i_qer_p->error);
	    return(status);
	}
    }
    else if (ddl_p->qed_d6_tab_info_p->dd_t3_tab_type != DD_5OBJ_REG_PROC)
    {
	
	/* 1.  promote into IIDD_TABLES unless it is a registered procedure */

	status = qel_32_tables(i_qer_p, v_lnk_p);
	if (status)
	    return(status);

	/* 2.  promote into IIDD_COLUMNS */

	status = qel_33_columns(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
    }

    if ( (ddl_p->qed_d6_tab_info_p->dd_t3_tab_type != DD_3OBJ_VIEW) &&
	 (ddl_p->qed_d6_tab_info_p->dd_t3_tab_type != DD_5OBJ_REG_PROC)
       )
    {
	/* 4.  promote into IIDD_ALT_COLUMNS */

	status = qel_34_altcols(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
    }

    if (ddl_p->qed_d9_reg_info_p != NULL)	/* query text to insert 
						** into iidd_registrations */
	status = qel_35_registrations(i_qer_p, v_lnk_p);

    return(status);
}    
Ejemplo n.º 3
0
DB_STATUS
qel_c1_cre_p1(
QEF_RCB		*v_qer_p,
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status;
    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_LDB_DESC	    *ldb_p = v_lnk_p->qec_19_ldb_p;
    bool	    obj_id_b = TRUE;	/* assume new object id required */


    /*  1.  determine if LDB is INGRES */

    if (
	(MEcmp(
		ldb_p->dd_l4_dbms_name, 
		IIQE_c6_cap_ingres, 
		QEK_005_LEN) == 0)
	||
	(MEcmp(
		ldb_p->dd_l4_dbms_name, 
		IIQE_c5_low_ingres, 
		QEK_005_LEN) == 0)
       )
	v_lnk_p->qec_10_haves |= QEC_03_INGRES;

    /*	2.  retrieve existing OBJECT_BASE from IIDD_DDB_OBJECT_BASE */

    if (dds_p->qes_d7_ses_state == QES_4ST_REFRESH
	&&
	ddl_p->qed_d6_tab_info_p->dd_t3_tab_type != DD_4OBJ_INDEX)
				/* REFRESH LINK ? */
	obj_id_b = FALSE;	/* Yes, retain original object id */

    if (obj_id_b)
    {
	/* retrieve the new object id as required */

	status = qel_c3_obj_base(v_qer_p, v_lnk_p);
	if (status)
	    return(status);
    }

    /*	3.  retrieve the LDB's id from IIDD_DDB_LDBIDS if it exists */

    if (v_lnk_p->qec_10_haves & QEC_04_LONG_LDBNAME)
	status = qel_c5_ldbid_long(v_qer_p, v_lnk_p);	
    else
	status = qel_c4_ldbid_short(FALSE, v_qer_p, v_lnk_p);	
					    /* FALSE for no database alias */
    if (status)
	return(status);

    v_lnk_p->qec_3_ldb_id = v_lnk_p->qec_7_ldbids_p->d2_5_ldb_id;

    /*	4.  retrieve the table's information from the LDB's IITABLES */

    status = qel_c6_ldb_tables(v_qer_p, v_lnk_p);	
    if (status)
	return(status);

    /*	5.  if the LDB is a new participant, do:
    **	
    **	    determine if it has an excessively long name, 
    **	    retrieve information about existence of user names, dba name, and
    **	    compute the minimum levels of LDB capabilities existing
    **	    in IIDD_DDB_LDB_DBCAPS */

    if (v_lnk_p->qec_3_ldb_id == 0)
    {
	if (v_lnk_p->qec_1_ddl_info_p->qed_d6_tab_info_p->
	    dd_t9_ldb_p->dd_i1_ldb_desc.dd_l3_ldb_name[0] == ' ')
	{
	    status = qed_u1_gen_interr(& v_qer_p->error);
	    return(status);
	}

	status = qel_c7_ldb_chrs(v_qer_p, v_lnk_p);
	if (status)
	    return(status);

	status = qel_a1_min_cap_lvls(TRUE, v_qer_p, v_lnk_p); 
						/* TRUE for filling what
						** qec_25_pre_mins_p points
						** at */
    }

    return(status);
}
Ejemplo n.º 4
0
DB_STATUS
qeq_c4_open(
QEF_RCB		*v_qer_p,
QEE_DSH		*v_dsh_p )
{
    DB_STATUS	    status = E_DB_OK;
    QEF_CB	    *qef_cb = v_qer_p->qef_cb;
    QEF_AHD	    *act_p = (QEF_AHD *) NULL,
		    *def_act_p = (QEF_AHD *) NULL;
    i4		    def_act_cnt = 0,
		    get_act_cnt = 0,
		    lnk_act_cnt = 0;
    QEQ_D1_QRY	    *sub_p = (QEQ_D1_QRY *) NULL;
    bool	    read_b = FALSE,
		    last_b = FALSE,
		    val_qp_51 = FALSE,
		    log_qry_55 = FALSE,
                    log_err_59 = FALSE;
    i4         i4_1, i4_2;


    if (ult_check_macro(& v_qer_p->qef_cb->qef_trace, QEF_TRACE_DDB_LOG_QRY_55,
        & i4_1, & i4_2))
    {
        log_qry_55 = TRUE;
        qeq_p31_opn_csr(v_qer_p, v_dsh_p);;
    }
    if (ult_check_macro(& v_qer_p->qef_cb->qef_trace, QEF_TRACE_DDB_LOG_ERR_59,
        & i4_1, & i4_2))
        log_err_59 = TRUE;

    /* verify that the following conditions are true of the query plan:
    **
    **  1)  there is exactly one last QEA_D7_OPN action,
    **  2)  there are no QEA_D2_GET, QEA_D4_LNK actions,
    **  3)  there are no read actions  */

    act_p = v_dsh_p->dsh_qp_ptr->qp_ahd; 

    while (act_p != (QEF_AHD *) NULL)
    {
	if (act_p->ahd_atype == QEA_D7_OPN)
	{
	    def_act_cnt++;
	    if (act_p->ahd_next == (QEF_AHD *) NULL)
		last_b = TRUE;
	}
	else if (act_p->ahd_atype == QEA_D2_GET)
	    get_act_cnt++;
	else if (act_p->ahd_atype == QEA_D4_LNK)
	    lnk_act_cnt++;
	else if (act_p->ahd_atype == QEA_D1_QRY)
	{
	    sub_p = & act_p->qhd_obj.qhd_d1_qry;
	    if (sub_p->qeq_q3_ctl_info & QEQ_001_READ_TUPLES)
		read_b = TRUE;
	}
	act_p = act_p->ahd_next;
    }
	
    if (! last_b || def_act_cnt != 1 || get_act_cnt != 0 || 
	lnk_act_cnt != 0 || read_b)
    {
	if (log_err_59 && !log_qry_55)
	    qeq_p31_opn_csr(v_qer_p, v_dsh_p);;

	status = qed_u2_set_interr(E_QE1999_BAD_QP, & v_qer_p->error);
	return(status);
    }

    qee_d1_qid(v_dsh_p);			/* generate query id for
						** sending to LDB */
    /* process each action in the QP */

    for (act_p = v_dsh_p->dsh_qp_ptr->qp_ahd; 
	 act_p != (QEF_AHD *)NULL; 
	 act_p = act_p->ahd_next)
    {
	/* check for deferred cursor, only one at a time is allowed */
	if (act_p->ahd_flags & QEA_DEF)
	{
	    v_dsh_p->dsh_qp_status |= DSH_DEFERRED_CURSOR;
	    if (qef_cb->qef_defr_curs)
	    {
		qed_u10_trap();
		v_qer_p->error.err_code = E_QE0026_DEFERRED_EXISTS;
		return(E_DB_ERROR);
	    }
	}

	switch (act_p->ahd_atype)
	{
	case QEA_D1_QRY:
	case QEA_D8_CRE:
	case QEA_D9_UPD:
	    status = qeq_d1_qry_act(v_qer_p, & act_p);
	    if (status)
		qed_u10_trap();
	    break;
	case QEA_D3_XFR:
	    status = qeq_d5_xfr_act(v_qer_p, act_p);
	    if (status)
		qed_u10_trap();
	    break;
	case QEA_D6_AGG:
	    status = qeq_d10_agg_act(v_qer_p, act_p);
	    if (status)
		qed_u10_trap();
	    break;
	case QEA_D7_OPN:
	    def_act_p = act_p;		/* keep track */

	    status = qeq_d8_def_act(v_qer_p, act_p);
	    if (status)
		qed_u10_trap();
	    break;
	default:
	    status = qed_u1_gen_interr(& v_qer_p->error);
	    qed_u10_trap();
	    break;
	}
	if (! status)
	    v_dsh_p->dsh_act_ptr = act_p;	/* promote to current dsh */
    }

    /* cleanup done by caller */

    v_dsh_p->dsh_act_ptr = def_act_p;    /* pt to define action */
    return (status);
}
Ejemplo n.º 5
0
DB_STATUS
qeq_c3_fetch(
QEF_RCB	    *v_qer_p,
QEE_DSH	    *i_dsh_p )
{
    DB_STATUS	    status = E_DB_OK;
    QES_DDB_SES	    *dds_p = & v_qer_p->qef_cb->qef_c2_ddb_ses;
    QES_QRY_SES	    *qss_p = & dds_p->qes_d8_union.u2_qry_ses;
    QEE_DDB_CB	    *qee_p = i_dsh_p->dsh_ddb_cb;
/*
    QEF_QP_CB	    *qph_p = 
		    ((QEE+DSH *)(v_qer_p->qef_cb->qef_dsh))->dsh_qp_ptr;
*/
    bool	    log_qry_55 = FALSE,
                    log_err_59 = FALSE;
    i4         i4_1, i4_2;
    TPR_CB	    tpr,
		    *tpr_p = & tpr;
    RQR_CB	    rqr,
		    *rqr_p = & rqr;


    if (ult_check_macro(& v_qer_p->qef_cb->qef_trace, QEF_TRACE_DDB_LOG_QRY_55,
        & i4_1, & i4_2))
    {
        log_qry_55 = TRUE;
	qeq_p33_fet_csr(v_qer_p, i_dsh_p);
    }
    if (ult_check_macro(& v_qer_p->qef_cb->qef_trace, QEF_TRACE_DDB_LOG_ERR_59,
        & i4_1, & i4_2))
        log_err_59 = TRUE;

    if (! (qee_p->qee_d3_status & QEE_03Q_DEF))
    {
	/* cursor either not opened or closed */

	status = qed_u1_gen_interr(& v_qer_p->error);
	return(status);
    }

    if (qee_p->qee_d3_status & QEE_04Q_EOD)
    {
	/* no more data */

	v_qer_p->qef_rowcount = 0;

	/* must return E_QE0015_NO_MORE_ROWS to signal exhaustion of data */

	v_qer_p->error.err_code = E_QE0015_NO_MORE_ROWS;
	return(E_DB_WARN);
    }

/*
    ** 1.  set up to call TPF for read operation **

    MEfill(sizeof(tpr), '\0', (PTR) & tpr);
    tpr_p->tpr_session = dds_p->qes_d2_tps_p;	** TPF session id **
    tpr_p->tpr_rqf = dds_p->qes_d3_rqs_p;	** RQF session id **
    tpr_p->tpr_lang_type = qss_p->qes_q2_lang;
    tpr_p->tpr_site = & qee_p->qee_d11_ldbdesc;

    status = qed_u17_tpf_call(TPF_READ_DML, tpr_p, v_qer_p);
    if (status)
    {
	return(status);
    }
*/

    /* 2.  set up to call RQF to load data */

    MEfill(sizeof(rqr), '\0', (PTR) & rqr);
    rqr_p->rqr_session = dds_p->qes_d3_rqs_p;   /* RQF session id */

    rqr_p->rqr_q_language = qss_p->qes_q2_lang;
    rqr_p->rqr_timeout = QEK_0_TIME_QUANTUM;
    rqr_p->rqr_1_site = & qee_p->qee_d11_ldbdesc;
    STRUCT_ASSIGN_MACRO(qee_p->qee_d5_local_qid, rqr_p->rqr_qid);
    rqr_p->rqr_inv_parms = (PTR) v_qer_p->qef_param;	

    /* 3.  relay SCF parameters */

    rqr_p->rqr_tupcount = v_qer_p->qef_rowcount;
    rqr_p->rqr_tupdata = (PTR) v_qer_p->qef_output;
    rqr_p->rqr_tupdesc_p = (PTR) NULL;

    status = qed_u3_rqf_call(RQR_FETCH, rqr_p, v_qer_p);
    if (status)
    {
	if (log_err_59 && !log_qry_55)
	    qeq_p33_fet_csr(v_qer_p, i_dsh_p);

	/* it is assumed that RQF has repaired itself before returning */

	dds_p->qes_d7_ses_state = QES_0ST_NONE;	/* reset */
	STRUCT_ASSIGN_MACRO(rqr_p->rqr_error, v_qer_p->error);
	return(status);
    }

    if (rqr_p->rqr_end_of_data)
	qee_p->qee_d3_status |= QEE_04Q_EOD;	/* must set */

    /* return data gotten so far */

    v_qer_p->qef_rowcount = rqr_p->rqr_tupcount;
    v_qer_p->qef_count = rqr_p->rqr_count;

    if ((v_qer_p->qef_rowcount == 0) || (v_qer_p->qef_count == 0))
    {
	/* no more data */

	qee_p->qee_d3_status |= QEE_04Q_EOD;	/* must set */

	/* must return E_QE0015_NO_MORE_ROWS to signal no more data for 
	** subquery */

	v_qer_p->error.err_code = E_QE0015_NO_MORE_ROWS;
	return(E_DB_WARN);
    }
    else if ((v_qer_p->qef_rowcount == 0)
	     && (v_qer_p->qef_count != 0))
    {
	/* Here we emulate an incomplete condition */

	v_qer_p->error.err_code = E_AD0002_INCOMPLETE;
	return(E_DB_INFO);
    }

    return(E_DB_OK);
}
Ejemplo n.º 6
0
DB_STATUS
qel_35_registrations(
QEF_RCB		*i_qer_p,
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status;
    QES_DDB_SES	    *dds_p = & i_qer_p->qef_cb->qef_c2_ddb_ses;
    DD_LDB_DESC	    *cdb_p = 
			& dds_p->qes_d4_ddb_p->dd_d3_cdb_info.dd_i1_ldb_desc;
    QED_DDL_INFO    *ddl_p = v_lnk_p->qec_1_ddl_info_p;
    QED_QUERY_INFO  *qry_p;
    DD_2LDB_TAB_INFO
		    *tab_p = ddl_p->qed_d6_tab_info_p;
    QEC_L14_REGISTRATIONS
		    regs,
		    *regs_p = & regs;
    QEC_L18_PROCEDURES
		    procs,
		    *proc_p = & procs;
    QEQ_1CAN_QRY    *ins_p = v_lnk_p->qec_22_insert_p;
    DD_PACKET	    *pkt_p;
    i4		    seq;


    /* insert query text only for CREATE LINK | TABLE */

    if (ddl_p->qed_d9_reg_info_p == NULL)
	return(E_DB_OK);			/* no query text to insert */

    switch (ddl_p->qed_d8_obj_type)
    {
    case DD_1OBJ_LINK:
    case DD_2OBJ_TABLE:
    case DD_5OBJ_REG_PROC:
	break;
    default:
	return(E_DB_OK);			/* no query text to insert */
    }

    qry_p = ddl_p->qed_d9_reg_info_p;

    /* 1.  set up constant values for all entries */

    qed_u0_trimtail( ddl_p->qed_d1_obj_name, (u_i2) DB_OBJ_MAXNAME,
	regs_p->l14_1_obj_name);

    qed_u0_trimtail( ddl_p->qed_d2_obj_owner, (u_i2) DB_OWN_MAXNAME,
	regs_p->l14_2_obj_owner);

    if (qry_p->qed_q2_lang == DB_SQL)
	regs_p->l14_3_dml[0] = 'S';
    else if (qry_p->qed_q2_lang == DB_QUEL)
	regs_p->l14_3_dml[0] = 'Q';
    else
    {
	status = qed_u1_gen_interr(& i_qer_p->error);
	return(status);
    }
    regs_p->l14_3_dml[1] = EOS;

    if (tab_p->dd_t3_tab_type == DD_2OBJ_TABLE)
    {
	regs_p->l14_4_obj_type[0] = 'T';	/* local table */
    }
    else if (tab_p->dd_t3_tab_type == DD_3OBJ_VIEW)
    {
	regs_p->l14_4_obj_type[0] = 'V';	/* local view */
    }
    else if (tab_p->dd_t3_tab_type == DD_4OBJ_INDEX)
    {
	regs_p->l14_4_obj_type[0] = 'I';	/* local index */
    }
    else if (tab_p->dd_t3_tab_type == DD_5OBJ_REG_PROC)
    {
	regs_p->l14_4_obj_type[0] = 'P';	/* local index */
    }
    else
    {
	status = qed_u1_gen_interr(& i_qer_p->error);
	return(status);
    }
    regs_p->l14_4_obj_type[1] = EOS;
    regs_p->l14_5_obj_subtype[0] = 'L';		/* must set to link */
    regs_p->l14_5_obj_subtype[1] = EOS;

    pkt_p = qry_p->qed_q4_pkt_p;

    for (seq = 0; pkt_p != NULL; seq++)
    {
	/* 2.  construct text segment for current entry */

	regs_p->l14_6_sequence = seq + 1;
	regs_p->l14_7_pkt_p = pkt_p;

	if (pkt_p->dd_p1_len > QEK_256_VIEW_SIZE)
	{
	    status = qed_u1_gen_interr(& i_qer_p->error);
	    return(status);
	}

	/* 3.  insert into IIDD_DDB_REGISTRATIONS */

	ins_p->qeq_c1_can_id = INS_629_DD_REGISTRATIONS;
	ins_p->qeq_c3_ptr_u.l14_registrations_p = regs_p;
	ins_p->qeq_c4_ldb_p = cdb_p;
	status = qel_i1_insert(i_qer_p, v_lnk_p);
	if (status)
	    return(status);

	pkt_p = pkt_p->dd_p3_nxt_p;		/* advance to next segment,
						** if any */
    } 

    /* if a registered procedure, update iiprocedures */
    if (tab_p->dd_t3_tab_type == DD_5OBJ_REG_PROC)
    {
	qed_u0_trimtail( ddl_p->qed_d1_obj_name, (u_i2) DB_OBJ_MAXNAME,
	    proc_p->l18_1_proc_name);

	qed_u0_trimtail( ddl_p->qed_d2_obj_owner, (u_i2) DB_OWN_MAXNAME,
	    proc_p->l18_2_proc_owner);

	STcopy(v_lnk_p->qec_24_cur_time, proc_p->l18_3_cre_date);
	proc_p->l18_4_proc_subtype[0] = 'L';		/* must set to link */
	proc_p->l18_4_proc_subtype[1] = EOS;

	pkt_p = qry_p->qed_q4_pkt_p;

	for (seq = 0; pkt_p != NULL; seq++)
	{
	    /* 3.  construct text segment for current entry */

	    proc_p->l18_5_sequence = seq + 1;
	    proc_p->l18_6_pkt_p = pkt_p;

	    if (pkt_p->dd_p1_len > QEK_256_VIEW_SIZE)
	    {
		status = qed_u1_gen_interr(& i_qer_p->error);
		return(status);
	    }

	    /* 4.  insert into IIDD_DDB_REGISTRATIONS */

	    ins_p->qeq_c1_can_id = INS_633_DD_PROCEDURES;
	    ins_p->qeq_c3_ptr_u.l18_procedures_p = proc_p;
	    ins_p->qeq_c4_ldb_p = cdb_p;
	    status = qel_i1_insert(i_qer_p, v_lnk_p);
	    if (status)
		return(status);

	    pkt_p = pkt_p->dd_p3_nxt_p;		/* advance to next segment,
						    ** if any */
	} 
    }

    return(E_DB_OK);
}    
Ejemplo n.º 7
0
DB_STATUS
qel_33_columns(
QEF_RCB		*i_qer_p,
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status,
		    ignore;
    DB_ERROR	    sav_error;
    QES_DDB_SES	    *dds_p = & i_qer_p->qef_cb->qef_c2_ddb_ses;
    QED_DDL_INFO    *ddl_p = v_lnk_p->qec_1_ddl_info_p;
    DD_2LDB_TAB_INFO
		    *ldbtab_p = ddl_p->qed_d6_tab_info_p;
    DD_LDB_DESC	    *cdb_p = 
			& dds_p->qes_d4_ddb_p->dd_d3_cdb_info.dd_i1_ldb_desc,
		    *ldb_p = v_lnk_p->qec_19_ldb_p;
    QEC_D9_TABLEINFO
		    *tabinfo_p = v_lnk_p->qec_2_tableinfo_p;
    QEC_L3_COLUMNS  dd_columns,
		    *ddcolumns_p = & dd_columns;	/* tuple struct */
    QEQ_1CAN_QRY    *sel_p = v_lnk_p->qec_6_select_p,
		    *ins_p = v_lnk_p->qec_22_insert_p;
    DD_COLUMN_DESC  **col_descs_pp = ddl_p->qed_d4_ddb_cols_pp,
		    *name_p;
    i4		    tupcnt;

    if (v_lnk_p->qec_10_haves & QEC_08_NO_IITABLES)
	return(E_DB_OK);

    /* 1.  set up for looping through each retrieved local column */

    qed_u0_trimtail( ldbtab_p->dd_t1_tab_name, (u_i4) DB_TAB_MAXNAME,
		    ddcolumns_p->l3_1_tab_name);
    qed_u0_trimtail( ldbtab_p->dd_t2_tab_owner, (u_i4) DB_OWN_MAXNAME,
		    ddcolumns_p->l3_2_tab_owner);

    sel_p->qeq_c1_can_id = SEL_102_II_COLUMNS;
    sel_p->qeq_c2_rqf_bind_p = v_lnk_p->qec_20_rqf_bind_p;
    sel_p->qeq_c3_ptr_u.l3_columns_p = ddcolumns_p;
    sel_p->qeq_c4_ldb_p = ldb_p;

    ddcolumns_p->l3_15_internal_ingtype = 0;    /* init in case not ingres */

    /* 2.  send SELECT query and fetch first tuple */

    status = qel_s4_prepare(i_qer_p, v_lnk_p);
    if (status)
	return(status);
        
    if (sel_p->qeq_c5_eod_b)
    {
	/* no data ! */

	status = qed_u1_gen_interr(& i_qer_p->error);
	return(status);
    }

    tupcnt  = 0;

    if (col_descs_pp)
    {
	col_descs_pp++;			/* must start from slot 1 */
	name_p = *col_descs_pp;
    }

    while (! sel_p->qeq_c5_eod_b && ! status)
    {
	/* 4.  do column mapping if necessary  */

	if (col_descs_pp)
	{

	    /* 4.  set up for insertion */

	    /* substitue the link column name for inserting into IIDD_COLUMNS */

	    qed_u0_trimtail( name_p->dd_c1_col_name, (u_i4) DB_ATT_MAXNAME,
			ddcolumns_p->l3_3_col_name);
	}
	else
	{
	    qel_a2_case_col(i_qer_p, ddcolumns_p->l3_3_col_name,
			    *i_qer_p->qef_cb->qef_dbxlate,
			    &ldbtab_p->dd_t9_ldb_p->dd_i2_ldb_plus.
			    dd_p3_ldb_caps);
	}

	/* 4+. handle special datatypes (if any) */

	if(ddcolumns_p->l3_15_internal_ingtype >= 16384 ||
	   ddcolumns_p->l3_15_internal_ingtype <= -16384)    /* user datatype */
	{
	    /* copy internal type, length, ingtype into external for 6.2 cats */
	    MEcopy((PTR)ddcolumns_p->l3_13_internal_datatype,
		   DB_TYPE_MAXLEN +1,
		   (PTR)ddcolumns_p->l3_4_data_type);
	    ddcolumns_p->l3_5_length = ddcolumns_p->l3_14_internal_length;
	    ddcolumns_p->l3_12_ing_datatype =
					ddcolumns_p->l3_15_internal_ingtype;
	}
	ddcolumns_p->l3_15_internal_ingtype = 0;    /* init for next */


	/* 5.  replace with link name, link owner, and link creation date */

	qed_u0_trimtail( ddl_p->qed_d1_obj_name, (u_i4) DB_OBJ_MAXNAME,
			ddcolumns_p->l3_1_tab_name);
	qed_u0_trimtail( ddl_p->qed_d2_obj_owner, (u_i4) DB_OWN_MAXNAME,
			ddcolumns_p->l3_2_tab_owner);

	/* 6.  insert into IIDD_COLUMNS */

	ins_p->qeq_c1_can_id = INS_602_DD_COLUMNS;
	ins_p->qeq_c3_ptr_u.l3_columns_p = ddcolumns_p;
	ins_p->qeq_c4_ldb_p = cdb_p;
	status = qel_i1_insert(i_qer_p, v_lnk_p);
	if (status)
	{
	    /* must flush sending LDB */

	    STRUCT_ASSIGN_MACRO(i_qer_p->error, sav_error);
	    ignore = qel_s3_flush(i_qer_p, v_lnk_p);
	    STRUCT_ASSIGN_MACRO(sav_error, i_qer_p->error);
	    return(status);
	}

	tupcnt++;

	if (col_descs_pp)
	{
	    col_descs_pp++;			/* increment to pick up the
						** next DD_COLUMN_DESC */
	    name_p = *col_descs_pp;
	}

	/* 3.  retrieve next tuple */

	sel_p->qeq_c4_ldb_p = ldb_p;
	status = qel_s2_fetch(i_qer_p, v_lnk_p);
	if (status)
	    return(status);

    } /* end while */

    /*	the following check cannot be applied in the following 2 cases:
    **
    **	1)  an INGRES index because the count from IIINDEX_COLUMNS may be 
    **	    one less than the count from II_COLUMNS which includes "tidp" 
    **	    as an column,
    **	2)  on a REFRESH on an LDB table whose old schema can be a proper
    **	    subset of the new schema */

    if (ldbtab_p->dd_t3_tab_type == DD_2OBJ_TABLE
	&&
	dds_p->qes_d7_ses_state != QES_4ST_REFRESH)
    {
	if (tupcnt != ddl_p->qed_d3_col_count)
	{
	    status = qed_u1_gen_interr(& i_qer_p->error);
	    return(status);
	}
    }

    return(status);
}    
Ejemplo n.º 8
0
DB_STATUS
qel_32_tables(
QEF_RCB		*i_qer_p,
QEC_LINK	*v_lnk_p )
{
    DB_STATUS	    status;
    QES_DDB_SES	    *dds_p = & i_qer_p->qef_cb->qef_c2_ddb_ses;
    QED_DDL_INFO    *ddl_p = v_lnk_p->qec_1_ddl_info_p;
    DD_2LDB_TAB_INFO
		    *tabinfo_p = ddl_p->qed_d6_tab_info_p;
    QEC_L16_TABLES  *tables_p = v_lnk_p->qec_9_tables_p;
    QEQ_1CAN_QRY    *sel_p = v_lnk_p->qec_6_select_p,
		    *ins_p = v_lnk_p->qec_22_insert_p;
						/* working structure */
    DD_LDB_DESC	    *cdb_p = 
			& dds_p->qes_d4_ddb_p->dd_d3_cdb_info.dd_i1_ldb_desc,
		    *ldb_p = v_lnk_p->qec_19_ldb_p;
    u_i4	    l_obj;


    if (v_lnk_p->qec_10_haves & QEC_08_NO_IITABLES)
	return(E_DB_OK);

    /* 1.  set up to retrieve from IITABLES */

    qed_u0_trimtail( tabinfo_p->dd_t1_tab_name, (u_i4) DB_TAB_MAXNAME,
		    tables_p->l16_1_tab_name);
    qed_u0_trimtail( tabinfo_p->dd_t2_tab_owner, (u_i4) DB_OWN_MAXNAME,
		    tables_p->l16_2_tab_owner);

    sel_p->qeq_c1_can_id = SEL_117_II_TABLES;
    sel_p->qeq_c3_ptr_u.l16_tables_p = tables_p;
    sel_p->qeq_c4_ldb_p = ldb_p;
    sel_p->qeq_c2_rqf_bind_p = v_lnk_p->qec_20_rqf_bind_p;

    /* 2.  send SELECT query and fetch first tuple */

    status = qel_s4_prepare(i_qer_p, v_lnk_p);
    if (status)
	return(status);
        
    if (! sel_p->qeq_c5_eod_b)
    {
	status = qel_s3_flush(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
    }

    if (v_lnk_p->qec_27_select_cnt != 1)
    {
	status = qed_u1_gen_interr(& i_qer_p->error);
	return(status);
    }

    if (v_lnk_p->qec_10_haves & QEC_10_USE_PHY_SRC)
    {
	/* 3.  read remaining information from the LDB's IIPHYSICAL_TABLES */

	sel_p->qeq_c1_can_id = SEL_113_II_PHYSICAL_TABLES;

	/* 3.1  send SELECT query and fetch first tuple */

	status = qel_s4_prepare(i_qer_p, v_lnk_p);
	if (status)
	    return(status);
        
	if (! sel_p->qeq_c5_eod_b)
	{
	    status = qel_s3_flush(i_qer_p, v_lnk_p);
	    if (status)
		return(status);
	}

	if (v_lnk_p->qec_27_select_cnt != 1)
	{
	    status = qed_u1_gen_interr(& i_qer_p->error);
	    return(status);
	}
    }

    if (v_lnk_p->qec_10_haves & QEC_11_LDB_DIFF_ARCH)
    {
	/* binary statistics data cannot be propagated for use due to 
	** different LDB architecture */

	tables_p->l16_9_stats[0] = 'N';		/* declare no statistics */
    }
    else if (!
	(
	(tables_p->l16_9_stats[0] == 'N')
	||
	(tables_p->l16_9_stats[0] == 'n')
	))
	v_lnk_p->qec_10_haves |= QEC_05_STATS;

    if (!
	(
	(tables_p->l16_10_indexes[0] == 'N')
	||
	(tables_p->l16_10_indexes[0] == 'n')
	))
	v_lnk_p->qec_10_haves |= QEC_02_INDEXES;

    /* 3.  set up tuple for insertion */

    l_obj = (u_i4)qed_u0_trimtail( ddl_p->qed_d1_obj_name, (u_i4)DB_OBJ_MAXNAME,
		tables_p->l16_1_tab_name);

    qed_u0_trimtail( ddl_p->qed_d2_obj_owner, (u_i4) DB_OWN_MAXNAME,
		tables_p->l16_2_tab_owner);

    STcopy(v_lnk_p->qec_24_cur_time, 
	    tables_p->l16_3_cre_date);
    STcopy(v_lnk_p->qec_24_cur_time, 
	    tables_p->l16_4_alt_date);

    if (tabinfo_p->dd_t3_tab_type == DD_2OBJ_TABLE)
	tables_p->l16_5_tab_type[0] = 'T';	/* local table */
    else if (tabinfo_p->dd_t3_tab_type == DD_3OBJ_VIEW)
	tables_p->l16_5_tab_type[0] = 'V';	/* local view */
    else if (tabinfo_p->dd_t3_tab_type == DD_4OBJ_INDEX)
	tables_p->l16_5_tab_type[0] = 'I';	/* local index */
    else 
    {
	status = qed_u2_set_interr(E_QE0018_BAD_PARAM_IN_CB,
		    & i_qer_p->error);
	return(status);
    }
    tables_p->l16_5_tab_type[1] = EOS;		/* null terminate */

    if (ddl_p->qed_d8_obj_type == DD_1OBJ_LINK)
   	tables_p->l16_6_sub_type[0] = 'L';	/* DDB link */
    else if (ddl_p->qed_d8_obj_type == DD_2OBJ_TABLE
	     ||
	     ddl_p->qed_d8_obj_type == DD_3OBJ_VIEW)
	tables_p->l16_6_sub_type[0] = 'N';	/* DDB native */
    else
    {
	status = qed_u2_set_interr(E_QE0018_BAD_PARAM_IN_CB,
		    & i_qer_p->error);
	return(status);
    }
    tables_p->l16_6_sub_type[1] = EOS;		/* null terminate */

    STcopy(IIQE_42_ing_60, tables_p->l16_7_version);

    if (dds_p->qes_d9_ctl_info & QES_05CTL_SYSCAT_USER)
    {
	char *ch2 = ddl_p->qed_d1_obj_name + CMbytecnt(ddl_p->qed_d1_obj_name);

	if( ( l_obj >= 2 ) &&
	    (CMcmpnocase(ddl_p->qed_d1_obj_name, "i") == 0 ) &&
	    (CMcmpnocase(ch2, "i") == 0 ))
	{
	    tables_p->l16_8_sys_use[0] = 'S';	/* system object */

	}
	else
	    tables_p->l16_8_sys_use[0] = 'U';	/* user object */
    }
    else
	tables_p->l16_8_sys_use[0] = 'U';	/* user object */
    tables_p->l16_8_sys_use[1] = EOS;		/* null terminate */

    if (! (v_lnk_p->qec_10_haves & QEC_03_INGRES) )
    {
	/* index information NOT propagated for gateways */
	tables_p->l16_10_indexes[0] = 'N';	/* N */
	tables_p->l16_10_indexes[1] = EOS;	/* null terminate */
    }
    tables_p->l16_23_integrities[0] = 'N';	/* always N */
    tables_p->l16_23_integrities[1] = EOS;	/* null terminate */

    tables_p->l16_24_permits[0] = 'N';		/* always N */
    tables_p->l16_24_permits[1] = EOS;	/* null terminate */

    if (tabinfo_p->dd_t3_tab_type == DD_4OBJ_INDEX)
	tables_p->l16_25_all_to_all[0] = 'N';	/* always N if an index */
    else
	tables_p->l16_25_all_to_all[0] = 'Y';	/* always Y otherwise */
    tables_p->l16_25_all_to_all[1] = EOS;	/* null terminate */

    /* 4.  insert into IIDD_TABLES */

    ins_p->qeq_c1_can_id = INS_631_DD_TABLES;	
    ins_p->qeq_c3_ptr_u.l16_tables_p = tables_p;	
    ins_p->qeq_c4_ldb_p = cdb_p;
    status = qel_i1_insert(i_qer_p, v_lnk_p);

    return(status);
}