/*{ ** Name: psq_crdump - Dump cursor control block given cursor and session ids ** ** INTERNAL PSF call format: status = psq_crdump(&psq_cb, &sess_cb); ** ** EXTERNAL call format: status = psq_call(PSQ_CURDUMP, &psq_cb, &sess_cb); ** ** Description: ** The psq_crdump function will format and print a cursor control block ** given the cursor id and the session id that identify it. The output ** will go to the output terminal and/or file named by the user in the ** "SET TRACE TERMINAL" and "SET TRACE OUTPUT" commands. ** ** Inputs: ** psq_cb ** .psq_cursid Cursor id ** sess_cb Pointer to session control block ** (Can be NULL) ** ** Outputs: ** psq_cb ** .psq_error Error information ** .err_code What error occurred ** E_PS0000_OK Success ** E_PS0002_INTERNAL_ERROR Internal inconsistency in PSF ** E_PS0205_SRV_NOT_INIT Server not initialized ** E_PS0401_CUR_NOT_FOUND Cursor not found ** Returns: ** E_DB_OK Function completed normally. ** E_DB_WARN Function completed with warning(s) ** E_DB_ERROR Function failed; non-catastrophic error ** E_DB_FATAL Function failed; catastrophic error ** Exceptions: ** none ** ** Side Effects: ** Writes to output file and/or terminal as specified in the "set trace ** output" and "set trace terminal" commands. ** ** History: ** 02-oct-85 (jeff) ** written ** 27-oct-88 (stec) ** Dump psc_iupdmap. ** 10-may-89 (neil) ** Tracing of new rule-related objects. ** 22-dec-92 (rblumer) ** Added tracing of new statement-level rules. ** 10-mar-93 (andre) ** dump psc_expmap ** 07-apr-93 (andre) ** psc_tbl_mask, psc_rchecked, psc_rules, and psc_stmt_rules have all ** been moved from PSC_CURBLK into PSC_TBL_DESCR. A list of one or ** more PSC_TBL_DESCR structures will hang off PSC_CURBLK for ** updatable cursors ** 11-oct-1993 (tad) ** Bug #56449 ** Changed %x to %p for pointer values. ** 15-june-06 (dougi) ** Add support for "before" triggers. */ DB_STATUS psq_crdump( PSQ_CB *psq_cb, PSS_SESBLK *sess_cb) { PSC_CURBLK *cursor; DB_STATUS status; i4 i; i4 thisline; PSC_RESCOL *column; extern PSF_SERVBLK *Psf_srvblk; /* ** Make sure server is initialized. */ if (!Psf_srvblk->psf_srvinit) { psq_cb->psq_error.err_code = E_PS0205_SRV_NOT_INIT; return (E_DB_ERROR); } /* ** Get pointer to cursor control block. */ status = psq_crfind(sess_cb, &psq_cb->psq_cursid, &cursor, &psq_cb->psq_error); if (status != E_DB_OK) return (status); /* ** NULL means no such cursor. */ if (cursor == (PSC_CURBLK *) NULL) { psq_cb->psq_error.err_code = E_PS0401_CUR_NOT_FOUND; return (E_DB_ERROR); } /* ** Now print out everything in the cursor control block. */ TRdisplay("Cursor Control Block for Cursor:"); status = psq_ciddmp(&psq_cb->psq_cursid); if (status != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n\n"); /* First, the control block header */ if ((status = psq_headdmp((PSQ_CBHEAD *) cursor)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } /* The cursor id */ TRdisplay("\tpsc_blkid:\n"); if ((status = psq_ciddmp(&cursor->psc_blkid)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } /* Used / Not Used flag */ TRdisplay("\tpsc_used:\t"); if ((status = psq_booldmp(cursor->psc_used)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* Stream pointer */ TRdisplay("\tpsc_stream:\t%p\n", cursor->psc_stream); /* Query language */ TRdisplay("\tpsc_lang:\t(%d) ", cursor->psc_lang); if ((status = psq_lngdmp(cursor->psc_lang)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* Delete permission flag */ TRdisplay("\tpsc_delall:\t"); if ((status = psq_booldmp(cursor->psc_delall)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* For update flag */ TRdisplay("\tpsc_forupd:\t"); if ((status = psq_booldmp(cursor->psc_forupd)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* Readonly flag */ TRdisplay("\tpsc_readonly:\t"); if ((status = psq_booldmp(cursor->psc_readonly)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* Repeat cursor flag */ TRdisplay("\tpsc_repeat:\t"); if ((status = psq_booldmp(cursor->psc_repeat)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); /* Open flag */ TRdisplay("\tpsc_open:\t"); if ((status = psq_booldmp(cursor->psc_open)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n"); TRdisplay("\tList of descriptions of cursor's underlying table/views:\n"); if (cursor->psc_tbl_descr_queue.q_next == &cursor->psc_tbl_descr_queue) { TRdisplay("\t\tNONE\n"); } else { PSC_TBL_DESCR *descr, *last_descr; i4 i = 0; descr = (PSC_TBL_DESCR *) cursor->psc_tbl_descr_queue.q_next; last_descr = (PSC_TBL_DESCR *) cursor->psc_tbl_descr_queue.q_prev; do { if (i++) descr = (PSC_TBL_DESCR *) descr->psc_queue.q_next; /* element number (starting at 1) */ TRdisplay("\t\telement %d:\n", i); /* table/view id */ TRdisplay("\t\t\t\tpsc_tabid:\t(%d,%d)\n", descr->psc_tabid.db_tab_base, descr->psc_tabid.db_tab_index); /* table mask */ TRdisplay("\t\t\tpsc_tbl_mask:\t0x%x\n", descr->psc_tbl_mask); /* Row-level after user-defined rules */ TRdisplay("\t\t\tpsc_row_lvl_usr_rules:\t(address) 0x%p\n", descr->psc_row_lvl_usr_rules); /* Row-level after system-generated rules */ TRdisplay("\t\t\tpsc_row_lvl_sys_rules:\t(address) 0x%p\n", descr->psc_row_lvl_sys_rules); /* statement-level after user-defined rules */ TRdisplay("\t\t\tpsc_stmt_lvl_usr_rules:\t(address) 0x%p\n", descr->psc_stmt_lvl_usr_rules); /* statement-level after system-generated rules */ TRdisplay("\t\t\tpsc_stmt_lvl_sys_rules:\t(address) 0x%p\n", descr->psc_stmt_lvl_sys_rules); /* Row-level before user-defined rules */ TRdisplay("\t\t\tpsc_row_lvl_usr_before_rules:\t(address) 0x%p\n", descr->psc_row_lvl_usr_before_rules); /* Row-level before system-generated rules */ TRdisplay("\t\t\tpsc_row_lvl_sys_before_rules:\t(address) 0x%p\n", descr->psc_row_lvl_sys_before_rules); /* statement-level before user-defined rules */ TRdisplay("\t\t\tpsc_stmt_lvl_usr_before_rules:\t(address) 0x%p\n", descr->psc_stmt_lvl_usr_before_rules); /* statement-level before system-generated rules */ TRdisplay("\t\t\tpsc_stmt_lvl_sys_before_rules:\t(address) 0x%p\n", descr->psc_stmt_lvl_sys_before_rules); /* psc_flags */ TRdisplay("\t\t\tpsc_flags:\t"); TRdisplay("\t\t\t\tPSC_RULES_CHECKED:\t"); if ((status = psq_booldmp(descr->psc_flags & PSC_RULES_CHECKED)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } } while (descr != last_descr); } TRdisplay("\n"); /* Now do the set of columns for update. psc_updmap is a bit map. */ TRdisplay("\tpsc_updmap:\t"); thisline = 0; for (i = 0; i < (i4)sizeof(cursor->psc_updmap) * BITSPERBYTE; i++) { if (BTtest(i, (char *) &cursor->psc_updmap)) { TRdisplay("%d ", i); thisline++; /* Limit to 10 numbers per row */ if (thisline >= 10) { TRdisplay("\n\t\t"); thisline = 0; } } } TRdisplay("\n"); /* Now do the column set */ TRdisplay("\tpsc_restab:\n"); TRdisplay("\t\tpsc_tabsize: %d\n", cursor->psc_restab.psc_tabsize); TRdisplay("\t\tpsc_coltab:\n"); for (i = 0; i < cursor->psc_restab.psc_tabsize; i++) { for (column = cursor->psc_restab.psc_coltab[i]; column != (PSC_RESCOL *) NULL; column = column->psc_colnext) { TRdisplay("\n"); TRdisplay("\t\t\tpsc_attname:\t%#s\n", sizeof (column->psc_attname), &column->psc_attname); TRdisplay("\t\t\tpsc_type:\t"); if ((status = psq_dtdump(column->psc_type)) != E_DB_OK) { psq_cb->psq_error.err_code = E_PS0002_INTERNAL_ERROR; return (status); } TRdisplay("\n\t\t\tpsc_len:\t%d\n", column->psc_len); TRdisplay("\t\t\tpsc_prec:\t%d\n", column->psc_prec); TRdisplay("\t\t\tpsc_attid:\t%d\n", column->psc_attid.db_att_id); TRdisplay("\n"); } } /* Now do the internal set of columns for update, ** psc_iupdmap is a bit map. */ TRdisplay("\tpsc_iupdmap:\t"); thisline = 0; for (i = 0; i < (i4)sizeof(cursor->psc_iupdmap) * BITSPERBYTE; i++) { if (BTtest(i, (char *) &cursor->psc_iupdmap)) { TRdisplay("%d ", i); thisline++; /* Limit to 10 numbers per row */ if (thisline >= 10) { TRdisplay("\n\t\t"); thisline = 0; } } } TRdisplay("\n"); /* ** Now dump a map of attributes of a view on which a cursor is declared ** which (attributes that is) are based on an expression ** psc_expmap is a bit map. */ TRdisplay("\tpsc_expmap:\t"); thisline = 0; for (i = 0; i < (i4)sizeof(cursor->psc_expmap) * BITSPERBYTE; i++) { if (BTtest(i, (char *) &cursor->psc_expmap)) { TRdisplay("%d ", i); thisline++; /* Limit to 10 numbers per row */ if (thisline >= 10) { TRdisplay("\n\t\t"); thisline = 0; } } } TRdisplay("\n"); return (E_DB_OK); }
/*{ ** Name: psq_prmdump - Dump the parameters in a control block. ** ** INTERNAL PSF call format: status = psq_prmdump(&psq_cb) ** ** EXTERNAL call format: status = psq_call(PSQ_PRMDUMP, &psq_cb, NULL); ** ** Description: ** The psq_prmdump function formats and prints the given control block. ** The output will go to the output terminal and/or file named by the ** user in the "SET TRACE TERMINAL" and "SET TRACE OUTPUT" commands. ** ** Inputs: ** psq_cb Everything in the control block gets ** printed. ** sess_cb Ignored. ** ** Outputs: ** NONE Nothing in the control block will be ** altered by this command, even if there ** is an error. ** Returns: ** E_DB_OK Function completed normally. ** E_DB_WARN Function completed with warning(s) ** E_DB_ERROR Function failed; non-catastrophic error ** E_DB_FATAL Function failed; catastrophic error ** Exceptions: ** none ** ** Side Effects: ** Sends output to terminal and/or log file ** ** History: ** 02-oct-85 (jeff) ** written ** 13-sep-90 (teresa) ** changed to dump PSQ_FLAG fields. Flag pqs_force has changed to ** be a bitflag instead of a boolean. Also, many new flags have been ** added and some of those are in psq_flag. Now all psq_flag bits ** will be dumped. ** 08-sep-93 (swm) ** Changed cast of session id parameter to psq_siddmp() function ** to CS_SID. ** 17-dec-93 (rblumer) ** "FIPS mode" no longer exists. It was replaced some time ago by ** several feature-specific flags (e.g. flatten_nosingleton and ** direct_cursor_mode). So I removed all FIPS_MODE flags. ** 11-oct-1993 (tad) ** Bug #56449 ** Changed %x to %p for pointer values. */ DB_STATUS psq_prmdump( register PSQ_CB *psq_cb) { DB_STATUS status; if (TRdisplay("Contents of PSQ_CB at 0x%p:\n", psq_cb) != TR_OK) return (E_DB_ERROR); /* Print common header for all cb's */ if ((status = psq_headdmp((PSQ_CBHEAD *) psq_cb)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_sessid:\t") != TR_OK) return (E_DB_ERROR); /* Print session id */ if ((status = psq_siddmp((CS_SID *) &psq_cb->psq_sessid)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_qlang:\t") != TR_OK) return (E_DB_ERROR); /* Print query language id */ if ((status = psq_lngdmp(psq_cb->psq_qlang)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_decimal:\t") != TR_OK) return (E_DB_ERROR); /* Print decimal specification */ if ((status = psq_decdmp(&psq_cb->psq_decimal)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_distrib:\t") != TR_OK) return (E_DB_ERROR); /* Print distributed specifier */ if ((status = psq_dstdmp(psq_cb->psq_distrib)) != E_DB_OK) return (status); /* display bitflags in psq_flags */ if (TRdisplay("\n\tpsq_flag.PSQ_FORCE:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_FORCE)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_IIQRYTEXT:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_IIQRYTEXT)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_ALIAS_SET:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_ALIAS_SET)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_CATUPD:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_CATUPD)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_WARNINGS:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_WARNINGS)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_ALLDELUPD:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_ALLDELUPD)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_flag.PSQ_DBA_DROP_ALL:\t") != TR_OK) return (E_DB_ERROR); if ((status = psq_booldmp(psq_cb->psq_flag & PSQ_DBA_DROP_ALL)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_version:\t%d", psq_cb->psq_version) != TR_OK) return (E_DB_ERROR); if (TRdisplay("\n\tpsq_mode:\t") != TR_OK) return (E_DB_ERROR); /* Print the query mode */ if ((status = psq_modedmp(psq_cb->psq_mode)) != E_DB_OK) return (status); /* ** if (TRdisplay("\n\tpsq_qryid:\t") != TR_OK) ** return (E_DB_ERROR); ** {Print the query id} ** if ((status = psq_qiddmp(&psq_cb->psq_qryid)) != E_DB_OK) ** return (status); ** */ if (TRdisplay("\n\tpsq_table:\t") != TR_OK) return (E_DB_ERROR); /* Print the id of the given table */ if ((status = psq_tbiddmp(&psq_cb->psq_table)) != E_DB_OK) return (status); if (TRdisplay("\n\tpsq_cursid:\t") != TR_OK) return (E_DB_ERROR); /* Print the cursor id */ if ((status = psq_ciddmp(&psq_cb->psq_cursid)) != E_DB_OK) return (status); /* ** if (TRdisplay("\n\tpsq_result:\t") != TR_OK) ** return (E_DB_ERROR); ** {Print the id for the parse result } ** if ((status = psq_qiddmp(&psq_cb->psq_result)) != E_DB_OK) ** return (status); ** */ if (TRdisplay("\n\tpsq_error:\t:") != TR_OK) return (E_DB_ERROR); /* Print the error block */ if ((status = psq_errdmp(&psq_cb->psq_error)) != E_DB_OK) return (status); return (E_DB_OK); }