Exemple #1
0
/*{
** 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);  
    }
Exemple #2
0
static STATUS
initialize( i4 argc, char **argv )
{
    CL_ERR_DESC	cl_err;
    char	*instance = ERx("*");
    char	*env;
    char	name[ 16 ];
    i4		i;

    GCD_global.language = 1;
    MHsrand( TMsecs() );

    for( i = 1; i < argc; i++ )
	if ( ! STbcompare( argv[i], 0, ERx("-instance"), 9, TRUE ) )
	{
	    if ( argv[i][9] == ERx('=')  &&  argv[i][10] != EOS )
		instance = &argv[i][10];
	    else  if ( argv[i][9] == EOS  &&  (i + 1) < argc )
		instance = argv[++i];
	    break;
	}

    NMgtAt( ERx("II_INSTALLATION"), &env );
    STprintf( name, ERx("II_CHARSET%s"), (env  &&  *env) ? env : "" );
    NMgtAt( name, &env );

    if ( ! env  ||  ! *env || STlength(env) > CM_MAXATTRNAME)
    {
	switch( CMgetDefCS() )
	{
#if ( !defined(UNIX) && !defined(VMS) )
	case CM_IBM :	    env = "IBMPC850";	break;
#endif
	case CM_DECMULTI :  env = "DECMULTI";	break;
	default :	    env = "ISO88591";	break;
	}
    }

    GCD_global.charset = STalloc( env );
    CVupper( GCD_global.charset );
    gcu_read_cset( gcd_cset_id );

    if ( CMset_attr( GCD_global.charset, &cl_err) != OK )
    {
	gcu_erlog( 0, GCD_global.language, 
		    E_GC0105_GCN_CHAR_INIT, NULL, 0, NULL );
	return( E_GC0105_GCN_CHAR_INIT );
    }

    PMinit();

    switch( PMload( (LOCATION *)NULL, (PM_ERR_FUNC *)NULL ) )
    {
	case OK: break;

	case PM_FILE_BAD:
	    gcu_erlog( 0, GCD_global.language, 
			E_GC003D_BAD_PMFILE, NULL, 0, NULL );
	    return( E_GC003D_BAD_PMFILE );
	    break;

	default:
	    gcu_erlog( 0, GCD_global.language, 
			E_GC003E_PMLOAD_ERR, NULL, 0, NULL );
	    return( E_GC003E_PMLOAD_ERR );
	    break;
    }

    PMsetDefault( 0, SystemCfgPrefix );
    PMsetDefault( 1, PMhost() );
    PMsetDefault( 2, ERx("gcd") );
    PMsetDefault( 3, instance );

    gcd_tl_services[0] = &gcd_dmtl_service;
    gcd_tl_services[1] = &gcd_jctl_service;
    GCD_global.tl_services = gcd_tl_services;
    GCD_global.tl_srvc_cnt = ARR_SIZE( gcd_tl_services );

    QUinit( &GCD_global.pib_q );
    QUinit( &GCD_global.rcb_q );
    QUinit( &GCD_global.ccb_q );
    QUinit( &GCD_global.ccb_free );
    for( i = 0; i < ARR_SIZE( GCD_global.cib_free ); i++ )  
	QUinit( &GCD_global.cib_free[ i ] );

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.client_max"), &env );
    if ( env  &&  *env )
    {
	i4 count;

	if ( CVal( env, &count ) == OK  &&  count > 0 )
	    GCD_global.client_max = count;
    }

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.client_timeout"), &env );
    if ( env  &&  *env )  
    {
	i4 timeout;

	if ( CVal( env, &timeout ) == OK  &&  timeout > 0 )
	    GCD_global.client_idle_limit = timeout * 60; /* Cnvt to seconds */
    }

    env = NULL;
    gcu_get_tracesym( NULL, ERx("!.connect_pool_status"), &env );
    if ( env  &&  *env )
    {
	if ( ! STbcompare( env, 0, "optional", 0, TRUE ) )
	    GCD_global.client_pooling = TRUE;

	if ( GCD_global.client_pooling  ||
	     ! STbcompare( env, 0, "on", 0, TRUE ) )
	{
	    env = NULL;
	    gcu_get_tracesym( NULL, ERx("!.connect_pool_size"), &env );
	    if ( env  &&  *env )  CVal( env, &GCD_global.pool_max );

	    env = NULL;
	    gcu_get_tracesym( NULL, ERx("!.connect_pool_expire"), &env );
	    if ( env  &&  *env )  
	    {
		i4 limit;

		if ( CVal( env, &limit ) == OK  &&  limit > 0 )
		    GCD_global.pool_idle_limit = limit * 60; /* Seconds */
	    }
	}
    }

    env = NULL;
    gcu_get_tracesym( "II_GCD_TRACE", ERx("!.gcd_trace_level"), &env );
    if ( env  &&  *env )  CVal( env, &GCD_global.gcd_trace_level );

    env = NULL;
    gcu_get_tracesym( "II_GCD_LOG", ERx("!.gcd_trace_log"), &env );
    if ( env  &&  *env ) 
	TRset_file( TR_F_OPEN, env, (i4)STlength( env ), &cl_err );

    return( OK );
}