Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
7.1 KiB

  1. /* node status returned from VERAccess*
  2. /**/
  3. typedef enum
  4. {
  5. nsVersion,
  6. nsVerInDB,
  7. nsDatabase,
  8. nsInvalid
  9. } NS;
  10. /* version status returned from VERCheck
  11. /**/
  12. typedef enum
  13. {
  14. vsCommitted,
  15. vsUncommittedByCaller,
  16. vsUncommittedByOther
  17. } VS;
  18. // ===========================================================================
  19. // RCE (Revision Control Entry)
  20. /* operation type
  21. /**/
  22. typedef UINT OPER;
  23. #define operReplace 0
  24. #define operInsert 1
  25. #define operFlagDelete 2
  26. #define operNull 3 // to void an RCE
  27. #define operExpungeLink 4
  28. #define operExpungeBackLink 5
  29. #define operWriteLock 6
  30. #define operAllocExt 7
  31. #define operDeferFreeExt 8
  32. #define operDelete 9 // a real delete
  33. #define operReplaceWithDeferredBI 10 // recovery only, replace deferred before image.
  34. #define operDelta 0x0010
  35. #define operMaskItem 0x0020
  36. #define operInsertItem 0x0020
  37. #define operFlagInsertItem 0x0060
  38. #define operFlagDeleteItem 0x00a0
  39. #define operMaskDDL 0x0100
  40. #define operCreateTable 0x0100
  41. #define operDeleteTable 0x0300
  42. #define operRenameTable 0x0500
  43. #define operAddColumn 0x0700
  44. #define operDeleteColumn 0x0900
  45. #define operRenameColumn 0x0b00
  46. #define operCreateIndex 0x0d00
  47. #define operDeleteIndex 0x0f00
  48. #define operRenameIndex 0x1100
  49. /* create table: table pgnoFDP
  50. /* rename table: before image table name
  51. /* add column: before image pfdb, NULL if not first DDL at level
  52. /* delete column: before image pfdb, NULL if not first DDL at level
  53. /* rename column: before image column name
  54. /* create index: index pgnoFDP
  55. /* delete index: index pfcb
  56. /* rename index: before image index name
  57. /**/
  58. #define FOperDDL( oper ) ( (oper) & operMaskDDL )
  59. #define FOperItem( oper ) ( (oper) & operMaskItem )
  60. typedef struct _rce
  61. {
  62. struct _rce *prceHashOverflow; // hash over flow RCE chain
  63. struct _rce *prcePrevOfNode; // previous versions for same node, lower trx
  64. struct _rce *prcePrevOfSession; // previous RCE of same session
  65. struct _rce *prceNextOfSession; // next RCE of same session
  66. USHORT ibPrev; // index to prev RCE in bucket
  67. // UNDONE: DBID->BYTE and put with level
  68. LEVEL level; // current level of RCE, can change
  69. BYTE bReserved; // make it aligned.
  70. SRID bm; // bookmark of node
  71. TRX trxPrev; // time when previous RCE is committed
  72. TRX trxCommitted; // time when this RCE is committed
  73. FUCB *pfucb; // for undo
  74. // UNDONE: OPER should be UINT16 and put with cbData
  75. OPER oper; // operation that causes creation of RCE
  76. DBID dbid; // database id of node
  77. WORD cbData; // length of data portion of node
  78. // UNDONE: remove pfcb after unified bucket chain allows
  79. // presynchronized version clean up.
  80. FCB *pfcb; // for clean up
  81. // UNDONE: remove bmTarget and ulDBTime after VR bookmark implementation.
  82. // These fields should not be necessary, since version store
  83. // will be aware of node movements.
  84. SRID bmTarget; // for recovery of undo
  85. QWORD qwDBTime; // for recovery of undo
  86. struct _bf *pbfDeferredBI; // which page deferred before image is on.
  87. struct _rce *prceDeferredBINext; // link list for deferred before image.
  88. #ifdef DEBUG
  89. QWORD qwDBTimeDeferredBIRemoved;
  90. #endif
  91. BYTE rgbData[0]; // storing the data portion of a node
  92. } RCE;
  93. /* first 2 SHORTs of rgbData are used to remember cbMax and cbAdjust for
  94. * each replace operation.
  95. */
  96. #define cbReplaceRCEOverhead (2 * sizeof(SHORT))
  97. //============================================================================
  98. // bucket
  99. #define cbBucketHeader \
  100. ( 2 * sizeof(struct _bucket *) + sizeof(UINT) )
  101. #define cbBucket 16384 // number of bytes in a bucket
  102. typedef struct _bucket
  103. {
  104. struct _bucket *pbucketPrev; // prev bucket for same user
  105. struct _bucket *pbucketNext; // next bucket for same user
  106. UINT ibNewestRCE; // newest RCE within bucket
  107. BYTE rgb[ cbBucket - cbBucketHeader ];
  108. // space for storing RCEs
  109. } BUCKET;
  110. /* free extent parameter block
  111. /**/
  112. typedef struct {
  113. PGNO pgnoFDP;
  114. PGNO pgnoChildFDP;
  115. PGNO pgnoFirst;
  116. CPG cpgSize;
  117. } VEREXT;
  118. /* rename rollback parameter block
  119. /**/
  120. typedef struct {
  121. CHAR szName[ JET_cbNameMost + 1 ];
  122. CHAR szNameNew[ JET_cbNameMost + 1 ];
  123. } VERRENAME;
  124. /* delete column rollback parameter block
  125. /**/
  126. typedef struct tagVERCOLUMN
  127. {
  128. JET_COLTYP coltyp; // column type
  129. FID fid; // field id
  130. } VERCOLUMN;
  131. /* ErrRCEClean flags
  132. /**/
  133. #define fRCECleanSession (1<<0)
  134. ERR ErrVERInit( VOID );
  135. VOID VERTerm( BOOL fNormal );
  136. VS VsVERCheck( FUCB *pfucb, SRID bm );
  137. NS NsVERAccessNode( FUCB *pfucb, SRID bm );
  138. NS NsVERAccessItem( FUCB *pfucb, SRID bm );
  139. ERR FVERUncommittedVersion( FUCB *pfucb, SRID bm );
  140. ERR FVERDelta( FUCB *pfucb, SRID bm );
  141. ERR ErrVERCreate( FUCB *pfucb, SRID bm, OPER oper, RCE **pprce );
  142. ERR ErrVERModify( FUCB *pfucb, SRID bm, OPER oper, RCE **pprce);
  143. BOOL FVERNoVersion( DBID dbid, SRID bm );
  144. ERR ErrRCEClean( PIB *ppib, INT fCleanSession );
  145. ERR ErrVERBeginTransaction( PIB *ppib );
  146. VOID VERPrecommitTransaction( PIB *ppib );
  147. VOID VERCommitTransaction( PIB *ppib, BOOL fCleanSession );
  148. ERR ErrVERRollback(PIB *ppib);
  149. RCE *PrceRCEGet( DBID dbid, SRID bm );
  150. #define fDoNotUpdatePage fFalse
  151. #define fDoUpdatePage fTrue
  152. VOID VERSetCbAdjust(FUCB *pfucb, RCE *prce, INT cbDataNew, INT cbData, BOOL fNotUpdatePage );
  153. INT CbVERGetNodeMax( DBID dbid, SRID bm );
  154. INT CbVERGetNodeReserve( PIB *ppib, DBID dbid, SRID bm, INT cbCurrentData );
  155. INT CbVERUncommittedFreed( BF *pbf );
  156. BOOL FVERCheckUncommittedFreedSpace( BF *pbf, INT cbReq );
  157. BOOL FVERItemVersion( DBID dbid, SRID bm, ITEM item );
  158. BOOL FVERMostRecent( FUCB *pfucb, SRID bm );
  159. VOID VERDeleteFromDeferredBIChain( RCE *prce );
  160. #define ErrVERReplace( pfucb, srid, pprce ) ErrVERModify( pfucb, srid, operReplace, pprce )
  161. #define ErrVERInsert( pfucb, srid ) ErrVERCreate( pfucb, srid, operInsert, pNil )
  162. #define ErrVERFlagDelete( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagDelete, pNil )
  163. #define ErrVERInsertItem( pfucb, srid ) ErrVERCreate( pfucb, srid, operInsertItem, pNil )
  164. #define ErrVERFlagInsertItem( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagInsertItem, pNil )
  165. #define ErrVERFlagDeleteItem( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagDeleteItem, pNil )
  166. #define ErrVERDelta( pfucb, srid ) ErrVERModify( pfucb, srid, operDelta, pNil )
  167. #define ErrRCECleanAllPIB( ) ErrRCEClean( ppibNil, 0 )
  168. #define FVERPotThere( vs, fDelete ) \
  169. ( ( (vs) != vsUncommittedByOther && !(fDelete) ) || \
  170. (vs) == vsUncommittedByOther )
  171. ERR ErrVERFlag( FUCB *pfucb, OPER oper, VOID *pv, INT cb );
  172. VOID VERDeleteRce( RCE *prce );
  173. #define FVERUndoLoggedOper( prce ) \
  174. ( prce->oper == operReplace || \
  175. prce->oper == operInsert || \
  176. prce->oper == operFlagDelete || \
  177. prce->oper == operInsertItem || \
  178. prce->oper == operFlagInsertItem || \
  179. prce->oper == operFlagDeleteItem || \
  180. prce->oper == operDelta )
  181. ERR ErrVERUndo( RCE *prce );