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

📄 spsdescriptor.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		}	}	//////////////////////////////////////////////////////	//	// PROVIDER INTERFACE	//	//////////////////////////////////////////////////////	/**			 * Return the stored form of this provider	 *	 * @see Dependable#getDependableFinder	 */	public final DependableFinder getDependableFinder()	{	    return	getDependableFinder(StoredFormatIds.SPS_DESCRIPTOR_FINDER_V01_ID);	}	/**	 * Return the name of this Provider.  (Useful for errors.)	 *	 * @return String	The name of this provider.	 */	public final String getObjectName()	{		return name;	}	/**	 * Get the provider's UUID 	 *	 * @return String	The provider's UUID	 */	public final UUID getObjectID()	{		return uuid;	}	/**	 * Get the provider's type.	 *	 * @return String The provider's type.	 */	public final String getClassType()	{		return Dependable.STORED_PREPARED_STATEMENT;	}	//////////////////////////////////////////////////////	//	// DEPENDENT INTERFACE	//	//////////////////////////////////////////////////////	/**	 * Check that all of the dependent's dependencies are valid.	 *	 * @return true if the dependent is currently valid	 */	public final synchronized boolean isValid()	{		return valid;	}	/**	 * 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	 *	 * @exception StandardException thrown if unable to make it invalid	 */	public final synchronized void prepareToInvalidate(									Provider p, int action,									LanguageConnectionContext lcc) 		throws StandardException	{		switch (action)		{			/*			** Things that don't affect us			*/		    case DependencyManager.CREATE_VIEW:				/*			** Things that force a recompile, but are			** allowed.			*/			case DependencyManager.CREATE_INDEX:			case DependencyManager.CREATE_CONSTRAINT:			case DependencyManager.DROP_CONSTRAINT:			case DependencyManager.DROP_INDEX:			case DependencyManager.DROP_TABLE:			case DependencyManager.DROP_VIEW: 			case DependencyManager.DROP_METHOD_ALIAS:			case DependencyManager.DROP_SYNONYM:			case DependencyManager.ALTER_TABLE:			case DependencyManager.RENAME:			case DependencyManager.RENAME_INDEX:			case DependencyManager.PREPARED_STATEMENT_RELEASE:			case DependencyManager.USER_RECOMPILE_REQUEST:			case DependencyManager.CHANGED_CURSOR:			case DependencyManager.BULK_INSERT:			case DependencyManager.COMPRESS_TABLE:			case DependencyManager.SET_CONSTRAINTS_ENABLE:			case DependencyManager.SET_CONSTRAINTS_DISABLE:			case DependencyManager.SET_TRIGGERS_ENABLE:			case DependencyManager.SET_TRIGGERS_DISABLE:			case DependencyManager.ROLLBACK:			case DependencyManager.INTERNAL_RECOMPILE_REQUEST:			case DependencyManager.CREATE_TRIGGER:			case DependencyManager.DROP_TRIGGER:			case DependencyManager.DROP_TABLE_CASCADE:			case DependencyManager.DROP_VIEW_CASCADE:			case DependencyManager.DROP_COLUMN:			case DependencyManager.DROP_COLUMN_CASCADE:		    case DependencyManager.UPDATE_STATISTICS:		    case DependencyManager.DROP_STATISTICS:    		case DependencyManager.TRUNCATE_TABLE:				break;			/*			** The rest are errors			*/		    default:				DependencyManager dm;				dm = getDataDictionary().getDependencyManager();				throw StandardException.newException(SQLState.LANG_PROVIDER_HAS_DEPENDENT_S_P_S, 					dm.getActionString(action), 					p.getObjectName(), name);		}	}	/**	 * Mark the dependent as invalid (due to at least one of	 * its dependencies being invalid).	 *	 * @param	action	The action causing the invalidation	 *	 * @exception StandardException thrown if unable to make it invalid	 */	public final synchronized void makeInvalid(int action,											   LanguageConnectionContext lcc) 		throws StandardException	{		DependencyManager dm;		dm = getDataDictionary().getDependencyManager();		switch (action)		{			/*			** Some things that don't affect stored prepared	 		** statements.			*/			case DependencyManager.PREPARED_STATEMENT_RELEASE:		    case DependencyManager.CREATE_VIEW:				break;			/*		 	** Things that can invalidate a stored			** prepared statement.			*/			case DependencyManager.CREATE_INDEX:			case DependencyManager.CREATE_CONSTRAINT:			case DependencyManager.DROP_CONSTRAINT:			case DependencyManager.DROP_TABLE:			case DependencyManager.DROP_INDEX:			case DependencyManager.DROP_VIEW: 			case DependencyManager.DROP_METHOD_ALIAS:			case DependencyManager.DROP_SYNONYM:			case DependencyManager.ALTER_TABLE:			case DependencyManager.RENAME:			case DependencyManager.RENAME_INDEX:			case DependencyManager.USER_RECOMPILE_REQUEST:			case DependencyManager.CHANGED_CURSOR:			case DependencyManager.BULK_INSERT:			case DependencyManager.COMPRESS_TABLE:			case DependencyManager.SET_CONSTRAINTS_ENABLE:			case DependencyManager.SET_CONSTRAINTS_DISABLE:			case DependencyManager.SET_TRIGGERS_ENABLE:			case DependencyManager.SET_TRIGGERS_DISABLE:			case DependencyManager.ROLLBACK:			case DependencyManager.INTERNAL_RECOMPILE_REQUEST:			case DependencyManager.CREATE_TRIGGER:			case DependencyManager.DROP_TRIGGER:			case DependencyManager.DROP_TABLE_CASCADE:			case DependencyManager.DROP_VIEW_CASCADE:			case DependencyManager.DROP_COLUMN:			case DependencyManager.DROP_COLUMN_CASCADE:		    case DependencyManager.UPDATE_STATISTICS:		    case DependencyManager.DROP_STATISTICS:			case DependencyManager.TRUNCATE_TABLE:				/*				** If we are already invalid, don't write ourselves				** out.  Just to be safe, we'll send out an invalidate				** to our dependents either way.				*/				if (valid == true)				{					valid = false;					updateSYSSTATEMENTS(lcc, INVALIDATE, null);				}				dm.invalidateFor(this, dm.USER_RECOMPILE_REQUEST, lcc);				break;			case DependencyManager.DROP_SPS:				//System.out.println("SPSD " + preparedStatement);				dm.clearDependencies(lcc, this);				break;			    default:				/* 				** We should never get here, since we can't have dangling references 				*/				if (SanityManager.DEBUG)				{					SanityManager.THROWASSERT("makeInvalid("+						dm.getActionString(action)+						") not expected to get called; should have failed in "+						"prepareToInvalidate()");				}				break;		}	}	/**     * Attempt to revalidate the dependent. For prepared statements,	 * this could go through its dependencies and check that they	 * are up to date; if not, it would recompile the statement.	 * Any failure during this attempt should throw	 * StandardException.unableToRevalidate().	 *	 * @exception StandardException thrown if unable to make it valid	 */	public final synchronized void makeValid(LanguageConnectionContext lcc) 		throws StandardException	{		if (valid)		{			return;		}		prepareAndRelease(lcc);		updateSYSSTATEMENTS(lcc, RECOMPILE, null);			}	/**	 * Invalidate and revalidate.  The functional equivalent	 * of calling makeInvalid() and makeValid(), except it	 * is optimized.	 *	 * @exception StandardException on error	 */	public final synchronized void revalidate(LanguageConnectionContext lcc)		throws StandardException	{		/*		** Mark it as invalid first to ensure that		** we don't write SYSSTATEMENTS 2x.		*/		valid = false;		makeInvalid(DependencyManager.USER_RECOMPILE_REQUEST, lcc);		prepareAndRelease(lcc);		updateSYSSTATEMENTS(lcc, RECOMPILE, null);	}	/**	 * Load the underlying generatd class.  This is not expected	 * to be used outside of the datadictionary package.  It	 * is used for optimizing class loading for sps	 * cacheing.	 *	 * @exception StandardException on error	 */	public void loadGeneratedClass() throws StandardException	{		/*		** On upgrade, we null out the statement body,		** so handle that here.		*/		if (preparedStatement != null)		{			((StorablePreparedStatement)preparedStatement).loadGeneratedClass();		}	}	/*	** Update SYSSTATEMENTS with the changed the descriptor.  	** Always done in the user XACT.	** <p>	** Ideally, the changes to SYSSTATEMENTS would be made 	** in a separate xact as the current user xact, but this	** is painful (you'ld need to get a new ContextManager	** and then push all of the usual langauge contexts	** onto it and THEN call AccessManager.getTransaction()),	** and it wont work, because the xact is in a different	** compatibility space and will self deadlock (e.g.	** in the process of call DependencyManager.makeInvalid() 	** we first did a DDdependableFinder.getDependable()	** which called DataDictionaryImpl.getSPSDescriptor()	** so we hold a lock on SYS.SYSSTATEMENTS by the	** time we get a 2nd xact and try to drop the statement).	*/	private void updateSYSSTATEMENTS(LanguageConnectionContext lcc, int mode, TransactionController tc)		throws StandardException	{		int[] 					colsToUpdate;		boolean					updateSYSCOLUMNS,  recompile;		//bug 4821 - we want to wait for locks if updating sysstatements on parent transaction		boolean wait = false;		boolean firstCompilation = false;		if (mode == RECOMPILE)		{			recompile = true;			updateSYSCOLUMNS = true;			if(!initiallyCompilable)			{				firstCompilation = true;				initiallyCompilable = true;			}		}		else		{			recompile = false;			updateSYSCOLUMNS = false;		}		DataDictionary dd = getDataDictionary();		if (((org.apache.derby.impl.sql.catalog.DataDictionaryImpl) dd).readOnlyUpgrade)			return;		/*		** Get busy time		*/		dd.startWriting(lcc);			if (tc == null) { //bug 4821 - tc will passed null if we want to use the user transaction			tc = lcc.getTransactionExecute();			wait = true;		}		dd.updateSPS(this,					 tc, 					 recompile,					 updateSYSCOLUMNS,					 wait,					 firstCompilation);	}	/**	 * Get the UUID for the given string	 *	 * @param the string	 *	 * @return the UUID	 */	private UUID recreateUUID(String idString)	{		if (uuidFactory == null)		{			uuidFactory = Monitor.getMonitor().getUUIDFactory();		}		return uuidFactory.recreateUUID(idString);	}	/** @see TupleDescriptor#getDescriptorType */	public String getDescriptorType() { return "Statement"; }	/** @see TupleDescriptor#getDescriptorName */	// RESOLVE: some descriptors have getName.  some descriptors have	// getTableName, getColumnName whatever! try and unify all of this to one	// getDescriptorName! 	public String getDescriptorName() { return name; }	}

⌨️ 快捷键说明

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