/*{ ** Name: psq_dtdump - Dump a datatype id ** ** Description: ** This function dumps a datatype id in human-readable form. ** ** Inputs: ** dt_id The datatype id to dump ** ** Outputs: ** None ** Returns: ** E_DB_OK Success ** E_DB_ERROR Non-catastrophic failure ** E_DB_FATAL Catastrophic failure ** Exceptions: ** None ** ** Side Effects: ** Sends output to terminal and/or log file ** ** History: ** 29-may-86 (jeff) ** written ** 14-nov-88 (stec) ** Initialize ADF_CB on the stack. ** 10-Jan-2001 (jenjo02) ** Use ADF_CB* from session control block ** instead of SCU_INFORMATION. */ DB_STATUS psq_dtdump( DB_DT_ID dt_id) { ADI_DT_NAME adt_name; PSS_SESBLK *sess_cb; ADF_CB *adf_cb; PTR ad_errmsgp; /* Get ADF_CB* from session control block */ sess_cb = psf_sesscb(); adf_cb = (ADF_CB*)sess_cb->pss_adfcb; /* Preserve and restore ad_errmsgp */ ad_errmsgp = adf_cb->adf_errcb.ad_errmsgp; adf_cb->adf_errcb.ad_errmsgp = NULL; if (adi_tyname(adf_cb, dt_id, &adt_name) == E_DB_OK) { TRdisplay("%#s", sizeof (adt_name.adi_dtname), adt_name.adi_dtname); } else { TRdisplay("Bad datatype id %d", dt_id); } adf_cb->adf_errcb.ad_errmsgp = ad_errmsgp; return (E_DB_OK); }
/*{ ** Name: psy_put - Put characters in blocks for output ** ** Description: ** This function buffers up characters to be sent to the user by SCF. ** It puts as much of the current request in the current block as ** possible. If there is any overflow, it allocates another block and ** puts the excess there. It keeps doing this until all the input is ** used up. ** ** Inputs: ** mstream Memory stream to use for allocating ** blocks. ** inbuf Characters to send to user ** len Number of chars to send to user ** block Pointer to pointer to block to use ** err_blk Filled in if an error happens ** ** Outputs: ** block Filled in with string to send to user. ** A new block may be allocated and this ** pointer modified to point to new one. ** err_blk Filled in if an error happened ** Returns: ** E_DB_OK Success ** E_DB_FATAL Failure ** Exceptions: ** none ** ** Side Effects: ** Can allocate memory ** ** History: ** 15-jul-86 (jeff) ** written */ DB_STATUS psy_put( PSF_MSTREAM *mstream, register char *inbuf, register i4 len, PSY_QTEXT **block, DB_ERROR *err_blk) { i4 tocopy; i4 left; char *outplace; PSY_QTEXT *newblock; DB_STATUS status; #ifdef xDEBUG i4 val1, val2; /* tracing temps */ PSS_SESBLK *sess_cb; sess_cb = psf_sesscb(); #endif while (len > 0) { /* Copy as much of input as will fit in current block */ left = PSY_QTSIZE - (*block)->psy_qcount; tocopy = len > left ? left : len; outplace = (*block)->psy_qtext + (*block)->psy_qcount; #ifdef xDEBUG if (ult_check_macro(&sess_cb->pss_trace, PSS_PSY_PUT_TRACE, &val1, &val2)) { TRdisplay("%.#s", tocopy, inbuf); } #endif MEcopy(inbuf, tocopy, outplace); len -= tocopy; (*block)->psy_qcount += tocopy; inbuf += tocopy; /* If there is more input, create another block and link it up */ if (len > 0) { status = psy_txtalloc(mstream, &newblock, err_blk); if (DB_FAILURE_MACRO(status)) return (status); (*block)->psy_qnext = newblock; /* Use the new block until a new one is allocated */ *block = newblock; } } return (E_DB_OK); }
/*{ ** Name: psy_txtalloc - Allocate a new text block ** ** Description: ** This function allocates a new text block in a memory stream, ** fills it in, and returns a pointer to it. ** ** Inputs: ** mstream Pointer to memory stream ** newblock Place to put pointer to new block ** err_blk Filled in if error happens ** ** Outputs: ** newblock Filled in with pointer to new block ** err_blk Filled in if an error happened ** Returns: ** E_DB_OK Success ** E_DB_ERROR Failure ** Exceptions: ** none ** ** Side Effects: ** Allocates memory ** ** History: ** 15-jul-86 (jeff) ** written */ DB_STATUS psy_txtalloc( PSF_MSTREAM *mstream, PSY_QTEXT **newblock, DB_ERROR *err_blk) { DB_STATUS status; PSS_SESBLK *sess_cb; sess_cb = psf_sesscb(); /* Allocate the block */ status = psf_malloc(sess_cb, mstream, sizeof(PSY_QTEXT), (PTR *) newblock, err_blk); if (DB_FAILURE_MACRO(status)) return (status); /* Fill in the block */ (*newblock)->psy_qnext = (PSY_QTEXT *) NULL; (*newblock)->psy_qcount = 0; return (E_DB_OK); }
/*{ ** Name: psf_debug - Standard entry point for debugging PSF. ** ** Description: ** This function is the standard entry point to PSF for setting and ** clearing tracepoints. ** ** Inputs: ** debug_cb Pointer to a DB_DEBUG_CB ** .db_trswitch What operation to perform ** DB_TR_NOCHANGE None ** DB_TR_ON Turn on a tracepoint ** DB_TR_OFF Turn off a tracepoint ** .db_trace_point The number of the tracepoint to be ** effected ** .db_vals[2] Optional values, to be interpreted ** differently for each tracepoint ** .db_value_count The number of values specified in ** the above array ** ** Outputs: ** None ** Returns: ** E_DB_OK Success ** E_DB_WARN Operation completed with warning(s) ** E_DB_ERROR Function failed; non-catastrophic error ** E_DB_FATAL Function failed; catastrophic error ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 17-apr-86 (jeff) ** written ** 13-feb-90 (andre) ** set scf_stype to SCU_EXCLUSIVE before calling scu_swait. ** 14-jul-93 (ed) ** replacing <dbms.h> by <gl.h> <sl.h> <iicommon.h> <dbdbms.h> ** 10-aug-93 (andre) ** removed declaration of scf_call() ** 08-oct-93 (rblumer) ** In order to allow session trace points that take a value, ** changed ult_set_macro call to use firstval and secondval ** instead of hard-coding zeros for the values. ** 09-Oct-1998 (jenjo02) ** Removed SCF semaphore functions, inlining the CS calls instead. ** 04-may-1999 (hanch04) ** Change TRformat's print function to pass a PTR not an i4. ** 21-Feb-2007 (hanal04) Bug 117736 ** Added trace point PS503 to dump PSF's ULM memory usage to the ** DBMS log. */ DB_STATUS psf_debug( DB_DEBUG_CB *debug_cb) { i4 flag; i4 firstval; i4 secondval; PSS_SESBLK *sess_cb; extern PSF_SERVBLK *Psf_srvblk; /* Get the session control block */ sess_cb = psf_sesscb(); /* Flags 0 - PSF_TBITS-1 are for the server; all others are for sessions */ flag = debug_cb->db_trace_point; if (flag >= PSF_TBITS) { flag = flag - PSF_TBITS; if (flag >= PSS_TBITS) return (E_DB_ERROR); } /* There can be UP TO two values, but maybe they weren't given */ if (debug_cb->db_value_count > 0) firstval = debug_cb->db_vals[0]; else firstval = 0L; if (debug_cb->db_value_count > 1) secondval = debug_cb->db_vals[1]; else secondval = 0L; /* ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: /* First PSF_TBITS flags belong to server, others to session */ if (debug_cb->db_trace_point < PSF_TBITS) { CSp_semaphore(1, &Psf_srvblk->psf_sem); /* exclusive */ ult_set_macro(&Psf_srvblk->psf_trace, flag, firstval, secondval); CSv_semaphore(&Psf_srvblk->psf_sem); } else { /* Do nothing if couln't get session control block */ if (sess_cb != (PSS_SESBLK *) NULL) { if(flag == PSS_ULM_DUMP_POOL) { ULM_RCB ulm_rcb; char buf[512]; SCF_CB scf_cb; ulm_rcb.ulm_poolid = Psf_srvblk->psf_poolid; ulm_rcb.ulm_facility = DB_PSF_ID; _VOID_ ulm_mappool(&ulm_rcb); ulm_print_pool(&ulm_rcb); STprintf(buf, "ULM Memory Pool Map and ULM Memory Print Pool for PSF has been \nwritten to the DBMS log file."); scf_cb.scf_length = sizeof(scf_cb); scf_cb.scf_type = SCF_CB_TYPE; scf_cb.scf_facility = DB_PSF_ID; scf_cb.scf_session = DB_NOSESSION; scf_cb.scf_nbr_union.scf_local_error = 0; scf_cb.scf_len_union.scf_blength = STlength(buf); scf_cb.scf_ptr_union.scf_buffer = buf; _VOID_ scf_call(SCC_TRACE, &scf_cb); } else { ult_set_macro(&sess_cb->pss_trace, flag, firstval, secondval); /* Yacc debugging requires a special call */ if (flag == PSS_YTRACE) psl_trace((PTR) sess_cb->pss_yacc, TRUE); } } } break; case DB_TR_OFF: /* First PSF_TBITS flags belong to server, others to session */ if (debug_cb->db_trace_point < PSF_TBITS) { CSp_semaphore(1, &Psf_srvblk->psf_sem); /* exclusive */ ult_clear_macro(&Psf_srvblk->psf_trace, flag); CSv_semaphore(&Psf_srvblk->psf_sem); } else { /* Do nothing if couldn't get session control block */ if (sess_cb != (PSS_SESBLK *) NULL) { ult_clear_macro(&sess_cb->pss_trace, flag); /* Yacc debugging requires a special call */ if (flag == PSS_YTRACE) psl_trace((PTR) sess_cb->pss_yacc, FALSE); } } break; case DB_TR_NOCHANGE: /* Do nothing */ break; default: return (E_DB_ERROR); } return (E_DB_OK); }