⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_consistencychecker.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	/* Get the various descriptors */	private void getDescriptors()		throws StandardException	{		sd = dd.getSchemaDescriptor(schemaName, tc, true);		td = dd.getTableDescriptor(tableName, sd);		if (td == null)		{			throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, schemaName + "." + tableName);		}		if (indexName != null)		{			id = dd.getConglomerateDescriptor(indexName, sd, true);			if (id == null)			{				throw StandardException.newException(SQLState.LANG_INDEX_NOT_FOUND, indexName);			}		}	}	/* Get a heap row full of nulls */	private ExecRow getHeapRowOfNulls()		throws StandardException	{		ConglomerateController	baseCC;		ExecRow					baseRow;		/* Open the heap for reading */		baseCC = tc.openConglomerate(		            td.getHeapConglomerateId(), false, 0, 			        TransactionController.MODE_TABLE,				    TransactionController.ISOLATION_SERIALIZABLE);		/* Get a row template for the base table */		baseRow = ec.getExecutionFactory().getValueRow(td.getNumberOfColumns());		/* Fill the row with nulls of the correct type */		ColumnDescriptorList cdl = td.getColumnDescriptorList();		int					 cdlSize = cdl.size();		for (int index = 0; index < cdlSize; index++)		{			ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);			DataTypeDescriptor dts = cd.getType();			baseRow.setColumn(cd.getPosition(),									dts.getNull());		}		baseCC.close();		return baseRow;	}	/* Open an unqualified scan on the heap for update */	private ScanController openUnqualifiedHeapScan()		throws StandardException	{		ScanController heapScan;		heapScan = tc.openScan(td.getHeapConglomerateId(),								false,	// hold								TransactionController.OPENMODE_FORUPDATE,		//  forUpdate								TransactionController.MODE_TABLE,						        TransactionController.ISOLATION_SERIALIZABLE,								(FormatableBitSet) null,								null,	// startKeyValue								0,		// not used with null start posn.								null,	// qualifier								null,	// stopKeyValue								0);		// not used with null stop posn.		return heapScan;	}	/* Open the heap conglomerate for update */	private ConglomerateController openHeapCC()		throws StandardException	{		ConglomerateController heapCC;		heapCC = tc.openConglomerate(			            td.getHeapConglomerateId(),                        false,						TransactionController.OPENMODE_FORUPDATE,		//  forUpdate				        TransactionController.MODE_TABLE,					    TransactionController.ISOLATION_SERIALIZABLE);		return heapCC;	}	/* Get a template row for the specified index */	private ExecRow getIndexTemplateRow(RowLocation baseRL)		throws StandardException	{		int[]					baseColumnPositions;		int						baseColumns = 0;		ExecRow					indexScanTemplate;		baseColumnPositions =				id.getIndexDescriptor().baseColumnPositions();		baseColumns = baseColumnPositions.length;		FormatableBitSet indexColsBitSet = new FormatableBitSet();		for (int i = 0; i < baseColumns; i++)		{			indexColsBitSet.grow(baseColumnPositions[i]);			indexColsBitSet.set(baseColumnPositions[i] - 1);		}		/* Get a row template */		indexScanTemplate = ec.getExecutionFactory().getValueRow(baseColumns + 1);		/* Fill the row with nulls of the correct type */		for (int column = 0; column < baseColumns; column++)		{			/* Column positions in the data dictionary are one-based */			ColumnDescriptor cd = td.getColumnDescriptor(baseColumnPositions[column]);			DataTypeDescriptor dts = cd.getType();			indexScanTemplate.setColumn(column + 1,									dts.getNull());		}		/* Set the row location in the last column of the index row */		indexScanTemplate.setColumn(baseColumns + 1, baseRL);		return indexScanTemplate;	}	/* Open an unqualified scan on the index for update */	private ScanController openUnqualifiedIndexScan()		throws StandardException	{		ScanController indexScan;		indexScan = tc.openScan(id.getConglomerateNumber(),								false,	// hold								TransactionController.OPENMODE_FORUPDATE,		//  forUpdate								TransactionController.MODE_TABLE,						        TransactionController.ISOLATION_SERIALIZABLE,								(FormatableBitSet) null,								null,	// startKeyValue								0,		// not used with null start posn.								null,	// qualifier								null,	// stopKeyValue								0);		// not used with null stop posn.		return indexScan;	}	/* Open the index conglomerate for update */	private ConglomerateController openIndexCC()		throws StandardException	{		ConglomerateController indexCC;		indexCC = tc.openConglomerate(			            id.getConglomerateNumber(),                        false,						TransactionController.OPENMODE_FORUPDATE,		//  forUpdate				        TransactionController.MODE_TABLE,					    TransactionController.ISOLATION_SERIALIZABLE);		return indexCC;	}	/* Return the ConglomerateDescriptor for the index */	private ConglomerateDescriptor getIndexDescriptor()	{		return id;	}	// following methods are originally from a different class - used in the test store/backupRestore1	// original comment for that class:	/**	 * This class provides static methods for checking the consistency of database	 * objects like tables.	 */	/**	 * Run all of the consistency checkers which do not take parameters.	 * Actually, just run the ones that "make sense" to run.  Today,	 * that is:	 *		countOpens()	 *	 * @return String		If an inconsistency is found, and if DEBUG is on, 	 *						then a string will be returned with more info.  	 *						If DEBUG is off, then a simple string will be 	 *						returned stating whether or not there are open scans.	 *	 * @exception StandardException		Thrown on error	 * @exception java.sql.SQLException		Thrown on error	 */	public static String runConsistencyChecker() throws StandardException, java.sql.SQLException	{		return countOpens() + countDependencies();	}	/**	 * Check to make sure that there are no open conglomerates, scans or sorts.	 *	 * @return String		If an inconsistency is found, and if DEBUG is on, 	 *						then a string will be returned with more info.  	 *						If DEBUG is off, then a simple string will be 	 *						returned stating whether or not there are open scans.	 *	 * @exception StandardException		Thrown on error	 */	public static String countOpens() throws StandardException	{		int						numOpens = 0;		LanguageConnectionContext lcc;		String					output = "No open scans, etc.\n";		TransactionController	tc;		lcc = (LanguageConnectionContext)			ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);		tc = lcc.getTransactionExecute();		numOpens = tc.countOpens(TransactionController.OPEN_TOTAL);		if (numOpens > 0)		{            output = numOpens + " conglomerates/scans/sorts found open\n";		}		return output;	}	/**	 * Check to make sure that there are no active dependencies (stored or	 * in memory).	 *	 * @return String		If an inconsistency is found, and if DEBUG is on, 	 *						then a string will be returned with more info.  	 *						If DEBUG is off, then a simple string will be 	 *						returned stating whether or not there are open scans.	 *	 * @exception StandardException		Thrown on error	 * @exception java.sql.SQLException		Thrown on error	 */	public static String countDependencies() throws StandardException, java.sql.SQLException	{		int						numDependencies = 0;		DataDictionary			dd;		DataDictionaryContext	ddc;		DependencyManager		dm;		StringBuffer			debugBuf = new StringBuffer();		ddc = (DataDictionaryContext)				(ContextService.getContext(DataDictionaryContext.CONTEXT_ID));		dd = ddc.getDataDictionary();		dm = dd.getDependencyManager();		numDependencies = dm.countDependencies();		if (numDependencies > 0)		{			debugBuf.append(numDependencies + " dependencies found");		}		else		{			debugBuf.append("No outstanding dependencies.\n");		}		return debugBuf.toString();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -