/*{ ** Name: opt_seg_dump - Dump a list of text segments ** ** Description: ** Display a list of text segments as trace output. ** Text will be used as literally specified in ** the segment. Temp table names will be displayed ** as 't' followed by the temp number. ** ** Inputs: ** global Ptr to the global state variable ** qseg addr of first QEQ_TXT_SEG ** ** Outputs: ** Returns: ** VOID ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 27-sep-88 (robin) ** Created. [@history_template@]... */ VOID opt_seg_dump( OPS_STATE *global, QEQ_TXT_SEG *qseg) { DD_PACKET *pktptr; QEQ_TXT_SEG *segptr; i4 lensofar; if ( qseg == NULL ) { return; } /* Print initial newline */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s", "\n"); for ( segptr = qseg; segptr != NULL; segptr = segptr->qeq_s3_nxt_p ) { for (lensofar = 0,pktptr = segptr->qeq_s2_pkt_p; pktptr != NULL; pktptr = pktptr->dd_p3_nxt_p ) { if (lensofar >= 55) { TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s", "\n"); lensofar = 0; } if (pktptr->dd_p4_slot != DD_NIL_SLOT ) { /* this segment specifies a temp table or column */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "**{ %d }**", pktptr->dd_p4_slot); lensofar += 10; } else { /* there is text in this segment */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%t", pktptr->dd_p1_len, pktptr->dd_p2_pkt_p ); lensofar += pktptr->dd_p1_len; } } } }
/*{ ** Name: opt_ldb_dump - Dump an ldb descriptor ** ** Description: ** Print out an ldb descriptor for tracing. ** ** Inputs: ** global Global state variable ** ldbdesc Addr of ldb desc. to display ** justone True if only 1 should be dumped ** ** Outputs: ** Returns: ** VOID ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 27-sep-88 (robin) ** Created. [@history_template@]... */ VOID opt_ldb_dump( OPS_STATE *global, QEQ_LDB_DESC *ldbdesc, bool justone) { DD_LDB_DESC *ddldbptr; char *tfptr; bool stop; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nLDB DESCRIPTORS:\n"); for(stop = FALSE ; ldbdesc != NULL && stop == FALSE; ldbdesc = ldbdesc->qeq_l2_nxt_ldb_p ) { if (justone) stop = TRUE; ddldbptr = &ldbdesc->qeq_l1_ldb_desc; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nNODE NAME: %24t", sizeof(ddldbptr->dd_l2_node_name), ddldbptr->dd_l2_node_name ); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nLDB NAME: %24t", DD_256_MAXDBNAME, ddldbptr->dd_l3_ldb_name ); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nDBMS NAME: %24t", sizeof(ddldbptr->dd_l4_dbms_name), ddldbptr->dd_l4_dbms_name ); if (ddldbptr->dd_l1_ingres_b) tfptr = " "; else tfptr = "not"; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nLDB ID: %5d $INGRES status is %s required for access", ddldbptr->dd_l5_ldb_id, tfptr ); } return; }
/*{ ** Name: opt_qpdump - Dump query plan tracing info ** ** Description: ** ** Dumps data structures in a distributed query plan ** ** Inputs: ** global Global state variable ** qplan Ptr to a distributed query plan ** ** Outputs: ** Returns: ** ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 27-sep-88 (robin) ** created. [@history_template@]... */ VOID opt_qpdump ( OPS_STATE *global, QEF_QP_CB *qplan) { if ( qplan == NULL ) return; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nDISTRIBUTED QUERY PLAN\nQP_NEXT:%6x QP_PREV:%6x", qplan->qp_next, qplan->qp_prev); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nQP_MODE:%6d QP_RES_ROW_SZ:%6d", qplan->qp_qmode, qplan->qp_res_row_sz); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nQP_AHD_CNT:%6d" ,qplan->qp_ahd_cnt); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nThe query actions are:"); opt_qtdump( global, qplan->qp_ahd); if (qplan->qp_ddq_cb.qeq_d1_end_p != NULL) { TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nThe drop list is:"); opt_qtdump( global, qplan->qp_ddq_cb.qeq_d1_end_p); } else { TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nThere is no drop list"); } TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\nThe ldbs are:"); opt_ldb_dump( global, qplan->qp_ddq_cb.qeq_d2_ldb_p, (bool) FALSE); }
/*{ ** Name: sxf_display - like TRdisplay but output goes to user's terminal ** ** Description: ** send a formatted output line to the front end ** ** Inputs: ** format format string ** params variable number of parameters ** ** Outputs: ** Returns: ** VOID ** Exceptions: ** none ** ** Side Effects: ** If output requires more than 131 chars, part of it will be truncated. ** ** History: ** 24-sep-92 (robf) ** Created */ VOID sxf_display(char *format, PTR p1, PTR p2, PTR p3, PTR p4, PTR p5) { char buffer[SXF_MAX_MSGLEN + 1]; /* last char for `\n' */ MEfill (sizeof(buffer), 0, buffer); /* TRformat removes `\n' chars, so to ensure that gwf_scctrace() ** outputs a logical line (which it is supposed to do), we allocate ** a buffer with one extra char for NL and will hide it from TRformat ** by specifying length of 1 byte less. The NL char will be inserted ** at the end of the message by gwf_scctrace(). */ _VOID_ TRformat(sxf_scctalk, 0, buffer, sizeof(buffer) - 1, format, p1, p2, p3, p4, p5 ); }
/* ** Name: ADFmo_adg_op_use_get - MO Get function for the op_use field ** ** Description: ** This routine is called by MO to provide a "user-friendly" ** interpretation of the operation use. ** ** Inputs: ** offset - offset into the ADI_OPRATION, ignored. ** objsize - size of the use field, ignored ** object - the ADI_OPRATION address ** luserbuf - length of the output buffer ** ** Outputs: ** userbuf - written with nice status string ** ** Returns: ** STATUS ** ** History: ** 18-Jun-2008 (kiria01) b120519 ** Created */ static STATUS ADFmo_adg_op_use_get( i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf ) { ADI_OPRATION *op = (ADI_OPRATION *)object; char format_buf [30]; MEfill(sizeof(format_buf), (u_char)0, format_buf); TRformat(NULL, 0, format_buf, sizeof(format_buf), "%w", use_string, op->adi_opuse); return (MOstrout( MO_VALUE_TRUNCATED, format_buf, luserbuf, userbuf )); }
/* ** Name: ADFmo_adg_fi_type_get - MO Get function for the fi_type field ** ** Description: ** This routine is called by MO to provide a "user-friendly" ** interpretation of the operation type. ** ** Inputs: ** offset - offset into the ADI_FI_DESC, ignored. ** objsize - size of the type field, ignored ** object - the ADI_FI_DESC address ** luserbuf - length of the output buffer ** ** Outputs: ** userbuf - written with nice status string ** ** Returns: ** STATUS ** ** History: ** 22-may-1996 (shero03) ** Created from LK_lkb_rsb_get. */ static STATUS ADFmo_adg_fi_type_get( i4 offset, i4 objsize, PTR object, i4 luserbuf, char *userbuf ) { ADI_FI_DESC *fi = (ADI_FI_DESC *)object; char format_buf [30]; MEfill(sizeof(format_buf), (u_char)0, format_buf); TRformat(NULL, 0, format_buf, sizeof(format_buf), "%w", type_string, fi->adi_fitype); return (MOstrout( MO_VALUE_TRUNCATED, format_buf, luserbuf, userbuf )); }
/*{ ** Name: adu_cpn_dump - Dump the value of a coupon ** ** Description: ** This routine simply dumps the current value of a particular ADP_COUPON ** structure. The information is provided as ADF knows it -- tag & length ** are labelled, the coupon itself is just a bunch of numbers. ** ** Inputs: ** adf_scb Session Control Block. ** cpn_dv Ptr to DB_DATA_VALUE describing the ** coupon to be printed ** res_dv Ptr to DB_DATA_VALUE describing the ** result area. ** ** Outputs: ** *res_dv->db_data Filled in. ** ** Returns: ** DB_STATUS ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 01-feb-1990 (fred) ** Created. [@history_template@]... */ DB_STATUS adu_cpn_dump( ADF_CB *adf_scb, DB_DATA_VALUE *cpn_dv, DB_DATA_VALUE *res_dv) { DB_DT_ID dtid = abs(cpn_dv->db_datatype); ADP_PERIPHERAL *p = (ADP_PERIPHERAL *) cpn_dv->db_data; DB_TEXT_STRING *result = (DB_TEXT_STRING *) res_dv->db_data; ADP_PERIPHERAL peripheral; if ((Adf_globs->Adi_dtptrs[dtid]->adi_dtstat_bits & AD_PERIPHERAL) == 0) { STcopy("<Not a peripheral>", (char *)result->db_t_text); result->db_t_count = STlength((char *)result->db_t_text); } else if (cpn_dv->db_length < sizeof(ADP_PERIPHERAL)) { STcopy("<Too short to be a coupon>", (char *)result->db_t_text); result->db_t_count = STlength((char *)result->db_t_text); } else if (res_dv->db_length < 100) { STcopy("<Result too short>", (char *)result->db_t_text); result->db_t_count = STlength((char *)result->db_t_text); } else { MECOPY_CONST_MACRO((PTR)p, sizeof(peripheral), (PTR)&peripheral); p = &peripheral; TRformat(adu_finish_format, result, result->db_t_text, (res_dv->db_length - sizeof(result->db_t_count)), "Tag: %d., Length: %8x%8x, Cpn: <%#.#{%8x %}>", p->per_tag, p->per_length0, p->per_length1, (sizeof(p->per_value.val_coupon) / sizeof(p->per_value.val_coupon.cpn_id[0])), sizeof(p->per_value.val_coupon.cpn_id[0]), p->per_value.val_coupon.cpn_id, 0); } return(E_DB_OK); }
/*{ ** Name: dmfinfo - Database information display. ** ** Description: ** ** Inputs: ** journal_context Pointer to DMF_JSX ** dcb Pointer to DCB. ** ** Outputs: ** err_code Reason for error return status. ** Returns: ** E_DB_OK ** E_DB_ERROR ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 01-nov-1986 (Derek) ** Created for Jupiter. ** 03-feb-1989 (EdHsu) ** Updated for online backup. ** 09-apr-1990 (Sandyh) ** Added inconsistency reason. ** 17-may-90 (bryanp) ** Display the new DUMP_DIR_EXISTS status in the database descriptor. ** 25-feb-1991 (rogerk) ** Added check for JOURNAL_DISABLED status. Also added some ** comment messages for some database states. These were added ** for the Archiver Stability project. ** 25-mar-1991 (rogerk) ** Added checks for NOLOGGING status and nologging inconsistency types. ** 30-apr-1991 (bryanp) ** Support trace processing ("#x"). ** 8-nov-1992 (ed) ** remove DB_MAXNAME dependency ** 04-nov-92 (jrb) ** Changed "SORT" to "WORK" for multi-location sorts project. ** 30-nov-92 (robf) ** Add C2 security auditing. ** 14-dec-1992 (rogerk) ** Reduced Logging Project: Changed database inconsistent codes. ** 18-jan-1993 (rogerk) ** Fixed problem with reporting inconsistency codes added in last ** integration. Shifted TRdisplay vector over one to get correct ** output. ** 24-may-1993 (jnash) ** Show last journaled log address in <%d:%d:%d> format. ** 20-sep-1993 (bryanp) ** Fix TRdisplay calls to line up properly with DB_MAX_NAME=32. ** 20-sep-1993 (jnash) ** Fix problem where dump information not presented. Also include ** version information in infodb output. ** 14-oct-93 (jrb) ** Added informational line to say when the db is NOT journaled. ** 22-nov-1993 (jnash) ** B53797. Apply Walt's 6.4 VMS fix where if a database never ** checkpointed, INFODB AVs. Use CL_OFFSETOF rather than zero-pointer ** construction in TRdisplay statement. Bug caused by compiler ** bug when dmfinfo.c containing original expression was compiled ** with /opt. ** 15-feb-1994 (andyw) ** Modified dmfinfo to check for checkpoint sequence number of ** journals and dumps instead of using DSC_CKP_INPROGRESS. ** 15-feb-1994 (andyw) ** Modified the dump log address incorporating the standard ** address format <a:b:c> bug reference 58553. ** 25-apr-1994 (bryanp) B62023 ** Used CL_OFFSETOF to format and display the components of the ** checkpoint history and dump history. The old technique using ** casts of null pointers doesn't work on the Alpha. ** 13-Dec-1994 (liibi01) ** Cross integration from 6.4 (Bug 56364). ** Added new inconsistency class instance RFP_FAIL as ** side effect of fix to bug 56364. ** 24-jan-1995 (stial01) ** BUG 66473: display if checkpoint is table checkpoint ** 12-sep-1995 (thaju02) ** Added routine output_tbllist(). Implementation of ** sending to output the contents of the checkpoint table list ** file. ** 6-feb-1996 (nick) ** Call to output_tbllist() was missing the err_code param - this ** caused an access violation if output_tbllist() tried to set it. ** Moved call to output_tbllist() to a) ensure we security audit ** the operation, b) ensure the checkpoint in question exists and ** c) the output format looks like normal 'infodb'. ** 12-mar-96 (nick) ** 'Next table id' is actually the last one. ** 29-mar-96 (nick) ** Change CKP_INPROGRESS back to CKP. ** 17-may-96 (nick) ** Move RFP_FAIL in the TRformat(). ** 28-feb-1997 (angusm) ** Output collation sequence defined for database. (SIR 72251) ** 07-aug-2000 (somsa01) ** When printing out the table list, we were incorrectly passing ** an argument to TRformat(). ** 12-apr-2005 (gupsh01) ** Added support for unicode information. [@history_template@]... */ DB_STATUS dmfinfo( DMF_JSX *jsx, DMP_DCB *dcb, DB_STATUS *err_code) { DM0C_CNF *config; DM0C_CNF *cnf; i4 i; i4 length; DB_STATUS status; DB_STATUS local_status; STATUS cl_status; bool jnode_info = FALSE; bool dnode_info = FALSE; char line_buffer[132]; CL_ERR_DESC sys_err; SXF_ACCESS access; LG_HEADER log_hdr; if (jsx->jsx_status & JSX_TRACE) TRset_file(TR_F_OPEN, "infodb.dbg", 10, &sys_err); /* Pretend the database is exclusive. */ dcb->dcb_status |= DCB_S_EXCLUSIVE; /* Lock the database. */ status = dm0c_open(dcb, 0, dmf_svcb->svcb_lock_list, &config, err_code); /* ** Make sure access is security audited. */ if ( dmf_svcb->svcb_status & SVCB_C2SECURE ) { access = SXF_A_SELECT; if (status) access |= SXF_A_FAIL; else access |= SXF_A_SUCCESS; local_status = dma_write_audit( SXF_E_DATABASE, access, dcb->dcb_name.db_db_name, /* Object name (database) */ sizeof(dcb->dcb_name.db_db_name), /* Object name (database) */ &dcb->dcb_db_owner, /* Object owner */ I_SX2711_INFODB, /* Message */ TRUE, /* Force */ err_code, NULL); if (local_status != E_DB_OK) status=local_status; } if (status != E_DB_OK) return (status); cnf = config; TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), "%18*=%@ Database Information%17*=\n\n"); if (STcompare(" ", cnf->cnf_dsc->dsc_collation)==0) STcopy("default", cnf->cnf_dsc->dsc_collation); TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Database : (%~t,%~t) ID : 0x%x Default collation : %~t\n", sizeof(cnf->cnf_dsc->dsc_name), &cnf->cnf_dsc->dsc_name, sizeof(cnf->cnf_dsc->dsc_owner), &cnf->cnf_dsc->dsc_owner, cnf->cnf_dsc->dsc_dbid, sizeof(cnf->cnf_dsc->dsc_collation) ,&cnf->cnf_dsc->dsc_collation); /* Provide Unicode support information here */ TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Unicode enabled : %s\n", cnf->cnf_dsc->dsc_dbservice & DU_UTYPES_ALLOWED ? "Yes" : "No"); if (cnf->cnf_dsc->dsc_dbservice & DU_UTYPES_ALLOWED) { TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Default unicode collation : %~t \t Unicode normalization : %s\n", sizeof(cnf->cnf_dsc->dsc_ucollation) ,&cnf->cnf_dsc->dsc_ucollation, (cnf->cnf_dsc->dsc_dbservice & DU_UNICODE_NFC) ? "NFC" : "NFD"); } if (jsx->jsx_status1 & JSX1_OUT_FILE) { status = output_tbllist(jsx, dcb, cnf, err_code); (void)dm0c_close(cnf, 0, err_code); return(status); } TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Extents : %d Last Table Id : %d\n", cnf->cnf_dsc->dsc_ext_count, cnf->cnf_dsc->dsc_last_table_id); TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Config File Version Id : 0x%x Database Version Id : %d\n", cnf->cnf_dsc->dsc_cnf_version, cnf->cnf_dsc->dsc_c_version); /* ** Show mode of operation: production on | off ** online checkpoint enabled | disabled */ TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Mode : DDL %s, ONLINE CHECKPOINT %s\n", cnf->cnf_dsc->dsc_dbaccess & DU_PRODUCTION ? "DISALLOWED" : "ALLOWED", cnf->cnf_dsc->dsc_dbaccess & DU_NOBACKUP ? "DISABLED" : "ENABLED"); /* ** The flag is 'DSC_DUMP_DIR_EXISTS', but we report it as 'CFG_BACKUP', ** since its current use is to enable config file auto-backup. */ TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), " Status : %v\n\n", "VALID,JOURNAL,CKP,DUMP,ROLL_FORWARD,SMINC,PART,,PRE,CFG_BACKUP,\ JOURNAL_DISABLED,NOLOGGING", cnf->cnf_dsc->dsc_status); /* ** Print database status information comments. */ if (!(cnf->cnf_dsc->dsc_status & DSC_VALID)) { TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), "%15* The Database is Inconsistent.\n"); TRformat(dmf_put_line, 0, line_buffer, sizeof(line_buffer), "%19* Cause of Inconsistency: %w\n", ",REC_OPEN_FAILURE,RECOVER_ERROR,REDO_ERROR,UNDO_ERROR,OPEN_COUNT,,\ WILL_COMMIT_ERR,NOLOGGING_ERROR,NOLOGGING_OPENDB,,RFP_FAIL", cnf->cnf_dsc->dsc_inconst_code); }
/*{ ** Name: opt_qtdump - Dump list of query text for an action ** ** Description: ** ** Inputs: ** global Global state variable ** dda Ptr to first distributed action header ** ** Outputs: ** Returns: ** {@return_description@} ** Exceptions: ** [@description_or_none@] ** ** Side Effects: ** [@description_or_none@] ** ** History: ** 27-sep-88 (robin) ** created. ** 11-nov-88 (robin) ** Added code for xfr actions. [@history_template@]... */ VOID opt_qtdump ( OPS_STATE *global, QEF_AHD *dda) { i4 acttype; QEF_AHD *ddaptr; QEQ_D1_QRY *qryptr; char *actstr; for ( ddaptr = dda; ddaptr != NULL; ddaptr = ddaptr->ahd_next) { acttype = ddaptr->ahd_atype; switch (acttype) { case QEA_D2_GET: /* this is a get - follows when a query returns tuples */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nGET:"); opt_ldb_dump( global, (QEQ_LDB_DESC *)ddaptr->qhd_obj.qhd_d2_get.qeq_g1_ldb_p, (bool) TRUE ); break; case QEA_D3_XFR: /* this is a transfer action */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nXFR:"); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nXFR srce:"); qryptr = &ddaptr->qhd_obj.qhd_d3_xfr.qeq_x1_srce; opt_qrydump( global, qryptr ); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nXFR temp:"); qryptr = &ddaptr->qhd_obj.qhd_d3_xfr.qeq_x2_temp; opt_qrydump( global, qryptr ); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nXFR sink:"); qryptr = &ddaptr->qhd_obj.qhd_d3_xfr.qeq_x3_sink; opt_qrydump( global, qryptr ); break; case QEA_D4_LNK: /* Not yet implemented */ break; case QEA_D5_DEF: /* this is a define cursor */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\nDEFINE CURSOR:"); opt_qrydump( global, &ddaptr->qhd_obj.qhd_d1_qry); break; default: if ( acttype == QEA_D1_QRY ) { actstr = "\nQUERY: "; } else if ( acttype == QEA_D8_CRE ) { actstr = "\nINTERNAL CREATE_AS_SELECT: "; } else if ( acttype == QEA_D6_AGG ) { actstr = "\nAGGREGATE: "; } else if ( acttype == QEA_D7_OPN ) { actstr = "\nDEFINE/OPEN CURSOR: "; } else if ( acttype == QEA_D9_UPD ) { actstr = "\nCURSOR UPDATE: "; } else { actstr = "\n**UNKNOWN ACTION TYPE** "; } /* this is a query */ TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s", actstr); opt_qrydump( global, &ddaptr->qhd_obj.qhd_d1_qry); } } return; }
/*{ ** Name: opt_qrydump - Dump a QEQ_D1_QRY structure ** ** Description: ** ** Inputs: ** global global stat variable ** qryptr Ptr to the QEQ_D1_QRY to dump ** ** Outputs: ** Returns: ** VOID ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 08-dec-88 (robin) ** Created. [@history_template@]... */ VOID opt_qrydump( OPS_STATE *global, QEQ_D1_QRY *qryptr) { char *varstring; i4 n; if (qryptr->qeq_q1_lang == DB_SQL) varstring = "DB_SQL"; else if (qryptr->qeq_q1_lang == DB_QUEL) varstring = "DB_QUEL"; else varstring = "***UNKNOWN - ERROR****"; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\n Query Language: %s", varstring); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\n Quantum: %d", qryptr->qeq_q2_quantum); if (qryptr->qeq_q3_read_b == TRUE) varstring = "TRUE"; else varstring = "FALSE"; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\n Retrieval (qeq_q3_read_b): %s", varstring); opt_seg_dump( global, qryptr->qeq_q4_seg_p); opt_ldb_dump( global, (QEQ_LDB_DESC *)qryptr->qeq_q5_ldb_p, (bool) TRUE ); TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\n Column count: %d", qryptr->qeq_q6_col_cnt); if (qryptr->qeq_q6_col_cnt > 0 && qryptr->qeq_q7_col_pp != NULL ) { /* dump out column names */ for (n = 0; n < qryptr->qeq_q6_col_cnt; n++) { varstring = (char *) qryptr->qeq_q7_col_pp[n]; TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "\n Column %d: %s", n, varstring ); } TRformat( opt_scc, (i4 *) global, (char *) &global->ops_trace.opt_trformat[0], (i4) sizeof(global->ops_trace.opt_trformat), "%s","\n\n"); } return; }
/* ** Name: ascs_iformat - Format a session control block ** ** Description: ** This routine formats the provided scb into the location ** passed in. If the memory provided is not large enough, ** an error is returned. ** ** Inputs: ** scb The scb to format ** powerful Indicates that the caller is powerful ** (I.e. is a super user). ** supress_sid Indicates that the caller already ** printed the session id. ** err_output If true, then the output should go to ** the errlog and II_DBMS_LOG; otherwise, ** it goes to SCC_TRACE. ** ** Outputs: ** *buf is filled ** Returns: ** STATUS ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 24-mar-1987 (fred) ** Created. ** 15-jan-91 (ralph) ** Correct TRdisplay for session group id ** 21-may-91 (andre) ** Effective user, group, and role ids are stored in ics_eusername, ** ics_egrpid, and ics_eaplid, respectively. Values of user, group, ** and role identifiers which were in effect at session startup are ** stored in ics_susername, ics_sgrpid, and ics_saplid. ** 27-feb-1992 (rog) ** Renamed from scs_format so we can use this function for both ** iimonitor and AV tracing, cleaned up the argument list, and ** change the function so that the out can go to various places. ** 8-nov-1992 (ed) ** remove DB_MAXNAME dependency ** 03-dec-92 (andre) ** ics_eusername will become a pointer that will point at ics_susername ** unless we are inside a module with <module auth id> in which case ** the <module auth id> will be stored in ics_musername and ** ics_eusername will be made to point at ics_musername until we leave ** the module. ** ** As a part of desupporting SET GROUP/ROLE, we are getting rid of ** ics_saplid and ics_sgrpid ** ** user name as session startup (the Initial user name) will be stored ** in ics_iusername (used to be ics_susername). ics_susername is now ** used for the session auth id which can be changed by SET SESSION ** AUTHORIZATION ** 2-Jul-1993 (daveb) ** prototyped. removed unused viar 'size_so_far'. ** 9-nov-93 (robf) ** Display session description. Comes after activity, before ** query. ** 09-mar-94 (swm) ** Bug #60425 ** CS_SID was displayed with %x rather than %p, %x truncates ** on 64-bit platforms. [@history_template@]... */ STATUS ascs_iformat(SCD_SCB *scb, i4 powerful, i4 suppress_sid, i4 err_output ) { i4 print_mask = 0; char buf[ER_MAX_LEN]; char user[ GL_MAXNAME * 2 + 1 ]; char host[ GL_MAXNAME * 2 + 1 ]; char tty[ GL_MAXNAME * 2 + 1 ]; char pid[ GL_MAXNAME * 2 + 1 ]; char conn[ GL_MAXNAME * 4 + 1 ]; if (scb->scb_cscb.cscb_comm_size < 256) return(FAIL); print_mask |= (err_output) ? SCE_FORMAT_ERRLOG : SCE_FORMAT_GCA; if (!suppress_sid) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, ">>>>>Session %p<<<<<", scb->cs_scb.cs_self); } if (scb->scb_sscb.sscb_stype!=SCS_SMONITOR) { /* ** Monitor session doesn't connect to a specific database */ TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " DB Name: %#s%s (Owned by: %#s )", DB_DB_MAXNAME, &scb->scb_sscb.sscb_ics.ics_dbname, (scb->scb_sscb.sscb_ics.ics_lock_mode & DMC_L_EXCLUSIVE ? "(exclusive)" : ""), DB_OWN_MAXNAME, &scb->scb_sscb.sscb_ics.ics_dbowner); } TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " User: %#s (%#s) ", DB_OWN_MAXNAME, scb->scb_sscb.sscb_ics.ics_eusername, DB_OWN_MAXNAME, &scb->scb_sscb.sscb_ics.ics_rusername); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " User Name at Session Startup: %#s", DB_OWN_MAXNAME, &scb->scb_sscb.sscb_ics.ics_iusername); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Terminal: %16s", &scb->scb_sscb.sscb_ics.ics_terminal); if (scb->scb_sscb.sscb_stype!=SCS_SMONITOR) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Group Id: %#s", DB_OWN_MAXNAME, &scb->scb_sscb.sscb_ics.ics_egrpid); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Role Id: %#s", DB_OWN_MAXNAME, &scb->scb_sscb.sscb_ics.ics_eaplid); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Application Code: %x Current Facility: %w %<(%x)", scb->scb_sscb.sscb_ics.ics_appl_code, "<None>,CLF,ADF,DMF,OPF,PSF,QEF,QSF,RDF,SCF,ULF,DUF,GCF,RQF,TPF,GWF,SXF", scb->scb_sscb.sscb_cfac); } if (scb->scb_sscb.sscb_ics.ics_l_act1 || scb->scb_sscb.sscb_ics.ics_l_act2) { if (scb->scb_sscb.sscb_ics.ics_l_act1) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Activity: %t", scb->scb_sscb.sscb_ics.ics_l_act1, scb->scb_sscb.sscb_ics.ics_act1); } else if (scb->scb_sscb.sscb_cfac == DB_DMF_ID) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Activity: (Aborting)"); } else if (scb->scb_sscb.sscb_cfac == DB_OPF_ID) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Activity: (Optimizing)"); } if (scb->scb_sscb.sscb_ics.ics_l_act2) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Act. Detail: %t", scb->scb_sscb.sscb_ics.ics_l_act2, scb->scb_sscb.sscb_ics.ics_act2); } } else if (scb->scb_sscb.sscb_stype==SCS_SMONITOR) TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Activity: (Monitor Session)"); if( scb->scb_sscb.sscb_ics.ics_gw_parms != NULL ) { ascs_a_user_get( 0, 0, (PTR)scb, sizeof( user ), user ); ascs_a_host_get( 0, 0, (PTR)scb, sizeof( host ), host ); ascs_a_tty_get( 0, 0, (PTR)scb, sizeof( tty ), tty ); ascs_a_pid_get( 0, 0, (PTR)scb, sizeof( pid ), pid ); ascs_a_conn_get( 0, 0, (PTR)scb, sizeof( conn ), conn ); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Client user: %s\n Client host: %s", user, host ); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Client tty: %s\n Client pid: %s", tty, pid ); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Client connection target: %s", conn ); TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Client information: %s", scb->scb_sscb.sscb_ics.ics_gw_parms ); } /* Session description. This is only available to privileged sessions, ** since it could be a comms channel on a secure system. ** Same for Query: */ if (powerful && scb->scb_sscb.sscb_stype!=SCS_SMONITOR) { TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Description: %t", scb->scb_sscb.sscb_ics.ics_l_desc , (scb->scb_sscb.sscb_ics.ics_l_desc ? scb->scb_sscb.sscb_ics.ics_description : "")); /* ** Monitor sessions do not have a query */ TRformat(sc0e_tput, &print_mask, buf, sizeof(buf) - 1, " Query: %t", (scb->scb_sscb.sscb_ics.ics_l_qbuf ? scb->scb_sscb.sscb_ics.ics_l_qbuf : 0), (scb->scb_sscb.sscb_ics.ics_l_qbuf ? scb->scb_sscb.sscb_ics.ics_qbuf : "")); } return(OK); }
STATUS ERsend(i4 flag, char *message, i4 msg_length, CL_ERR_DESC *err_code) { # ifdef NT_GENERIC static bool er_init = FALSE; static bool is_w95 = FALSE; # else /* !NT_GENERIC */ static int er_ifi = -2; static int ar_ifi = -2; # endif /* !NT_GENERIC */ STATUS status; char tmp_buf[ER_MAX_LEN]; char* logmsg = message; /* Check for bad paramters. */ CL_CLEAR_ERR( err_code ); if ((message == 0 || msg_length == 0) && flag != ER_AUDIT_MSG) return (ER_BADPARAM); if ((flag != ER_ERROR_MSG) && (flag != ER_AUDIT_MSG) && ( flag != ER_OPER_MSG)) return (ER_BADPARAM); # ifndef NT_GENERIC if (flag & ER_AUDIT_MSG) { key_t msg_key; char *ipc_number; struct { long mtype; char mtext[ER_MAX_LEN]; } msg; if (ar_ifi == -2) { NMgtAt("II_AUDIT_IPC", &ipc_number); if (ipc_number && ipc_number[0]) { CVal(ipc_number, &msg_key); ar_ifi = msgget(msg_key, 0); if (ar_ifi == -1) { SETCLERR(err_code, 0, ER_open); return(ER_NO_AUDIT); } } else { SETCLERR(err_code, 0, ER_open); return(ER_NO_AUDIT); } } /* Handle special case to connect only but not send message. */ if (msg_length == 0 && message == 0) return (OK); MEcopy(message, msg_length, msg.mtext); msg.mtype = 1; if (msgsnd(ar_ifi, &msg, msg_length, 0)) { SETCLERR(err_code, 0, ER_open); return(ER_BADSEND); } return (OK); } else # endif /* ! NT_GENERIC */ if (flag & ER_OPER_MSG) { char hostname[GL_MAXNAME]; STATUS status; message[msg_length] = EOS; TRdisplay("ER Operator:\"%s\"\n",message); if (!ERsysinit) ERinitsyslog(); # ifdef NT_GENERIC { wchar_t *wmessage = NULL; /* ** Update the ReportEvent to report information in the event log. */ if ( ReportEvent( EventLog, (WORD) EVENTLOG_INFORMATION_TYPE, (WORD) 0, /* event category */ (DWORD) I_ING_INFO, /* event identifier */ (PSID) NULL, (WORD) 1, /* number of strings */ (DWORD) 0, &message, NULL ) == FALSE) status = GetLastError(); if ( !er_init ) { char VersionString[256]; FUNC_EXTERN BOOL GVosvers(char *OSVersionString); GVosvers(VersionString); is_w95 = ( STstrindex(VersionString, "Microsoft Windows 9", 0, FALSE) != NULL ) ? TRUE : FALSE; if ( !is_w95 ) /* netapi32 only on NT */ { HANDLE hDll; if ((hDll = LoadLibrary(TEXT("netapi32.dll"))) != NULL) { pNetMessageNameAdd = (NET_API_STATUS (*)(LPCWSTR,LPCWSTR)) GetProcAddress(hDll, TEXT("NetMessageNameAdd")); pNetMessageNameDel = (NET_API_STATUS (*)(LPCWSTR,LPCWSTR)) GetProcAddress(hDll, TEXT("NetMessageNameDel")); pNetMessageBufferSend = (NET_API_STATUS (*)(LPCWSTR,LPCWSTR,LPCWSTR,LPBYTE,DWORD)) GetProcAddress(hDll, TEXT("NetMessageBufferSend")); } /* if any problem, pretend we don't support it */ if ( pNetMessageNameAdd == NULL || pNetMessageNameDel == NULL || pNetMessageBufferSend == NULL ) is_w95 = TRUE; } } if ( !is_w95 ) { /* ** Now, send the message to the server console, ** putting up a message box (if the messenger service ** is running. Everything must be in Unicode. */ if ( whostname[0] == 0 ) { unsigned int len = sizeof(hostname); /* ** get the hostname in Unicode format for use ** by messenger service */ GetComputerName( (char *)hostname, &len ); MultiByteToWideChar( GetACP(), 0, hostname, sizeof(hostname), whostname, sizeof(whostname) ); } /* initialize the messenger service */ status = (*pNetMessageNameAdd)( whostname, msgname ); if ( status != NERR_Success ) status = GetLastError(); /* Allocate a buffer for the Unicode */ wmessage = (wchar_t *) MEreqmem( 0, msg_length * sizeof(wchar_t), TRUE, &status ); if ( wmessage ) { /* copy the message to the Unicode buffer */ MultiByteToWideChar( GetACP(), 0, message, msg_length, wmessage, msg_length * sizeof(wchar_t) ); status = (*pNetMessageBufferSend)( whostname, msgname, NULL, (LPBYTE) wmessage, msg_length*sizeof(wchar_t) ); if ( status != NERR_Success ) status = GetLastError(); MEfree( (PTR)wmessage ); } /* re-initialize the messenger service */ status = (*pNetMessageNameDel)( whostname, msgname ); if ( status != NERR_Success ) status = GetLastError(); } } # elif defined(OS_THREADS_USED) && defined(any_aix) syslog_r( LOG_ALERT|LOG_ERR, message ); # else syslog( LOG_ALERT|LOG_ERR, message ); # endif /* NT_GENERIC */ } if (flag & ER_OPER_MSG) { i4 msglen = 0; char* host = PMhost(); MEfill( ER_MAX_LEN, 0, tmp_buf ); /* ** Format the message string for the event log. As the source is ** not known a fixed string of INGSYSLOG is used. */ TRformat( NULL, 0, tmp_buf, ER_MAX_LEN - 1, "%8.8t::[INGSYSLOG , 00000000]: %@ ", STlength(host), host ); msglen = STlength(tmp_buf); STcat( tmp_buf, message ); /* append original message */ msg_length += msglen; logmsg = tmp_buf; } status = ERlog( logmsg, msg_length, err_code ); return( status ); }
/*{ ** Name: scs_monitor - Implement the SCS part of the monitor task ** ** Description: ** This routine is called ala the regular thread processing routine. ** It parses its input, decides what to do, and returns the output. ** ** The commmands completely interpreted here are: ** ** set server shut (CS_CLOSE) ** Disallow new connections, shutdown when ** last current session exits. ** ** remove SESSION ** New improved "safe" version, acts the same ** as front-end exiting and dropping GCA connection. ** ** kill SESSION ** Signal CS_KILL_EVENT to a user session actively ** running a query. ** ** NEW: ** set server closed ** Disallow new regular user sessions. ** ** set server open ** Reallow new regular user sessions. Cancel ** any pending 'set server shut' shutdown. ** ** show server listen ** ** crash session SESSIONID ** ** Commands partially handled here and partially in CSmonitor are: ** ** stop server (CS_KILL) ** Kill user sessions, shutdown when they're gone. ** ** stop server conditional (CS_COND_CLOSE) ** Shutdown if no sessions, which never works because ** this session always exists. ** ** crash server (CS_CRASH) ** Take the server down immediately. ** ** All other commands are passed to CSmonitor for handling. ** ** Inputs: ** mode Mode of operation ** CS_INPUT, _OUPUT, ... ** scb Sessions control block to monitor ** *command Text of the command ** powerful Is this user powerful ** output_fcn Function to call to perform the output. ** This routine will be called as ** (*output_fcn)(newline_present, ** length, ** buffer) ** where buffer is the length character ** output string, and newline_present ** indicates whether a newline needs to ** be added to the end of the string. ** ** Outputs: ** next_mode As above. ** Returns: ** OK ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 26-Jul-1993 (daveb) ** created. ** 15-Sep-1993 (daveb) ** ifdef out all but drop connection for now. ** 1-Nov-1993 (daveb) ** Match LRC proposal. Drop becomes remove, remove becomes kill. ** 10-Nov-1993 (daveb) ** Match approved proposal. Kill becomes "crash session SESSIONID" ** 15-dec-93 (robf) ** Add prototype "broadcast" message request. ** 4-mar-94 (robf) ** Add initial security auditing to iimonitor events. ** 12-dec-1996 (canor01) ** Add support for sampler thread. ** 24-Apr-2003 (jenjo02) ** Added "kill" command to abort eligible queries ** while leaving the session intact, SIR 110141. ** 17-Sep-2004 (schka24) ** Manual fix to remove command so that it fires. ** 05-may-2005 (horda03) Bug 114453/INGSRV 3290 ** For server/session changes log the command. ** 22-may-2007 (horda03) Bug 117966 ** Log the command before calling CSmonitor, as ** the CS could be crashing the server. ** 23-Sep-2009 (hanal04) Bug 115316 ** Added "SHOW SERVER CAPABILITIES". */ static STATUS scs_monitor( i4 mode, CS_SCB *scb, i4 *nmode, char *command, i4 powerful, i4 (*output_fcn)(PTR, i4, char *) ) { STATUS ret_stat; char buf[81]; bool completely_done; PTR ptr_scb; SCD_SCB *an_scb; i4 log_cmd = 0; i4 local_error; SCD_SCB *my_scb = (SCD_SCB*)scb; *nmode = CS_EXCHANGE; completely_done = FALSE; ret_stat = OK; switch (mode) { case CS_INITIATE: *nmode = CS_INPUT; break; case CS_TERMINATE: break; case CS_INPUT: CVlower(command); if (STscompare("setservershut", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to stop servers"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274D_SET_SERVER_SHUT ); } else /* disallow regular listens, exit when last conn exits */ { Sc_main_cb->sc_listen_mask = (SC_LSN_TERM_IDLE |SC_LSN_SPECIAL_OK) ; TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Server will stop. %d. sessions remaining", Sc_main_cb->sc_current_conns ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274D_SET_SERVER_SHUT ); log_cmd = 1; } completely_done = TRUE; } else if (STscompare("setserverclosed", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to disable connections"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2748_SET_SERVER_CLOSED ); } else /* Disallow regular listens */ { if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2748_SET_SERVER_CLOSED ); Sc_main_cb->sc_listen_mask &= (~SC_LSN_REGULAR_OK); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "User connections now disabled" ); log_cmd = 1; } completely_done = TRUE; } else if (STscompare("setserveropen", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to enable connections"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2749_SET_SERVER_OPEN ); } else /* allow all listens, cancel any impending shutdown */ { Sc_main_cb->sc_listen_mask = (SC_LSN_REGULAR_OK | SC_LSN_SPECIAL_OK); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "User connections now allowed" ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2749_SET_SERVER_OPEN ); log_cmd = 1; } completely_done = TRUE; } else if (STncasecmp("broadcast", command, 9) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to broadcast messages"); } else { /* ** Broadcast the message to any connected sessions */ scs_scan_scbs(scs_broadcast_mesg, (PTR)(command+10)); } completely_done = TRUE; } else if (STscompare("stopserverconditional", 0, command, 0) == 0 || STscompare("stopserver", 0, command, 0) == 0 || STscompare("crashserver", 0, command, 0) == 0 ) { /* Audit log the attempt here? */ if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, powerful? SXF_A_CONTROL|SXF_A_SUCCESS: SXF_A_CONTROL|SXF_A_FAIL, /* Action */ I_SX274A_STOP_SERVER ); log_cmd = powerful; } else if (STscompare("showservercapabilities", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%v", SC_CAPABILITIES_FLAGS, Sc_main_cb->sc_capabilities ); completely_done = TRUE; } else if (STscompare("showserverlisten", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%s", Sc_main_cb->sc_listen_mask & SC_LSN_REGULAR_OK ? "OPEN" : "CLOSED" ); completely_done = TRUE; } else if (STscompare("showservershutdown", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%s", Sc_main_cb->sc_listen_mask & SC_LSN_TERM_IDLE ? "PENDING" : "OPEN" ); completely_done = TRUE; } # ifdef NOT_SUPPORTED else if (STscompare("showconnections", 0, command, 0) == 0 ) { scs_scan_scbs( scs_show_func, (PTR)&powerful ); completely_done = TRUE; } else if (STscompare("show connection", 15, command, 15) == 0 ) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 14, &ptr_scb) || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid connection id"); break; } scs_show_func( an_scb, &powerful ); } # endif else if (STscompare("remove", 6, command, 6) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 6, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); break; } if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to remove session"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274B_REMOVE_SESSION ); break; } if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274B_REMOVE_SESSION ); scs_remove_sess( an_scb ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p removed", an_scb); log_cmd = 1; } else if (STscompare("crash session", 13, command, 13) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 12, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); break; } if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to crash session"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274C_CRASH_SESSION ); break; } if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274C_CRASH_SESSION ); scs_crash_sess( an_scb ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p crashed", an_scb); log_cmd = 1; } else if (STscompare("kill", 4, command, 4) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 4, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); } else if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to kill query"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2755_KILL_QUERY ); } else switch ( an_scb->scb_sscb.sscb_qmode ) { case 0: TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p is not executing a query", an_scb); break; /* Honor only "meaningful" types of queries: */ case PSQ_RETRIEVE: case PSQ_RETINTO: case PSQ_APPEND: case PSQ_REPLACE: case PSQ_DELETE: case PSQ_COPY: case PSQ_MODIFY: case PSQ_EXECQRY: case PSQ_EXCURS: case PSQ_CALLPROC: case PSQ_REPCURS: case PSQ_RETCURS: case PSQ_EXEDBP: case PSQ_REGPROC: case PSQ_DDEXECPROC: case PSQ_CREATE: if ( an_scb->scb_sscb.sscb_force_abort || an_scb->scb_sscb.sscb_interrupt ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query already aborting", an_scb); } else { scs_kill_query( an_scb ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2755_KILL_QUERY ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query killed", an_scb); } break; default: TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query cannot be killed", an_scb); break; } } # ifdef NOT_SUPPORTED else if (STscompare("help", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "SCS monitor commands:\nset server shut\nset server closed\nset server open\nshow server listen\nshow server shutdown\nremove SESSION\ncrash session SESSION\n\nCS monitor commands:\n"); } # endif else if (! CS_is_mt()) /* OS Thread version will start an OS thread in the CS */ if ((STscompare("start sampling", 14, command, 14) == 0)) { if (!powerful) { TRformat(output_fcn, (i4 *) 1, buf, sizeof(buf)-1, "Superuser status required to start sampling.", 0L); } else { GCA_LS_PARMS local_crb; CL_ERR_DESC errdesc; local_crb.gca_status = 0; local_crb.gca_assoc_id = 0; local_crb.gca_size_advise = 0; local_crb.gca_user_name = "<Sampler Thread>"; local_crb.gca_account_name = 0; local_crb.gca_access_point_identifier = "NONE"; local_crb.gca_application_id = 0; /* set up all the CS control blocks for the sampler */ ret_stat = CSmonitor( mode, scb, nmode, command, powerful, output_fcn ); if ( ret_stat == OK ) ret_stat = CSadd_thread(CS_LIM_PRIORITY-1, (PTR) &local_crb, SCS_SSAMPLER, (CS_SID*)NULL, &errdesc); if (ret_stat) { TRformat(output_fcn, (i4 *) 1, buf, sizeof(buf)-1, "Sampling failed to start."); } } } /* log the command before calling CSmonitor(), as the server could be left in an ** unknown state if the command CRASH SERVER or STOP SERVER are used */ if (log_cmd) { ule_format( I_SC051E_IIMONITOR_CMD, 0, ULE_LOG, NULL, 0, 0, 0, &local_error, 3, STlength(command), command, DB_OWN_MAXNAME, &((SCD_SCB *)scb)->scb_sscb.sscb_ics.ics_rusername, sizeof(DB_TERM_NAME), &((SCD_SCB *)scb)->scb_sscb.sscb_ics.ics_terminal, 0, 0); } if( !completely_done ) ret_stat = CSmonitor( mode, scb, nmode, command, powerful, output_fcn ); break; case CS_OUTPUT: break; } return( ret_stat ); }