示例#1
0
/*{
** Name: psy_qminit	- Allocate and initialize the PSY_CB
**
** Description:
**      This function allocates and initialzes the qrymod control
**	block, PSY_CB.  It is called by the grammar.
**
** Inputs:
**	sess_cb				Current session control block
**	psq_cb
**	    .err_blk			Filled in if an error happens
**	mstream				memory stream to use for allocating a
**					PSY_CB
**
** Outputs:
**	sess_cb
**	    .pss_object			Points to allocated psy_cb
**	Returns:
**	    E_DB_OK			Success
**	    Other			Return code from called functions
**	Exceptions:
**	    none
**
** Side Effects:
**	    Allocates memory
**
** History:
**      22-jul-89 (ralph)
**          Written.
**	08-aug-90 (ralph)
**	    Initialize new psy_cb fields.
**	14-jul-92 (andre)
**	    init PSY_CB.psy_flags
**	14-jul-92 (andre)
**	    added mstream to the function's interface which will enable it to no
**	    longer assume that PSY_CB must be allocated from any given stream.
**	20-jul-92 (andre)
**	    added initialization for psy_xcolq
**	20-jul-92 (andre)
**	    iprocessing DROP PROCEDURE (psq_cb->psq_mode == PSQ_DRODBP), memory
**	    stream has already been opened, so don't do it here
**	21-jul-92 (andre)
**	    removed initialization for psy_xcolq;
**
**	    replaced code initializing various fields to 0 with a call to MEfill
**	    to fill a newly allocated PSY_CB with 0's
**	06-dec-92 (andre)
**	    Added code to initialize psy_u_colq and psy_r_colq
**	10-jul-93 (andre)
**	    cast QUinit()'s arg to (QUEUE *) to agree with the prototype
**	    declaration
**	 7-jan-94 (swm)
**	    Bug #58635
**	    Added PTR cast for qsf_owner which has changed type to PTR.
**	28-apr-94 (andre)
**	    (part of fix for bug 62890)
**	    if the statement was generated internally 
**	    (psq_cb->psq_info->pst_execflags & PST_SYSTEM_GENERATED), set 
**	    PSY_SYSTEM_GENEARTED in psy_cb->psy_flags.
*/
DB_STATUS
psy_qminit(
	PSS_SESBLK	    *sess_cb,
	PSQ_CB		    *psq_cb,
	PSF_MSTREAM	    *mstream)
{
    DB_STATUS	    status;
    PSY_CB	    *psy_cb;

    /*
    ** open the memory stream unless we are processing DROP PROCEDURE, in which
    ** case it has already been opened
    */
    if (psq_cb->psq_mode != PSQ_DRODBP)
    {
	/* Allocate the PSY_CB statement */
	status = psf_mopen(sess_cb, QSO_QP_OBJ, mstream, &psq_cb->psq_error);
	if (status != E_DB_OK)
	    return (status);
    }

    status = psf_malloc(sess_cb, mstream, sizeof(PSY_CB), &sess_cb->pss_object,
	&psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);

    status = psf_mroot(sess_cb, mstream, sess_cb->pss_object, &psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);

    psy_cb = (PSY_CB *) sess_cb->pss_object;

    MEfill(sizeof(PSY_CB), (u_char) 0, (PTR) psy_cb);

    /* Fill in control block header */
    psy_cb->psy_length	 = sizeof(PSY_CB);
    psy_cb->psy_type	 = PSYCB_CB;
    psy_cb->psy_owner	 = (PTR)DB_PSF_ID;
    psy_cb->psy_ascii_id = PSYCB_ASCII_ID;

    (VOID) QUinit((QUEUE *) &psy_cb->psy_usrq);	/* No users */
    (VOID) QUinit((QUEUE *) &psy_cb->psy_tblq);	/* No tables */
    (VOID) QUinit((QUEUE *) &psy_cb->psy_colq);	/* No columns */
    (VOID) QUinit((QUEUE *) &psy_cb->psy_u_colq);
    (VOID) QUinit((QUEUE *) &psy_cb->psy_r_colq);

    /*
    ** remember whether the statement was generated internally
    */
    if (   psq_cb->psq_info 
	&& psq_cb->psq_info->pst_execflags & PST_SYSTEM_GENERATED)
    {
	psy_cb->psy_flags |= PSY_SYSTEM_GENERATED;
    }

    return(E_DB_OK);
}
示例#2
0
/*{
** Name: psq_tout	- Copy a text chain to QSF memory
**
** Description:
**      This function copies a text chain to QSF memory, as a text object.
**	It allocates it as a contiguous piece.
**
** Inputs:
**	rngtab			if non-NULL, range statements will be
**				generated for all entries of the range table
**				that are active (pss_used && pss_rgno >= 0);
**				should be non-NULL only for QUEL queries
**      header                  Pointer to chain header
**	mstream			Pointer to unopened memory stream
**	err_blk			Filled in if an error happens
**
** Outputs:
**      mstream                 Filled with object id for new text
**				object
**	err_blk			Filled in if an error happened
**	Returns:
**	    E_DB_OK		Success
**	    E_DB_ERROR		Non-catastrophic failure
**	    E_DB_FATAL		Catastrophic failure
**	Exceptions:
**	    none
**
** Side Effects:
**	    Allocates memory
**
** History:
**      18-jul-86 (jeff)
**          written
**      2-sep-86 (seputis)
**          changed MEcopy routine parameter to be &hp->psq_tsize
**	6-may-87 (daved)
**	    clear mstream lock id after unlocking memory stream
**	29-jun-87 (daved)
**	    emit the range table entries if a range table is provided.
**	10-aug-93 (andre)
**	    removed declaration of qsf_call()
*/
DB_STATUS
psq_tout(
	PSS_SESBLK	   *sess_cb,
	PSS_USRRANGE	   *rngtab,
	PTR                header,
	PSF_MSTREAM	   *mstream,
	DB_ERROR	   *err_blk)
{
    DB_STATUS           status;
    i4		err_code;
    u_char		*buf;
    QSF_RCB		qsf_rb;

    /* Open the QSF memory stream for the text object */
    status = psf_mopen(sess_cb, QSO_QTEXT_OBJ, mstream, err_blk);
    if (status != E_DB_OK)
	return (status);

    status = psq_store_text(sess_cb, rngtab, header, mstream, 
	(PTR *) &buf, (bool) FALSE, err_blk);
    if (DB_FAILURE_MACRO(status))
	return(status);

    /* Set the root of the object */
    status = psf_mroot(sess_cb, mstream, (PTR) buf, err_blk);
    if (status != E_DB_OK)
	return (status);

    /* Unlock the object */
    qsf_rb.qsf_type = QSFRB_CB;
    qsf_rb.qsf_ascii_id = QSFRB_ASCII_ID;
    qsf_rb.qsf_length = sizeof(qsf_rb);
    qsf_rb.qsf_owner = (PTR)DB_PSF_ID;
    qsf_rb.qsf_sid = sess_cb->pss_sessid;
    STRUCT_ASSIGN_MACRO(mstream->psf_mstream, qsf_rb.qsf_obj_id);
    qsf_rb.qsf_lk_id = mstream->psf_mlock;
    status = qsf_call(QSO_UNLOCK, &qsf_rb);
    if (status != E_DB_OK)
    {
	(VOID) psf_error(E_PS0375_UNLOCK_QSF_TEXT,
	    qsf_rb.qsf_error.err_code, PSF_INTERR, &err_code, err_blk, 0);
	return (status);
    }
    mstream->psf_mlock = 0;

    return (E_DB_OK);
}
示例#3
0
/*
** Name psl_lm1_setlockstmnt() - perform semantic action for SETLOCKSTMNT
**			         production
**
** Description:
**	perform semantic action for SETLOCKSTMNT production in QUEL and SQL
**	grammars
**
** Input:
**	sess_cb		    PSF session CB
**	    pss_distrib	    DB_3_DDB_SESS if distributed thread
**	    pss_ostream	    stream to be opened for memory allocation
**	    pss_stmt_flags  PSS_SET_LOCKMODE_SESS if SET LOCKMODE SESSION
**	psq_cb		    PSF request CB
**
** Output:
**	sess_cb
**	    pss_ostream	    stream has been opened for memory allocation
**	    pss_object	    point to the root of a new QSF object
**			    (of type (DMC_CB *) or (QEF_RCB *)).
**	psq_cb
**	    psq_mode	    set to PSQ_SLOCKMODE
**	    psq_error	    filled in if an error occurred
**
** Returns:
**	E_DB_{OK, ERROR, SEVERE}
**
** Side effects:
**	Opens a memory stream and allocates memory
**
**  History:
**	07-mar-91 (andre)
**	    plagiarized from SETLOCKSTMNT production
**	17-apr-92 (barbara)
**	    Updated for Sybil.  Distributed thread allocates QEF_RCB and
**	    calls QEF directly.
**	07-oct-93 (swm)
**	    Bug #56437
**	    added PTR cast in assignment to dmc_cb->dmc_id.
**	09-oct-93 (swm)
**	    Bug #56437
**	    Put pss_sessid into new dmc_session_id rather than dmc_id.
**	26-Feb-2001 (jenjo02)
**	    Set session_id in QEF_RCB;
**	11-Jun-2010 (kiria01) b123908
**	    Initialise pointers after psf_mopen would have invalidated any
**	    prior content.
*/
DB_STATUS
psl_lm1_setlockstmnt(
	PSS_SESBLK	*sess_cb,
	PSQ_CB		*psq_cb)
{
    DB_STATUS		status;
    i4		err_code;
    DMC_CB		*dmc_cb;
    DB_ERROR		err_blk;
    DB_STATUS	        tempstat;

    psq_cb->psq_mode = PSQ_SLOCKMODE;

    /* Verify the user has LOCKMODE permission */

    status = psy_ckdbpr(psq_cb, (u_i4) DBPR_LOCKMODE);
    if (DB_FAILURE_MACRO(status))
    {
	(VOID) psf_error(6247L, 0L, PSF_USERERR, &err_code,
	    &psq_cb->psq_error, 0);
	/*
	** Audit failed  set lockmode
	*/
	if ( Psf_srvblk->psf_capabilities & PSF_C_C2SECURE )
	{
	    (VOID)psy_secaudit(
		    FALSE,
		    sess_cb,
		    "LOCKMODE",
		    (DB_OWN_NAME *)0,
		    8,
		    SXF_E_RESOURCE,
		    I_SX2741_SET_LOCKMODE,
		    SXF_A_FAIL|SXF_A_LIMIT,
		    &err_blk);
	}
	return(status);
    }

    /* Create control block for DMC_ALTER or QEF_CALL for set lockmode */
    status = psf_mopen(sess_cb, QSO_QP_OBJ, &sess_cb->pss_ostream, &psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);
    sess_cb->pss_stk_freelist = NULL;

    if (sess_cb->pss_distrib & DB_3_DDB_SESS)
    {
	/* Distributed thread calls QEF directly */
	QEF_RCB	*qef_rcb;

	status = psf_malloc(sess_cb, &sess_cb->pss_ostream, sizeof(QEF_RCB),
	    &sess_cb->pss_object, &psq_cb->psq_error);
	if (status != E_DB_OK)
	    return (status);

	status = psf_mroot(sess_cb, &sess_cb->pss_ostream, sess_cb->pss_object,
			   &psq_cb->psq_error);
	if (status != E_DB_OK)
	    return (status);

	/* Fill in the QEF control block */
	qef_rcb = (QEF_RCB *) sess_cb->pss_object;
	qef_rcb->qef_length = sizeof(QEF_RCB);
	qef_rcb->qef_type = QEFRCB_CB;
	qef_rcb->qef_owner = (PTR)DB_PSF_ID;
	qef_rcb->qef_ascii_id = QEFRCB_ASCII_ID;
	qef_rcb->qef_modifier = QEF_MSTRAN;
	qef_rcb->qef_flag = 0;
	qef_rcb->qef_cb = (QEF_CB *) NULL;
	qef_rcb->qef_sess_id = sess_cb->pss_sessid;
	return (E_DB_OK);
    }

    status = psf_malloc(sess_cb, &sess_cb->pss_ostream, sizeof(DMC_CB), (PTR *) &dmc_cb,
	&psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);

    status = psf_mroot(sess_cb, &sess_cb->pss_ostream, (PTR) dmc_cb, &psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);

    sess_cb->pss_object		= (PTR) dmc_cb;
    dmc_cb->type		= DMC_CONTROL_CB;
    dmc_cb->length		= sizeof (DMC_CB);
    dmc_cb->dmc_op_type		= DMC_SESSION_OP;
    dmc_cb->dmc_session_id	= (PTR)sess_cb->pss_sessid;
    dmc_cb->dmc_flags_mask	= DMC_SETLOCKMODE;
    dmc_cb->dmc_db_id		= sess_cb->pss_dbid;
    dmc_cb->dmc_db_access_mode  =
    dmc_cb->dmc_lock_mode	= 0;

    /* need to allocate characteristics array with MAX_LOCKMODE_CHARS entries */
    status = psf_malloc(sess_cb, &sess_cb->pss_ostream,
	sizeof(DMC_CHAR_ENTRY) * MAX_LOCKMODE_CHARS,
	(PTR *) &dmc_cb->dmc_char_array.data_address, &psq_cb->psq_error);
    if (status != E_DB_OK)
	return (status);

    dmc_cb->dmc_char_array.data_in_size = 0;

    /*
    ** Audit allowed to issue lockmode
    */
    if ( Psf_srvblk->psf_capabilities & PSF_C_C2SECURE )
    {
	(VOID)psy_secaudit(
	    FALSE,
	    sess_cb,
	    "LOCKMODE",
	    (DB_OWN_NAME *)0,
	    8,
	    SXF_E_RESOURCE,
	    I_SX2741_SET_LOCKMODE,
	    SXF_A_SUCCESS|SXF_A_LIMIT,
	    &err_blk);
    }

    return(E_DB_OK);
}