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

📄 updateresultset.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		if (tableScan.lastCursorKey == null)			tableScan.lastCursorKey = new ValueRow(aRow.nColumns() - 1);		for (int i = 1; i <= tableScan.lastCursorKey.nColumns(); i++)		{			DataValueDescriptor aCol = aRow.getColumn(i);			if (aCol != null)				tableScan.lastCursorKey.setColumn(i, aCol.getClone());		}	}	void fireBeforeTriggers() throws StandardException	{		if (deferred)		{			if (triggerInfo != null)			{				if (triggerActivator == null)				{				triggerActivator = new TriggerEventActivator(lcc, 											tc, 											constants.targetUUID,											triggerInfo,											TriggerExecutionContext.UPDATE_EVENT,											activation, null);				}				else				{					triggerActivator.reopen();				}				// fire BEFORE trigger, do this before checking constraints				triggerActivator.notifyEvent(TriggerEvents.BEFORE_UPDATE, 												deletedRowHolder.getResultSet(),												insertedRowHolder.getResultSet());			}		}	}    void fireAfterTriggers() throws StandardException	{		if (deferred)		{			if (triggerActivator != null)			{				triggerActivator.notifyEvent(TriggerEvents.AFTER_UPDATE, 										deletedRowHolder.getResultSet(),										insertedRowHolder.getResultSet());			}		}	}	void updateDeferredRows() throws StandardException	{		if (deferred)		{			// we already have everything locked 			deferredBaseCC =                 tc.openCompiledConglomerate(                    false,                    tc.OPENMODE_FORUPDATE|tc.OPENMODE_SECONDARY_LOCKED,                    lockMode,                    TransactionController.ISOLATION_SERIALIZABLE,                    constants.heapSCOCI,                    heapDCOCI);						CursorResultSet rs = insertedRowHolder.getResultSet();			try			{				/*				** We need to do a fetch doing a partial row				** read.  We need to shift our 1-based bit				** set to a zero based bit set like the store				** expects.				*/				FormatableBitSet readBitSet = RowUtil.shift(baseRowReadList, 1);				ExecRow deferredTempRow2;				rs.open();				while ((deferredTempRow2 = rs.getNextRow()) != null)				{					/*					** Check the constraint now if we have triggers.					** Otherwise we evaluated them as we read the					** rows in from the source.					*/					if (triggerInfo != null)					{						source.setCurrentRow(deferredTempRow);						evaluateCheckConstraints(checkGM, activation);					}					/* 					** The last column is a Ref, which contains a 					** RowLocation.					*/					DataValueDescriptor rlColumn = deferredTempRow2.getColumn(numberOfBaseColumns + 1);					RowLocation baseRowLocation = 							(RowLocation) (rlColumn).getObject();						/* Get the base row at the given RowLocation */					boolean row_exists = 						deferredBaseCC.fetch(							baseRowLocation, deferredSparseRow.getRowArray(), 							readBitSet);					if (SanityManager.DEBUG)					{						SanityManager.ASSERT(row_exists, "did not find base row in deferred update");					}						/*					** Copy the columns from the temp row to the base row.					** The base row has fewer columns than the temp row,					** because it doesn't contain the row location.					*/					RowUtil.copyRefColumns(newBaseRow,											deferredTempRow2,											numberOfBaseColumns);					rowChanger.updateRow(deferredBaseRow,										newBaseRow,										baseRowLocation);				}			} finally			{				source.clearCurrentRow();				rs.close();			}		}	}		void runChecker(boolean restrictCheckOnly) throws StandardException	{		/*		** For a deferred update, make sure that there		** aren't any primary keys that were removed which		** are referenced.  		*/		if (deferred && updatingReferencedKey)		{			ExecRow	deletedRow;			CursorResultSet deletedRows; 			/*			** For each referenced key that was modified			*/			for (int i = 0; i < fkInfoArray.length; i++)			{				if (fkInfoArray[i].type == FKInfo.FOREIGN_KEY)				{					continue;				}				deletedRows = deletedRowHolder.getResultSet();				try				{					/*					** For each delete row					*/						deletedRows.open();					while ((deletedRow = deletedRows.getNextRow()) != null)					{						if (!foundRow(deletedRow, 										fkInfoArray[i].colArray, 										insertedRowHolder))						{							riChecker.doRICheck(i, deletedRow, restrictCheckOnly);						}					}					}				finally				{					deletedRows.close();				}			}		}		/*		** For a deferred update, make sure that there		** aren't any foreign keys that were added that 		** aren't referenced.  		*/		if (deferred && updatingForeignKey)		{			ExecRow	insertedRow;			CursorResultSet insertedRows; 			/*			** For each foreign key that was modified			*/			for (int i = 0; i < fkInfoArray.length; i++)			{				if (fkInfoArray[i].type == FKInfo.REFERENCED_KEY)				{					continue;				}				insertedRows = insertedRowHolder.getResultSet();				try				{					/*					** For each inserted row					*/						insertedRows.open();					while ((insertedRow = insertedRows.getNextRow()) != null)					{						if (!foundRow(insertedRow, 										fkInfoArray[i].colArray, 										deletedRowHolder))						{							riChecker.doRICheck(i, insertedRow, restrictCheckOnly);						}					}					}				finally				{					insertedRows.close();				}			}		}	}	public static boolean foundRow	(		ExecRow					checkRow, 		int[]					colsToCheck,		TemporaryRowHolderImpl	rowHolder	)		throws StandardException	{		ExecRow				scanRow;		boolean				foundMatch = false;		Object[] 			checkRowArray = checkRow.getRowArray();		DataValueDescriptor	checkCol;		DataValueDescriptor	scanCol;		CursorResultSet rs = rowHolder.getResultSet();		try		{				/*			** For each inserted row			*/				rs.open();			while ((scanRow = rs.getNextRow()) != null)			{				Object[] scanRowArray = scanRow.getRowArray();				int i;				for (i = 0; i < colsToCheck.length; i++)				{					checkCol = (DataValueDescriptor)checkRowArray[colsToCheck[i]-1];					scanCol = (DataValueDescriptor)scanRowArray[colsToCheck[i]-1];					BooleanDataValue result = checkCol.equals(											scanCol,											checkCol); // result					if (!result.getBoolean())					{						break;					}				}				if (i == colsToCheck.length)				{					foundMatch = true;					break;				}				}		}		finally		{			rs.close();		}		return foundMatch;	}	/**	 * @see ResultSet#cleanUp	 *	 * @exception StandardException		Thrown on error	 */	public void	cleanUp() throws StandardException	{ 		numOpens = 0;		/* Close down the source ResultSet tree */		if (source != null)		{			source.close();			// cache source across open()s		}		if (triggerActivator != null)		{			triggerActivator.cleanup();			// cache triggerActivator across open()s		}		if (rowChanger != null)			rowChanger.close();		if (deferredBaseCC != null)			deferredBaseCC.close();		deferredBaseCC = null;		if (insertedRowHolder != null)		{			insertedRowHolder.close();		}			if (deletedRowHolder != null)		{			deletedRowHolder.close();		}		if (riChecker != null)		{			riChecker.close();			// cache riChecker across open()s		}		super.close();		endTime = getCurrentTimeMillis();	}    /**     * Decode the update lock mode.     * <p>     * The value for update lock mode is in the 2nd 2 bytes for      * ExecutionContext.SERIALIZABLE_ISOLATION_LEVEL isolation level.  Otherwise     * (REPEATABLE READ, READ COMMITTED, and READ UNCOMMITTED) the lock mode is     * located in the first 2 bytes.     * <p>     * This is done to override the optimizer choice to provide maximum      * concurrency of record level locking except in SERIALIZABLE where table     * level locking is required in heap scans for correctness.     * <p>     * See Compilation!QueryTree!FromBaseTable for encoding of the lockmode.     * <p>     *	 * @return The lock mode (record or table) to use to open the result set.     *     * @param lcc       The context to look for current isolation level.     * @param lockMode  The compiled encoded lock mode for this query.     *	 * @exception  StandardException  Standard exception policy.     **/	protected static int decodeLockMode(    LanguageConnectionContext   lcc,     int                         lockMode)	{		if ((lockMode >>> 16) != 0)		{            // Note that isolation level encoding from             // getCurrentIsolationLevel() returns             // ExecutionContext.*ISOLATION_LEVEL constants, not             // TransactionController.ISOLATION* constants.			int isolationLevel = lcc.getCurrentIsolationLevel();            if (isolationLevel != ExecutionContext.SERIALIZABLE_ISOLATION_LEVEL)            {				lockMode = lockMode & 0xff;            }            else            {				lockMode = lockMode >>> 16;            }		}		return lockMode;	}		void rowChangerFinish() throws StandardException	{		rowChanger.finish();	}}

⌨️ 快捷键说明

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