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

📄 genericstatementcontext.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*   Derby - Class org.apache.derby.impl.sql.conn.GenericStatementContext   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License. */package org.apache.derby.impl.sql.conn;import org.apache.derby.iapi.services.context.Context;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;import org.apache.derby.iapi.sql.conn.StatementContext;import org.apache.derby.iapi.sql.depend.Dependency;import org.apache.derby.iapi.sql.depend.DependencyManager;import org.apache.derby.iapi.sql.execute.NoPutResultSet;import org.apache.derby.iapi.sql.ResultSet;import org.apache.derby.iapi.sql.ParameterValueSet;import org.apache.derby.iapi.store.access.TransactionController;import org.apache.derby.iapi.services.context.ContextImpl;import org.apache.derby.iapi.error.ExceptionSeverity;import org.apache.derby.iapi.reference.SQLState;import java.util.ArrayList;import java.util.Iterator;import java.sql.SQLException;/** * GenericStatementContext is pushed/popped around a statement prepare and execute * so that any statement specific clean up can be performed. * * @author jerry * */final class GenericStatementContext 	extends ContextImpl implements StatementContext{	private final TransactionController tc;	private boolean		setSavePoint;	private String		internalSavePointName;	private ResultSet	topResultSet;	private ArrayList		dependencies;	private NoPutResultSet[] subqueryTrackingArray;	private NoPutResultSet[] materializedSubqueries;	private	final LanguageConnectionContext lcc;	private boolean		inUse = true;    private	boolean		parentInTrigger;	// whetherparent started with a trigger on stack    private	boolean		isAtomic;		private boolean		isSystemCode;	private boolean		rollbackParentContext;    private	String		stmtText;    private	ParameterValueSet			pvs;	/**		Set to one of RoutineAliasInfo.{MODIFIES_SQL_DATA, READS_SQL_DATA, CONTAINS_SQL, NO_SQL}	*/	private short			sqlAllowed = -1;	/*	   constructor		@param tc transaction	*/	GenericStatementContext(LanguageConnectionContext lcc, TransactionController tc) 	{		super(lcc.getContextManager(), org.apache.derby.iapi.reference.ContextId.LANG_STATEMENT);		this.lcc = lcc;		this.tc = tc;		internalSavePointName = "ISSP" + hashCode();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT((lcc != null),					"Failed to get language connection context");		}	}	// StatementContext Interface	public void setInUse	( 		boolean parentInTrigger,		boolean isAtomic, 		String stmtText,		ParameterValueSet pvs	) 	{		inUse = true;		this.parentInTrigger = parentInTrigger;		this.isAtomic = isAtomic;		this.stmtText = stmtText;		this.pvs = pvs;		rollbackParentContext = false;	}	public void clearInUse() {		/* We must clear out the current top ResultSet to prepare for		 * reusing a StatementContext.		 */		stuffTopResultSet( null, null );		inUse = false;		parentInTrigger = false;		isAtomic = false;		this.stmtText = null;		sqlAllowed = -1;		isSystemCode = false;		rollbackParentContext = false;	}	/**	 * @see StatementContext#setSavePoint	 * @exception StandardException Thrown on error	 */	public void setSavePoint() throws StandardException {				if (SanityManager.DEBUG)		{			if (SanityManager.DEBUG_ON("traceSavepoints"))			{				SanityManager.DEBUG_PRINT(									"GenericStatementContext.setSavePoint()",									internalSavePointName);			}		}					pleaseBeOnStack();				// RESOLVE PLUGIN ???. For the plugin, there will be no transaction controller		if ( tc != null ) { tc.setSavePoint(internalSavePointName, null); }		setSavePoint = true;	}	/**	 * Resets the savepoint to the current spot if it is	 * set, otherwise, noop.  Used when a commit is	 * done on a nested connection.	 *	 * @see StatementContext#resetSavePoint	 * @exception StandardException Thrown on error	 */	public void resetSavePoint() throws StandardException {		if (SanityManager.DEBUG)		{			if (SanityManager.DEBUG_ON("traceSavepoints"))			{				SanityManager.DEBUG_PRINT(					"GenericStatementContext.resetSavePoint()",					internalSavePointName);			}		}					if (inUse && setSavePoint)		{					// RESOLVE PLUGIN ???. For the plugin, there will be no transaction controller			if ( tc != null ) { tc.setSavePoint(internalSavePointName, null); }			// stage buffer management		}	}	/**	 * @see StatementContext#clearSavePoint	 * @exception StandardException Thrown on error	 */	public void clearSavePoint() throws StandardException {		if (SanityManager.DEBUG)		{			if (SanityManager.DEBUG_ON("traceSavepoints"))			{				SanityManager.DEBUG_PRINT("GenericStatementContext.clearSavePoint()",										  internalSavePointName);			}		}		pleaseBeOnStack();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(setSavePoint, "setSavePoint is expected to be true");		}		// RESOLVE PLUGIN ???. For the plugin, there will be no transaction controller		if ( tc != null ) { tc.releaseSavePoint(internalSavePointName, null); }		setSavePoint = false;	}	/**	 * Set the top ResultSet in the ResultSet tree for close down on	 * an error.	 *	 * @exception StandardException thrown on error.	 * @return Nothing.	 */	public void setTopResultSet(ResultSet topResultSet, 							    NoPutResultSet[] subqueryTrackingArray)		 throws StandardException	{		pleaseBeOnStack();		/* We have to handle both materialize and non-materialized subqueries.		 * Materialized subqueries are attached before the top result set is 		 * set.  If there are any, then we must copy them into the new		 * subqueryTrackingArray.		 */		if (materializedSubqueries != null)		{			// Do the merging into the passed in array.			if (subqueryTrackingArray != null)			{				if (SanityManager.DEBUG)				{					if (this.materializedSubqueries.length != subqueryTrackingArray.length)					{						SanityManager.THROWASSERT(							"this.ms.length (" + this.materializedSubqueries.length +							") expected to = sta.length(" + subqueryTrackingArray.length +							")");					}				}				for (int index = 0; index < subqueryTrackingArray.length; index++)				{					if (this.subqueryTrackingArray[index] != null)					{						subqueryTrackingArray[index] = this.materializedSubqueries[index];					}				}			}			else			{				subqueryTrackingArray = this.materializedSubqueries;			}			materializedSubqueries = null;		}		stuffTopResultSet( topResultSet, subqueryTrackingArray );	}	/**	  *	Private minion of setTopResultSet() and clearInUse()	  *	  *	@param	topResultSet	make this the top result set	  *	@param	subqueryTrackingArray	where to keep track of subqueries in this statement	  *	  * @return Nothing.	  */	private	void	stuffTopResultSet(ResultSet topResultSet, 									  NoPutResultSet[] subqueryTrackingArray)	{		this.topResultSet = topResultSet;		this.subqueryTrackingArray = subqueryTrackingArray;		dependencies = null;	}	/**	 * Set the appropriate entry in the subquery tracking array for	 * the specified subquery.	 * Useful for closing down open subqueries on an exception.	 *	 * @param subqueryNumber	The subquery # for this subquery	 * @param subqueryResultSet	The ResultSet at the top of the subquery	 * @param numSubqueries		The total # of subqueries in the entire query	 *	 * @exception StandardException thrown on error.	 * @return Nothing.	 */	public void setSubqueryResultSet(int subqueryNumber,									 NoPutResultSet subqueryResultSet,									 int numSubqueries)		throws StandardException	{		pleaseBeOnStack();				/* NOTE: In degenerate cases, it is possible that there is no top		 * result set.  For example:		 *		call (select 1 from systables).valueOf('111');		 * In that case, we allocate our own subquery tracking array on		 * each call. (Gross!)		 * (Trust me, this is only done in degenerate cases.  The tests passed,		 * except for the degenerate cases, before making this change, so we		 * know that the top result set and array reuse is working for		 * the non-degenerate cases.)

⌨️ 快捷键说明

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