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

📄 genericlanguageconnectioncontext.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	 * @param pStmt		The prepared Statement	 * @param provider	The object precipitating a possible invalidation	 * @param action	The action causing the possible invalidation	 *	 * @return Nothing.	 *	 * @exception StandardException thrown on failure	 */	public boolean verifyNoOpenResultSets(PreparedStatement pStmt, Provider provider,									   int action)			throws StandardException	{		/*		** It is not a problem to create an index when there is an open		** result set, since it doesn't invalidate the access path that was		** chosen for the result set.		*/		boolean seenOpenResultSets = false;		/* For every activation */		// synchronize on acts as other threads may be closing activations		// in this list, thus invalidating the Enumeration		for (int i = acts.size() - 1; i >= 0; i--) {							Activation a = (Activation) acts.elementAt(i);			if (!a.isInUse())			{				continue;			}						/* for this prepared statement */			if (pStmt == a.getPreparedStatement()) {				ResultSet rs = a.getResultSet();				/* is there an open result set? */				if (rs != null && ! rs.isClosed())				{					if (!rs.returnsRows())						continue;					seenOpenResultSets = true;					break;				}							}		}		if (!seenOpenResultSets)			return false;		// There may be open ResultSet's that are yet to be garbage collected		// let's try and force these out rather than throw an error		System.gc();		System.runFinalization();		/* For every activation */		// synchronize on acts as other threads may be closing activations		// in this list, thus invalidating the Enumeration		for (int i = acts.size() - 1; i >= 0; i--) {							Activation a = (Activation) acts.elementAt(i);			if (!a.isInUse())			{				continue;			}			/* for this prepared statement */			if (pStmt == a.getPreparedStatement()) {				ResultSet rs = a.getResultSet();				/* is there an open result set? */				if (rs != null && ! rs.isClosed())				{					if ((provider != null) && rs.returnsRows()) {					DependencyManager dmgr = getDataDictionary().getDependencyManager();					throw StandardException.newException(SQLState.LANG_CANT_INVALIDATE_OPEN_RESULT_SET, 									dmgr.getActionString(action), 									provider.getObjectName());					}					return true;				}			}		}		return false;	}	/**	 *	Get the Authorization Id	 *	 * @return String	the authorization id	 */	public String getAuthorizationId()	{ 		return authorizer.getAuthorizationId();	}	/**	 *	Get the default schema	 *	 * @return SchemaDescriptor	the default schema	 */	public SchemaDescriptor getDefaultSchema() 	{ 		return sd; 	}	/**	 * Get the current schema name	 *	 * @return current schema name	 */	public String getCurrentSchemaName()	{        if( null == sd)            return null;		return sd.getSchemaName();	}	/**	 * Set the default schema -- used by SET SCHEMA.	 * 	 * @param SchemaDescriptor	the new default schema.	 * If null, then the default schema descriptor is used.	 *	 * @exception StandardException thrown on failure	 */	public void setDefaultSchema(SchemaDescriptor sd)		throws StandardException	{ 			if (sd == null)		{			    sd = initDefaultSchemaDescriptor();		}		this.sd = sd;			}	/**	 * Get the identity column value most recently generated.	 *	 * @return the generated identity column value	 */	public Long getIdentityValue()	{		return identityNotNull ? new Long(identityVal) : null;	}	/**	 * Set the field of most recently generated identity column value.	 *	 * @param the generated identity column value	 */	public void setIdentityValue(long val)	{		identityVal = val;		identityNotNull = true;	}	/**		Empty as much of the cache as possible. It is not guaranteed		that the cache is empty after this call, as statements may be kept		by currently executing queries, activations that are about to be garbage		collected.	*/	public void emptyCache() {		/* We know prepared statements don't become dirty		** statementCache.cleanAll(); 		*/		if (statementCache != null)			statementCache.ageOut(); 	}	/**	 * Push a CompilerContext on the context stack with	 * the current default schema as the default schema	 * which we compile against.	 *	 * @return the compiler context	 *	 * @exception StandardException thrown on failure	 */	public	final CompilerContext pushCompilerContext()	{		return pushCompilerContext((SchemaDescriptor)null);	}	/**	 * Push a CompilerContext on the context stack with	 * the passed in default schema as the default schema	 * we compile against.	 *	 * @param sd the default schema 	 *	 * @return the compiler context	 *	 */	public	CompilerContext pushCompilerContext(SchemaDescriptor sd)	{		CompilerContext cc;		boolean			firstCompilerContext = false;		//	DEBUG	END		cc = (CompilerContext) (getContextManager().getContext(CompilerContext.CONTEXT_ID));		/*		** If there is no compiler context, this is the first one on the		** stack, so don't pop it when we're done (saves time).		*/		if (cc == null) { firstCompilerContext = true; }		if (cc == null || cc.getInUse())		{			cc = new CompilerContextImpl(getContextManager(), connFactory, tcf);			if (firstCompilerContext) { cc.firstOnStack(); }		}		else		{			/* Reset the next column,table, subquery and ResultSet numbers at 		 	* the beginning of each statement 		 	*/			cc.resetContext();		}		cc.setInUse(true);		// Save off the current isolation level on entry so that it gets restored		cc.setEntryIsolationLevel( getCurrentIsolationLevel());		StatementContext sc = getStatementContext();		if (sc.getSystemCode())			cc.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);		return	cc;	}	/**	 * Pop a CompilerContext off the context stack.	 *	 * @param cc  The compiler context.	 *	 * @return Nothing.	 *	 */	public void popCompilerContext(CompilerContext cc)	{		cc.setCurrentDependent(null);		cc.setInUse(false);		// Restore the isolation level at the time of entry to CompilerContext		isolationLevel = cc.getEntryIsolationLevel();		/*		** Only pop the compiler context if it's not the first one		** on the stack.		*/		if (! cc.isFirstOnStack()) 		{ 			cc.popMe(); 		}		else		{			cc.setCompilationSchema((SchemaDescriptor)null);		}	}	/**	 * Push a StatementContext on the context stack.	 *	 * @param isAtomic whether this statement is atomic or not	 * @param stmtText the text of the statement.  Needed for any language	 * 	statement (currently, for any statement that can cause a trigger	 * 	to fire).  Please set this unless you are some funky jdbc setXXX	 *	method or something.	 * @param pvs parameter value set, if it has one	 * @param rollbackParentContext True if 1) the statement context is	 * 	NOT a top-level context, AND 2) in the event of a statement-level	 *	exception, the parent context needs to be rolled back, too.	 *	 * @return StatementContext  The statement context.	 *	 */	public StatementContext pushStatementContext(boolean isAtomic, String stmtText,		ParameterValueSet pvs, boolean rollbackParentContext)	{		int					parentStatementDepth = statementDepth;		boolean				inTrigger = false;		boolean				parentIsAtomic = false;		// by default, assume we are going to use the outermost statement context		StatementContext	statementContext = statementContexts[0];		/*		** If we haven't allocated any statement contexts yet, allocate		** the outermost stmt context now and push it.		*/		if (statementContext == null)		{			statementContext = statementContexts[0] = new GenericStatementContext(this, tran);		}		else if (statementDepth > 0)		{			StatementContext	parentStatementContext;			/*			** We also cache a 2nd statement context, though we still			** push and pop it. Note, new contexts are automatically pushed.			*/			if (statementDepth == 1)			{				statementContext = statementContexts[1];				if (statementContext == null)					statementContext = statementContexts[1] = new GenericStatementContext(this, tran);				else					statementContext.pushMe();				parentStatementContext = statementContexts[0];			}			else			{				parentStatementContext = getStatementContext();				statementContext = new GenericStatementContext(this, tran);			}			inTrigger = parentStatementContext.inTrigger() || (outermostTrigger == parentStatementDepth);			parentIsAtomic = parentStatementContext.isAtomic();			statementContext.setSQLAllowed(parentStatementContext.getSQLAllowed(), false);			if (parentStatementContext.getSystemCode())				statementContext.setSystemCode();		}		incrementStatementDepth();		statementContext.setInUse(inTrigger, isAtomic || parentIsAtomic, stmtText, pvs);		if (rollbackParentContext)			statementContext.setParentRollback();		return statementContext;	}	/**	 * Pop a StatementContext of the context stack.	 *	 * @param statementContext  The statement context.	 * @param error				The error, if any  (Only relevant for DEBUG)	 *	 * @return Nothing.	 *	 */	public void popStatementContext(StatementContext statementContext,									Throwable error) 	{		if ( statementContext != null ) 		{ 			/*			** If someone beat us to the punch, then it is ok,			** just silently ignore it.  We probably got here			** because we had a try catch block around a push/pop			** statement context, and we already got the context			** on a cleanupOnError.			*/			if (!statementContext.inUse())			{				return;			}			statementContext.clearInUse(); 		}		decrementStatementDepth();		if (statementDepth == -1)		{			/*			 * Only ignore the pop request for an already			 * empty stack when dealing with a session exception.			 */			if (SanityManager.DEBUG)			{				int severity = (error instanceof StandardException) ?									((StandardException)error).getSeverity() :								0;				SanityManager.ASSERT(error != null,					"Must have error to try popStatementContext with 0 depth");				SanityManager.ASSERT(					(severity == ExceptionSeverity.SESSION_SEVERITY),					"Must have session severity error to try popStatementContext with 0 depth");				SanityManager.ASSERT(statementContext == statementContexts[0],					"statementContext is expected to equal statementContexts[0]");			}			resetStatementDepth(); // pretend we did nothing.		}		else if (statementDepth == 0)		{			if (SanityManager.DEBUG)			{				/* Okay to pop last context on a session exception.				 * (We call clean up 

⌨️ 快捷键说明

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