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

📄 deleteresultset.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
							null);			}			rc.setRowHolder(rowHolder);		}		if (fkInfoArray != null)		{			if (fkChecker == null)			{				fkChecker = new RISetChecker(tc, fkInfoArray);			}			else			{				fkChecker.reopen();			}		}	}	boolean  collectAffectedRows() throws StandardException	{			DataValueDescriptor		rlColumn;		RowLocation	baseRowLocation;		boolean rowsFound = false;		if(cascadeDelete)			row = getNextRowCore(source);		while ( row != null )		{			/* By convention, the last column for a delete contains a SQLRef			 * containing the RowLocation of the row to be deleted.  If we're			 * doing a deferred delete, store the RowLocations in the			 * temporary conglomerate.  If we're not doing a deferred delete,			 * just delete the rows immediately.			 */			rowsFound = true;			rlColumn = row.getColumn( row.nColumns() );					if (constants.deferred || cascadeDelete)			{				/*				** If we are deferred because of a trigger or foreign				** key, we need to save off the entire row.  Otherwise,				** we just save the RID.				*/				if (noTriggersOrFks)				{					deferredRLRow.setColumn(1, rlColumn);					rowHolder.insert(deferredRLRow);				}				else				{					rowHolder.insert(row);				}								/*				** If we haven't already, lets get a template to				** use as a template for our rescan of the base table.				** Do this now while we have a real row to use				** as a copy.				**				** There is one less column in the base row than				** there is in source row, because the base row				** doesn't contain the row location.				*/				if (deferredBaseRow == null)				{					deferredBaseRow = RowUtil.getEmptyValueRow(numberOfBaseColumns - 1, lcc);								RowUtil.copyCloneColumns(deferredBaseRow, row, 											numberOfBaseColumns - 1);					deferredSparseRow = makeDeferredSparseRow(deferredBaseRow,																baseRowReadList,																lcc);				}			}			else			{				if (fkChecker != null)				{					fkChecker.doPKCheck(row, false);				}				baseRowLocation = 					(RowLocation) (rlColumn).getObject();				if (SanityManager.DEBUG)				{					SanityManager.ASSERT(baseRowLocation != null,							"baseRowLocation is null");				}				rc.deleteRow(row,baseRowLocation);			}            rowCount++;			// No need to do a next on a single row source			if (constants.singleRowSource)			{				row = null;			}			else			{				row = getNextRowCore(source);			}		}		return rowsFound;	}	// execute the before triggers set on the table    void fireBeforeTriggers() throws StandardException	{		if (triggerInfo != null)		{			if (triggerActivator == null)			{				triggerActivator = new TriggerEventActivator(lcc, 															 tc, 															 constants.targetUUID,															 triggerInfo,															 TriggerExecutionContext.DELETE_EVENT,															 activation, null															 );			}			else			{				triggerActivator.reopen();			}			// fire BEFORE trigger			triggerActivator.notifyEvent(TriggerEvents.BEFORE_DELETE, 										 rowHolder.getResultSet(), 										 (CursorResultSet)null);		}	}	//execute the after triggers set on the table.	void fireAfterTriggers() throws StandardException	{		// fire AFTER trigger		if (triggerActivator != null)		{			triggerActivator.notifyEvent(TriggerEvents.AFTER_DELETE, 										 rowHolder.getResultSet(),										 (CursorResultSet)null);		}			}	//delete the rows that in case deferred case and	//during cascade delete (All deletes are deferred during cascade action)	void deleteDeferredRows() throws StandardException	{				DataValueDescriptor		rlColumn; 		RowLocation	baseRowLocation;		ExecRow		deferredRLRow = null;		deferredBaseCC = tc.openCompiledConglomerate(false,													 tc.OPENMODE_FORUPDATE|tc.OPENMODE_SECONDARY_LOCKED,													 lockMode,													 TransactionController.ISOLATION_SERIALIZABLE,													 constants.heapSCOCI,													 heapDCOCI);					CursorResultSet rs = rowHolder.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);			rs.open();			while ((deferredRLRow = rs.getNextRow()) != null)			{				rlColumn = deferredRLRow.getColumn(rlColumnNumber);				baseRowLocation = 					(RowLocation) (rlColumn).getObject();					/* Get the base row at the given RowLocation */				boolean row_exists = 					deferredBaseCC.fetch(										 baseRowLocation, deferredSparseRow.getRowArray(), 										 readBitSet);				// In case of cascade delete , things like before triggers can delete 				// the rows before the dependent result get a chance to delete				if(cascadeDelete && !row_exists)					continue;				if (SanityManager.DEBUG)				{					if (!row_exists)					{                        	SanityManager.THROWASSERT("could not find row "+baseRowLocation);					}				}					rc.deleteRow(deferredBaseRow, baseRowLocation);			}		} finally		{				rs.close();		}	}	// make sure foreign key constraints are not violated    void runFkChecker(boolean restrictCheckOnly) throws StandardException	{		ExecRow		deferredRLRow = null;		if (fkChecker != null)		{			/*			** Second scan to make sure all the foreign key			** constraints are ok.  We have to do this after			** we have completed the deletes in case of self referencing			** constraints.			*/			CursorResultSet rs = rowHolder.getResultSet();			try			{				rs.open();				while ((deferredRLRow = rs.getNextRow()) != null)				{					fkChecker.doPKCheck(deferredRLRow, restrictCheckOnly);				}			} finally			{				rs.close();			}		}	}	/**	  *	create a source for the dependent table	  *	  * <P>Delete Cascade ResultSet class will override this method.	  *	  * @exception StandardException		Thrown on error	  */	NoPutResultSet createDependentSource(RowChanger rc)		throws StandardException	{		return null;	}	/**	 * @see ResultSet#cleanUp	 *	 * @exception StandardException		Thrown on error	 */	public void	cleanUp() throws StandardException	{ 		numOpens = 0;		if (triggerActivator != null)		{			triggerActivator.cleanup();			// trigger activator is reused		}		/* Close down the source ResultSet tree */		if (source != null)		{			source.close();			// source is reused across executions		}		if (rc != null)		{			rc.close();			// rc is reused across executions		}		if (rowHolder != null)		{			rowHolder.close();			// rowHolder is reused across executions		}		if (fkChecker != null)		{			fkChecker.close();			// fkcheckers is reused across executions		}		if (deferredBaseCC != null)			deferredBaseCC.close();		deferredBaseCC = null;		super.close();	}	public void finish() throws StandardException {		if (source != null)			source.finish();		super.finish();	}}

⌨️ 快捷键说明

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