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

📄 xact.c

📁 关系型数据库 Postgresql 6.5.2
💻 C
字号:
/*------------------------------------------------------------------------- * * xact.c *	  top level transaction system support routines * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $Header: /usr/local/cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42.2.3 1999/09/09 16:29:22 tgl Exp $ * * NOTES *		Transaction aborts can now occur two ways: * *		1)	system dies from some internal cause  (Assert, etc..) *		2)	user types abort * *		These two cases used to be treated identically, but now *		we need to distinguish them.  Why?	consider the following *		two situatuons: * *				case 1							case 2 *				------							------ *		1) user types BEGIN				1) user types BEGIN *		2) user does something			2) user does something *		3) user does not like what		3) system aborts for some reason *		   she shes and types ABORT * *		In case 1, we want to abort the transaction and return to the *		default state.	In case 2, there may be more commands coming *		our way which are part of the same transaction block and we have *		to ignore these commands until we see an END transaction. *		(or an ABORT! --djm) * *		Internal aborts are now handled by AbortTransactionBlock(), just as *		they always have been, and user aborts are now handled by *		UserAbortTransactionBlock().  Both of them rely on AbortTransaction() *		to do all the real work.  The only difference is what state we *		enter after AbortTransaction() does it's work: * *		* AbortTransactionBlock() leaves us in TBLOCK_ABORT and *		* UserAbortTransactionBlock() leaves us in TBLOCK_ENDABORT * *	 NOTES *		This file is an attempt at a redesign of the upper layer *		of the V1 transaction system which was too poorly thought *		out to describe.  This new system hopes to be both simpler *		in design, simpler to extend and needs to contain added *		functionality to solve problems beyond the scope of the V1 *		system.  (In particuler, communication of transaction *		information between parallel backends has to be supported) * *		The essential aspects of the transaction system are: * *				o  transaction id generation *				o  transaction log updating *				o  memory cleanup *				o  cache invalidation *				o  lock cleanup * *		Hence, the functional division of the transaction code is *		based on what of the above things need to be done during *		a start/commit/abort transaction.  For instance, the *		routine AtCommit_Memory() takes care of all the memory *		cleanup stuff done at commit time. * *		The code is layered as follows: * *				StartTransaction *				CommitTransaction *				AbortTransaction *				UserAbortTransaction * *		are provided to do the lower level work like recording *		the transaction status in the log and doing memory cleanup. *		above these routines are another set of functions: * *				StartTransactionCommand *				CommitTransactionCommand *				AbortCurrentTransaction * *		These are the routines used in the postgres main processing *		loop.  They are sensitive to the current transaction block state *		and make calls to the lower level routines appropriately. * *		Support for transaction blocks is provided via the functions: * *				StartTransactionBlock *				CommitTransactionBlock *				AbortTransactionBlock * *		These are invoked only in responce to a user "BEGIN", "END", *		or "ABORT" command.  The tricky part about these functions *		is that they are called within the postgres main loop, in between *		the StartTransactionCommand() and CommitTransactionCommand(). * *		For example, consider the following sequence of user commands: * *		1)		begin *		2)		retrieve (foo.all) *		3)		append foo (bar = baz) *		4)		end * *		in the main processing loop, this results in the following *		transaction sequence: * *			/	StartTransactionCommand(); *		1) /	ProcessUtility();				<< begin *		   \		StartTransactionBlock(); *			\	CommitTransactionCommand(); * *			/	StartTransactionCommand(); *		2) <	ProcessQuery();					<< retrieve (foo.all) *			\	CommitTransactionCommand(); * *			/	StartTransactionCommand(); *		3) <	ProcessQuery();					<< append foo (bar = baz) *			\	CommitTransactionCommand(); * *			/	StartTransactionCommand(); *		4) /	ProcessUtility();				<< end *		   \		CommitTransactionBlock(); *			\	CommitTransactionCommand(); * *		The point of this example is to demonstrate the need for *		StartTransactionCommand() and CommitTransactionCommand() to *		be state smart -- they should do nothing in between the calls *		to StartTransactionBlock() and EndTransactionBlock() and *		outside these calls they need to do normal start/commit *		processing. * *		Furthermore, suppose the "retrieve (foo.all)" caused an abort *		condition.	We would then want to abort the transaction and *		ignore all subsequent commands up to the "end". *		-cim 3/23/90 * *------------------------------------------------------------------------- *//* * Large object clean up added in CommitTransaction() to prevent buffer leaks. * [PA, 7/17/98] * [PA] is Pascal Andr

⌨️ 快捷键说明

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