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

📄 dmlmodstatementnode.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			TableDescriptor refTd = cd.getTableDescriptor();			fkVector.addElement(new FKInfo(									fkNames,							// foreign key names									refTd.getName(),				// table being modified									statementType,						// INSERT|UPDATE|DELETE									type,								// FOREIGN_KEY|REFERENCED_KEY									pkuuid,								// referenced backing index uuid									pkIndexConglom.getConglomerateNumber(), // referened backing index conglom									uuids,								// fk backing index uuids									conglomNumbers,						// fk backing index congloms									isSelfReferencingFK,				// is self ref array of bool									remapReferencedColumns(cd, rowMap),	// column referened by key									dd.getRowLocationTemplate(getLanguageConnectionContext(), refTd),									                                // row location template  for table being modified 									raRules));	// referential action rules		}				/*		** Now convert the vector into an array.		*/		int size = fkVector.size();		if (size > 0)		{			fkInfo = new FKInfo[size];			for (int i = 0; i < size; i++)			{				fkInfo[i] = (FKInfo)fkVector.elementAt(i);			}		}		//convert the ref action info vectors to  to arrays		size = refActions.size();		if (size > 0)		{			fkTableNames = new String[size];			fkRefActions  = new int[size];			fkColDescriptors = new ColumnDescriptorList[size];			fkIndexConglomNumbers = new long[size];			fkColArrays = new int[size][];			for (int i = 0; i < size; i++)			{				fkTableNames[i] = (String)refTableNames.elementAt(i);				fkRefActions[i]  = ((Integer) refActions.elementAt(i)).intValue();				fkColDescriptors[i] =					(ColumnDescriptorList)refColDescriptors.elementAt(i);				fkIndexConglomNumbers[i] =					((Long)refIndexConglomNum.elementAt(i)).longValue();				fkColArrays[i] = ((int[])fkColMap.elementAt(i));			}		}			}	/*	** Simple little helper method	*/		private void fkSetupArrays	(		DataDictionary						dd,		ForeignKeyConstraintDescriptor 		fkcd,		int									index,		UUID[]								uuids,		long[]								conglomNumbers,		String[]							fkNames,		boolean[]							isSelfReferencingFK,		int[]                               raRules	)		throws StandardException	{		fkNames[index] = fkcd.getConstraintName();		uuids[index] = fkcd.getIndexId();		conglomNumbers[index] = fkcd.getIndexConglomerateDescriptor(dd).getConglomerateNumber();		isSelfReferencingFK[index] = fkcd.isSelfReferencingFK();		if(statementType == StatementType.DELETE)			raRules[index] = fkcd.getRaDeleteRule();		else if(statementType == StatementType.UPDATE)			raRules[index] = fkcd.getRaUpdateRule();	}	/**	 * Generate the TriggerInfo structures used during code generation.	 *	 * @param tdl				The trigger descriptor list	 * @param td				The TableDescriptor	 * @param changedCols		The columns that are being modified	 *	 * @exception StandardException		Thrown on failure	 */	private void generateTriggerInfo 	(		GenericDescriptorList		triggerList,		TableDescriptor				td,		int[]						changedCols    )		throws StandardException	{			if ((triggerList != null) && (triggerList.size() > 0))		{			triggerInfo = new TriggerInfo(td, changedCols, triggerList);		}	}	/**	 * Return the FKInfo structure.  Just  a little wrapper	 * to make sure we don't try to access it until after	 * binding.	 *	 * @return the array of fkinfos	 */	public FKInfo[] getFKInfo()	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(bound, "attempt to access FKInfo "+					"before binding");		}		return fkInfo;	}	/**	 * Return the TriggerInfo structure.  Just  a little wrapper	 * to make sure we don't try to access it until after	 * binding.	 *	 * @return the trigger info	 */	public TriggerInfo getTriggerInfo()	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(bound, "attempt to access TriggerInfo "+					"before binding");		}		return triggerInfo;	}	/**	 * Get the check constraints for this node	 *	 * @return the check constraints, may be null	 */	public ValueNode getCheckConstraints()	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(bound, "attempt to access FKInfo "+					"before binding");		}		return checkConstraints;	}					/**	 * Makes the calling object (usually a Statement) dependent on all the constraints.	 *	 * @param tdl				The trigger descriptor list	 * @param dependent			Parent object that will depend on all the constraints	 *							that we look up. If this argument is null, then we	 *							use the default dependent (the statement being compiled).	 *	 * @exception StandardException		Thrown on failure	 */	private void createTriggerDependencies	(		GenericDescriptorList 		tdl,		Dependent					dependent	)		throws StandardException	{		CompilerContext 			compilerContext = getCompilerContext();		Enumeration descs = tdl.elements();		while (descs.hasMoreElements())		{			TriggerDescriptor td = (TriggerDescriptor)descs.nextElement();			/*			** The dependent now depends on this trigger. 			** the default dependent is the statement 			** being compiled.			*/			if (dependent == null) 			{ 				compilerContext.createDependency(td); 			}			else 			{ 				compilerContext.createDependency(dependent, td); 			}		}	}	/**	 * Get all the triggers relevant to this DML operation	 *	 * @param dd				The data dictionary	 * @param td				The TableDescriptor	 * @param changedColumnIds	If null, all columns being changed, otherwise array	 *							of 1-based column ids for columns being changed	 * @param includeTriggers	whether we allow trigger processing or not for	 * 							this table	 *	 * @return	the constraint descriptor list	 *	 * @exception StandardException		Thrown on failure	 */	protected GenericDescriptorList getAllRelevantTriggers	(		DataDictionary		dd,		TableDescriptor		td,		int[]				changedColumnIds,		boolean 			includeTriggers    )		throws StandardException	{		if ( relevantTriggers !=  null ) { return relevantTriggers; }		relevantTriggers =  new GenericDescriptorList();		if(!includeTriggers)			return relevantTriggers;		td.getAllRelevantTriggers( statementType, changedColumnIds, relevantTriggers );		adjustDeferredFlag( relevantTriggers.size() > 0 );		return relevantTriggers;	}	protected	void	adjustDeferredFlag( boolean adjustment )	{		if( !requiresDeferredProcessing ) { requiresDeferredProcessing = adjustment; }	}	/**	 * Get all of our dependents due to a constraint.	 *	 * Makes the calling object (usually a Statement) dependent on all the constraints.	 *	 * @param dd				The data dictionary	 * @param cdl				The constraint descriptor list	 * @param dependent			Parent object that will depend on all the constraints	 *							that we look up. If this argument is null, then we	 *							use the default dependent (the statement being compiled).	 *	 * @exception StandardException		Thrown on failure	 */	private void createConstraintDependencies	(		DataDictionary				dd,		ConstraintDescriptorList 	cdl,		Dependent					dependent	)		throws StandardException	{		CompilerContext 			compilerContext = getCompilerContext();		int cdlSize = cdl.size();		for (int index = 0; index < cdlSize; index++)		{			ConstraintDescriptor cd = cdl.elementAt(index);			/*			** The dependent now depends on this constraint. 			** the default dependent is the statement 			** being compiled.			*/			if (dependent == null) 			{ 				compilerContext.createDependency(cd); 			}			else 			{ 				compilerContext.createDependency(dependent, cd); 			}			/*			** We are also dependent on all referencing keys --			** if one of them is deleted, we'll have to recompile.			** Also, if there is a BULK_INSERT on the table			** we are going to scan to validate the constraint,			** the index number will change, so we'll add a			** dependency on all tables we will scan.			*/			if (cd instanceof ReferencedKeyConstraintDescriptor)			{					ConstraintDescriptorList fkcdl = dd.getActiveConstraintDescriptors					( ((ReferencedKeyConstraintDescriptor)cd).getForeignKeyConstraints(ConstraintDescriptor.ENABLED) );					int fklSize = fkcdl.size();				for (int inner = 0; inner < fklSize; inner++)				{					ConstraintDescriptor fkcd = fkcdl.elementAt(inner);					if (dependent == null) 					{ 						compilerContext.createDependency(fkcd); 						compilerContext.createDependency(fkcd.getTableDescriptor()); 					}					else 					{ 						compilerContext.createDependency(dependent, fkcd); 						compilerContext.createDependency(dependent, fkcd.getTableDescriptor()); 					}				}			}			else if (cd instanceof ForeignKeyConstraintDescriptor)			{				ForeignKeyConstraintDescriptor fkcd = (ForeignKeyConstraintDescriptor) cd;				if (dependent == null) 				{ 					compilerContext.createDependency(fkcd.getReferencedConstraint().getTableDescriptor()); 				}				else				{					compilerContext.createDependency(dependent, 									fkcd.getReferencedConstraint().getTableDescriptor()); 				}			}		}	}	/**	 * Get all the constraints relevant to this DML operation	 *	 * @param dd				The DataDictionary	 * @param td				The TableDescriptor	 * @param skipCheckConstraints Skip check constraints	 * @param changedColumnIds	If null, all columns being changed, otherwise array	 *							of 1-based column ids for columns being changed	 *	 * @return	the constraint descriptor list	 *	 * @exception StandardException		Thrown on failure	 */	protected ConstraintDescriptorList getAllRelevantConstraints	(		DataDictionary		dd, 		TableDescriptor		td,		boolean				skipCheckConstraints,		int[]				changedColumnIds    )		throws StandardException	{		if ( relevantCdl != null ) { return relevantCdl; }		boolean[]	needsDeferredProcessing = new boolean[1];		relevantCdl = new ConstraintDescriptorList();		needsDeferredProcessing[0] = requiresDeferredProcessing;		td.getAllRelevantConstraints			( statementType, skipCheckConstraints, changedColumnIds,			  needsDeferredProcessing, relevantCdl );		adjustDeferredFlag( needsDeferredProcessing[0] );		return relevantCdl;	}	/**	 * Does this DML Node require deferred processing?	 * Set to true if we have triggers or referential	 * constraints that need deferred processing.	 *	 * @return true/false 	 */	public boolean requiresDeferredProcessing()	{		return requiresDeferredProcessing;	}	/**	  *	Parse a check constraint and turn it into a query tree.	  *	  *	@param	checkConstraintText	Text of CHECK CONSTRAINT.	  * @param	td					The TableDescriptor for the table the the constraint is on.	  *	  *	  * @return	The parsed check constraint as a query tree.	  *	  * @exception StandardException		Thrown on failure	  */	public	ValueNode	parseCheckConstraint	(		String				checkConstraintText,		TableDescriptor		td    )		throws StandardException	{		Parser						p;		ValueNode					checkTree;		LanguageConnectionContext	lcc = getLanguageConnectionContext();		CompilerContext 			compilerContext = getCompilerContext();		/* Get a Statement to pass to the parser */		/* We're all set up to parse. We have to build a compile SQL statement		 * before we can parse - we just have a WHERE clause right now.

⌨️ 快捷键说明

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