@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $ PostgreSQL : pgsql / src / backend / access / transam / xact . c , v 1.215 .2 .5 2009 / 11 / 23 09 : 59 : 21 heikki Exp $
* $ PostgreSQL : pgsql / src / backend / access / transam / xact . c , v 1.215 .2 .6 2009 / 12 / 09 21 : 58 : 41 tgl Exp $
*
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
@ -116,12 +116,13 @@ typedef struct TransactionStateData
int savepointLevel ; /* savepoint level */
int savepointLevel ; /* savepoint level */
TransState state ; /* low-level state */
TransState state ; /* low-level state */
TBlockState blockState ; /* high-level state */
TBlockState blockState ; /* high-level state */
int nestingLevel ; /* nest depth */
int nestingLevel ; /* transaction nesting depth */
int gucNestLevel ; /* GUC context nesting depth */
MemoryContext curTransactionContext ; /* my xact-lifetime context */
MemoryContext curTransactionContext ; /* my xact-lifetime context */
ResourceOwner curTransactionOwner ; /* my query resources */
ResourceOwner curTransactionOwner ; /* my query resources */
List * childXids ; /* subcommitted child XIDs */
List * childXids ; /* subcommitted child XIDs */
Oid prevUser ; /* previous CurrentUserId setting */
Oid prevUser ; /* previous CurrentUserId setting */
bool prevSecDefCxt ; /* previous SecurityDefinerContext setting */
int prevSecContext ; /* previous SecurityRestrictionContext */
bool prevXactReadOnly ; /* entry-time xact r/o state */
bool prevXactReadOnly ; /* entry-time xact r/o state */
struct TransactionStateData * parent ; /* back link to parent */
struct TransactionStateData * parent ; /* back link to parent */
} TransactionStateData ;
} TransactionStateData ;
@ -149,12 +150,13 @@ static TransactionStateData TopTransactionStateData = {
TRANS_DEFAULT , /* transaction state */
TRANS_DEFAULT , /* transaction state */
TBLOCK_DEFAULT , /* transaction block state from the client
TBLOCK_DEFAULT , /* transaction block state from the client
* perspective */
* perspective */
0 , /* nesting level */
0 , /* transaction nesting depth */
0 , /* GUC context nesting depth */
NULL , /* cur transaction context */
NULL , /* cur transaction context */
NULL , /* cur transaction resource owner */
NULL , /* cur transaction resource owner */
NIL , /* subcommitted child Xids */
NIL , /* subcommitted child Xids */
InvalidOid , /* previous CurrentUserId setting */
InvalidOid , /* previous CurrentUserId setting */
false , /* previous SecurityDefinerContext setting */
0 , /* previous SecurityRestrictionContext */
false , /* entry-time xact r/o state */
false , /* entry-time xact r/o state */
NULL /* link to parent state block */
NULL /* link to parent state block */
} ;
} ;
@ -1379,14 +1381,16 @@ StartTransaction(void)
* note : prevXactReadOnly is not used at the outermost level
* note : prevXactReadOnly is not used at the outermost level
*/
*/
s - > nestingLevel = 1 ;
s - > nestingLevel = 1 ;
s - > gucNestLevel = 1 ;
s - > childXids = NIL ;
s - > childXids = NIL ;
GetUserIdAndContext ( & s - > prevUser , & s - > prevSecDefC xt ) ;
GetUserIdAndSec Context ( & s - > prevUser , & s - > prevSecConte xt ) ;
/* SecurityDefiner Context should never be set outside a transaction */
/* SecurityRestriction Context should never be set outside a transaction */
Assert ( ! s - > prevSecDefCxt ) ;
Assert ( s - > prevSecContext = = 0 ) ;
/*
/*
* initialize other subsystems for new transaction
* initialize other subsystems for new transaction
*/
*/
AtStart_GUC ( ) ;
AtStart_Inval ( ) ;
AtStart_Inval ( ) ;
AtStart_Cache ( ) ;
AtStart_Cache ( ) ;
AfterTriggerBeginXact ( ) ;
AfterTriggerBeginXact ( ) ;
@ -1570,7 +1574,7 @@ CommitTransaction(void)
/* Check we've released all catcache entries */
/* Check we've released all catcache entries */
AtEOXact_CatCache ( true ) ;
AtEOXact_CatCache ( true ) ;
AtEOXact_GUC ( true , false ) ;
AtEOXact_GUC ( true , 1 ) ;
AtEOXact_SPI ( true ) ;
AtEOXact_SPI ( true ) ;
AtEOXact_on_commit_actions ( true ) ;
AtEOXact_on_commit_actions ( true ) ;
AtEOXact_Namespace ( true ) ;
AtEOXact_Namespace ( true ) ;
@ -1590,6 +1594,7 @@ CommitTransaction(void)
s - > transactionId = InvalidTransactionId ;
s - > transactionId = InvalidTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > nestingLevel = 0 ;
s - > nestingLevel = 0 ;
s - > gucNestLevel = 0 ;
s - > childXids = NIL ;
s - > childXids = NIL ;
/*
/*
@ -1786,7 +1791,7 @@ PrepareTransaction(void)
AtEOXact_CatCache ( true ) ;
AtEOXact_CatCache ( true ) ;
/* PREPARE acts the same as COMMIT as far as GUC is concerned */
/* PREPARE acts the same as COMMIT as far as GUC is concerned */
AtEOXact_GUC ( true , false ) ;
AtEOXact_GUC ( true , 1 ) ;
AtEOXact_SPI ( true ) ;
AtEOXact_SPI ( true ) ;
AtEOXact_on_commit_actions ( true ) ;
AtEOXact_on_commit_actions ( true ) ;
AtEOXact_Namespace ( true ) ;
AtEOXact_Namespace ( true ) ;
@ -1805,6 +1810,7 @@ PrepareTransaction(void)
s - > transactionId = InvalidTransactionId ;
s - > transactionId = InvalidTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > nestingLevel = 0 ;
s - > nestingLevel = 0 ;
s - > gucNestLevel = 0 ;
s - > childXids = NIL ;
s - > childXids = NIL ;
/*
/*
@ -1868,13 +1874,13 @@ AbortTransaction(void)
* Reset user ID which might have been changed transiently . We need this
* Reset user ID which might have been changed transiently . We need this
* to clean up in case control escaped out of a SECURITY DEFINER function
* to clean up in case control escaped out of a SECURITY DEFINER function
* or other local change of CurrentUserId ; therefore , the prior value
* or other local change of CurrentUserId ; therefore , the prior value
* of SecurityDefiner Context also needs to be restored .
* of SecurityRestriction Context also needs to be restored .
*
*
* ( Note : it is not necessary to restore session authorization or role
* ( Note : it is not necessary to restore session authorization or role
* settings here because those can only be changed via GUC , and GUC will
* settings here because those can only be changed via GUC , and GUC will
* take care of rolling them back if need be . )
* take care of rolling them back if need be . )
*/
*/
SetUserIdAndContext ( s - > prevUser , s - > prevSecDefC xt ) ;
SetUserIdAndSec Context ( s - > prevUser , s - > prevSecConte xt ) ;
/*
/*
* do abort processing
* do abort processing
@ -1934,7 +1940,7 @@ AbortTransaction(void)
false , true ) ;
false , true ) ;
AtEOXact_CatCache ( false ) ;
AtEOXact_CatCache ( false ) ;
AtEOXact_GUC ( false , false ) ;
AtEOXact_GUC ( false , 1 ) ;
AtEOXact_SPI ( false ) ;
AtEOXact_SPI ( false ) ;
AtEOXact_on_commit_actions ( false ) ;
AtEOXact_on_commit_actions ( false ) ;
AtEOXact_Namespace ( false ) ;
AtEOXact_Namespace ( false ) ;
@ -1981,6 +1987,7 @@ CleanupTransaction(void)
s - > transactionId = InvalidTransactionId ;
s - > transactionId = InvalidTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > subTransactionId = InvalidSubTransactionId ;
s - > nestingLevel = 0 ;
s - > nestingLevel = 0 ;
s - > gucNestLevel = 0 ;
s - > childXids = NIL ;
s - > childXids = NIL ;
/*
/*
@ -3645,7 +3652,7 @@ CommitSubTransaction(void)
RESOURCE_RELEASE_AFTER_LOCKS ,
RESOURCE_RELEASE_AFTER_LOCKS ,
true , false ) ;
true , false ) ;
AtEOXact_GUC ( true , true ) ;
AtEOXact_GUC ( true , s - > gucNestLevel ) ;
AtEOSubXact_SPI ( true , s - > subTransactionId ) ;
AtEOSubXact_SPI ( true , s - > subTransactionId ) ;
AtEOSubXact_on_commit_actions ( true , s - > subTransactionId ,
AtEOSubXact_on_commit_actions ( true , s - > subTransactionId ,
s - > parent - > subTransactionId ) ;
s - > parent - > subTransactionId ) ;
@ -3718,7 +3725,7 @@ AbortSubTransaction(void)
* Reset user ID which might have been changed transiently . ( See notes
* Reset user ID which might have been changed transiently . ( See notes
* in AbortTransaction . )
* in AbortTransaction . )
*/
*/
SetUserIdAndContext ( s - > prevUser , s - > prevSecDefC xt ) ;
SetUserIdAndSec Context ( s - > prevUser , s - > prevSecConte xt ) ;
/*
/*
* We can skip all this stuff if the subxact failed before creating a
* We can skip all this stuff if the subxact failed before creating a
@ -3761,7 +3768,7 @@ AbortSubTransaction(void)
RESOURCE_RELEASE_AFTER_LOCKS ,
RESOURCE_RELEASE_AFTER_LOCKS ,
false , false ) ;
false , false ) ;
AtEOXact_GUC ( false , true ) ;
AtEOXact_GUC ( false , s - > gucNestLevel ) ;
AtEOSubXact_SPI ( false , s - > subTransactionId ) ;
AtEOSubXact_SPI ( false , s - > subTransactionId ) ;
AtEOSubXact_on_commit_actions ( false , s - > subTransactionId ,
AtEOSubXact_on_commit_actions ( false , s - > subTransactionId ,
s - > parent - > subTransactionId ) ;
s - > parent - > subTransactionId ) ;
@ -3855,10 +3862,11 @@ PushTransaction(void)
s - > subTransactionId = currentSubTransactionId ;
s - > subTransactionId = currentSubTransactionId ;
s - > parent = p ;
s - > parent = p ;
s - > nestingLevel = p - > nestingLevel + 1 ;
s - > nestingLevel = p - > nestingLevel + 1 ;
s - > gucNestLevel = NewGUCNestLevel ( ) ;
s - > savepointLevel = p - > savepointLevel ;
s - > savepointLevel = p - > savepointLevel ;
s - > state = TRANS_DEFAULT ;
s - > state = TRANS_DEFAULT ;
s - > blockState = TBLOCK_SUBBEGIN ;
s - > blockState = TBLOCK_SUBBEGIN ;
GetUserIdAndContext ( & s - > prevUser , & s - > prevSecDefC xt ) ;
GetUserIdAndSec Context ( & s - > prevUser , & s - > prevSecConte xt ) ;
s - > prevXactReadOnly = XactReadOnly ;
s - > prevXactReadOnly = XactReadOnly ;
CurrentTransactionState = s ;
CurrentTransactionState = s ;