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.

1867 lines
102 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. schema.c
  5. Abstract:
  6. Defines the initial values for the table layout structs in Jet
  7. for the NT File Replication Service.
  8. Note: The record layout and enums for record entries are defined in schema.h
  9. Any change here must be reflected there.
  10. See the comment header in schema.h for the procedure to add a new table
  11. definition.
  12. This header defines structures and macros for managing and initializing
  13. columns, indexes and tables in a JET Database.
  14. For each jet table there is a column descriptor struct, and index descriptor
  15. struct, a JET_SETCOLUMN array and an entry in a table descriptor struct.
  16. In addition there are ennums defined for the entries in the column descriptor,
  17. index descriptor and Table arrays. The example below illustrates the
  18. construction of the descriptors for the "IDTable". Note the use of the
  19. "IDTable" and "IDTABLE" prefixes. Also note the use of the "x" suffix on
  20. column field names in the enum declarations.
  21. //
  22. // The enum for the IDTable column entries.
  23. //
  24. typedef enum IDTABLE_COL_LIST {
  25. FileGuidx = 0, // The guid assigned to the file.
  26. IDTABLE_MAX_COL
  27. };
  28. //
  29. // The IDTable column descriptor definition.
  30. //
  31. JET_COLUMNCREATE IDTableColDesc[]=
  32. {
  33. {"FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0}
  34. };
  35. //
  36. // The IDTable JET_SETCOLUMN array for reading/writing IDTable rows.
  37. //
  38. JET_SETCOLUMN IDTableJetSetCol[IDTABLE_MAX_COL];
  39. //
  40. // The enum for the IDTable index entries.
  41. //
  42. typedef enum IDTABLE_INDEX_LIST {
  43. GuidIndexx = 0, // The index on the file GUID.
  44. IDTABLE_MAX_INDEX
  45. };
  46. //
  47. // The IDTable index descriptor definition.
  48. //
  49. JET_INDEXCREATE IDTableIndexDesc[] = {
  50. {"GuidIndex", "+FileGuid\0", 11, JET_bitIndexUnique, 60}
  51. };
  52. //
  53. // The enum for the each defined table with an entry for the IDTable.
  54. //
  55. typedef enum TABLE_LIST {
  56. IDTablex = 0, // The ID table description.
  57. TABLE_LIST_MAX
  58. };
  59. //
  60. // The Table descriptor array with an entry for the IDTable.
  61. //
  62. TABLE_DESC DBTables[] = {
  63. {"IDTable", INIT_IDTABLE_PAGES, INIT_IDTABLE_DENSITY,
  64. IDTABLE_MAX_COL, IDTableColDesc, IDTABLE_MAX_INDEX, IDTableIndexDesc}
  65. };
  66. The JET_COLUMNCREATE struct describes each column in a table. It has the name
  67. the data type, the max size, the GRbits, the default value, the returned
  68. column ID and an error status.
  69. The JET_INDEXCREATE struct describes each index in a table. It has the name of
  70. the index, the key description of the index, the GRbits, the requested
  71. density of the index pages amd an error status.
  72. The JET_TABLECREATE struct describes each type of table in the database. It has
  73. the name of the table, the initial size of the table in pages, the initial
  74. density parameter for the data pages (to allow for inserts without having to
  75. split the page right away), the column count, a ptr to the COLUMN_DESC struct,
  76. the index count, a pointer to the INDEX_DESC struct. It also has a grbits param
  77. and jet returns the table ID and a count of the number of columns and indexes
  78. created. Jet97 provides for creating a template table which you can then use to
  79. create duplicate tables. A parameter in the JET_TABLECREATE struct contains the
  80. name of the template table to use for the create. This ensures that the column
  81. IDs in all instances of the tables are the same so we need to keep only one copy
  82. of a JET_SETCOLUMN struct (with the column IDs) to read and write records in any
  83. instance of the table.
  84. Another grbit is JET_bitFixedDDL. When a table is created with this flag
  85. no columns or indexes can be deleted or created in the table. This allows
  86. jet to avoid taking some critical sections when doing set/retrieve on the
  87. column data thus improving performance/scalability.
  88. Author:
  89. David Orbits (davidor) - 14-Mar-1997
  90. Revision History:
  91. --*/
  92. #define UNICODE 1
  93. #define _UNICODE 1
  94. #include <ntreppch.h>
  95. #pragma hdrstop
  96. #define MB2 (2*1024*1024)
  97. #define CBJCC sizeof(JET_COLUMNCREATE)
  98. #define CBJIC sizeof(JET_INDEXCREATE)
  99. typedef struct ___tag_JET_COLUMNCREATE // from jet header for ref only.
  100. {
  101. unsigned long cbStruct; // size of this structure
  102. char *szColumnName; // column name
  103. JET_COLTYP coltyp; // column type
  104. unsigned long cbMax; // the maximum length of this column (only relevant for binary and text columns)
  105. JET_GRBIT grbit; // column options
  106. void *pvDefault; // default value (NULL if none)
  107. unsigned long cbDefault; // length of default value
  108. unsigned long cp; // code page (for text columns only)
  109. JET_COLUMNID columnid; // returned column id
  110. JET_ERR err; // returned error code
  111. } ___JET_COLUMNCREATE;
  112. /******************************************************************************
  113. *******************************************************************************
  114. ** **
  115. ** P a r t n e r C o n n e c t i o n T a b l e **
  116. ** **
  117. *******************************************************************************
  118. ******************************************************************************/
  119. //
  120. // The Connection Table column descriptions are as follows.
  121. // Note - the order of the enum in schema.h and the table entries must be kept in sync.
  122. //
  123. // Note: Buffers are allocated at runtime to hold data for fields with
  124. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  125. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  126. // ColMaxWidth equals the field size in the record struct the data is in the
  127. // record struct and no buffer is allocated.
  128. //
  129. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  130. //
  131. // **** Make sure any escrowed columns have an initial value.
  132. JET_COLUMNCREATE CXTIONTableColDesc[]=
  133. {
  134. {CBJCC, "CxtionGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  135. {CBJCC, "CxtionName", JET_coltypLongText, 2*(MAX_RDN_VALUE_SIZE+1),
  136. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  137. {CBJCC, "PartnerGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  138. {CBJCC, "PartnerName", JET_coltypLongText, 2*(MAX_RDN_VALUE_SIZE+1),
  139. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  140. {CBJCC, "PartSrvName", JET_coltypLongText, 2*(MAX_RDN_VALUE_SIZE+1),
  141. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  142. {CBJCC, "PartnerDnsName", JET_coltypLongText, 2*(DNS_MAX_NAME_LENGTH+1),
  143. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  144. {CBJCC, "Inbound", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  145. {CBJCC, "Schedule", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  146. {CBJCC, "TerminationCoSeqNum", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  147. {CBJCC, "LastJoinTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  148. {CBJCC, "Flags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  149. {CBJCC, "COLx", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  150. {CBJCC, "COTx", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  151. {CBJCC, "COTxNormalModeSave", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  152. {CBJCC, "COTslot", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  153. {CBJCC, "OutstandingQuota",JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  154. {CBJCC, "AckVector", JET_coltypBinary , ACK_VECTOR_BYTES,
  155. JET_bitColumnFixed, NULL, 0},
  156. {CBJCC, "PartnerNetBiosName", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  157. {CBJCC, "PartnerPrincName", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  158. {CBJCC, "PartnerCoDn", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  159. {CBJCC, "PartnerCoGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  160. // Note: PartnerDn is a misnomer; it should be PartnerSid.
  161. // BUT don't change the field name, PartnerDn! May cause DB problems.
  162. {CBJCC, "PartnerDn", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  163. {CBJCC, "Options", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  164. {CBJCC, "OverSite", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  165. {CBJCC, "PartnerAuthLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  166. // Note: Spare1Ull field is now used for AckVector Version.
  167. // Can't change field name without compatibility probs with existing DBs.
  168. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  169. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  170. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  171. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  172. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  173. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0}
  174. };
  175. //
  176. // The following is used to build the Jet Set Column struct for record read/write.
  177. // The first 2 params build the field offset and size. The 3rd param is the
  178. // data type.
  179. //
  180. //
  181. // *** WARNING ***
  182. //
  183. // If the record structure field size is less than the max column width AND
  184. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  185. // record is assumed to be variable length. The record insert code
  186. // automatically adjusts the length from the record's Size prefix. All
  187. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  188. // fields that are variable length which don't have a size prefix like
  189. // FSVolInfo in the config record. But these fields MUST have a unique / non
  190. // binary data type assigned to them. Failure to do this causes the insert
  191. // routines to stuff things up to ColMaxWidth bytes into the database.
  192. //
  193. RECORD_FIELDS CXTIONTableRecordFields[] = {
  194. {sizeof(CXTION_RECORD) , 0, CXTION_TABLE_MAX_COL },
  195. {RECORD_FIELD(CXTION_RECORD, CxtionGuid, DT_GUID )},
  196. {RECORD_FIELD(CXTION_RECORD, CxtionName, DT_UNICODE )},
  197. {RECORD_FIELD(CXTION_RECORD, PartnerGuid, DT_GUID )},
  198. {RECORD_FIELD(CXTION_RECORD, PartnerName, DT_UNICODE )},
  199. {RECORD_FIELD(CXTION_RECORD, PartSrvName, DT_UNICODE )},
  200. {RECORD_FIELD(CXTION_RECORD, PartnerDnsName, DT_UNICODE )},
  201. {RECORD_FIELD(CXTION_RECORD, Inbound, DT_ULONG )},
  202. {RECORD_FIELD(CXTION_RECORD, Schedule, DT_BINARY )},
  203. {RECORD_FIELD(CXTION_RECORD, TerminationCoSeqNum, DT_ULONG )},
  204. {RECORD_FIELD(CXTION_RECORD, LastJoinTime, DT_FILETIME )},
  205. {RECORD_FIELD(CXTION_RECORD, Flags, DT_CXTION_FLAGS)},
  206. {RECORD_FIELD(CXTION_RECORD, COLx, DT_ULONG )},
  207. {RECORD_FIELD(CXTION_RECORD, COTx, DT_ULONG )},
  208. {RECORD_FIELD(CXTION_RECORD, COTxNormalModeSave, DT_ULONG )},
  209. {RECORD_FIELD(CXTION_RECORD, COTslot, DT_ULONG )},
  210. {RECORD_FIELD(CXTION_RECORD, OutstandingQuota, DT_ULONG )},
  211. {RECORD_FIELD(CXTION_RECORD, AckVector, DT_BINARY )},
  212. {RECORD_FIELD(CXTION_RECORD, PartnerNetBiosName, DT_UNICODE )},
  213. {RECORD_FIELD(CXTION_RECORD, PartnerPrincName, DT_UNICODE )},
  214. {RECORD_FIELD(CXTION_RECORD, PartnerCoDn, DT_UNICODE )},
  215. {RECORD_FIELD(CXTION_RECORD, PartnerCoGuid, DT_GUID )},
  216. {RECORD_FIELD(CXTION_RECORD, PartnerSid, DT_UNICODE )},
  217. {RECORD_FIELD(CXTION_RECORD, Options, DT_ULONG )},
  218. {RECORD_FIELD(CXTION_RECORD, OverSite, DT_UNICODE )},
  219. {RECORD_FIELD(CXTION_RECORD, PartnerAuthLevel, DT_ULONG )},
  220. {RECORD_FIELD(CXTION_RECORD, AckVersion, DT_FILETIME )},
  221. {RECORD_FIELD(CXTION_RECORD, Spare2Ull, DT_LONGLONG_SPARE )},
  222. {RECORD_FIELD(CXTION_RECORD, Spare1Guid, DT_GUID_SPARE )},
  223. {RECORD_FIELD(CXTION_RECORD, Spare2Guid, DT_GUID_SPARE )},
  224. {RECORD_FIELD(CXTION_RECORD, Spare1Bin, DT_BINARY_SPARE )},
  225. {RECORD_FIELD(CXTION_RECORD, Spare2Bin, DT_BINARY_SPARE )}
  226. };
  227. JET_SETCOLUMN CXTIONTableJetSetCol[CXTION_TABLE_MAX_COL];
  228. JET_RETRIEVECOLUMN CXTIONTableJetRetCol[CXTION_TABLE_MAX_COL];
  229. //
  230. // The Connection Table index descriptions are as follows.
  231. // Note - the order of the enum and the table entries must be kept in sync.
  232. //
  233. //
  234. // See the comment under the config table index description for the meaning
  235. // and usage of the first character in the index name field.
  236. //
  237. // Name Key KeyLen JIndexGrBits Density
  238. //
  239. JET_INDEXCREATE CXTIONTableIndexDesc[] = {
  240. {CBJIC, "GCxtionGuid", "+CxtionGuid\0", 13, JET_bitIndexUnique, 80}
  241. };
  242. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  243. // The key designated as the primary index can't be changed. A Jet rule.
  244. // So on a directory restore all the directory file IDs can change and
  245. // the records have to be deleted and the table reconstructed.
  246. //
  247. /******************************************************************************
  248. *******************************************************************************
  249. ** **
  250. ** I n b o u n d L o g **
  251. ** C h a n g e O r d e r T a b l e **
  252. ** **
  253. ** **
  254. *******************************************************************************
  255. ******************************************************************************/
  256. //
  257. // The Inbound Log change order Table column descriptions are as follows.
  258. // Note - the order of the enum in schema.h and the table entries must be
  259. // kept in sync.
  260. //
  261. // Note: Buffers are allocated at runtime to hold data for fields with
  262. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  263. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  264. // ColMaxWidth equals the field size in the record struct the data is in the
  265. // record struct and no buffer is allocated.
  266. //
  267. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  268. //
  269. // **** Make sure any escrowed columns have an initial value.
  270. // ** Note ** The Sequence number field, an auto inc column, must be the first
  271. // column of the record because DbsInsertTable2 retrieves it for us after the
  272. // insert.
  273. JET_COLUMNCREATE ILChangeOrderTableColDesc[]=
  274. {
  275. {CBJCC, "SequenceNumber", JET_coltypLong, 4, JET_bitColumnAutoincrement |
  276. JET_bitColumnFixed, NULL, 0},
  277. {CBJCC, "Flags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  278. {CBJCC, "IFlags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  279. {CBJCC, "State", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  280. {CBJCC, "ContentCmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  281. {CBJCC, "Lcmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  282. {CBJCC, "FileAttributes", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  283. {CBJCC, "FileVersionNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  284. {CBJCC, "PartnerAckSeqNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  285. {CBJCC, "FileSize", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  286. {CBJCC, "FileOffset", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  287. {CBJCC, "FrsVsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  288. {CBJCC, "FileUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  289. {CBJCC, "JrnlUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  290. {CBJCC, "JrnlFirstUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  291. // Note: The following two fields now refer to OriginalReplicaNum and NewReplicaNum.
  292. // Can't change field name without compatibility probs with existing DBs.
  293. {CBJCC, "OriginalReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  294. {CBJCC, "NewReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  295. {CBJCC, "ChangeOrderGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  296. {CBJCC, "OriginatorGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  297. {CBJCC, "FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  298. {CBJCC, "OldParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  299. {CBJCC, "NewParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  300. {CBJCC, "CxtionGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  301. // Note: Spare1Ull field is now used for AckVector Version.
  302. // Can't change field name without compatibility probs with existing DBs.
  303. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  304. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  305. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  306. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  307. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  308. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  309. // Note: Spare1Bin field is now used for Change Order Command Extension.
  310. // Can't change field name without compatibility probs with existing DBs.
  311. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  312. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  313. {CBJCC, "EventTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  314. {CBJCC, "FileNameLength", JET_coltypShort, 2, JET_bitColumnFixed, NULL, 0},
  315. {CBJCC, "FileName", JET_coltypLongText, 2*(MAX_PATH+1),
  316. 0 , NULL, 0, CP_UNICODE_FOR_JET}
  317. };
  318. //
  319. // The following is used to build the Jet Set Column struct for record read/write.
  320. // The first 2 params build the field offset and size. The 3rd param is the
  321. // data type.
  322. //
  323. //
  324. // *** WARNING ***
  325. //
  326. // If the record structure field size is less than the max column width AND
  327. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  328. // record is assumed to be variable length. The record insert code
  329. // automatically adjusts the length from the record's Size prefix. All
  330. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  331. // fields that are variable length which don't have a size prefix like
  332. // FSVolInfo in the config record. But these fields MUST have a unique / non
  333. // binary data type assigned to them. Failure to do this causes the insert
  334. // routines to stuff things up to ColMaxWidth bytes into the database.
  335. //
  336. RECORD_FIELDS ILChangeOrderRecordFields[] = {
  337. {sizeof(CHANGE_ORDER_RECORD) , 0, CHANGE_ORDER_MAX_COL },
  338. {RECORD_FIELD(CHANGE_ORDER_RECORD, SequenceNumber, DT_ULONG )},
  339. {RECORD_FIELD(CHANGE_ORDER_RECORD, Flags, DT_COCMD_FLAGS )},
  340. {RECORD_FIELD(CHANGE_ORDER_RECORD, IFlags, DT_COCMD_IFLAGS )},
  341. {RECORD_FIELD(CHANGE_ORDER_RECORD, State, DT_COSTATE )},
  342. {RECORD_FIELD(CHANGE_ORDER_RECORD, ContentCmd, DT_USN_FLAGS )},
  343. {RECORD_FIELD(CHANGE_ORDER_RECORD, Lcmd, DT_CO_LOCN_CMD )},
  344. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileAttributes, DT_FILEATTR )},
  345. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileVersionNumber, DT_ULONG )},
  346. {RECORD_FIELD(CHANGE_ORDER_RECORD, PartnerAckSeqNumber, DT_ULONG )},
  347. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileSize, DT_X8 )},
  348. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileOffset, DT_X8 )},
  349. {RECORD_FIELD(CHANGE_ORDER_RECORD, FrsVsn, DT_X8 )},
  350. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileUsn, DT_X8 )},
  351. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlUsn, DT_X8 )},
  352. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlFirstUsn, DT_X8 )},
  353. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginalReplicaNum, DT_REPLICA_ID )},
  354. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewReplicaNum, DT_REPLICA_ID )},
  355. {RECORD_FIELD(CHANGE_ORDER_RECORD, ChangeOrderGuid, DT_GUID )},
  356. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginatorGuid, DT_GUID )},
  357. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileGuid, DT_GUID )},
  358. {RECORD_FIELD(CHANGE_ORDER_RECORD, OldParentGuid, DT_GUID )},
  359. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewParentGuid, DT_GUID )},
  360. {RECORD_FIELD(CHANGE_ORDER_RECORD, CxtionGuid, DT_CXTION_GUID )},
  361. {RECORD_FIELD(CHANGE_ORDER_RECORD, AckVersion, DT_FILETIME )},
  362. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  363. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Guid, DT_GUID_SPARE )},
  364. // Warning: See comment in schema.h before using Spare2Guid, Spare1Wcs or Spare2Wcs.
  365. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Guid, DT_GUID_SPARE )},
  366. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  367. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  368. {RECORD_FIELD(CHANGE_ORDER_RECORD, Extension, DT_COCMD_EXTENSION /*| DT_NO_DEFAULT_ALLOC_FLAG */)},
  369. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  370. {RECORD_FIELD(CHANGE_ORDER_RECORD, EventTime, DT_FILETIME )},
  371. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileNameLength, DT_SHORT )},
  372. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileName, DT_UNICODE )}
  373. };
  374. JET_SETCOLUMN ILChangeOrderJetSetCol[CHANGE_ORDER_MAX_COL];
  375. JET_RETRIEVECOLUMN ILChangeOrderJetRetCol[CHANGE_ORDER_MAX_COL];
  376. //
  377. // The Table index descriptions are as follows. Note - the order of the
  378. // enum and the table entries must be kept in sync.
  379. //
  380. typedef struct ___tagJET_INDEXCREATE // from jet header for ref only.
  381. {
  382. unsigned long cbStruct; // size of this structure
  383. char *szIndexName; // index name
  384. char *szKey; // index key
  385. unsigned long cbKey; // length of key
  386. JET_GRBIT grbit; // index options
  387. unsigned long ulDensity; // index density
  388. JET_ERR err; // returned error code
  389. } ___JET_INDEXCREATE;
  390. //
  391. // See the comment under the config table index description for the meaning
  392. // and usage of the first character in the index name field.
  393. //
  394. // Name Key KeyLen JIndexGrBits Density
  395. //
  396. // ** Note the file guid index is not unique because the Inbound log could
  397. // have a new change order come in on a file while a previous change
  398. // order is pending because of an incomplete install.
  399. //
  400. // ** The Change Order Guid is not unique because a duplicate CO could arrive
  401. // from a different inbound partner while we already have that CO in the
  402. // inbound log because of a retry. We need to track them all because each
  403. // partner needs an Ack.
  404. //
  405. JET_INDEXCREATE ILChangeOrderIndexDesc[] = {
  406. {CBJIC, "LSequenceNumberIndex", "+SequenceNumber\0" , 17, JET_bitIndexUnique |
  407. JET_bitIndexPrimary, 80},
  408. {CBJIC, "GFileGuidIndex", "+FileGuid\0" , 11, 0 , 80},
  409. {CBJIC, "GChangeOrderGuid", "+ChangeOrderGuid\0", 18, 0 , 80},
  410. {CBJIC, "2GGCxtionGuidCoGuid", "+CxtionGuid\0+ChangeOrderGuid\0",
  411. 30, JET_bitIndexUnique, 80}
  412. };
  413. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  414. // The key designated as the primary index can't be changed. A Jet rule.
  415. // So on a directory restore all the directory file IDs can change and
  416. // the records have to be deleted and the table reconstructed.
  417. //
  418. //
  419. // Change Order record flags.
  420. //
  421. FLAG_NAME_TABLE CoFlagNameTable[] = {
  422. {CO_FLAG_ABORT_CO , "Abort " },
  423. {CO_FLAG_VV_ACTIVATED , "VVAct " },
  424. {CO_FLAG_CONTENT_CMD , "Content " },
  425. {CO_FLAG_LOCATION_CMD , "Locn " },
  426. {CO_FLAG_ONLIST , "OnList " },
  427. {CO_FLAG_LOCALCO , "LclCo " },
  428. {CO_FLAG_RETRY , "Retry " },
  429. {CO_FLAG_INSTALL_INCOMPLETE , "InstallInc " },
  430. {CO_FLAG_REFRESH , "Refresh " },
  431. {CO_FLAG_OUT_OF_ORDER , "OofOrd " },
  432. {CO_FLAG_NEW_FILE , "NewFile " },
  433. {CO_FLAG_FILE_USN_VALID , "FileUsnValid "},
  434. {CO_FLAG_CONTROL , "CtrlCo " },
  435. {CO_FLAG_DIRECTED_CO , "DirectedCo " },
  436. {CO_FLAG_UNUSED4000 , "4000 " },
  437. {CO_FLAG_UNUSED8000 , "8000 " },
  438. {CO_FLAG_UNUSED10000 , "10000 " },
  439. {CO_FLAG_DEMAND_REFRESH , "DemandRef " },
  440. {CO_FLAG_VVJOIN_TO_ORIG , "VVjoinToOrig "},
  441. {CO_FLAG_MORPH_GEN , "MorphGen " },
  442. {CO_FLAG_SKIP_ORIG_REC_CHK , "SkipOrigChk " },
  443. {CO_FLAG_MOVEIN_GEN , "MoveinGen " },
  444. {CO_FLAG_MORPH_GEN_LEADER , "MorphGenLdr " },
  445. {CO_FLAG_JUST_OID_RESET , "OidReset " },
  446. {CO_FLAG_COMPRESSED_STAGE , "CmpresStage " },
  447. {CO_FLAG_SKIP_VV_UPDATE , "SkipVVUpdt " },
  448. {0, NULL}
  449. };
  450. //
  451. // Change Order record Interlocked flags.
  452. //
  453. FLAG_NAME_TABLE CoIFlagNameTable[] = {
  454. {CO_IFLAG_VVRETIRE_EXEC , "IFlagVVRetireExec " },
  455. {CO_IFLAG_CO_ABORT , "IFlagCoAbort " },
  456. {CO_IFLAG_DIR_ENUM_PENDING , "IFlagDirEnumPending " },
  457. {0, NULL}
  458. };
  459. //
  460. // Decode table for USN Reason Mask in ContentCmd.
  461. //
  462. FLAG_NAME_TABLE UsnReasonNameTable[] = {
  463. {USN_REASON_CLOSE , "Close " },
  464. {USN_REASON_FILE_CREATE , "Create " },
  465. {USN_REASON_FILE_DELETE , "Delete " },
  466. {USN_REASON_RENAME_NEW_NAME , "RenNew " },
  467. {USN_REASON_RENAME_OLD_NAME , "RenOld " },
  468. {USN_REASON_DATA_OVERWRITE , "DatOvrWrt " },
  469. {USN_REASON_DATA_EXTEND , "DatExt " },
  470. {USN_REASON_DATA_TRUNCATION , "DatTrunc " },
  471. {USN_REASON_BASIC_INFO_CHANGE , "Info " },
  472. {USN_REASON_OBJECT_ID_CHANGE , "Oid " },
  473. {USN_REASON_STREAM_CHANGE , "StreamNam " },
  474. {USN_REASON_NAMED_DATA_OVERWRITE , "StrmOvrWrt " },
  475. {USN_REASON_NAMED_DATA_EXTEND , "StrmExt " },
  476. {USN_REASON_NAMED_DATA_TRUNCATION , "StrmTrunc " },
  477. {USN_REASON_EA_CHANGE , "EAChg " },
  478. {USN_REASON_SECURITY_CHANGE , "Security " },
  479. {USN_REASON_INDEXABLE_CHANGE , "IndexableChg " },
  480. {USN_REASON_HARD_LINK_CHANGE , "HLink " },
  481. {USN_REASON_COMPRESSION_CHANGE , "CompressChg " },
  482. {USN_REASON_ENCRYPTION_CHANGE , "EncryptChg " },
  483. {USN_REASON_REPARSE_POINT_CHANGE , "Reparse " },
  484. {0, NULL}
  485. };
  486. /******************************************************************************
  487. *******************************************************************************
  488. ** **
  489. ** O u t b o u n d L o g **
  490. ** C h a n g e O r d e r T a b l e **
  491. ** **
  492. ** **
  493. *******************************************************************************
  494. ******************************************************************************/
  495. //
  496. // The Outbound Log change order Table column descriptions are as follows.
  497. // Note - the order of the enum in schema.h and the table entries must be
  498. // kept in sync.
  499. //
  500. // Note: Buffers are allocated at runtime to hold data for fields with
  501. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  502. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  503. // ColMaxWidth equals the field size in the record struct the data is in the
  504. // record struct and no buffer is allocated.
  505. //
  506. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  507. //
  508. // **** Make sure any escrowed columns have an initial value.
  509. //
  510. JET_COLUMNCREATE OLChangeOrderTableColDesc[]=
  511. {
  512. {CBJCC, "SequenceNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  513. {CBJCC, "Flags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  514. {CBJCC, "IFlags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  515. {CBJCC, "State", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  516. {CBJCC, "ContentCmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  517. {CBJCC, "Lcmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  518. {CBJCC, "FileAttributes", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  519. {CBJCC, "FileVersionNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  520. {CBJCC, "PartnerAckSeqNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  521. {CBJCC, "FileSize", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  522. {CBJCC, "FileOffset", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  523. {CBJCC, "FrsVsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  524. {CBJCC, "FileUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  525. {CBJCC, "JrnlUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  526. {CBJCC, "JrnlFirstUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  527. // Note: The following two fields now refer to OriginalReplicaNum and NewReplicaNum.
  528. // Can't change field name without compatibility probs with existing DBs.
  529. {CBJCC, "OriginalReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  530. {CBJCC, "NewReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  531. {CBJCC, "ChangeOrderGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  532. {CBJCC, "OriginatorGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  533. {CBJCC, "FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  534. {CBJCC, "OldParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  535. {CBJCC, "NewParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  536. {CBJCC, "CxtionGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  537. // Note: Spare1Ull field is now used for AckVector Version.
  538. // Can't change field name without compatibility probs with existing DBs.
  539. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  540. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  541. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  542. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  543. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  544. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  545. // Note: Spare1Bin field is now used for Change Order Command Extension.
  546. // Can't change field name without compatibility probs with existing DBs.
  547. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  548. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  549. {CBJCC, "EventTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  550. {CBJCC, "FileNameLength", JET_coltypShort, 2, JET_bitColumnFixed, NULL, 0},
  551. {CBJCC, "FileName", JET_coltypLongText, 2*(MAX_PATH+1),
  552. 0 , NULL, 0, CP_UNICODE_FOR_JET}
  553. };
  554. //
  555. // The following is used to build the Jet Set Column struct for record read/write.
  556. // The first 2 params build the field offset and size. The 3rd param is the
  557. // data type.
  558. //
  559. //
  560. // *** WARNING ***
  561. //
  562. // If the record structure field size is less than the max column width AND
  563. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  564. // record is assumed to be variable length. The record insert code
  565. // automatically adjusts the length from the record's Size prefix. All
  566. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  567. // fields that are variable length which don't have a size prefix like
  568. // FSVolInfo in the config record. But these fields MUST have a unique / non
  569. // binary data type assigned to them. Failure to do this causes the insert
  570. // routines to stuff things up to ColMaxWidth bytes into the database.
  571. //
  572. RECORD_FIELDS OLChangeOrderRecordFields[] = {
  573. {sizeof(CHANGE_ORDER_RECORD) , 0, CHANGE_ORDER_MAX_COL },
  574. {RECORD_FIELD(CHANGE_ORDER_RECORD, SequenceNumber, DT_ULONG )},
  575. {RECORD_FIELD(CHANGE_ORDER_RECORD, Flags, DT_COCMD_FLAGS )},
  576. {RECORD_FIELD(CHANGE_ORDER_RECORD, IFlags, DT_COCMD_IFLAGS )},
  577. {RECORD_FIELD(CHANGE_ORDER_RECORD, State, DT_COSTATE )},
  578. {RECORD_FIELD(CHANGE_ORDER_RECORD, ContentCmd, DT_USN_FLAGS )},
  579. {RECORD_FIELD(CHANGE_ORDER_RECORD, Lcmd, DT_CO_LOCN_CMD )},
  580. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileAttributes, DT_FILEATTR )},
  581. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileVersionNumber, DT_ULONG )},
  582. {RECORD_FIELD(CHANGE_ORDER_RECORD, PartnerAckSeqNumber, DT_ULONG )},
  583. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileSize, DT_X8 )},
  584. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileOffset, DT_X8 )},
  585. {RECORD_FIELD(CHANGE_ORDER_RECORD, FrsVsn, DT_X8 )},
  586. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileUsn, DT_X8 )},
  587. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlUsn, DT_X8 )},
  588. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlFirstUsn, DT_X8 )},
  589. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginalReplicaNum, DT_REPLICA_ID )},
  590. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewReplicaNum, DT_REPLICA_ID )},
  591. {RECORD_FIELD(CHANGE_ORDER_RECORD, ChangeOrderGuid, DT_GUID )},
  592. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginatorGuid, DT_GUID )},
  593. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileGuid, DT_GUID )},
  594. {RECORD_FIELD(CHANGE_ORDER_RECORD, OldParentGuid, DT_GUID )},
  595. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewParentGuid, DT_GUID )},
  596. {RECORD_FIELD(CHANGE_ORDER_RECORD, CxtionGuid, DT_CXTION_GUID )},
  597. {RECORD_FIELD(CHANGE_ORDER_RECORD, AckVersion, DT_FILETIME )},
  598. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  599. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Guid, DT_GUID_SPARE )},
  600. // Warning: See comment in schema.h before using Spare2Guid, Spare1Wcs or Spare2Wcs.
  601. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Guid, DT_GUID_SPARE )},
  602. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  603. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  604. {RECORD_FIELD(CHANGE_ORDER_RECORD, Extension, DT_COCMD_EXTENSION /*| DT_NO_DEFAULT_ALLOC_FLAG*/ )},
  605. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  606. {RECORD_FIELD(CHANGE_ORDER_RECORD, EventTime, DT_FILETIME )},
  607. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileNameLength, DT_SHORT )},
  608. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileName, DT_UNICODE )}
  609. };
  610. JET_SETCOLUMN OLChangeOrderJetSetCol[CHANGE_ORDER_MAX_COL];
  611. JET_RETRIEVECOLUMN OLChangeOrderJetRetCol[CHANGE_ORDER_MAX_COL];
  612. //
  613. // The Table index descriptions are as follows. Note - the order of the
  614. // enum and the table entries must be kept in sync.
  615. //
  616. // See the comment under the config table index description for the meaning
  617. // and usage of the first character in the index name field.
  618. //
  619. // Name Key KeyLen JIndexGrBits Density
  620. //
  621. JET_INDEXCREATE OLChangeOrderIndexDesc[] = {
  622. {CBJIC, "LSequenceNumberIndex", "+SequenceNumber\0" , 17, JET_bitIndexUnique |
  623. JET_bitIndexPrimary, 80},
  624. {CBJIC, "GFileGuidIndex", "+FileGuid\0" , 11, 0 , 80},
  625. {CBJIC, "GChangeOrderGuid", "+ChangeOrderGuid\0", 18, JET_bitIndexUnique, 80}
  626. };
  627. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  628. // The key designated as the primary index can't be changed. A Jet rule.
  629. // So on a directory restore all the directory file IDs can change and
  630. // the records have to be deleted and the table reconstructed.
  631. //
  632. /******************************************************************************
  633. *******************************************************************************
  634. ** **
  635. ** **
  636. ** D i r T a b l e **
  637. ** **
  638. ** **
  639. *******************************************************************************
  640. ******************************************************************************/
  641. //
  642. // The DIRTable column descriptions are as follows. Note - the order of the
  643. // enum in schema.h and the table entries must be kept in sync.
  644. //
  645. // Note: Buffers are allocated at runtime to hold data for fields with
  646. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  647. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  648. // ColMaxWidth equals the field size in the record struct the data is in the
  649. // record struct and no buffer is allocated.
  650. //
  651. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  652. //
  653. // **** Make sure any escrowed columns have an initial value.
  654. JET_COLUMNCREATE DIRTableColDesc[]=
  655. {
  656. {CBJCC, "DFileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  657. {CBJCC, "DFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  658. {CBJCC, "DParentFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  659. {CBJCC, "DReplicaNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  660. {CBJCC, "DFileName", JET_coltypLongText, 2*(MAX_PATH+1),
  661. 0 , NULL, 0, CP_UNICODE_FOR_JET}
  662. };
  663. //
  664. // The following is used to build the Jet Set Column struct for record read/write.
  665. // The first 2 params build the field offset and size. The 3rd param is the
  666. // data type.
  667. //
  668. //
  669. // *** WARNING ***
  670. //
  671. // If the record structure field size is less than the max column width AND
  672. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  673. // record is assumed to be variable length. The record insert code
  674. // automatically adjusts the length from the record's Size prefix. All
  675. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  676. // fields that are variable length which don't have a size prefix like
  677. // FSVolInfo in the config record. But these fields MUST have a unique / non
  678. // binary data type assigned to them. Failure to do this causes the insert
  679. // routines to stuff things up to ColMaxWidth bytes into the database.
  680. //
  681. RECORD_FIELDS DIRTableRecordFields[] = {
  682. {sizeof(DIRTABLE_RECORD) , 0, DIRTABLE_MAX_COL },
  683. {RECORD_FIELD(DIRTABLE_RECORD, DFileGuid, DT_GUID )},
  684. {RECORD_FIELD(DIRTABLE_RECORD, DFileID, DT_X8 )},
  685. {RECORD_FIELD(DIRTABLE_RECORD, DParentFileID, DT_X8 )},
  686. {RECORD_FIELD(DIRTABLE_RECORD, DReplicaNumber, DT_ULONG )},
  687. {RECORD_FIELD(DIRTABLE_RECORD, DFileName, DT_UNICODE )}
  688. };
  689. JET_SETCOLUMN DIRTableJetSetCol[DIRTABLE_MAX_COL];
  690. JET_RETRIEVECOLUMN DIRTableJetRetCol[DIRTABLE_MAX_COL];
  691. //
  692. // The DIRTable index descriptions are as follows. Note - the order of the
  693. // enum and the table entries must be kept in sync.
  694. //
  695. //
  696. // See the comment under the config table index description for the meaning
  697. // and usage of the first character in the index name field.
  698. //
  699. // Name Key KeyLen JIndexGrBits Density
  700. //
  701. JET_INDEXCREATE DIRTableIndexDesc[] = {
  702. {CBJIC, "GDFileGuidIndex", "+DFileGuid\0", 12, JET_bitIndexUnique |
  703. JET_bitIndexPrimary, 60},
  704. {CBJIC, "QDFileIDIndex", "+DFileID\0", 10, JET_bitIndexUnique, 60}
  705. };
  706. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  707. // The key designated as the primary index can't be changed. A Jet rule.
  708. // So on a directory restore all the directory file IDs can change and
  709. // the records have to be deleted and the table reconstructed.
  710. //
  711. /******************************************************************************
  712. *******************************************************************************
  713. ** **
  714. ** **
  715. ** I D T a b l e **
  716. ** **
  717. ** **
  718. *******************************************************************************
  719. ******************************************************************************/
  720. //
  721. // The IDTable column descriptions are as follows. Note - the order of the
  722. // enum in schema.h and the table entries must be kept in sync.
  723. //
  724. // Note: Buffers are allocated at runtime to hold data for fields with
  725. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  726. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  727. // ColMaxWidth equals the field size in the record struct the data is in the
  728. // record struct and no buffer is allocated.
  729. //
  730. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  731. //
  732. // **** Make sure any escrowed columns have an initial value.
  733. JET_COLUMNCREATE IDTableColDesc[]=
  734. {
  735. {CBJCC, "FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  736. {CBJCC, "FileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  737. {CBJCC, "ParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  738. {CBJCC, "ParentFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  739. {CBJCC, "VersionNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  740. {CBJCC, "EventTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  741. {CBJCC, "OriginatorGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  742. {CBJCC, "OriginatorVSN", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  743. {CBJCC, "CurrentFileUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  744. {CBJCC, "FileCreateTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  745. {CBJCC, "FileWriteTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  746. {CBJCC, "FileSize", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  747. {CBJCC, "FileObjID", JET_coltypBinary, FILE_OBJECTID_SIZE,
  748. JET_bitColumnFixed, NULL, 0},
  749. {CBJCC, "FileName", JET_coltypLongText, 2*(MAX_PATH+1),
  750. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  751. {CBJCC, "FileIsDir", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  752. {CBJCC, "FileAttributes", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  753. {CBJCC, "Flags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  754. {CBJCC, "ReplEnabled", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  755. {CBJCC, "TombStoneGC", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  756. {CBJCC, "OutLogSeqNum", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  757. // Note: Spare1Ull field is now used for the IdtVVFlags.
  758. // Can't change field name without compatibility probs with existing DBs.
  759. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  760. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  761. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  762. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  763. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  764. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  765. // Note: Spare1Bin field is now used for the IDTable Data Extension.
  766. // Can't change field name without compatibility probs with existing DBs.
  767. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  768. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0}
  769. };
  770. //
  771. // The following is used to build the Jet Set Column struct for record read/write.
  772. // The first 2 params build the field offset and size. The 3rd param is the
  773. // data type.
  774. //
  775. // *** WARNING ***
  776. //
  777. // If the record structure field size is less than the max column width AND
  778. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  779. // record is assumed to be variable length. The record insert code
  780. // automatically adjusts the length from the record's Size prefix. All
  781. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  782. // fields that are variable length which don't have a size prefix like
  783. // FSVolInfo in the config record. But these fields MUST have a unique / non
  784. // binary data type assigned to them. Failure to do this causes the insert
  785. // routines to stuff things up to ColMaxWidth bytes into the database.
  786. //
  787. RECORD_FIELDS IDTableRecordFields[] = {
  788. {sizeof(IDTABLE_RECORD) , 0, IDTABLE_MAX_COL },
  789. {RECORD_FIELD(IDTABLE_RECORD, FileGuid, DT_GUID )},
  790. {RECORD_FIELD(IDTABLE_RECORD, FileID, DT_X8 )},
  791. {RECORD_FIELD(IDTABLE_RECORD, ParentGuid, DT_GUID )},
  792. {RECORD_FIELD(IDTABLE_RECORD, ParentFileID, DT_X8 )},
  793. {RECORD_FIELD(IDTABLE_RECORD, VersionNumber, DT_ULONG )},
  794. {RECORD_FIELD(IDTABLE_RECORD, EventTime, DT_FILETIME )},
  795. {RECORD_FIELD(IDTABLE_RECORD, OriginatorGuid, DT_GUID )},
  796. {RECORD_FIELD(IDTABLE_RECORD, OriginatorVSN, DT_X8 )},
  797. {RECORD_FIELD(IDTABLE_RECORD, CurrentFileUsn, DT_USN )},
  798. {RECORD_FIELD(IDTABLE_RECORD, FileCreateTime, DT_FILETIME )},
  799. {RECORD_FIELD(IDTABLE_RECORD, FileWriteTime, DT_FILETIME )},
  800. {RECORD_FIELD(IDTABLE_RECORD, FileSize, DT_X8 )},
  801. {RECORD_FIELD(IDTABLE_RECORD, FileObjID, DT_OBJID )},
  802. {RECORD_FIELD(IDTABLE_RECORD, FileName, DT_UNICODE )},
  803. {RECORD_FIELD(IDTABLE_RECORD, FileIsDir, DT_BOOL )},
  804. {RECORD_FIELD(IDTABLE_RECORD, FileAttributes, DT_FILEATTR )},
  805. {RECORD_FIELD(IDTABLE_RECORD, Flags, DT_IDT_FLAGS )},
  806. {RECORD_FIELD(IDTABLE_RECORD, ReplEnabled, DT_BOOL )},
  807. {RECORD_FIELD(IDTABLE_RECORD, TombStoneGC, DT_FILETIME )},
  808. {RECORD_FIELD(IDTABLE_RECORD, OutLogSeqNum, DT_X8 )},
  809. {RECORD_FIELD(IDTABLE_RECORD, IdtVVFlags, DT_X8 )},
  810. {RECORD_FIELD(IDTABLE_RECORD, Spare2Ull, DT_X8_SPARE )},
  811. {RECORD_FIELD(IDTABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  812. {RECORD_FIELD(IDTABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  813. {RECORD_FIELD(IDTABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE)},
  814. {RECORD_FIELD(IDTABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE)},
  815. {RECORD_FIELD(IDTABLE_RECORD, Extension, DT_IDT_EXTENSION | DT_FIXED_SIZE_BUFFER)},
  816. {RECORD_FIELD(IDTABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )}
  817. };
  818. JET_SETCOLUMN IDTableJetSetCol[IDTABLE_MAX_COL];
  819. JET_RETRIEVECOLUMN IDTableJetRetCol[IDTABLE_MAX_COL];
  820. //
  821. // The IDTable index descriptions are as follows. Note - the order of the
  822. // enum and the table entries must be kept in sync. The Guid is the primary
  823. // key because the FID can change, e.g. Reformat and file restore.
  824. //
  825. // See the comment under the config table index description for the meaning
  826. // and usage of the first character in the index name field.
  827. //
  828. // Name Key KeyLen JIndexGrBits Density
  829. //
  830. JET_INDEXCREATE IDTableIndexDesc[] = {
  831. {CBJIC, "GGuidIndex", "+FileGuid\0", 11, JET_bitIndexUnique |
  832. JET_bitIndexPrimary, 60},
  833. {CBJIC, "QFileIDIndex", "+FileID\0", 9, JET_bitIndexUnique, 60},
  834. {CBJIC, "2GWParGuidFileName", "+ParentGuid\0+FileName\0", 23, 0, 80}
  835. };
  836. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  837. // The key designated as the primary index can't be changed. A Jet rule.
  838. // So don't make fileID a primary index since on a directory restore all the
  839. // file IDs could change and have to be updated.
  840. //
  841. //
  842. // IDRecord Table Flags.
  843. //
  844. FLAG_NAME_TABLE IDRecFlagNameTable[] = {
  845. {IDREC_FLAGS_DELETED , "DELETED " },
  846. {IDREC_FLAGS_CREATE_DEFERRED , "CreDefer " },
  847. {IDREC_FLAGS_DELETE_DEFERRED , "DelDefer " },
  848. {IDREC_FLAGS_RENAME_DEFERRED , "RenDefer " },
  849. {IDREC_FLAGS_NEW_FILE_IN_PROGRESS , "NewFileInProg "},
  850. {IDREC_FLAGS_ENUM_PENDING , "EnumPending " },
  851. {0, NULL}
  852. };
  853. //
  854. // FileAttribute Flags
  855. //
  856. FLAG_NAME_TABLE FileAttrFlagNameTable[] = {
  857. {FILE_ATTRIBUTE_READONLY , "READONLY " },
  858. {FILE_ATTRIBUTE_HIDDEN , "HIDDEN " },
  859. {FILE_ATTRIBUTE_SYSTEM , "SYSTEM " },
  860. {FILE_ATTRIBUTE_DIRECTORY , "DIRECTORY " },
  861. {FILE_ATTRIBUTE_ARCHIVE , "ARCHIVE " },
  862. {FILE_ATTRIBUTE_DEVICE , "DEVICE " },
  863. {FILE_ATTRIBUTE_NORMAL , "NORMAL " },
  864. {FILE_ATTRIBUTE_TEMPORARY , "TEMPORARY " },
  865. {FILE_ATTRIBUTE_SPARSE_FILE , "SPARSE_FILE " },
  866. {FILE_ATTRIBUTE_REPARSE_POINT , "REPARSE_POINT " },
  867. {FILE_ATTRIBUTE_COMPRESSED , "COMPRESSED " },
  868. {FILE_ATTRIBUTE_OFFLINE , "OFFLINE " },
  869. {FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "NOT_CONTENT_INDEXED "},
  870. {FILE_ATTRIBUTE_ENCRYPTED , "ENCRYPTED " },
  871. {0, NULL}
  872. };
  873. /******************************************************************************
  874. *******************************************************************************
  875. ** **
  876. ** **
  877. ** V V T a b l e **
  878. ** **
  879. ** **
  880. *******************************************************************************
  881. ******************************************************************************/
  882. //
  883. // The VVTable column descriptions are as follows. Note - the order of the
  884. // enum in schema.h and the table entries must be kept in sync.
  885. //
  886. // Note: Buffers are allocated at runtime to hold data for fields with
  887. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  888. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  889. // ColMaxWidth equals the field size in the record struct the data is in the
  890. // record struct and no buffer is allocated.
  891. //
  892. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  893. //
  894. // **** Make sure any escrowed columns have an initial value.
  895. JET_COLUMNCREATE VVTableColDesc[]=
  896. {
  897. {CBJCC, "VVOriginatorGuid",JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  898. {CBJCC, "VVOriginatorVsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  899. // Spare1Ull is now used for storing the VSN of the last CO that was deleted
  900. // from the outlog. This is used to build the OutlogVVector. It is called
  901. // VVOutlogOriginatorVsn
  902. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  903. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0}
  904. };
  905. //
  906. // The following is used to build the Jet Set Column struct for record read/write.
  907. // The first 2 params build the field offset and size. The 3rd param is the
  908. // data type.
  909. //
  910. //
  911. // *** WARNING ***
  912. //
  913. // If the record structure field size is less than the max column width AND
  914. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  915. // record is assumed to be variable length. The record insert code
  916. // automatically adjusts the length from the record's Size prefix. All
  917. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  918. // fields that are variable length which don't have a size prefix like
  919. // FSVolInfo in the config record. But these fields MUST have a unique / non
  920. // binary data type assigned to them. Failure to do this causes the insert
  921. // routines to stuff things up to ColMaxWidth bytes into the database.
  922. //
  923. RECORD_FIELDS VVTableRecordFields[] = {
  924. {sizeof(VVTABLE_RECORD) , 0, VVTABLE_MAX_COL },
  925. {RECORD_FIELD(VVTABLE_RECORD, VVOriginatorGuid, DT_GUID )},
  926. {RECORD_FIELD(VVTABLE_RECORD, VVOriginatorVsn, DT_X8 )},
  927. {RECORD_FIELD(VVTABLE_RECORD, VVOutlogOriginatorVsn, DT_LONGLONG )},
  928. {RECORD_FIELD(VVTABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)}
  929. };
  930. JET_SETCOLUMN VVTableJetSetCol[VVTABLE_MAX_COL];
  931. JET_RETRIEVECOLUMN VVTableJetRetCol[VVTABLE_MAX_COL];
  932. //
  933. // The VVTable index descriptions are as follows. Note - the order of the
  934. // enum and the table entries must be kept in sync.
  935. //
  936. //
  937. // See the comment under the config table index description for the meaning
  938. // and usage of the first character in the index name field.
  939. //
  940. // Name Key KeyLen JIndexGrBits Density
  941. //
  942. JET_INDEXCREATE VVTableIndexDesc[] = {
  943. {CBJIC, "GVVGuidIndex", "+VVOriginatorGuid\0", 19, JET_bitIndexUnique |
  944. JET_bitIndexPrimary, 80}
  945. };
  946. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  947. // The key designated as the primary index can't be changed. A Jet rule.
  948. // So on a directory restore all the directory file IDs can change and
  949. // the records have to be deleted and the table reconstructed.
  950. //
  951. /******************************************************************************
  952. *******************************************************************************
  953. ** **
  954. ** **
  955. ** R E P L I C A S E T C O N F I G T A B L E **
  956. ** **
  957. ** **
  958. *******************************************************************************
  959. ******************************************************************************/
  960. //
  961. //
  962. // Note: Order of entries must track enum in schema.h
  963. //
  964. // There is only one config table in the database. Each row in the table
  965. // describes the configuration info for a single replica set.
  966. //
  967. // Note: Buffers are allocated at runtime to hold data for fields with
  968. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  969. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  970. // ColMaxWidth equals the field size in the record struct the data is in the
  971. // record struct and no buffer is allocated.
  972. //
  973. //
  974. // Name ColType ColMaxWidth JColGrBits pvDefault cbDefault
  975. //
  976. JET_COLUMNCREATE ConfigTableColDesc[]=
  977. {
  978. {CBJCC, "ReplicaSetGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  979. {CBJCC, "ReplicaMemberGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  980. {CBJCC, "ReplicaSetName", JET_coltypText , 2*(DNS_MAX_NAME_LENGTH+1),
  981. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  982. {CBJCC, "ReplicaNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  983. {CBJCC, "ReplicaMemberUSN", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  984. {CBJCC, "ReplicaMemberName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  985. {CBJCC, "ReplicaMemberDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  986. {CBJCC, "ReplicaServerDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  987. {CBJCC, "ReplicaSubscriberDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  988. {CBJCC, "ReplicaRootGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  989. {CBJCC, "MembershipExpires", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  990. {CBJCC, "ReplicaVersionGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  991. {CBJCC, "ReplicaSetExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  992. {CBJCC, "ReplicaMemberExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  993. {CBJCC, "ReplicaSubscriberExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  994. {CBJCC, "ReplicaSubscriptionsExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  995. {CBJCC, "ReplicaSetType", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  996. {CBJCC, "ReplicaSetFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  997. {CBJCC, "ReplicaMemberFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  998. {CBJCC, "ReplicaSubscriberFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  999. {CBJCC, "ReplicaDsPoll", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1000. {CBJCC, "ReplicaAuthLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1001. {CBJCC, "ReplicaCtlDataCreation", JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  1002. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1003. {CBJCC, "ReplicaCtlInboundBacklog",JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  1004. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1005. {CBJCC, "ReplicaCtlOutboundBacklog",JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  1006. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1007. {CBJCC, "ReplicaFaultCondition", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1008. {CBJCC, "TimeLastCommand", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1009. {CBJCC, "DSConfigVersionNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1010. {CBJCC, "FSVolInfo", JET_coltypBinary , sizeof(FILE_FS_VOLUME_INFORMATION)+MAXIMUM_VOLUME_LABEL_LENGTH,
  1011. 0 , NULL, 0},
  1012. {CBJCC, "FSVolGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1013. {CBJCC, "FSVolLastUSN", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1014. {CBJCC, "FrsVsn", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1015. {CBJCC, "LastShutdown", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1016. {CBJCC, "LastPause", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1017. {CBJCC, "LastDSCheck", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1018. {CBJCC, "LastDSChangeAccepted", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1019. {CBJCC, "LastReplCycleStart", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1020. {CBJCC, "DirLastReplCycleEnded", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1021. {CBJCC, "ReplicaDeleteTime", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1022. {CBJCC, "LastReplCycleStatus", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1023. {CBJCC, "FSRootPath", JET_coltypLongText , 2*(MAX_PATH+1),
  1024. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1025. {CBJCC, "FSRootSD", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1026. {CBJCC, "FSStagingAreaPath", JET_coltypLongText , 2*(MAX_PATH+1),
  1027. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1028. {CBJCC, "SnapFileSizeLimit", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1029. {CBJCC, "ActiveServCntlCommand", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1030. {CBJCC, "ServiceState", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1031. {CBJCC, "ReplDirLevelLimit", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1032. {CBJCC, "InboundPartnerState", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1033. {CBJCC, "DsInfo", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1034. {CBJCC, "CnfFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1035. {CBJCC, "AdminAlertList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1036. {CBJCC, "ThrottleSched", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1037. {CBJCC, "ReplSched", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1038. {CBJCC, "FileTypePrioList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1039. {CBJCC, "ResourceStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1040. {CBJCC, "PerfStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1041. {CBJCC, "ErrorStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1042. {CBJCC, "FileFilterList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1043. {CBJCC, "DirFilterList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1044. {CBJCC, "TombstoneLife", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1045. {CBJCC, "GarbageCollPeriod", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1046. {CBJCC, "MaxOutBoundLogSize", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1047. {CBJCC, "MaxInBoundLogSize", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1048. {CBJCC, "UpdateBlockedTime", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1049. {CBJCC, "EventTimeDiffThreshold", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1050. {CBJCC, "FileCopyWarningLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1051. {CBJCC, "FileSizeWarningLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1052. {CBJCC, "FileSizeNoRepLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1053. {CBJCC, "CnfUsnJournalID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1054. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1055. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1056. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1057. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1058. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1059. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1060. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1061. //
  1062. // Everything below this line is present only in the FRS <init> record.
  1063. // Everything above is per-replica state.
  1064. //
  1065. // Future: move the following to the Service Table and then remove from config record.
  1066. {CBJCC, "MachineName", JET_coltypText , 2*(MAX_RDN_VALUE_SIZE+1),
  1067. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1068. {CBJCC, "MachineGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1069. {CBJCC, "MachineDnsName", JET_coltypLongText , 2*(DNS_MAX_NAME_LENGTH+1),
  1070. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1071. {CBJCC, "TableVersionNumbers", JET_coltypBinary , SIZEOF(CONFIG_TABLE_RECORD, TableVersionNumbers),
  1072. JET_bitColumnFixed, NULL, 0},
  1073. {CBJCC, "FSDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1074. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1075. {CBJCC, "FSBackupDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1076. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1077. {CBJCC, "ReplicaNetBiosName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1078. {CBJCC, "ReplicaPrincName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1079. {CBJCC, "ReplicaCoDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1080. {CBJCC, "ReplicaCoGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1081. {CBJCC, "ReplicaWorkingPath", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1082. {CBJCC, "ReplicaVersion", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1083. {CBJCC, "FrsDbMajor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1084. {CBJCC, "FrsDbMinor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1085. {CBJCC, "JetParameters", JET_coltypLongBinary, sizeof(JET_SYSTEM_PARAMS),
  1086. 0 , NULL, 0}
  1087. };
  1088. //
  1089. // The following is used to build the Jet Set Column struct for record read/write.
  1090. // The first 2 params build the field offset and size. The 3rd param is the
  1091. // data type.
  1092. //
  1093. //
  1094. // *** WARNING ***
  1095. //
  1096. // If the record structure field size is less than the max column width AND
  1097. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  1098. // record is assumed to be variable length. The record insert code
  1099. // automatically adjusts the length from the record's Size prefix. All
  1100. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  1101. // fields that are variable length which don't have a size prefix like
  1102. // FSVolInfo in the config record. But these fields MUST have a unique / non
  1103. // binary data type assigned to them. Failure to do this causes the insert
  1104. // routines to stuff things up to ColMaxWidth bytes into the database.
  1105. //
  1106. RECORD_FIELDS ConfigTableRecordFields[] = {
  1107. {sizeof(CONFIG_TABLE_RECORD) , 0, CONFIG_TABLE_MAX_COL },
  1108. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetGuid, DT_GUID )},
  1109. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberGuid, DT_GUID )},
  1110. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetName, DT_UNICODE )},
  1111. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaNumber, DT_ULONG )},
  1112. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberUSN, DT_X8 )},
  1113. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberName, DT_UNICODE )},
  1114. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberDn, DT_UNICODE )},
  1115. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaServerDn, DT_UNICODE )},
  1116. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberDn, DT_UNICODE )},
  1117. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaRootGuid, DT_GUID )},
  1118. {RECORD_FIELD(CONFIG_TABLE_RECORD, MembershipExpires, DT_FILETIME )},
  1119. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaVersionGuid, DT_GUID )},
  1120. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetExt, DT_BINARY )},
  1121. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberExt, DT_BINARY )},
  1122. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberExt, DT_BINARY )},
  1123. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriptionsExt, DT_BINARY )},
  1124. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetType, DT_ULONG )},
  1125. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetFlags, DT_ULONG )},
  1126. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberFlags, DT_ULONG )},
  1127. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberFlags,DT_ULONG )},
  1128. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaDsPoll, DT_ULONG )},
  1129. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaAuthLevel, DT_ULONG )},
  1130. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlDataCreation, DT_UNICODE )},
  1131. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlInboundBacklog, DT_UNICODE )},
  1132. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlOutboundBacklog, DT_UNICODE )},
  1133. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaFaultCondition, DT_ULONG )},
  1134. {RECORD_FIELD(CONFIG_TABLE_RECORD, TimeLastCommand, DT_FILETIME )},
  1135. {RECORD_FIELD(CONFIG_TABLE_RECORD, DSConfigVersionNumber, DT_ULONG )},
  1136. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolInfo, DT_FSVOLINFO )},
  1137. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolGuid, DT_GUID )},
  1138. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolLastUSN, DT_USN )},
  1139. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsVsn, DT_X8 )},
  1140. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastShutdown, DT_FILETIME )},
  1141. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastPause, DT_FILETIME )},
  1142. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastDSCheck, DT_FILETIME )},
  1143. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastDSChangeAccepted, DT_FILETIME )},
  1144. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastReplCycleStart, DT_FILETIME )},
  1145. {RECORD_FIELD(CONFIG_TABLE_RECORD, DirLastReplCycleEnded, DT_FILETIME )},
  1146. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaDeleteTime, DT_FILETIME )},
  1147. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastReplCycleStatus, DT_ULONG )},
  1148. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSRootPath, DT_UNICODE )},
  1149. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSRootSD, DT_BINARY )},
  1150. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSStagingAreaPath, DT_UNICODE )},
  1151. {RECORD_FIELD(CONFIG_TABLE_RECORD, SnapFileSizeLimit, DT_LONG )},
  1152. {RECORD_FIELD(CONFIG_TABLE_RECORD, ActiveServCntlCommand, DT_BINARY )},
  1153. {RECORD_FIELD(CONFIG_TABLE_RECORD, ServiceState, DT_LONG )},
  1154. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplDirLevelLimit, DT_LONG )},
  1155. {RECORD_FIELD(CONFIG_TABLE_RECORD, InboundPartnerState, DT_BINARY )},
  1156. {RECORD_FIELD(CONFIG_TABLE_RECORD, DsInfo, DT_BINARY )},
  1157. {RECORD_FIELD(CONFIG_TABLE_RECORD, CnfFlags, DT_ULONG )},
  1158. {RECORD_FIELD(CONFIG_TABLE_RECORD, AdminAlertList, DT_UNICODE )},
  1159. {RECORD_FIELD(CONFIG_TABLE_RECORD, ThrottleSched, DT_BINARY )},
  1160. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplSched, DT_BINARY )},
  1161. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileTypePrioList, DT_UNICODE )},
  1162. {RECORD_FIELD(CONFIG_TABLE_RECORD, ResourceStats, DT_BINARY )},
  1163. {RECORD_FIELD(CONFIG_TABLE_RECORD, PerfStats, DT_BINARY )},
  1164. {RECORD_FIELD(CONFIG_TABLE_RECORD, ErrorStats, DT_BINARY )},
  1165. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileFilterList, DT_UNICODE )},
  1166. {RECORD_FIELD(CONFIG_TABLE_RECORD, DirFilterList, DT_UNICODE )},
  1167. {RECORD_FIELD(CONFIG_TABLE_RECORD, TombstoneLife, DT_ULONG )},
  1168. {RECORD_FIELD(CONFIG_TABLE_RECORD, GarbageCollPeriod, DT_ULONG )},
  1169. {RECORD_FIELD(CONFIG_TABLE_RECORD, MaxOutBoundLogSize, DT_ULONG )},
  1170. {RECORD_FIELD(CONFIG_TABLE_RECORD, MaxInBoundLogSize, DT_ULONG )},
  1171. {RECORD_FIELD(CONFIG_TABLE_RECORD, UpdateBlockedTime, DT_ULONG )},
  1172. {RECORD_FIELD(CONFIG_TABLE_RECORD, EventTimeDiffThreshold,DT_ULONG )},
  1173. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileCopyWarningLevel, DT_ULONG )},
  1174. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileSizeWarningLevel, DT_ULONG )},
  1175. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileSizeNoRepLevel, DT_ULONG )},
  1176. {RECORD_FIELD(CONFIG_TABLE_RECORD, CnfUsnJournalID, DT_X8 )},
  1177. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  1178. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  1179. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  1180. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  1181. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  1182. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Bin, DT_BINARY_SPARE )},
  1183. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  1184. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineName, DT_UNICODE )},
  1185. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineGuid, DT_GUID )},
  1186. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineDnsName, DT_UNICODE )},
  1187. {RECORD_FIELD(CONFIG_TABLE_RECORD, TableVersionNumbers, DT_BINARY )},
  1188. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSDatabasePath, DT_UNICODE )},
  1189. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSBackupDatabasePath, DT_UNICODE )},
  1190. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaNetBiosName, DT_UNICODE )},
  1191. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaPrincName, DT_UNICODE )},
  1192. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCoDn, DT_UNICODE )},
  1193. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCoGuid, DT_GUID )},
  1194. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaWorkingPath, DT_UNICODE )},
  1195. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaVersion, DT_UNICODE )},
  1196. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsDbMajor, DT_ULONG )},
  1197. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsDbMinor, DT_ULONG )},
  1198. {RECORD_FIELD(CONFIG_TABLE_RECORD, JetParameters, DT_BINARY )}
  1199. };
  1200. JET_SETCOLUMN ConfigTableJetSetCol[CONFIG_TABLE_MAX_COL];
  1201. JET_RETRIEVECOLUMN ConfigTableJetRetCol[CONFIG_TABLE_MAX_COL];
  1202. //
  1203. // The ConfigTable index descriptions are as follows. Note - the order of the
  1204. // enum in schema.h and the table entries must be kept in sync.
  1205. //
  1206. // If the first character of the Index Name is a digit then this index is
  1207. // composed of n keys. The following n characters tell us how to compute
  1208. // the keylength for each component. E.G. a 2 key index on a Guid and a
  1209. // Long binary would have a name prefix of "2GL...".
  1210. // If the first character is not a digit then this is a single key index
  1211. // and the first character is the key length code as follows:
  1212. //
  1213. // L: Long binary length is 4 bytes
  1214. // Q: Quad binary length is 8 bytes
  1215. // G: 16 byte GUID length is 16 bytes
  1216. // W: Wide Char length is 2 * _wcslen
  1217. // C: Narrow Char length is _strlen
  1218. //
  1219. // Name Key KeyLen JIndexGrBits Density
  1220. //
  1221. JET_INDEXCREATE ConfigTableIndexDesc[] = {
  1222. {CBJIC, "LReplicaNumberIndex", "+ReplicaNumber\0" ,16, JET_bitIndexUnique |
  1223. JET_bitIndexPrimary, 80},
  1224. {CBJIC, "GReplicaMemberGuidIndex","+ReplicaMemberGuid\0",20, JET_bitIndexUnique, 80},
  1225. {CBJIC, "WReplicaSetNameIndex", "+ReplicaSetName\0" ,17, 0 , 80}
  1226. };
  1227. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  1228. // The key designated as the primary index can't be changed. A Jet rule.
  1229. //
  1230. /******************************************************************************
  1231. *******************************************************************************
  1232. ** **
  1233. ** **
  1234. ** S e r v i c e T a b l e **
  1235. ** **
  1236. ** **
  1237. *******************************************************************************
  1238. ******************************************************************************/
  1239. //
  1240. // There is only one Service table in the database. It has a single record
  1241. // with service specific params that apply to all replica sets.
  1242. // The ServiceTable column descriptions are as follows. Note - the order of the
  1243. // enum in schema.h and the table entries must be kept in sync.
  1244. //
  1245. // Note: Buffers are allocated at runtime to hold data for fields with
  1246. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  1247. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  1248. // ColMaxWidth equals the field size in the record struct the data is in the
  1249. // record struct and no buffer is allocated.
  1250. //
  1251. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  1252. //
  1253. // **** Make sure any escrowed columns have an initial value.
  1254. JET_COLUMNCREATE ServiceTableColDesc[]=
  1255. {
  1256. {CBJCC, "FrsDbMajor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1257. {CBJCC, "FrsDbMinor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1258. {CBJCC, "MachineName", JET_coltypText , 2*(MAX_RDN_VALUE_SIZE+1),
  1259. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1260. {CBJCC, "MachineGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1261. {CBJCC, "MachineDnsName", JET_coltypLongText , 2*(DNS_MAX_NAME_LENGTH+1),
  1262. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1263. {CBJCC, "TableVersionNumbers", JET_coltypBinary , SIZEOF(CONFIG_TABLE_RECORD, TableVersionNumbers),
  1264. JET_bitColumnFixed, NULL, 0},
  1265. {CBJCC, "FSDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1266. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1267. {CBJCC, "FSBackupDatabasePath",JET_coltypLongText , 2*(MAX_PATH+1),
  1268. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1269. {CBJCC, "ReplicaNetBiosName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1270. {CBJCC, "ReplicaPrincName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1271. {CBJCC, "ReplicaCoDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1272. {CBJCC, "ReplicaCoGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1273. {CBJCC, "ReplicaWorkingPath", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1274. {CBJCC, "ReplicaVersion", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1275. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1276. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1277. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1278. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1279. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1280. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1281. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1282. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1283. {CBJCC, "JetParameters", JET_coltypLongBinary, sizeof(JET_SYSTEM_PARAMS),
  1284. 0 , NULL, 0}
  1285. };
  1286. //
  1287. // The following is used to build the Jet Set Column struct for record read/write.
  1288. // The first 2 params build the field offset and size. The 3rd param is the
  1289. // data type.
  1290. //
  1291. //
  1292. // *** WARNING ***
  1293. //
  1294. // If the record structure field size is less than the max column width AND
  1295. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  1296. // record is assumed to be variable length. The record insert code
  1297. // automatically adjusts the length from the record's Size prefix. All
  1298. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  1299. // fields that are variable length which don't have a size prefix like
  1300. // FSVolInfo in the config record. But these fields MUST have a unique / non
  1301. // binary data type assigned to them. Failure to do this causes the insert
  1302. // routines to stuff things up to ColMaxWidth bytes into the database.
  1303. //
  1304. RECORD_FIELDS ServiceTableRecordFields[] = {
  1305. {sizeof(SERVICE_TABLE_RECORD) , 0, SERVICE_TABLE_MAX_COL },
  1306. {RECORD_FIELD(SERVICE_TABLE_RECORD, FrsDbMajor, DT_ULONG )},
  1307. {RECORD_FIELD(SERVICE_TABLE_RECORD, FrsDbMinor, DT_ULONG )},
  1308. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineName, DT_UNICODE )},
  1309. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineGuid, DT_GUID )},
  1310. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineDnsName, DT_UNICODE )},
  1311. {RECORD_FIELD(SERVICE_TABLE_RECORD, TableVersionNumbers, DT_BINARY )},
  1312. {RECORD_FIELD(SERVICE_TABLE_RECORD, FSDatabasePath, DT_UNICODE )},
  1313. {RECORD_FIELD(SERVICE_TABLE_RECORD, FSBackupDatabasePath, DT_UNICODE )},
  1314. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaNetBiosName, DT_UNICODE )},
  1315. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaPrincName, DT_UNICODE )},
  1316. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaCoDn, DT_UNICODE )},
  1317. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaCoGuid, DT_GUID )},
  1318. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaWorkingPath, DT_UNICODE )},
  1319. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaVersion, DT_UNICODE )},
  1320. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Ull, DT_LONGLONG_SPARE)},
  1321. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  1322. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  1323. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  1324. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  1325. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  1326. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Bin, DT_BINARY_SPARE )},
  1327. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  1328. {RECORD_FIELD(SERVICE_TABLE_RECORD, JetParameters, DT_BINARY )}
  1329. };
  1330. JET_SETCOLUMN ServiceTableJetSetCol[SERVICE_TABLE_MAX_COL];
  1331. JET_RETRIEVECOLUMN ServiceTableJetRetCol[SERVICE_TABLE_MAX_COL];
  1332. //
  1333. // The Service Table index descriptions are as follows. Note - the order of the
  1334. // enum and the table entries must be kept in sync.
  1335. //
  1336. //
  1337. // See the comment under the config table index description for the meaning
  1338. // and usage of the first character in the index name field.
  1339. //
  1340. // Name Key KeyLen JIndexGrBits Density
  1341. //
  1342. JET_INDEXCREATE ServiceTableIndexDesc[] = {
  1343. {CBJIC, "LFrsDbMajor", "+FrsDbMajor\0", 13, JET_bitIndexPrimary, 80}
  1344. };
  1345. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  1346. // The key designated as the primary index can't be changed. A Jet rule.
  1347. // So on a directory restore all the directory file IDs can change and
  1348. // the records have to be deleted and the table reconstructed.
  1349. //
  1350. //
  1351. // The TableVersionNumbers array as saved in the init record when new tables
  1352. // are created. This is used to detect a mismatch between a database and
  1353. // the version of FRS running.
  1354. //
  1355. ULONG TableVersionNumbers[FRS_MAX_TABLE_TYPES]=
  1356. {
  1357. VersionCount,
  1358. VersionINLOGTable,
  1359. VersionOUTLOGTable,
  1360. VersionIDTable,
  1361. VersionDIRTable,
  1362. VersionVVTable,
  1363. VersionCXTIONTable,
  1364. VersionConfigTable,
  1365. VersionServiceTable,
  1366. 0, 0, 0, 0, 0, 0, 0
  1367. };
  1368. /******************************************************************************
  1369. *******************************************************************************
  1370. ** **
  1371. ** **
  1372. ** T A B L E C R E A T E & P R O P E R T Y D E F I N I T I O N S **
  1373. ** **
  1374. ** **
  1375. *******************************************************************************
  1376. ******************************************************************************/
  1377. //
  1378. // The list of Jet Tables created for each replica set are as follows.
  1379. // Note - the order of the enum in schema.h and the table entries and the
  1380. // table property entries must be kept in sync.
  1381. //
  1382. #define CBJTC sizeof(JET_TABLECREATE)
  1383. #define INIT_INBOUND_LOG_TABLE_PAGES 50
  1384. #define INIT_INBOUND_LOG_TABLE_DENSITY 90
  1385. #define INIT_OUTBOUND_LOG_TABLE_PAGES 50
  1386. #define INIT_OUTBOUND_LOG_TABLE_DENSITY 90
  1387. #define INIT_IDTABLE_PAGES 50
  1388. #define INIT_IDTABLE_DENSITY 60
  1389. #define INIT_DIRTABLE_PAGES 10
  1390. #define INIT_DIRTABLE_DENSITY 80
  1391. #define INIT_VVTABLE_PAGES 1
  1392. #define INIT_VVTABLE_DENSITY 80
  1393. #define INIT_CXTIONTABLE_PAGES 2
  1394. #define INIT_CXTIONTABLE_DENSITY 90
  1395. #define INIT_CONFIG_PAGES 10
  1396. #define INIT_CONFIG_DENSITY 90
  1397. #define INIT_SERVICE_PAGES 4
  1398. #define INIT_SERVICE_DENSITY 90
  1399. typedef struct ___tagJET_TABLECREATE // from Jet header for ref only.
  1400. {
  1401. ULONG cbStruct; // size of this structure
  1402. CHAR *szTableName; // name of table to create.
  1403. CHAR *szTemplateTableName; // name of table from which to inherit base DDL
  1404. ULONG ulPages; // initial pages to allocate for table.
  1405. ULONG ulDensity; // table density.
  1406. JET_COLUMNCREATE *rgcolumncreate; // array of column creation info
  1407. ULONG cColumns; // number of columns to create
  1408. JET_INDEXCREATE *rgindexcreate; // array of index creation info
  1409. ULONG cIndexes; // number of indexes to create
  1410. JET_GRBIT grbit; // JET_bitTableCreateTemplateTable when creating template
  1411. // JET_bitTableCreateFixedDDL when creating derived table.
  1412. JET_TABLEID tableid; // returned tableid.
  1413. ULONG cCreated; // count of objects created (columns+table+indexes).
  1414. } ___JET_TABLECREATE;
  1415. JET_TABLECREATE DBTables[] = {
  1416. {CBJTC, "INLOGTable", NULL, INIT_INBOUND_LOG_TABLE_PAGES, INIT_INBOUND_LOG_TABLE_DENSITY,
  1417. ILChangeOrderTableColDesc, CHANGE_ORDER_MAX_COL, ILChangeOrderIndexDesc, ILCHANGE_ORDER_MAX_INDEX,
  1418. JET_bitTableCreateTemplateTable},
  1419. {CBJTC, "OUTLOGTable", NULL, INIT_OUTBOUND_LOG_TABLE_PAGES, INIT_OUTBOUND_LOG_TABLE_DENSITY,
  1420. OLChangeOrderTableColDesc, CHANGE_ORDER_MAX_COL, OLChangeOrderIndexDesc, OLCHANGE_ORDER_MAX_INDEX,
  1421. JET_bitTableCreateTemplateTable},
  1422. {CBJTC, "IDTable", NULL, INIT_IDTABLE_PAGES, INIT_IDTABLE_DENSITY,
  1423. IDTableColDesc, IDTABLE_MAX_COL, IDTableIndexDesc, IDTABLE_MAX_INDEX,
  1424. JET_bitTableCreateTemplateTable},
  1425. {CBJTC, "DIRTable", NULL, INIT_DIRTABLE_PAGES, INIT_DIRTABLE_DENSITY,
  1426. DIRTableColDesc, DIRTABLE_MAX_COL, DIRTableIndexDesc, DIRTABLE_MAX_INDEX,
  1427. JET_bitTableCreateTemplateTable},
  1428. {CBJTC, "VVTable", NULL, INIT_VVTABLE_PAGES, INIT_VVTABLE_DENSITY,
  1429. VVTableColDesc, VVTABLE_MAX_COL, VVTableIndexDesc, VVTABLE_MAX_INDEX,
  1430. JET_bitTableCreateTemplateTable},
  1431. {CBJTC, "CXTIONTable", NULL, INIT_CXTIONTABLE_PAGES, INIT_CXTIONTABLE_DENSITY,
  1432. CXTIONTableColDesc, CXTION_TABLE_MAX_COL, CXTIONTableIndexDesc, CXTION_TABLE_MAX_INDEX,
  1433. JET_bitTableCreateTemplateTable},
  1434. //
  1435. // set rgcolumncreate to ConfigTableColDesc so init is simpler.
  1436. //
  1437. {CBJTC, "Unused", NULL, 0, 0, ConfigTableColDesc, 0, NULL, 0, 0},
  1438. {CBJTC, "ConfigTable", NULL, INIT_CONFIG_PAGES, INIT_CONFIG_DENSITY,
  1439. ConfigTableColDesc, CONFIG_TABLE_MAX_COL,
  1440. ConfigTableIndexDesc, CONFIG_TABLE_MAX_INDEX,
  1441. JET_bitTableCreateFixedDDL},
  1442. {CBJTC, "ServiceTable", NULL, INIT_SERVICE_PAGES, INIT_SERVICE_DENSITY,
  1443. ServiceTableColDesc, SERVICE_TABLE_MAX_COL,
  1444. ServiceTableIndexDesc, SERVICE_TABLE_MAX_INDEX,
  1445. JET_bitTableCreateFixedDDL}
  1446. };
  1447. //
  1448. // The following describes some properties of each defined table in the schema.
  1449. // This is used mainly for initialization.
  1450. //
  1451. // Name RecordFields Flags
  1452. FRS_TABLE_PROPERTIES FrsTableProperties[] = {
  1453. {"INLOGTable", ILChangeOrderRecordFields, FRS_TPF_NONE },
  1454. {"OUTLOGTable", OLChangeOrderRecordFields, FRS_TPF_NONE },
  1455. {"IDTable", IDTableRecordFields , FRS_TPF_NONE },
  1456. {"DIRTable", DIRTableRecordFields , FRS_TPF_NONE },
  1457. {"VVTable", VVTableRecordFields , FRS_TPF_NONE },
  1458. {"CXTIONTable", CXTIONTableRecordFields , FRS_TPF_NONE },
  1459. {"Unused", NULL , 0 }, // Gap between single instance tables.
  1460. {"ConfigTable", ConfigTableRecordFields , FRS_TPF_SINGLE},
  1461. {"ServiceTable", ServiceTableRecordFields , FRS_TPF_SINGLE}
  1462. };
  1463. /******************************************************************************
  1464. *******************************************************************************
  1465. ** **
  1466. ** **
  1467. ** J E T S Y S T E M P A R A M E T E R S T A B L E **
  1468. ** **
  1469. ** **
  1470. *******************************************************************************
  1471. ******************************************************************************/
  1472. //
  1473. // Definition of the Jet system parameters stored in config record.
  1474. // If you add or delete a parameter adjust MAX_JET_SYSTEM_PARAMS accordingly.
  1475. //
  1476. JET_SYSTEM_PARAMS JetSystemParamsDef = {
  1477. sizeof(JET_SYSTEM_PARAMS) ,
  1478. {
  1479. {"SystemPath ", JET_paramSystemPath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, ChkPointFilePath) },
  1480. {"TempPath ", JET_paramTempPath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, TempFilePath) },
  1481. {"LogFilePath ", JET_paramLogFilePath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, LogFilePath) },
  1482. {"BaseName ", JET_paramBaseName , JPARAM_TYPE_SKIP, 0 },
  1483. {"EventSource ", JET_paramEventSource , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, EventSource) },
  1484. {"MaxSessions ", JET_paramMaxSessions , JPARAM_TYPE_LONG, 200 },
  1485. {"MaxOpenTables ", JET_paramMaxOpenTables , JPARAM_TYPE_SKIP, 0 },
  1486. {"PreferredMaxOpenTables", JET_paramPreferredMaxOpenTables, JPARAM_TYPE_SKIP, 0 },
  1487. {"MaxCursors ", JET_paramMaxCursors , JPARAM_TYPE_SKIP, 0 },
  1488. {"MaxVerPages ", JET_paramMaxVerPages , JPARAM_TYPE_SKIP, 0 },
  1489. {"MaxTemporaryTables ", JET_paramMaxTemporaryTables , JPARAM_TYPE_SKIP, 0 },
  1490. {"LogFileSize ", JET_paramLogFileSize , JPARAM_TYPE_SKIP, 0 },
  1491. {"LogBuffers ", JET_paramLogBuffers , JPARAM_TYPE_SKIP, 0 },
  1492. {"WaitLogFlush ", JET_paramWaitLogFlush , JPARAM_TYPE_SKIP, 0 },
  1493. {"LogCheckpointPeriod ", JET_paramLogCheckpointPeriod , JPARAM_TYPE_SKIP, 0 },
  1494. {"LogWaitingUserMax ", JET_paramLogWaitingUserMax , JPARAM_TYPE_SKIP, 0 },
  1495. {"CommitDefault ", JET_paramCommitDefault , JPARAM_TYPE_SKIP, 0 },
  1496. {"CircularLog ", JET_paramCircularLog , JPARAM_TYPE_SKIP, 0 },
  1497. {"DbExtensionSize ", JET_paramDbExtensionSize , JPARAM_TYPE_SKIP, 0 },
  1498. {"PageTempDBMin ", JET_paramPageTempDBMin , JPARAM_TYPE_SKIP, 0 },
  1499. {"PageFragment ", JET_paramPageFragment , JPARAM_TYPE_SKIP, 0 },
  1500. {"PageReadAheadMax ", JET_paramPageReadAheadMax , JPARAM_TYPE_SKIP, 0 },
  1501. {"BatchIOBufferMax ", JET_paramBatchIOBufferMax , JPARAM_TYPE_SKIP, 0 },
  1502. {"CacheSize ", JET_paramCacheSize , JPARAM_TYPE_SKIP, 0 },
  1503. {"CacheSizeMax ", JET_paramCacheSizeMax , JPARAM_TYPE_SKIP, 0 },
  1504. {"CheckpointDepthMax ", JET_paramCheckpointDepthMax , JPARAM_TYPE_SKIP, 0 },
  1505. {"LRUKCorrInterval ", JET_paramLRUKCorrInterval , JPARAM_TYPE_SKIP, 0 },
  1506. {"LRUKHistoryMax ", JET_paramLRUKHistoryMax , JPARAM_TYPE_SKIP, 0 },
  1507. {"LRUKPolicy ", JET_paramLRUKPolicy , JPARAM_TYPE_SKIP, 0 },
  1508. {"LRUKTimeout ", JET_paramLRUKTimeout , JPARAM_TYPE_SKIP, 0 },
  1509. {"LRUKTrxCorrInterval ", JET_paramLRUKTrxCorrInterval , JPARAM_TYPE_SKIP, 0 },
  1510. {"OutstandingIOMax ", JET_paramOutstandingIOMax , JPARAM_TYPE_SKIP, 0 },
  1511. {"StartFlushThreshold ", JET_paramStartFlushThreshold , JPARAM_TYPE_SKIP, 0 },
  1512. {"StopFlushThreshold ", JET_paramStopFlushThreshold , JPARAM_TYPE_SKIP, 0 },
  1513. {"TableClassName ", JET_paramTableClassName , JPARAM_TYPE_SKIP, 0 },
  1514. {"ExceptionAction ", JET_paramExceptionAction , JPARAM_TYPE_SKIP, 0 },
  1515. {"EventLogCache ", JET_paramEventLogCache , JPARAM_TYPE_SKIP, 0 },
  1516. {"end ", 0 , JPARAM_TYPE_LAST, 0 },
  1517. },
  1518. "", // CHAR ChkPointFilePath[MAX_PATH];
  1519. "", // CHAR TempFilePath[MAX_PATH];
  1520. "", // CHAR LogFilePath[MAX_PATH];
  1521. "FileReplSvc " // CHAR EventSource[20];
  1522. };
  1523. #if 0
  1524. //
  1525. // The Jet97 aka Jet500 system parameters and defaults are shown below
  1526. // for reference only. See the Jet header file for the latest info.
  1527. //
  1528. JET_paramSystemPath // path to check point file [".\\"]
  1529. JET_paramTempPath // path to the temporary database [".\\"]
  1530. JET_paramLogFilePath // path to the log file directory [".\\"]
  1531. JET_paramBaseName // base name for all DBMS object names ["edb"]
  1532. JET_paramEventSource // language independant process descriptor string [""]
  1533. //
  1534. // performance parameters
  1535. //
  1536. JET_paramMaxSessions // maximum number of sessions [128]
  1537. JET_paramMaxOpenTables // maximum number of open directories [300]
  1538. // need 1 for each open table index,
  1539. // plus 1 for each open table with no indexes,
  1540. // plus 1 for each table with long column data,
  1541. // plus a few more.
  1542. // for 4.1, 1/3 for regular table, 2/3 for index
  1543. JET_paramPreferredMaxOpenTables // preferred maximum number of open directories [300]
  1544. JET_paramMaxCursors // maximum number of open cursors [1024]
  1545. JET_paramMaxVerPages // maximum version store size in 16kByte units [64]
  1546. JET_paramMaxTemporaryTables // maximum concurrent open temporary
  1547. // table/index creation [20]
  1548. JET_paramLogFileSize // log file size in kBytes [5120]
  1549. JET_paramLogBuffers // log buffers in 512 bytes [21]
  1550. JET_paramWaitLogFlush // log flush wait time in milliseconds [0]
  1551. JET_paramLogCheckpointPeriod // checkpoint period in 512 bytes [1024]
  1552. JET_paramLogWaitingUserMax // maximum sessions waiting log flush [3]
  1553. JET_paramCommitDefault // default grbit for JetCommitTransaction [0]
  1554. JET_paramCircularLog // boolean flag for circular logging [0]
  1555. JET_paramDbExtensionSize // database extension size in pages [16]
  1556. JET_paramPageTempDBMin // minimum size temporary database in pages [0]
  1557. JET_paramPageFragment // maximum disk extent considered fragment in pages [8]
  1558. JET_paramPageReadAheadMax // maximum read-ahead in pages [20]
  1559. //
  1560. // cache performance parameters
  1561. //
  1562. JET_paramBatchIOBufferMax // maximum batch I/O buffers in pages [64]
  1563. JET_paramCacheSize // current cache size in pages [512]
  1564. JET_paramCacheSizeMax // maximum cache size in pages [512]
  1565. JET_paramCheckpointDepthMax // maximum checkpoint depth in bytes [10MB]
  1566. JET_paramLRUKCorrInterval // time (usec) under which page accesses are
  1567. // correlated [10000]
  1568. JET_paramLRUKHistoryMax // maximum LRUK history records [1024]
  1569. // (proportional to cache size max)
  1570. JET_paramLRUKPolicy // K-ness of LRUK page eviction algorithm (1...2) [2]
  1571. JET_paramLRUKTimeout // time (sec) after which cached pages are
  1572. // always evictable [100]
  1573. JET_paramLRUKTrxCorrInterval // time (usec) under which page accesses by the
  1574. // same transaction are correlated [5000000]
  1575. JET_paramOutstandingIOMax // maximum outstanding I/Os [64]
  1576. JET_paramStartFlushThreshold // evictable pages at which to start a flush
  1577. // [100] (proportional to CacheSizeMax)
  1578. JET_paramStopFlushThreshold // evictable pages at which to stop a flush
  1579. // [400] (proportional to CacheSizeMax)
  1580. JET_paramTableClassName // table stats class name (class #, string)
  1581. JET_paramExceptionAction // what to do with exceptions generated within JET
  1582. JET_paramEventLogCache // number of bytes of eventlog records to cache
  1583. // if service is not available [0]
  1584. #endif