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

📄 sysconstraintsrowfactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				}				conglomDesc = td.getConglomerateDescriptor( 										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getIndexId());				/* Take care the rare case of conglomDesc being null.  The				 * reason is that our "td" is out of date.  Another thread				 * which was adding a constraint committed between the moment				 * we got the table descriptor (conglomerate list) and the				 * moment we scanned and got the constraint desc list.  Since				 * that thread just added a new row to SYSCONGLOMERATES, 				 * SYSCONSTRAINTS, etc.  We wouldn't have wanted to lock the				 * system tables just to prevent other threads from adding new				 * rows.				 */				if (conglomDesc == null)				{					// we can't be getting td from cache because if we are					// here, we must have been in dd's ddl mode (that's why					// the ddl thread went through), we are not done yet, the					// dd ref count is not 0, hence it couldn't have turned					// into COMPILE_ONLY mode					td = dd.getTableDescriptor(tableUUID);					if (scd != null)						scd.setTableDescriptor(td);					// try again now					conglomDesc = td.getConglomerateDescriptor( 									((SubKeyConstraintDescriptor) 										parentTupleDescriptor).getIndexId());				}				if (SanityManager.DEBUG)				{					SanityManager.ASSERT(conglomDesc != null,					"conglomDesc is expected to be non-null for backing index");				}				keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();				referencedConstraintId = ((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getKeyConstraintId();				keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();				break;			case 'C' :				constraintIType = DataDictionary.CHECK_CONSTRAINT;				if (SanityManager.DEBUG)				{					if (!(parentTupleDescriptor instanceof SubCheckConstraintDescriptor))					{						SanityManager.THROWASSERT("parentTupleDescriptor expected to be instanceof " +						"SubCheckConstraintDescriptor, not " +						parentTupleDescriptor.getClass().getName());					}				}				break;			default:				if (SanityManager.DEBUG)				{					SanityManager.THROWASSERT("Fourth column value invalid");				}		}		/* 5th column is SCHEMAID (UUID - char(36)) */		col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);		schemaUUIDString = col.getString();		schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);		schema = dd.getSchemaDescriptor(schemaUUID, null);		/* 6th column is STATE (char(1)) */		col = row.getColumn(SYSCONSTRAINTS_STATE);		constraintStateStr = col.getString();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(constraintStateStr.length() == 1, 				"Sixth column (state) type incorrect");		}		switch (constraintStateStr.charAt(0))		{			case 'E': 				constraintEnabled = true;				break;			case 'D':				constraintEnabled = false;				break;			default: 				constraintEnabled = true;				if (SanityManager.DEBUG)				{					SanityManager.THROWASSERT("Invalidate state value '"							+constraintStateStr+ "' for constraint");				}		}		/* 7th column is REFERENCECOUNT, boolean */		col = row.getColumn(SYSCONSTRAINTS_REFERENCECOUNT);		referenceCount = col.getInt();				/* now build and return the descriptor */		switch (constraintIType)		{			case DataDictionary.PRIMARYKEY_CONSTRAINT : 				constraintDesc = ddg.newPrimaryKeyConstraintDescriptor(										td, 										constraintName, 										false, //deferable,										false, //initiallyDeferred,										keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],										constraintUUID,										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getIndexId(),										schema,										constraintEnabled,										referenceCount);				break;			case DataDictionary.UNIQUE_CONSTRAINT :				constraintDesc = ddg.newUniqueConstraintDescriptor(										td, 										constraintName, 										false, //deferable,										false, //initiallyDeferred,										keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],										constraintUUID,										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getIndexId(),										schema,										constraintEnabled,										referenceCount);				break;			case DataDictionary.FOREIGNKEY_CONSTRAINT : 				if (SanityManager.DEBUG)				{					SanityManager.ASSERT(referenceCount == 0, 						"REFERENCECOUNT column is nonzero for fk constraint");				}									constraintDesc = ddg.newForeignKeyConstraintDescriptor(										td, 										constraintName, 										false, //deferable,										false, //initiallyDeferred,										keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],										constraintUUID,										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getIndexId(),										schema,										referencedConstraintId,										constraintEnabled,										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getRaDeleteRule(),										((SubKeyConstraintDescriptor) 											parentTupleDescriptor).getRaUpdateRule()										);				break;			case DataDictionary.CHECK_CONSTRAINT :				if (SanityManager.DEBUG)				{					SanityManager.ASSERT(referenceCount == 0, 						"REFERENCECOUNT column is nonzero for check constraint");				}									constraintDesc = ddg.newCheckConstraintDescriptor(										td, 										constraintName, 										false, //deferable,										false, //initiallyDeferred,										constraintUUID,										((SubCheckConstraintDescriptor) 											parentTupleDescriptor).getConstraintText(),										((SubCheckConstraintDescriptor) 											parentTupleDescriptor).getReferencedColumnsDescriptor(),										schema,										constraintEnabled);				break;		}		return constraintDesc;	}	/**	 * Get the constraint ID of the row.	 * 	 * @param row	The row from sysconstraints	 *	 * @return UUID	The constraint id	 *	 * @exception   StandardException thrown on failure	 */	 protected UUID getConstraintId(ExecRow row)		 throws StandardException	 {		DataValueDescriptor	col;		String				constraintUUIDString;		/* 1st column is CONSTRAINTID (UUID - char(36)) */		col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTID);		constraintUUIDString = col.getString();		return getUUIDFactory().recreateUUID(constraintUUIDString);	 }	/**	 * Get the constraint name of the row.	 * 	 * @param row	The row from sysconstraints	 *	 * @return UUID	The constraint name	 *	 * @exception   StandardException thrown on failure	 */	 protected String getConstraintName(ExecRow row)		 throws StandardException	 {		DataValueDescriptor	col;		String				constraintName;		/* 3rd column is CONSTRAINTNAME (char(128)) */		col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTNAME);		constraintName = col.getString();		return constraintName;	 }	/**	 * Get the schema ID of the row.	 * 	 * @param row	The row from sysconstraints	 *	 * @return UUID	The schema	 *	 * @exception   StandardException thrown on failure	 */	 protected UUID getSchemaId(ExecRow row)		 throws StandardException	 {		DataValueDescriptor	col;		String				schemaUUIDString;		/* 5th column is SCHEMAID (UUID - char(36)) */		col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);		schemaUUIDString =col.getString();		return getUUIDFactory().recreateUUID(schemaUUIDString);	 }	/**	 * Get the table ID of the row.	 * 	 * @param row	The row from sysconstraints	 *	 * @return UUID	The table id	 *	 * @exception   StandardException thrown on failure	 */	 protected UUID getTableId(ExecRow row)		 throws StandardException	 {		DataValueDescriptor	col;		String				tableUUIDString;		/* 2nd column is TABLEID (UUID - char(36)) */		col = row.getColumn(SYSCONSTRAINTS_TABLEID);		tableUUIDString = col.getString();		return getUUIDFactory().recreateUUID(tableUUIDString);	 }	/**	 * Get the constraint type out of the row.	 * 	 * @param row	The row from sysconstraints	 *	 * @return int	The constraint type	as an int	 *	 * @exception   StandardException thrown on failure	 */	 protected int getConstraintType(ExecRow row)		 throws StandardException	 {		DataValueDescriptor	col;		int					constraintIType;		String				constraintSType;		/* 4th column is TYPE (char(1)) */		col = row.getColumn(SYSCONSTRAINTS_TYPE);		constraintSType = col.getString();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(constraintSType.length() == 1, 				"Fourth column type incorrect");		}		switch (constraintSType.charAt(0))		{			case 'P' : 				constraintIType = DataDictionary.PRIMARYKEY_CONSTRAINT;				break;			case 'U' :				constraintIType = DataDictionary.UNIQUE_CONSTRAINT;				break;			case 'C' :				constraintIType = DataDictionary.CHECK_CONSTRAINT;				break;			case 'F' :				constraintIType = DataDictionary.FOREIGNKEY_CONSTRAINT;				break;			default:				if (SanityManager.DEBUG)				{					SanityManager.THROWASSERT("Fourth column value invalid");				}				constraintIType = -1;		}		return constraintIType;	 }	/**	 * Builds a list of columns suitable for creating this Catalog.	 *	 *	 * @return array of SystemColumn suitable for making this catalog.	 */	public SystemColumn[]	buildColumnList()	{		int						index = 0;		SystemColumn[]			columnList = new SystemColumn[SYSCONSTRAINTS_COLUMN_COUNT];		// describe columns		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "CONSTRAINTID"),			// column name							SYSCONSTRAINTS_CONSTRAINTID,	// column number							0,					// precision							0,					// scale							false,				// nullability							"CHAR",				// dataType							true,				// built-in type							36					// maxLength			               );		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "TABLEID"),			// column name							SYSCONSTRAINTS_TABLEID,	// column number							0,					// precision							0,					// scale							false,				// nullability							"CHAR",				// dataType							true,				// built-in type							36					// maxLength			               );		columnList[index++] =					new SystemColumnImpl(		// SQL IDENTIFIER							convertIdCase( "CONSTRAINTNAME"),	// column name							SYSCONSTRAINTS_CONSTRAINTNAME,							false				// nullability							);		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "TYPE"),			// column name							SYSCONSTRAINTS_TYPE,	// column number							0,					// precision							0,					// scale							false,				// nullability							"CHAR",				// dataType							true,				// built-in type							1					// maxLength			               );		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "SCHEMAID"),		// column name							SYSCONSTRAINTS_SCHEMAID,	// column number							0,					// precision							0,					// scale							false,				// nullability							"CHAR",				// dataType							true,				// built-in type							36					// maxLength			               );		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "STATE"),		// column name							SYSCONSTRAINTS_STATE,	// column number							0,					// precision							0,					// scale							false,				// nullability							"CHAR",				// dataType							true,				// built-in type							1					// maxLength			               );		columnList[index++] = 					new SystemColumnImpl(								convertIdCase( "REFERENCECOUNT"),		// column name							SYSCONSTRAINTS_REFERENCECOUNT,	// column number							0,					// precision							0,					// scale							false,				// nullability							"INTEGER",				// dataType							true,				// built-in type							1					// maxLength			               );		return	columnList;	}}

⌨️ 快捷键说明

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