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.

183 lines
6.0 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
  11. /* returned from VERCheck
  12. /**/
  13. typedef enum
  14. {
  15. vsCommitted,
  16. vsUncommittedByCaller,
  17. vsUncommittedByOther
  18. } VS;
  19. // ===========================================================================
  20. // RCE (RC Entry)
  21. /* operation type
  22. /**/
  23. typedef UINT OPER;
  24. #define operReplace 0
  25. #define operInsert 1
  26. #define operFlagDelete 2
  27. #define operNull 3 // to nullify an RCE
  28. #define operExpungeLink 4
  29. #define operExpungeBackLink 5
  30. #define operWriteLock 6
  31. #define operAllocExt 7
  32. #define operDeferFreeExt 8
  33. #define operDelete 9 // a real delete
  34. #define operDelta 0x00000010
  35. #define operMaskItem 0x00000100
  36. #define operInsertItem 0x00000100
  37. #define operFlagInsertItem 0x00000300
  38. #define operFlagDeleteItem 0x00000500
  39. #define operMaskDDL 0x00001000
  40. #define operCreateTable 0x00001000
  41. #define operDeleteTable 0x00003000
  42. #define operRenameTable 0x00005000
  43. #define operAddColumn 0x00007000
  44. #define operDeleteColumn 0x00009000
  45. #define operRenameColumn 0x0000b000
  46. #define operCreateIndex 0x0000d000
  47. #define operDeleteIndex 0x0000f000
  48. #define operRenameIndex 0x00011000
  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 *prceHeadNext; // next rce ListHead in hash over flow list
  63. struct _rce *prcePrev; // previous versions, lower trx
  64. USHORT ibUserLinkBackward; // link back to older RCE in bucket
  65. DBID dbid; // database id of node
  66. SRID bm; // bookmark of node
  67. TRX trxPrev; // time when previous RCE is committed
  68. TRX trxCommitted; // time when this RCE is committed
  69. OPER oper; // operation that causes creation of RCE
  70. LEVEL level; // current level of RCE, can change
  71. WORD cbData; // length of data portion of node
  72. FUCB *pfucb; // for undo
  73. FCB *pfcb; // for clean up
  74. SRID bmTarget; // for recovery
  75. ULONG ulDBTime;
  76. BYTE rgbData[0]; // storing the data portion of a node
  77. } RCE;
  78. /* first 2 SHORTs of rgbData are used to remember cbMax and cbAdjust for
  79. * each replace operation.
  80. */
  81. #define cbReplaceRCEOverhead (2 * sizeof(SHORT))
  82. //============================================================================
  83. // bucket
  84. #define cbBucketHeader \
  85. ( 2 * sizeof(struct _bucket *) + sizeof( USHORT ) )
  86. #define cbBucket 16384 // number of bytes in a bucket
  87. //#define cbBucket 8192 // number of bytes in a bucket
  88. typedef struct _bucket
  89. {
  90. struct _bucket *pbucketPrev; // prev bucket for same user
  91. struct _bucket *pbucketNext; // next bucket for same user
  92. USHORT ibNewestRCE; // newest RCE within bucket
  93. BYTE rgb[ cbBucket - cbBucketHeader ];
  94. // space for storing RCEs
  95. } BUCKET;
  96. #define PbucketMEMAlloc() ((BUCKET *)PbMEMAlloc(iresVersionBucket) )
  97. #ifdef DEBUG /* Debug check for illegal use of freed pbucket */
  98. #define MEMReleasePbucket(pbucket) { MEMRelease( iresVersionBucket, (BYTE*)(pbucket) ); pbucket = pbucketNil; }
  99. #else
  100. #define MEMReleasePbucket(pbucket) { MEMRelease( iresVersionBucket, (BYTE*)(pbucket) ); }
  101. #endif
  102. /* free extent parameter block
  103. /**/
  104. typedef struct {
  105. PGNO pgnoFDP;
  106. PGNO pgnoChildFDP;
  107. PGNO pgnoFirst;
  108. CPG cpgSize;
  109. } VEREXT;
  110. /* rename rollback parameter block
  111. /**/
  112. typedef struct {
  113. CHAR szName[ JET_cbNameMost + 1 ];
  114. CHAR szNameNew[ JET_cbNameMost + 1 ];
  115. } VERRENAME;
  116. /* ErrRCECleanPIB flags
  117. /**/
  118. #define fRCECleanAll (1<<0)
  119. ERR ErrVERInit( VOID );
  120. VOID VERTerm( VOID );
  121. VS VsVERCheck( FUCB *pfucb, SRID bm );
  122. NS NsVERAccessNode( FUCB *pfucb, SRID bm );
  123. NS NsVERAccessItem( FUCB *pfucb, SRID bm );
  124. ERR FVERUncommittedVersion( FUCB *pfucb, SRID bm );
  125. ERR FVERDelta( FUCB *pfucb, SRID bm );
  126. ERR ErrVERCreate( FUCB *pfucb, SRID bm, OPER oper, RCE **pprce );
  127. ERR ErrVERModify( FUCB *pfucb, SRID bm, OPER oper, RCE **pprce);
  128. BOOL FVERNoVersion( DBID dbid, SRID bm );
  129. ERR ErrRCECleanPIB( PIB *ppibAccess, PIB *ppib, INT fRCEClean );
  130. ERR ErrRCECleanAllPIB( VOID );
  131. ERR ErrVERBeginTransaction( PIB *ppib );
  132. VOID VERPrecommitTransaction( PIB *ppib );
  133. VOID VERCommitTransaction( PIB *ppib );
  134. ERR ErrVERRollback(PIB *ppib);
  135. RCE *PrceRCEGet( DBID dbid, SRID bm );
  136. #define fDoNotUpdatePage fTrue
  137. #define fDoUpdatePage fFalse
  138. VOID VERSetCbAdjust(FUCB *pfucb, RCE *prce, INT cbDataNew, INT cbData, BOOL fNotUpdatePage );
  139. INT CbVERGetCbReserved( RCE *prce );
  140. INT CbVERGetNodeMax( FUCB *pfucb, SRID bm );
  141. INT CbVERGetNodeReserve( FUCB *pfucb, SRID bm );
  142. #define ErrVERReplace( pfucb, srid, pprce ) ErrVERModify( pfucb, srid, operReplace, pprce )
  143. #define ErrVERInsert( pfucb, srid ) ErrVERCreate( pfucb, srid, operInsert, pNil )
  144. #define ErrVERFlagDelete( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagDelete, pNil )
  145. #define ErrVERInsertItem( pfucb, srid ) ErrVERCreate( pfucb, srid, operInsertItem, pNil )
  146. #define ErrVERFlagInsertItem( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagInsertItem, pNil )
  147. #define ErrVERFlagDeleteItem( pfucb, srid ) ErrVERModify( pfucb, srid, operFlagDeleteItem, pNil )
  148. #define ErrVERDelta( pfucb, srid ) ErrVERModify( pfucb, srid, operDelta, pNil )
  149. #define ErrVERDeferFreeFDP( pfucb, pgno ) ErrVERFlag( pfucb, operDeferFreeFDP, &pgno, siozeof(pgno) )
  150. #define FVERPotThere( vs, fDelete ) \
  151. ( ( (vs) != vsUncommittedByOther && !(fDelete) ) || \
  152. (vs) == vsUncommittedByOther )
  153. ERR ErrVERFlag( FUCB *pfucb, OPER oper, VOID *pv, INT cb );
  154. VOID VERDeleteRce( RCE *prce );