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

📄 triggerdescriptor.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 */	public void setEnabled()	{		isEnabled = true;	}	/**	 * Mark this trigger as disabled	 *	 */	public void setDisabled()	{		isEnabled = false;	}	/**	 * Does this trigger need to fire on this type of	 * DML?	 *	 * @param dmlType	the type of DML 	 * (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)	 * @param modifiedCols	the columns modified, or null for all	 *	 * @return true/false	 *	 * @exception StandardException on error	 */	public boolean needsToFire(int stmtType, int[] modifiedCols)		throws StandardException	{		if (SanityManager.DEBUG)		{			if (!((stmtType == StatementType.INSERT) ||								 (stmtType == StatementType.BULK_INSERT_REPLACE) ||								 (stmtType == StatementType.UPDATE) ||								 (stmtType == StatementType.DELETE)))			{				SanityManager.THROWASSERT("invalid statement type "+stmtType);			}		}		/*		** If we are disabled, we never fire		*/		if (!isEnabled)		{			return false;		}		if (stmtType == StatementType.INSERT)		{ 			return (eventMask & TRIGGER_EVENT_INSERT) == eventMask;		}		if (stmtType == StatementType.DELETE) 		{			return (eventMask & TRIGGER_EVENT_DELETE) == eventMask;		}		// this is a temporary restriction, but it may not be lifted		// anytime soon.		if (stmtType == StatementType.BULK_INSERT_REPLACE)		{			throw StandardException.newException(SQLState.LANG_NO_BULK_INSERT_REPLACE_WITH_TRIGGER, 												 getTableDescriptor().getQualifiedName(), name);		}		// if update, only relevant if columns intersect		return ((eventMask & TRIGGER_EVENT_UPDATE) == eventMask) &&				ConstraintDescriptor.doColumnsIntersect(modifiedCols, referencedCols);	}	/**	 * Get the original trigger definition.	 *	 * @return The trigger definition.	 */	public String getTriggerDefinition()	{		return triggerDefinition;	}	/**	 * Get whether or not OLD was replaced	 * in the REFERENCING clause.	 *	 * @return Whether or not OLD was replaced	 * in the REFERENCING clause.	 */	public boolean getReferencingOld()	{		return referencingOld;	}	/**	 * Get whether or not NEW was replaced	 * in the REFERENCING clause.	 *	 * @return Whether or not NEW was replaced	 * in the REFERENCING clause.	 */	public boolean getReferencingNew()	{		return referencingNew;	}	/**	 * Get the old Referencing name, if any,	 * from the REFERENCING clause.	 *	 * @return The old Referencing name, if any,	 * from the REFERENCING clause.	 */	public String getOldReferencingName()	{		return oldReferencingName;	}	/**	 * Get the new Referencing name, if any,	 * from the REFERENCING clause.	 *	 * @return The new Referencing name, if any,	 * from the REFERENCING clause.	 */	public String getNewReferencingName()	{		return newReferencingName;	}	public String toString()	{		if (SanityManager.DEBUG)		{			return "TRIGGER: "+name;		}		else		{			return "";		}	}	////////////////////////////////////////////////////////////////////	//	// PROVIDER INTERFACE	//	////////////////////////////////////////////////////////////////////	/**			 * @return the stored form of this provider	 *	 * @see Dependable#getDependableFinder	 */	public DependableFinder getDependableFinder() 	{	    return getDependableFinder(StoredFormatIds.TRIGGER_DESCRIPTOR_FINDER_V01_ID);	}	/**	 * Return the name of this Provider.  (Useful for errors.)	 *	 * @return String	The name of this provider.	 */	public String getObjectName()	{		return name;	}	/**	 * Get the provider's UUID	 *	 * @return 	The provider's UUID	 */	public UUID getObjectID()	{		return id;	}	/**	 * Get the provider's type.	 *	 * @return char		The provider's type.	 */	public String getClassType()	{		return Dependable.TRIGGER;	}	//////////////////////////////////////////////////////	//	// DEPENDENT INTERFACE	//	// Triggers are dependent on the underlying table, 	// and their spses (for the trigger action and the WHEN	// clause).	//	//////////////////////////////////////////////////////	/**	 * Check that all of the dependent's dependencies are valid.	 *	 * @return true if the dependent is currently valid	 */	public synchronized boolean isValid()	{		return true;	}	/**	 * Prepare to mark the dependent as invalid (due to at least one of	 * its dependencies being invalid).	 *	 * @param action	The action causing the invalidation	 * @param p			the provider	 * @param lcc		the language connection context	 *	 * @exception StandardException thrown if unable to make it invalid	 */	public void prepareToInvalidate	(		Provider 					p, 		int							action, 		LanguageConnectionContext	lcc	) throws StandardException	{				switch (action)		{			/*			** We are only dependent on the underlying			** table, and our spses.  (we should be			** dropped before our table is dropped).			*/		    case DependencyManager.DROP_TABLE:		    case DependencyManager.DROP_SYNONYM:		    case DependencyManager.DROP_SPS:		    case DependencyManager.RENAME:				DependencyManager dm = getDataDictionary().getDependencyManager();				throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT, 									dm.getActionString(action), 									p.getObjectName(), "TRIGGER", name);			/*			** The trigger descriptor depends on the trigger table.			** This means that we get called whenever anything happens			** to the trigger table. There are so many cases where this			** can happen that it doesn't make sense to have an assertion			** here to check whether the action was expected (it makes			** the code hard to maintain, and creates a big switch statement).			*/			default:				break;		}	}	/**	 * Mark the dependent as invalid (due to at least one of	 * its dependencies being invalid).  Always an error	 * for a trigger -- should never have gotten here.	 *	 * @param 	lcc the language connection context	 * @param	action	The action causing the invalidation	 *	 * @exception StandardException thrown if called in sanity mode	 */	public void makeInvalid(int action, LanguageConnectionContext lcc) throws StandardException	{		// No sanity check for valid action. Trigger descriptors depend on		// the trigger table, so there is a very large number of actions		// that we would have to check against. This is hard to maintain,		// so don't bother.	}	/**     * Attempt to revalidate the dependent. Meaningless	 * for a trigger.	 *	 * @param 	lcc the language connection context	 */	public void makeValid(LanguageConnectionContext lcc) 	{	}	//////////////////////////////////////////////////////////////	//	// FORMATABLE	//	//////////////////////////////////////////////////////////////	/**	 * Read this object from a stream of stored objects.	 *	 * @param in read this.	 *	 * @exception IOException					thrown on error	 * @exception ClassNotFoundException		thrown on error	 */	public void readExternal(ObjectInput in)		 throws IOException, ClassNotFoundException	{		id = (UUID)in.readObject();		name = (String)in.readObject();		triggerSchemaId = (UUID)in.readObject();		triggerTableId = (UUID)in.readObject();		eventMask = in.readInt();		isBefore = in.readBoolean();		isRow = in.readBoolean();		isEnabled = in.readBoolean();		whenSPSId = (UUID)in.readObject();		actionSPSId = (UUID)in.readObject();		int length = in.readInt();		if (length != 0)		{			referencedCols = new int[length];			for (int i = 0; i < length; i++)			{				referencedCols[i] = in.readInt();			}		}		triggerDefinition = (String)in.readObject();		referencingOld = in.readBoolean();		referencingNew = in.readBoolean();		oldReferencingName = (String)in.readObject();		newReferencingName = (String)in.readObject();			}	protected DataDictionary getDataDictionary() throws StandardException	{		/* 		  note: we need to do this since when this trigger is read back from		  disk (when it is associated with a sps), the dataDictionary has not  		  been initialized and therefore can give a NullPointerException 		*/		DataDictionary dd = super.getDataDictionary(); 		if (dd == null) 		{  			LanguageConnectionContext lcc = (LanguageConnectionContext)				ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);  			dd = lcc.getDataDictionary();			setDataDictionary(dd);  		}		return dd; 	}	/**	 * Write this object to a stream of stored objects.	 *	 * @param out write bytes here.	 *	 * @exception IOException		thrown on error	 */	public void writeExternal( ObjectOutput out )		 throws IOException	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(triggerSchemaId != null,				"triggerSchemaId expected to be non-null");			SanityManager.ASSERT(triggerTableId != null,				"triggerTableId expected to be non-null");		}		out.writeObject(id);		out.writeObject(name);		out.writeObject(triggerSchemaId);		out.writeObject(triggerTableId);		out.writeInt(eventMask);		out.writeBoolean(isBefore);		out.writeBoolean(isRow);		out.writeBoolean(isEnabled);		out.writeObject(whenSPSId);		out.writeObject(actionSPSId);		if (referencedCols == null)		{			out.writeInt(0);		}		else		{			out.writeInt(referencedCols.length);			for (int i = 0; i < referencedCols.length; i++)			{				out.writeInt(referencedCols[i]);			}		}			out.writeObject(triggerDefinition);		out.writeBoolean(referencingOld);		out.writeBoolean(referencingNew);		out.writeObject(oldReferencingName);		out.writeObject(newReferencingName);	} 	/**	 * Get the formatID which corresponds to this class.	 *	 *	@return	the formatID of this class	 */	public	int	getTypeFormatId()	{ return StoredFormatIds.TRIGGER_DESCRIPTOR_V01_ID; }	/** @see TupleDescriptor#getDescriptorType */	public String getDescriptorType()	{		return "Trigger";	}	/** @see TupleDescriptor#getDescriptorName */	public String getDescriptorName() { return name; }	}

⌨️ 快捷键说明

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