Source code of Windows XP (NT5)
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.

1858 lines
99 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. {0, NULL}
  448. };
  449. //
  450. // Change Order record Interlocked flags.
  451. //
  452. FLAG_NAME_TABLE CoIFlagNameTable[] = {
  453. {CO_IFLAG_VVRETIRE_EXEC , "IFlagVVRetireExec " },
  454. {CO_IFLAG_CO_ABORT , "IFlagCoAbort " },
  455. {CO_IFLAG_DIR_ENUM_PENDING , "IFlagDirEnumPending " },
  456. {0, NULL}
  457. };
  458. //
  459. // Decode table for USN Reason Mask in ContentCmd.
  460. //
  461. FLAG_NAME_TABLE UsnReasonNameTable[] = {
  462. {USN_REASON_CLOSE , "Close " },
  463. {USN_REASON_FILE_CREATE , "Create " },
  464. {USN_REASON_FILE_DELETE , "Delete " },
  465. {USN_REASON_RENAME_NEW_NAME , "RenNew " },
  466. {USN_REASON_RENAME_OLD_NAME , "RenOld " },
  467. {USN_REASON_DATA_OVERWRITE , "DatOvrWrt " },
  468. {USN_REASON_DATA_EXTEND , "DatExt " },
  469. {USN_REASON_DATA_TRUNCATION , "DatTrunc " },
  470. {USN_REASON_BASIC_INFO_CHANGE , "Info " },
  471. {USN_REASON_OBJECT_ID_CHANGE , "Oid " },
  472. {USN_REASON_STREAM_CHANGE , "StreamNam " },
  473. {USN_REASON_NAMED_DATA_OVERWRITE , "StrmOvrWrt " },
  474. {USN_REASON_NAMED_DATA_EXTEND , "StrmExt " },
  475. {USN_REASON_NAMED_DATA_TRUNCATION , "StrmTrunc " },
  476. {USN_REASON_EA_CHANGE , "EAChg " },
  477. {USN_REASON_SECURITY_CHANGE , "Security " },
  478. {USN_REASON_INDEXABLE_CHANGE , "IndexableChg " },
  479. {USN_REASON_HARD_LINK_CHANGE , "HLink " },
  480. {USN_REASON_COMPRESSION_CHANGE , "CompressChg " },
  481. {USN_REASON_ENCRYPTION_CHANGE , "EncryptChg " },
  482. {USN_REASON_REPARSE_POINT_CHANGE , "Reparse " },
  483. {0, NULL}
  484. };
  485. /******************************************************************************
  486. *******************************************************************************
  487. ** **
  488. ** O u t b o u n d L o g **
  489. ** C h a n g e O r d e r T a b l e **
  490. ** **
  491. ** **
  492. *******************************************************************************
  493. ******************************************************************************/
  494. //
  495. // The Outbound Log change order Table column descriptions are as follows.
  496. // Note - the order of the enum in schema.h and the table entries must be
  497. // kept in sync.
  498. //
  499. // Note: Buffers are allocated at runtime to hold data for fields with
  500. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  501. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  502. // ColMaxWidth equals the field size in the record struct the data is in the
  503. // record struct and no buffer is allocated.
  504. //
  505. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  506. //
  507. // **** Make sure any escrowed columns have an initial value.
  508. //
  509. JET_COLUMNCREATE OLChangeOrderTableColDesc[]=
  510. {
  511. {CBJCC, "SequenceNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  512. {CBJCC, "Flags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  513. {CBJCC, "IFlags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  514. {CBJCC, "State", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  515. {CBJCC, "ContentCmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  516. {CBJCC, "Lcmd", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  517. {CBJCC, "FileAttributes", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  518. {CBJCC, "FileVersionNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  519. {CBJCC, "PartnerAckSeqNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  520. {CBJCC, "FileSize", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  521. {CBJCC, "FileOffset", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  522. {CBJCC, "FrsVsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  523. {CBJCC, "FileUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  524. {CBJCC, "JrnlUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  525. {CBJCC, "JrnlFirstUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  526. // Note: The following two fields now refer to OriginalReplicaNum and NewReplicaNum.
  527. // Can't change field name without compatibility probs with existing DBs.
  528. {CBJCC, "OriginalReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  529. {CBJCC, "NewReplica", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  530. {CBJCC, "ChangeOrderGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  531. {CBJCC, "OriginatorGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  532. {CBJCC, "FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  533. {CBJCC, "OldParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  534. {CBJCC, "NewParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  535. {CBJCC, "CxtionGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  536. // Note: Spare1Ull field is now used for AckVector Version.
  537. // Can't change field name without compatibility probs with existing DBs.
  538. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  539. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  540. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  541. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  542. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  543. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  544. // Note: Spare1Bin field is now used for Change Order Command Extension.
  545. // Can't change field name without compatibility probs with existing DBs.
  546. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  547. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  548. {CBJCC, "EventTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  549. {CBJCC, "FileNameLength", JET_coltypShort, 2, JET_bitColumnFixed, NULL, 0},
  550. {CBJCC, "FileName", JET_coltypLongText, 2*(MAX_PATH+1),
  551. 0 , NULL, 0, CP_UNICODE_FOR_JET}
  552. };
  553. //
  554. // The following is used to build the Jet Set Column struct for record read/write.
  555. // The first 2 params build the field offset and size. The 3rd param is the
  556. // data type.
  557. //
  558. //
  559. // *** WARNING ***
  560. //
  561. // If the record structure field size is less than the max column width AND
  562. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  563. // record is assumed to be variable length. The record insert code
  564. // automatically adjusts the length from the record's Size prefix. All
  565. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  566. // fields that are variable length which don't have a size prefix like
  567. // FSVolInfo in the config record. But these fields MUST have a unique / non
  568. // binary data type assigned to them. Failure to do this causes the insert
  569. // routines to stuff things up to ColMaxWidth bytes into the database.
  570. //
  571. RECORD_FIELDS OLChangeOrderRecordFields[] = {
  572. {sizeof(CHANGE_ORDER_RECORD) , 0, CHANGE_ORDER_MAX_COL },
  573. {RECORD_FIELD(CHANGE_ORDER_RECORD, SequenceNumber, DT_ULONG )},
  574. {RECORD_FIELD(CHANGE_ORDER_RECORD, Flags, DT_COCMD_FLAGS )},
  575. {RECORD_FIELD(CHANGE_ORDER_RECORD, IFlags, DT_COCMD_IFLAGS )},
  576. {RECORD_FIELD(CHANGE_ORDER_RECORD, State, DT_COSTATE )},
  577. {RECORD_FIELD(CHANGE_ORDER_RECORD, ContentCmd, DT_USN_FLAGS )},
  578. {RECORD_FIELD(CHANGE_ORDER_RECORD, Lcmd, DT_CO_LOCN_CMD )},
  579. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileAttributes, DT_FILEATTR )},
  580. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileVersionNumber, DT_ULONG )},
  581. {RECORD_FIELD(CHANGE_ORDER_RECORD, PartnerAckSeqNumber, DT_ULONG )},
  582. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileSize, DT_X8 )},
  583. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileOffset, DT_X8 )},
  584. {RECORD_FIELD(CHANGE_ORDER_RECORD, FrsVsn, DT_X8 )},
  585. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileUsn, DT_X8 )},
  586. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlUsn, DT_X8 )},
  587. {RECORD_FIELD(CHANGE_ORDER_RECORD, JrnlFirstUsn, DT_X8 )},
  588. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginalReplicaNum, DT_REPLICA_ID )},
  589. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewReplicaNum, DT_REPLICA_ID )},
  590. {RECORD_FIELD(CHANGE_ORDER_RECORD, ChangeOrderGuid, DT_GUID )},
  591. {RECORD_FIELD(CHANGE_ORDER_RECORD, OriginatorGuid, DT_GUID )},
  592. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileGuid, DT_GUID )},
  593. {RECORD_FIELD(CHANGE_ORDER_RECORD, OldParentGuid, DT_GUID )},
  594. {RECORD_FIELD(CHANGE_ORDER_RECORD, NewParentGuid, DT_GUID )},
  595. {RECORD_FIELD(CHANGE_ORDER_RECORD, CxtionGuid, DT_CXTION_GUID )},
  596. {RECORD_FIELD(CHANGE_ORDER_RECORD, AckVersion, DT_FILETIME )},
  597. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  598. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Guid, DT_GUID_SPARE )},
  599. // Warning: See comment in schema.h before using Spare2Guid, Spare1Wcs or Spare2Wcs.
  600. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Guid, DT_GUID_SPARE )},
  601. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  602. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  603. {RECORD_FIELD(CHANGE_ORDER_RECORD, Extension, DT_COCMD_EXTENSION /*| DT_NO_DEFAULT_ALLOC_FLAG*/ )},
  604. {RECORD_FIELD(CHANGE_ORDER_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  605. {RECORD_FIELD(CHANGE_ORDER_RECORD, EventTime, DT_FILETIME )},
  606. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileNameLength, DT_SHORT )},
  607. {RECORD_FIELD(CHANGE_ORDER_RECORD, FileName, DT_UNICODE )}
  608. };
  609. JET_SETCOLUMN OLChangeOrderJetSetCol[CHANGE_ORDER_MAX_COL];
  610. JET_RETRIEVECOLUMN OLChangeOrderJetRetCol[CHANGE_ORDER_MAX_COL];
  611. //
  612. // The Table index descriptions are as follows. Note - the order of the
  613. // enum and the table entries must be kept in sync.
  614. //
  615. // See the comment under the config table index description for the meaning
  616. // and usage of the first character in the index name field.
  617. //
  618. // Name Key KeyLen JIndexGrBits Density
  619. //
  620. JET_INDEXCREATE OLChangeOrderIndexDesc[] = {
  621. {CBJIC, "LSequenceNumberIndex", "+SequenceNumber\0" , 17, JET_bitIndexUnique |
  622. JET_bitIndexPrimary, 80},
  623. {CBJIC, "GFileGuidIndex", "+FileGuid\0" , 11, 0 , 80},
  624. {CBJIC, "GChangeOrderGuid", "+ChangeOrderGuid\0", 18, JET_bitIndexUnique, 80}
  625. };
  626. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  627. // The key designated as the primary index can't be changed. A Jet rule.
  628. // So on a directory restore all the directory file IDs can change and
  629. // the records have to be deleted and the table reconstructed.
  630. //
  631. /******************************************************************************
  632. *******************************************************************************
  633. ** **
  634. ** **
  635. ** D i r T a b l e **
  636. ** **
  637. ** **
  638. *******************************************************************************
  639. ******************************************************************************/
  640. //
  641. // The DIRTable column descriptions are as follows. Note - the order of the
  642. // enum in schema.h and the table entries must be kept in sync.
  643. //
  644. // Note: Buffers are allocated at runtime to hold data for fields with
  645. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  646. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  647. // ColMaxWidth equals the field size in the record struct the data is in the
  648. // record struct and no buffer is allocated.
  649. //
  650. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  651. //
  652. // **** Make sure any escrowed columns have an initial value.
  653. JET_COLUMNCREATE DIRTableColDesc[]=
  654. {
  655. {CBJCC, "DFileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  656. {CBJCC, "DFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  657. {CBJCC, "DParentFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  658. {CBJCC, "DReplicaNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  659. {CBJCC, "DFileName", JET_coltypLongText, 2*(MAX_PATH+1),
  660. 0 , NULL, 0, CP_UNICODE_FOR_JET}
  661. };
  662. //
  663. // The following is used to build the Jet Set Column struct for record read/write.
  664. // The first 2 params build the field offset and size. The 3rd param is the
  665. // data type.
  666. //
  667. //
  668. // *** WARNING ***
  669. //
  670. // If the record structure field size is less than the max column width AND
  671. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  672. // record is assumed to be variable length. The record insert code
  673. // automatically adjusts the length from the record's Size prefix. All
  674. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  675. // fields that are variable length which don't have a size prefix like
  676. // FSVolInfo in the config record. But these fields MUST have a unique / non
  677. // binary data type assigned to them. Failure to do this causes the insert
  678. // routines to stuff things up to ColMaxWidth bytes into the database.
  679. //
  680. RECORD_FIELDS DIRTableRecordFields[] = {
  681. {sizeof(DIRTABLE_RECORD) , 0, DIRTABLE_MAX_COL },
  682. {RECORD_FIELD(DIRTABLE_RECORD, DFileGuid, DT_GUID )},
  683. {RECORD_FIELD(DIRTABLE_RECORD, DFileID, DT_X8 )},
  684. {RECORD_FIELD(DIRTABLE_RECORD, DParentFileID, DT_X8 )},
  685. {RECORD_FIELD(DIRTABLE_RECORD, DReplicaNumber, DT_ULONG )},
  686. {RECORD_FIELD(DIRTABLE_RECORD, DFileName, DT_UNICODE )}
  687. };
  688. JET_SETCOLUMN DIRTableJetSetCol[DIRTABLE_MAX_COL];
  689. JET_RETRIEVECOLUMN DIRTableJetRetCol[DIRTABLE_MAX_COL];
  690. //
  691. // The DIRTable index descriptions are as follows. Note - the order of the
  692. // enum and the table entries must be kept in sync.
  693. //
  694. //
  695. // See the comment under the config table index description for the meaning
  696. // and usage of the first character in the index name field.
  697. //
  698. // Name Key KeyLen JIndexGrBits Density
  699. //
  700. JET_INDEXCREATE DIRTableIndexDesc[] = {
  701. {CBJIC, "GDFileGuidIndex", "+DFileGuid\0", 12, JET_bitIndexUnique |
  702. JET_bitIndexPrimary, 60},
  703. {CBJIC, "QDFileIDIndex", "+DFileID\0", 10, JET_bitIndexUnique, 60}
  704. };
  705. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  706. // The key designated as the primary index can't be changed. A Jet rule.
  707. // So on a directory restore all the directory file IDs can change and
  708. // the records have to be deleted and the table reconstructed.
  709. //
  710. /******************************************************************************
  711. *******************************************************************************
  712. ** **
  713. ** **
  714. ** I D T a b l e **
  715. ** **
  716. ** **
  717. *******************************************************************************
  718. ******************************************************************************/
  719. //
  720. // The IDTable column descriptions are as follows. Note - the order of the
  721. // enum in schema.h and the table entries must be kept in sync.
  722. //
  723. // Note: Buffers are allocated at runtime to hold data for fields with
  724. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  725. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  726. // ColMaxWidth equals the field size in the record struct the data is in the
  727. // record struct and no buffer is allocated.
  728. //
  729. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  730. //
  731. // **** Make sure any escrowed columns have an initial value.
  732. JET_COLUMNCREATE IDTableColDesc[]=
  733. {
  734. {CBJCC, "FileGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  735. {CBJCC, "FileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  736. {CBJCC, "ParentGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  737. {CBJCC, "ParentFileID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  738. {CBJCC, "VersionNumber", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  739. {CBJCC, "EventTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  740. {CBJCC, "OriginatorGuid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  741. {CBJCC, "OriginatorVSN", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  742. {CBJCC, "CurrentFileUsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  743. {CBJCC, "FileCreateTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  744. {CBJCC, "FileWriteTime", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  745. {CBJCC, "FileSize", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  746. {CBJCC, "FileObjID", JET_coltypBinary, FILE_OBJECTID_SIZE,
  747. JET_bitColumnFixed, NULL, 0},
  748. {CBJCC, "FileName", JET_coltypLongText, 2*(MAX_PATH+1),
  749. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  750. {CBJCC, "FileIsDir", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  751. {CBJCC, "FileAttributes", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  752. {CBJCC, "Flags", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  753. {CBJCC, "ReplEnabled", JET_coltypLong, 4, JET_bitColumnFixed, NULL, 0},
  754. {CBJCC, "TombStoneGC", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  755. {CBJCC, "OutLogSeqNum", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  756. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  757. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  758. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  759. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  760. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  761. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  762. // Note: Spare1Bin field is now used for the IDTable Data Extension.
  763. // Can't change field name without compatibility probs with existing DBs.
  764. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  765. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0}
  766. };
  767. //
  768. // The following is used to build the Jet Set Column struct for record read/write.
  769. // The first 2 params build the field offset and size. The 3rd param is the
  770. // data type.
  771. //
  772. // *** WARNING ***
  773. //
  774. // If the record structure field size is less than the max column width AND
  775. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  776. // record is assumed to be variable length. The record insert code
  777. // automatically adjusts the length from the record's Size prefix. All
  778. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  779. // fields that are variable length which don't have a size prefix like
  780. // FSVolInfo in the config record. But these fields MUST have a unique / non
  781. // binary data type assigned to them. Failure to do this causes the insert
  782. // routines to stuff things up to ColMaxWidth bytes into the database.
  783. //
  784. RECORD_FIELDS IDTableRecordFields[] = {
  785. {sizeof(IDTABLE_RECORD) , 0, IDTABLE_MAX_COL },
  786. {RECORD_FIELD(IDTABLE_RECORD, FileGuid, DT_GUID )},
  787. {RECORD_FIELD(IDTABLE_RECORD, FileID, DT_X8 )},
  788. {RECORD_FIELD(IDTABLE_RECORD, ParentGuid, DT_GUID )},
  789. {RECORD_FIELD(IDTABLE_RECORD, ParentFileID, DT_X8 )},
  790. {RECORD_FIELD(IDTABLE_RECORD, VersionNumber, DT_ULONG )},
  791. {RECORD_FIELD(IDTABLE_RECORD, EventTime, DT_FILETIME )},
  792. {RECORD_FIELD(IDTABLE_RECORD, OriginatorGuid, DT_GUID )},
  793. {RECORD_FIELD(IDTABLE_RECORD, OriginatorVSN, DT_X8 )},
  794. {RECORD_FIELD(IDTABLE_RECORD, CurrentFileUsn, DT_USN )},
  795. {RECORD_FIELD(IDTABLE_RECORD, FileCreateTime, DT_FILETIME )},
  796. {RECORD_FIELD(IDTABLE_RECORD, FileWriteTime, DT_FILETIME )},
  797. {RECORD_FIELD(IDTABLE_RECORD, FileSize, DT_X8 )},
  798. {RECORD_FIELD(IDTABLE_RECORD, FileObjID, DT_OBJID )},
  799. {RECORD_FIELD(IDTABLE_RECORD, FileName, DT_UNICODE )},
  800. {RECORD_FIELD(IDTABLE_RECORD, FileIsDir, DT_BOOL )},
  801. {RECORD_FIELD(IDTABLE_RECORD, FileAttributes, DT_FILEATTR )},
  802. {RECORD_FIELD(IDTABLE_RECORD, Flags, DT_IDT_FLAGS )},
  803. {RECORD_FIELD(IDTABLE_RECORD, ReplEnabled, DT_BOOL )},
  804. {RECORD_FIELD(IDTABLE_RECORD, TombStoneGC, DT_FILETIME )},
  805. {RECORD_FIELD(IDTABLE_RECORD, OutLogSeqNum, DT_X8 )},
  806. {RECORD_FIELD(IDTABLE_RECORD, Spare1Ull, DT_X8_SPARE )},
  807. {RECORD_FIELD(IDTABLE_RECORD, Spare2Ull, DT_X8_SPARE )},
  808. {RECORD_FIELD(IDTABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  809. {RECORD_FIELD(IDTABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  810. {RECORD_FIELD(IDTABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE)},
  811. {RECORD_FIELD(IDTABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE)},
  812. {RECORD_FIELD(IDTABLE_RECORD, Extension, DT_IDT_EXTENSION | DT_FIXED_SIZE_BUFFER)},
  813. {RECORD_FIELD(IDTABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )}
  814. };
  815. JET_SETCOLUMN IDTableJetSetCol[IDTABLE_MAX_COL];
  816. JET_RETRIEVECOLUMN IDTableJetRetCol[IDTABLE_MAX_COL];
  817. //
  818. // The IDTable index descriptions are as follows. Note - the order of the
  819. // enum and the table entries must be kept in sync. The Guid is the primary
  820. // key because the FID can change, e.g. Reformat and file restore.
  821. //
  822. // See the comment under the config table index description for the meaning
  823. // and usage of the first character in the index name field.
  824. //
  825. // Name Key KeyLen JIndexGrBits Density
  826. //
  827. JET_INDEXCREATE IDTableIndexDesc[] = {
  828. {CBJIC, "GGuidIndex", "+FileGuid\0", 11, JET_bitIndexUnique |
  829. JET_bitIndexPrimary, 60},
  830. {CBJIC, "QFileIDIndex", "+FileID\0", 9, JET_bitIndexUnique, 60},
  831. {CBJIC, "2GWParGuidFileName", "+ParentGuid\0+FileName\0", 23, 0, 80}
  832. };
  833. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  834. // The key designated as the primary index can't be changed. A Jet rule.
  835. // So don't make fileID a primary index since on a directory restore all the
  836. // file IDs could change and have to be updated.
  837. //
  838. //
  839. // IDRecord Table Flags.
  840. //
  841. FLAG_NAME_TABLE IDRecFlagNameTable[] = {
  842. {IDREC_FLAGS_DELETED , "DELETED " },
  843. {IDREC_FLAGS_CREATE_DEFERRED , "CreDefer " },
  844. {IDREC_FLAGS_DELETE_DEFERRED , "DelDefer " },
  845. {IDREC_FLAGS_RENAME_DEFERRED , "RenDefer " },
  846. {IDREC_FLAGS_NEW_FILE_IN_PROGRESS , "NewFileInProg "},
  847. {IDREC_FLAGS_ENUM_PENDING , "EnumPending " },
  848. {0, NULL}
  849. };
  850. //
  851. // FileAttribute Flags
  852. //
  853. FLAG_NAME_TABLE FileAttrFlagNameTable[] = {
  854. {FILE_ATTRIBUTE_READONLY , "READONLY " },
  855. {FILE_ATTRIBUTE_HIDDEN , "HIDDEN " },
  856. {FILE_ATTRIBUTE_SYSTEM , "SYSTEM " },
  857. {FILE_ATTRIBUTE_DIRECTORY , "DIRECTORY " },
  858. {FILE_ATTRIBUTE_ARCHIVE , "ARCHIVE " },
  859. {FILE_ATTRIBUTE_DEVICE , "DEVICE " },
  860. {FILE_ATTRIBUTE_NORMAL , "NORMAL " },
  861. {FILE_ATTRIBUTE_TEMPORARY , "TEMPORARY " },
  862. {FILE_ATTRIBUTE_SPARSE_FILE , "SPARSE_FILE " },
  863. {FILE_ATTRIBUTE_REPARSE_POINT , "REPARSE_POINT " },
  864. {FILE_ATTRIBUTE_COMPRESSED , "COMPRESSED " },
  865. {FILE_ATTRIBUTE_OFFLINE , "OFFLINE " },
  866. {FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, "NOT_CONTENT_INDEXED "},
  867. {FILE_ATTRIBUTE_ENCRYPTED , "ENCRYPTED " },
  868. {0, NULL}
  869. };
  870. /******************************************************************************
  871. *******************************************************************************
  872. ** **
  873. ** **
  874. ** V V T a b l e **
  875. ** **
  876. ** **
  877. *******************************************************************************
  878. ******************************************************************************/
  879. //
  880. // The VVTable column descriptions are as follows. Note - the order of the
  881. // enum in schema.h and the table entries must be kept in sync.
  882. //
  883. // Note: Buffers are allocated at runtime to hold data for fields with
  884. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  885. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  886. // ColMaxWidth equals the field size in the record struct the data is in the
  887. // record struct and no buffer is allocated.
  888. //
  889. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  890. //
  891. // **** Make sure any escrowed columns have an initial value.
  892. JET_COLUMNCREATE VVTableColDesc[]=
  893. {
  894. {CBJCC, "VVOriginatorGuid",JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  895. {CBJCC, "VVOriginatorVsn", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  896. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  897. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0}
  898. };
  899. //
  900. // The following is used to build the Jet Set Column struct for record read/write.
  901. // The first 2 params build the field offset and size. The 3rd param is the
  902. // data type.
  903. //
  904. //
  905. // *** WARNING ***
  906. //
  907. // If the record structure field size is less than the max column width AND
  908. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  909. // record is assumed to be variable length. The record insert code
  910. // automatically adjusts the length from the record's Size prefix. All
  911. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  912. // fields that are variable length which don't have a size prefix like
  913. // FSVolInfo in the config record. But these fields MUST have a unique / non
  914. // binary data type assigned to them. Failure to do this causes the insert
  915. // routines to stuff things up to ColMaxWidth bytes into the database.
  916. //
  917. RECORD_FIELDS VVTableRecordFields[] = {
  918. {sizeof(VVTABLE_RECORD) , 0, VVTABLE_MAX_COL },
  919. {RECORD_FIELD(VVTABLE_RECORD, VVOriginatorGuid, DT_GUID )},
  920. {RECORD_FIELD(VVTABLE_RECORD, VVOriginatorVsn, DT_X8 )},
  921. {RECORD_FIELD(VVTABLE_RECORD, Spare1Ull, DT_LONGLONG_SPARE)},
  922. {RECORD_FIELD(VVTABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)}
  923. };
  924. JET_SETCOLUMN VVTableJetSetCol[VVTABLE_MAX_COL];
  925. JET_RETRIEVECOLUMN VVTableJetRetCol[VVTABLE_MAX_COL];
  926. //
  927. // The VVTable index descriptions are as follows. Note - the order of the
  928. // enum and the table entries must be kept in sync.
  929. //
  930. //
  931. // See the comment under the config table index description for the meaning
  932. // and usage of the first character in the index name field.
  933. //
  934. // Name Key KeyLen JIndexGrBits Density
  935. //
  936. JET_INDEXCREATE VVTableIndexDesc[] = {
  937. {CBJIC, "GVVGuidIndex", "+VVOriginatorGuid\0", 19, JET_bitIndexUnique |
  938. JET_bitIndexPrimary, 80}
  939. };
  940. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  941. // The key designated as the primary index can't be changed. A Jet rule.
  942. // So on a directory restore all the directory file IDs can change and
  943. // the records have to be deleted and the table reconstructed.
  944. //
  945. /******************************************************************************
  946. *******************************************************************************
  947. ** **
  948. ** **
  949. ** R E P L I C A S E T C O N F I G T A B L E **
  950. ** **
  951. ** **
  952. *******************************************************************************
  953. ******************************************************************************/
  954. //
  955. //
  956. // Note: Order of entries must track enum in schema.h
  957. //
  958. // There is only one config table in the database. Each row in the table
  959. // describes the configuration info for a single replica set.
  960. //
  961. // Note: Buffers are allocated at runtime to hold data for fields with
  962. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  963. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  964. // ColMaxWidth equals the field size in the record struct the data is in the
  965. // record struct and no buffer is allocated.
  966. //
  967. //
  968. // Name ColType ColMaxWidth JColGrBits pvDefault cbDefault
  969. //
  970. JET_COLUMNCREATE ConfigTableColDesc[]=
  971. {
  972. {CBJCC, "ReplicaSetGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  973. {CBJCC, "ReplicaMemberGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  974. {CBJCC, "ReplicaSetName", JET_coltypText , 2*(DNS_MAX_NAME_LENGTH+1),
  975. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  976. {CBJCC, "ReplicaNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  977. {CBJCC, "ReplicaMemberUSN", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  978. {CBJCC, "ReplicaMemberName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  979. {CBJCC, "ReplicaMemberDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  980. {CBJCC, "ReplicaServerDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  981. {CBJCC, "ReplicaSubscriberDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  982. {CBJCC, "ReplicaRootGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  983. {CBJCC, "MembershipExpires", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  984. {CBJCC, "ReplicaVersionGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  985. {CBJCC, "ReplicaSetExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  986. {CBJCC, "ReplicaMemberExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  987. {CBJCC, "ReplicaSubscriberExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  988. {CBJCC, "ReplicaSubscriptionsExt", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  989. {CBJCC, "ReplicaSetType", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  990. {CBJCC, "ReplicaSetFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  991. {CBJCC, "ReplicaMemberFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  992. {CBJCC, "ReplicaSubscriberFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  993. {CBJCC, "ReplicaDsPoll", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  994. {CBJCC, "ReplicaAuthLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  995. {CBJCC, "ReplicaCtlDataCreation", JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  996. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  997. {CBJCC, "ReplicaCtlInboundBacklog",JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  998. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  999. {CBJCC, "ReplicaCtlOutboundBacklog",JET_coltypText , 2*(CONTROL_STRING_MAX+1),
  1000. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1001. {CBJCC, "ReplicaFaultCondition", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1002. {CBJCC, "TimeLastCommand", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1003. {CBJCC, "DSConfigVersionNumber", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1004. {CBJCC, "FSVolInfo", JET_coltypBinary , sizeof(FILE_FS_VOLUME_INFORMATION)+MAXIMUM_VOLUME_LABEL_LENGTH,
  1005. 0 , NULL, 0},
  1006. {CBJCC, "FSVolGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1007. {CBJCC, "FSVolLastUSN", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1008. {CBJCC, "FrsVsn", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1009. {CBJCC, "LastShutdown", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1010. {CBJCC, "LastPause", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1011. {CBJCC, "LastDSCheck", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1012. {CBJCC, "LastDSChangeAccepted", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1013. {CBJCC, "LastReplCycleStart", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1014. {CBJCC, "DirLastReplCycleEnded", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1015. {CBJCC, "ReplicaDeleteTime", JET_coltypCurrency , 8, JET_bitColumnFixed, NULL, 0},
  1016. {CBJCC, "LastReplCycleStatus", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1017. {CBJCC, "FSRootPath", JET_coltypLongText , 2*(MAX_PATH+1),
  1018. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1019. {CBJCC, "FSRootSD", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1020. {CBJCC, "FSStagingAreaPath", JET_coltypLongText , 2*(MAX_PATH+1),
  1021. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1022. {CBJCC, "SnapFileSizeLimit", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1023. {CBJCC, "ActiveServCntlCommand", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1024. {CBJCC, "ServiceState", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1025. {CBJCC, "ReplDirLevelLimit", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1026. {CBJCC, "InboundPartnerState", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1027. {CBJCC, "DsInfo", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1028. {CBJCC, "CnfFlags", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1029. {CBJCC, "AdminAlertList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1030. {CBJCC, "ThrottleSched", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1031. {CBJCC, "ReplSched", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1032. {CBJCC, "FileTypePrioList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1033. {CBJCC, "ResourceStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1034. {CBJCC, "PerfStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1035. {CBJCC, "ErrorStats", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1036. {CBJCC, "FileFilterList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1037. {CBJCC, "DirFilterList", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1038. {CBJCC, "TombstoneLife", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1039. {CBJCC, "GarbageCollPeriod", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1040. {CBJCC, "MaxOutBoundLogSize", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1041. {CBJCC, "MaxInBoundLogSize", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1042. {CBJCC, "UpdateBlockedTime", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1043. {CBJCC, "EventTimeDiffThreshold", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1044. {CBJCC, "FileCopyWarningLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1045. {CBJCC, "FileSizeWarningLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1046. {CBJCC, "FileSizeNoRepLevel", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1047. {CBJCC, "CnfUsnJournalID", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1048. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1049. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1050. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1051. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1052. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1053. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1054. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1055. //
  1056. // Everything below this line is present only in the FRS <init> record.
  1057. // Everything above is per-replica state.
  1058. //
  1059. // Future: move the following to the Service Table and then remove from config record.
  1060. {CBJCC, "MachineName", JET_coltypText , 2*(MAX_RDN_VALUE_SIZE+1),
  1061. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1062. {CBJCC, "MachineGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1063. {CBJCC, "MachineDnsName", JET_coltypLongText , 2*(DNS_MAX_NAME_LENGTH+1),
  1064. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1065. {CBJCC, "TableVersionNumbers", JET_coltypBinary , SIZEOF(CONFIG_TABLE_RECORD, TableVersionNumbers),
  1066. JET_bitColumnFixed, NULL, 0},
  1067. {CBJCC, "FSDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1068. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1069. {CBJCC, "FSBackupDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1070. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1071. {CBJCC, "ReplicaNetBiosName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1072. {CBJCC, "ReplicaPrincName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1073. {CBJCC, "ReplicaCoDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1074. {CBJCC, "ReplicaCoGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1075. {CBJCC, "ReplicaWorkingPath", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1076. {CBJCC, "ReplicaVersion", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1077. {CBJCC, "FrsDbMajor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1078. {CBJCC, "FrsDbMinor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1079. {CBJCC, "JetParameters", JET_coltypLongBinary, sizeof(JET_SYSTEM_PARAMS),
  1080. 0 , NULL, 0}
  1081. };
  1082. //
  1083. // The following is used to build the Jet Set Column struct for record read/write.
  1084. // The first 2 params build the field offset and size. The 3rd param is the
  1085. // data type.
  1086. //
  1087. //
  1088. // *** WARNING ***
  1089. //
  1090. // If the record structure field size is less than the max column width AND
  1091. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  1092. // record is assumed to be variable length. The record insert code
  1093. // automatically adjusts the length from the record's Size prefix. All
  1094. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  1095. // fields that are variable length which don't have a size prefix like
  1096. // FSVolInfo in the config record. But these fields MUST have a unique / non
  1097. // binary data type assigned to them. Failure to do this causes the insert
  1098. // routines to stuff things up to ColMaxWidth bytes into the database.
  1099. //
  1100. RECORD_FIELDS ConfigTableRecordFields[] = {
  1101. {sizeof(CONFIG_TABLE_RECORD) , 0, CONFIG_TABLE_MAX_COL },
  1102. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetGuid, DT_GUID )},
  1103. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberGuid, DT_GUID )},
  1104. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetName, DT_UNICODE )},
  1105. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaNumber, DT_ULONG )},
  1106. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberUSN, DT_X8 )},
  1107. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberName, DT_UNICODE )},
  1108. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberDn, DT_UNICODE )},
  1109. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaServerDn, DT_UNICODE )},
  1110. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberDn, DT_UNICODE )},
  1111. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaRootGuid, DT_GUID )},
  1112. {RECORD_FIELD(CONFIG_TABLE_RECORD, MembershipExpires, DT_FILETIME )},
  1113. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaVersionGuid, DT_GUID )},
  1114. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetExt, DT_BINARY )},
  1115. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberExt, DT_BINARY )},
  1116. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberExt, DT_BINARY )},
  1117. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriptionsExt, DT_BINARY )},
  1118. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetType, DT_ULONG )},
  1119. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSetFlags, DT_ULONG )},
  1120. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaMemberFlags, DT_ULONG )},
  1121. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaSubscriberFlags,DT_ULONG )},
  1122. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaDsPoll, DT_ULONG )},
  1123. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaAuthLevel, DT_ULONG )},
  1124. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlDataCreation, DT_UNICODE )},
  1125. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlInboundBacklog, DT_UNICODE )},
  1126. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCtlOutboundBacklog, DT_UNICODE )},
  1127. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaFaultCondition, DT_ULONG )},
  1128. {RECORD_FIELD(CONFIG_TABLE_RECORD, TimeLastCommand, DT_FILETIME )},
  1129. {RECORD_FIELD(CONFIG_TABLE_RECORD, DSConfigVersionNumber, DT_ULONG )},
  1130. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolInfo, DT_FSVOLINFO )},
  1131. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolGuid, DT_GUID )},
  1132. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSVolLastUSN, DT_USN )},
  1133. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsVsn, DT_X8 )},
  1134. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastShutdown, DT_FILETIME )},
  1135. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastPause, DT_FILETIME )},
  1136. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastDSCheck, DT_FILETIME )},
  1137. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastDSChangeAccepted, DT_FILETIME )},
  1138. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastReplCycleStart, DT_FILETIME )},
  1139. {RECORD_FIELD(CONFIG_TABLE_RECORD, DirLastReplCycleEnded, DT_FILETIME )},
  1140. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaDeleteTime, DT_FILETIME )},
  1141. {RECORD_FIELD(CONFIG_TABLE_RECORD, LastReplCycleStatus, DT_ULONG )},
  1142. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSRootPath, DT_UNICODE )},
  1143. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSRootSD, DT_BINARY )},
  1144. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSStagingAreaPath, DT_UNICODE )},
  1145. {RECORD_FIELD(CONFIG_TABLE_RECORD, SnapFileSizeLimit, DT_LONG )},
  1146. {RECORD_FIELD(CONFIG_TABLE_RECORD, ActiveServCntlCommand, DT_BINARY )},
  1147. {RECORD_FIELD(CONFIG_TABLE_RECORD, ServiceState, DT_LONG )},
  1148. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplDirLevelLimit, DT_LONG )},
  1149. {RECORD_FIELD(CONFIG_TABLE_RECORD, InboundPartnerState, DT_BINARY )},
  1150. {RECORD_FIELD(CONFIG_TABLE_RECORD, DsInfo, DT_BINARY )},
  1151. {RECORD_FIELD(CONFIG_TABLE_RECORD, CnfFlags, DT_ULONG )},
  1152. {RECORD_FIELD(CONFIG_TABLE_RECORD, AdminAlertList, DT_UNICODE )},
  1153. {RECORD_FIELD(CONFIG_TABLE_RECORD, ThrottleSched, DT_BINARY )},
  1154. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplSched, DT_BINARY )},
  1155. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileTypePrioList, DT_UNICODE )},
  1156. {RECORD_FIELD(CONFIG_TABLE_RECORD, ResourceStats, DT_BINARY )},
  1157. {RECORD_FIELD(CONFIG_TABLE_RECORD, PerfStats, DT_BINARY )},
  1158. {RECORD_FIELD(CONFIG_TABLE_RECORD, ErrorStats, DT_BINARY )},
  1159. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileFilterList, DT_UNICODE )},
  1160. {RECORD_FIELD(CONFIG_TABLE_RECORD, DirFilterList, DT_UNICODE )},
  1161. {RECORD_FIELD(CONFIG_TABLE_RECORD, TombstoneLife, DT_ULONG )},
  1162. {RECORD_FIELD(CONFIG_TABLE_RECORD, GarbageCollPeriod, DT_ULONG )},
  1163. {RECORD_FIELD(CONFIG_TABLE_RECORD, MaxOutBoundLogSize, DT_ULONG )},
  1164. {RECORD_FIELD(CONFIG_TABLE_RECORD, MaxInBoundLogSize, DT_ULONG )},
  1165. {RECORD_FIELD(CONFIG_TABLE_RECORD, UpdateBlockedTime, DT_ULONG )},
  1166. {RECORD_FIELD(CONFIG_TABLE_RECORD, EventTimeDiffThreshold,DT_ULONG )},
  1167. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileCopyWarningLevel, DT_ULONG )},
  1168. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileSizeWarningLevel, DT_ULONG )},
  1169. {RECORD_FIELD(CONFIG_TABLE_RECORD, FileSizeNoRepLevel, DT_ULONG )},
  1170. {RECORD_FIELD(CONFIG_TABLE_RECORD, CnfUsnJournalID, DT_X8 )},
  1171. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  1172. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  1173. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  1174. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  1175. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  1176. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare1Bin, DT_BINARY_SPARE )},
  1177. {RECORD_FIELD(CONFIG_TABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  1178. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineName, DT_UNICODE )},
  1179. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineGuid, DT_GUID )},
  1180. {RECORD_FIELD(CONFIG_TABLE_RECORD, MachineDnsName, DT_UNICODE )},
  1181. {RECORD_FIELD(CONFIG_TABLE_RECORD, TableVersionNumbers, DT_BINARY )},
  1182. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSDatabasePath, DT_UNICODE )},
  1183. {RECORD_FIELD(CONFIG_TABLE_RECORD, FSBackupDatabasePath, DT_UNICODE )},
  1184. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaNetBiosName, DT_UNICODE )},
  1185. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaPrincName, DT_UNICODE )},
  1186. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCoDn, DT_UNICODE )},
  1187. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaCoGuid, DT_GUID )},
  1188. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaWorkingPath, DT_UNICODE )},
  1189. {RECORD_FIELD(CONFIG_TABLE_RECORD, ReplicaVersion, DT_UNICODE )},
  1190. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsDbMajor, DT_ULONG )},
  1191. {RECORD_FIELD(CONFIG_TABLE_RECORD, FrsDbMinor, DT_ULONG )},
  1192. {RECORD_FIELD(CONFIG_TABLE_RECORD, JetParameters, DT_BINARY )}
  1193. };
  1194. JET_SETCOLUMN ConfigTableJetSetCol[CONFIG_TABLE_MAX_COL];
  1195. JET_RETRIEVECOLUMN ConfigTableJetRetCol[CONFIG_TABLE_MAX_COL];
  1196. //
  1197. // The ConfigTable index descriptions are as follows. Note - the order of the
  1198. // enum in schema.h and the table entries must be kept in sync.
  1199. //
  1200. // If the first character of the Index Name is a digit then this index is
  1201. // composed of n keys. The following n characters tell us how to compute
  1202. // the keylength for each component. E.G. a 2 key index on a Guid and a
  1203. // Long binary would have a name prefix of "2GL...".
  1204. // If the first character is not a digit then this is a single key index
  1205. // and the first character is the key length code as follows:
  1206. //
  1207. // L: Long binary length is 4 bytes
  1208. // Q: Quad binary length is 8 bytes
  1209. // G: 16 byte GUID length is 16 bytes
  1210. // W: Wide Char length is 2 * _wcslen
  1211. // C: Narrow Char length is _strlen
  1212. //
  1213. // Name Key KeyLen JIndexGrBits Density
  1214. //
  1215. JET_INDEXCREATE ConfigTableIndexDesc[] = {
  1216. {CBJIC, "LReplicaNumberIndex", "+ReplicaNumber\0" ,16, JET_bitIndexUnique |
  1217. JET_bitIndexPrimary, 80},
  1218. {CBJIC, "GReplicaMemberGuidIndex","+ReplicaMemberGuid\0",20, JET_bitIndexUnique, 80},
  1219. {CBJIC, "WReplicaSetNameIndex", "+ReplicaSetName\0" ,17, 0 , 80}
  1220. };
  1221. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  1222. // The key designated as the primary index can't be changed. A Jet rule.
  1223. //
  1224. /******************************************************************************
  1225. *******************************************************************************
  1226. ** **
  1227. ** **
  1228. ** S e r v i c e T a b l e **
  1229. ** **
  1230. ** **
  1231. *******************************************************************************
  1232. ******************************************************************************/
  1233. //
  1234. // There is only one Service table in the database. It has a single record
  1235. // with service specific params that apply to all replica sets.
  1236. // The ServiceTable column descriptions are as follows. Note - the order of the
  1237. // enum in schema.h and the table entries must be kept in sync.
  1238. //
  1239. // Note: Buffers are allocated at runtime to hold data for fields with
  1240. // a ColMaxWidth greater than 4 bytes where the field def in the corresponding
  1241. // record struct is 4 bytes (i.e. it holds a pointer). For fields where the
  1242. // ColMaxWidth equals the field size in the record struct the data is in the
  1243. // record struct and no buffer is allocated.
  1244. //
  1245. // Name ColType ColMaxWidth GrBits pvDefault cbDefault
  1246. //
  1247. // **** Make sure any escrowed columns have an initial value.
  1248. JET_COLUMNCREATE ServiceTableColDesc[]=
  1249. {
  1250. {CBJCC, "FrsDbMajor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1251. {CBJCC, "FrsDbMinor", JET_coltypLong , 4, JET_bitColumnFixed, NULL, 0},
  1252. {CBJCC, "MachineName", JET_coltypText , 2*(MAX_RDN_VALUE_SIZE+1),
  1253. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1254. {CBJCC, "MachineGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1255. {CBJCC, "MachineDnsName", JET_coltypLongText , 2*(DNS_MAX_NAME_LENGTH+1),
  1256. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1257. {CBJCC, "TableVersionNumbers", JET_coltypBinary , SIZEOF(CONFIG_TABLE_RECORD, TableVersionNumbers),
  1258. JET_bitColumnFixed, NULL, 0},
  1259. {CBJCC, "FSDatabasePath", JET_coltypLongText , 2*(MAX_PATH+1),
  1260. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1261. {CBJCC, "FSBackupDatabasePath",JET_coltypLongText , 2*(MAX_PATH+1),
  1262. 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1263. {CBJCC, "ReplicaNetBiosName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1264. {CBJCC, "ReplicaPrincName", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1265. {CBJCC, "ReplicaCoDn", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1266. {CBJCC, "ReplicaCoGuid", JET_coltypBinary , 16, JET_bitColumnFixed, NULL, 0},
  1267. {CBJCC, "ReplicaWorkingPath", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1268. {CBJCC, "ReplicaVersion", JET_coltypLongText , MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1269. {CBJCC, "Spare1Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1270. {CBJCC, "Spare2Ull", JET_coltypCurrency, 8, JET_bitColumnFixed, NULL, 0},
  1271. {CBJCC, "Spare1Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1272. {CBJCC, "Spare2Guid", JET_coltypBinary, 16, JET_bitColumnFixed, NULL, 0},
  1273. {CBJCC, "Spare1Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1274. {CBJCC, "Spare2Wcs", JET_coltypLongText, MB2, 0 , NULL, 0, CP_UNICODE_FOR_JET},
  1275. {CBJCC, "Spare1Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1276. {CBJCC, "Spare2Bin", JET_coltypLongBinary, MB2, 0 , NULL, 0},
  1277. {CBJCC, "JetParameters", JET_coltypLongBinary, sizeof(JET_SYSTEM_PARAMS),
  1278. 0 , NULL, 0}
  1279. };
  1280. //
  1281. // The following is used to build the Jet Set Column struct for record read/write.
  1282. // The first 2 params build the field offset and size. The 3rd param is the
  1283. // data type.
  1284. //
  1285. //
  1286. // *** WARNING ***
  1287. //
  1288. // If the record structure field size is less than the max column width AND
  1289. // is big enough to hold a pointer AND has a datatype of DT_BINARY then the
  1290. // record is assumed to be variable length. The record insert code
  1291. // automatically adjusts the length from the record's Size prefix. All
  1292. // DT_BINARY fields MUST BE prefixed with a ULONG SIZE. There are some
  1293. // fields that are variable length which don't have a size prefix like
  1294. // FSVolInfo in the config record. But these fields MUST have a unique / non
  1295. // binary data type assigned to them. Failure to do this causes the insert
  1296. // routines to stuff things up to ColMaxWidth bytes into the database.
  1297. //
  1298. RECORD_FIELDS ServiceTableRecordFields[] = {
  1299. {sizeof(SERVICE_TABLE_RECORD) , 0, SERVICE_TABLE_MAX_COL },
  1300. {RECORD_FIELD(SERVICE_TABLE_RECORD, FrsDbMajor, DT_ULONG )},
  1301. {RECORD_FIELD(SERVICE_TABLE_RECORD, FrsDbMinor, DT_ULONG )},
  1302. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineName, DT_UNICODE )},
  1303. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineGuid, DT_GUID )},
  1304. {RECORD_FIELD(SERVICE_TABLE_RECORD, MachineDnsName, DT_UNICODE )},
  1305. {RECORD_FIELD(SERVICE_TABLE_RECORD, TableVersionNumbers, DT_BINARY )},
  1306. {RECORD_FIELD(SERVICE_TABLE_RECORD, FSDatabasePath, DT_UNICODE )},
  1307. {RECORD_FIELD(SERVICE_TABLE_RECORD, FSBackupDatabasePath, DT_UNICODE )},
  1308. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaNetBiosName, DT_UNICODE )},
  1309. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaPrincName, DT_UNICODE )},
  1310. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaCoDn, DT_UNICODE )},
  1311. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaCoGuid, DT_GUID )},
  1312. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaWorkingPath, DT_UNICODE )},
  1313. {RECORD_FIELD(SERVICE_TABLE_RECORD, ReplicaVersion, DT_UNICODE )},
  1314. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Ull, DT_LONGLONG_SPARE)},
  1315. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Ull, DT_LONGLONG_SPARE)},
  1316. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Guid, DT_GUID_SPARE )},
  1317. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Guid, DT_GUID_SPARE )},
  1318. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Wcs, DT_UNICODE_SPARE )},
  1319. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Wcs, DT_UNICODE_SPARE )},
  1320. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare1Bin, DT_BINARY_SPARE )},
  1321. {RECORD_FIELD(SERVICE_TABLE_RECORD, Spare2Bin, DT_BINARY_SPARE )},
  1322. {RECORD_FIELD(SERVICE_TABLE_RECORD, JetParameters, DT_BINARY )}
  1323. };
  1324. JET_SETCOLUMN ServiceTableJetSetCol[SERVICE_TABLE_MAX_COL];
  1325. JET_RETRIEVECOLUMN ServiceTableJetRetCol[SERVICE_TABLE_MAX_COL];
  1326. //
  1327. // The Service Table index descriptions are as follows. Note - the order of the
  1328. // enum and the table entries must be kept in sync.
  1329. //
  1330. //
  1331. // See the comment under the config table index description for the meaning
  1332. // and usage of the first character in the index name field.
  1333. //
  1334. // Name Key KeyLen JIndexGrBits Density
  1335. //
  1336. JET_INDEXCREATE ServiceTableIndexDesc[] = {
  1337. {CBJIC, "LFrsDbMajor", "+FrsDbMajor\0", 13, JET_bitIndexPrimary, 80}
  1338. };
  1339. // Note - Key must have a double null at the end. KeyLen includes this extra null.
  1340. // The key designated as the primary index can't be changed. A Jet rule.
  1341. // So on a directory restore all the directory file IDs can change and
  1342. // the records have to be deleted and the table reconstructed.
  1343. //
  1344. //
  1345. // The TableVersionNumbers array as saved in the init record when new tables
  1346. // are created. This is used to detect a mismatch between a database and
  1347. // the version of FRS running.
  1348. //
  1349. ULONG TableVersionNumbers[FRS_MAX_TABLE_TYPES]=
  1350. {
  1351. VersionCount,
  1352. VersionINLOGTable,
  1353. VersionOUTLOGTable,
  1354. VersionIDTable,
  1355. VersionDIRTable,
  1356. VersionVVTable,
  1357. VersionCXTIONTable,
  1358. VersionConfigTable,
  1359. VersionServiceTable,
  1360. 0, 0, 0, 0, 0, 0, 0
  1361. };
  1362. /******************************************************************************
  1363. *******************************************************************************
  1364. ** **
  1365. ** **
  1366. ** 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 **
  1367. ** **
  1368. ** **
  1369. *******************************************************************************
  1370. ******************************************************************************/
  1371. //
  1372. // The list of Jet Tables created for each replica set are as follows.
  1373. // Note - the order of the enum in schema.h and the table entries and the
  1374. // table property entries must be kept in sync.
  1375. //
  1376. #define CBJTC sizeof(JET_TABLECREATE)
  1377. #define INIT_INBOUND_LOG_TABLE_PAGES 50
  1378. #define INIT_INBOUND_LOG_TABLE_DENSITY 90
  1379. #define INIT_OUTBOUND_LOG_TABLE_PAGES 50
  1380. #define INIT_OUTBOUND_LOG_TABLE_DENSITY 90
  1381. #define INIT_IDTABLE_PAGES 50
  1382. #define INIT_IDTABLE_DENSITY 60
  1383. #define INIT_DIRTABLE_PAGES 10
  1384. #define INIT_DIRTABLE_DENSITY 80
  1385. #define INIT_VVTABLE_PAGES 1
  1386. #define INIT_VVTABLE_DENSITY 80
  1387. #define INIT_CXTIONTABLE_PAGES 2
  1388. #define INIT_CXTIONTABLE_DENSITY 90
  1389. #define INIT_CONFIG_PAGES 10
  1390. #define INIT_CONFIG_DENSITY 90
  1391. #define INIT_SERVICE_PAGES 4
  1392. #define INIT_SERVICE_DENSITY 90
  1393. typedef struct ___tagJET_TABLECREATE // from Jet header for ref only.
  1394. {
  1395. ULONG cbStruct; // size of this structure
  1396. CHAR *szTableName; // name of table to create.
  1397. CHAR *szTemplateTableName; // name of table from which to inherit base DDL
  1398. ULONG ulPages; // initial pages to allocate for table.
  1399. ULONG ulDensity; // table density.
  1400. JET_COLUMNCREATE *rgcolumncreate; // array of column creation info
  1401. ULONG cColumns; // number of columns to create
  1402. JET_INDEXCREATE *rgindexcreate; // array of index creation info
  1403. ULONG cIndexes; // number of indexes to create
  1404. JET_GRBIT grbit; // JET_bitTableCreateTemplateTable when creating template
  1405. // JET_bitTableCreateFixedDDL when creating derived table.
  1406. JET_TABLEID tableid; // returned tableid.
  1407. ULONG cCreated; // count of objects created (columns+table+indexes).
  1408. } ___JET_TABLECREATE;
  1409. JET_TABLECREATE DBTables[] = {
  1410. {CBJTC, "INLOGTable", NULL, INIT_INBOUND_LOG_TABLE_PAGES, INIT_INBOUND_LOG_TABLE_DENSITY,
  1411. ILChangeOrderTableColDesc, CHANGE_ORDER_MAX_COL, ILChangeOrderIndexDesc, ILCHANGE_ORDER_MAX_INDEX,
  1412. JET_bitTableCreateTemplateTable},
  1413. {CBJTC, "OUTLOGTable", NULL, INIT_OUTBOUND_LOG_TABLE_PAGES, INIT_OUTBOUND_LOG_TABLE_DENSITY,
  1414. OLChangeOrderTableColDesc, CHANGE_ORDER_MAX_COL, OLChangeOrderIndexDesc, OLCHANGE_ORDER_MAX_INDEX,
  1415. JET_bitTableCreateTemplateTable},
  1416. {CBJTC, "IDTable", NULL, INIT_IDTABLE_PAGES, INIT_IDTABLE_DENSITY,
  1417. IDTableColDesc, IDTABLE_MAX_COL, IDTableIndexDesc, IDTABLE_MAX_INDEX,
  1418. JET_bitTableCreateTemplateTable},
  1419. {CBJTC, "DIRTable", NULL, INIT_DIRTABLE_PAGES, INIT_DIRTABLE_DENSITY,
  1420. DIRTableColDesc, DIRTABLE_MAX_COL, DIRTableIndexDesc, DIRTABLE_MAX_INDEX,
  1421. JET_bitTableCreateTemplateTable},
  1422. {CBJTC, "VVTable", NULL, INIT_VVTABLE_PAGES, INIT_VVTABLE_DENSITY,
  1423. VVTableColDesc, VVTABLE_MAX_COL, VVTableIndexDesc, VVTABLE_MAX_INDEX,
  1424. JET_bitTableCreateTemplateTable},
  1425. {CBJTC, "CXTIONTable", NULL, INIT_CXTIONTABLE_PAGES, INIT_CXTIONTABLE_DENSITY,
  1426. CXTIONTableColDesc, CXTION_TABLE_MAX_COL, CXTIONTableIndexDesc, CXTION_TABLE_MAX_INDEX,
  1427. JET_bitTableCreateTemplateTable},
  1428. //
  1429. // set rgcolumncreate to ConfigTableColDesc so init is simpler.
  1430. //
  1431. {CBJTC, "Unused", NULL, 0, 0, ConfigTableColDesc, 0, NULL, 0, 0},
  1432. {CBJTC, "ConfigTable", NULL, INIT_CONFIG_PAGES, INIT_CONFIG_DENSITY,
  1433. ConfigTableColDesc, CONFIG_TABLE_MAX_COL,
  1434. ConfigTableIndexDesc, CONFIG_TABLE_MAX_INDEX,
  1435. JET_bitTableCreateFixedDDL},
  1436. {CBJTC, "ServiceTable", NULL, INIT_SERVICE_PAGES, INIT_SERVICE_DENSITY,
  1437. ServiceTableColDesc, SERVICE_TABLE_MAX_COL,
  1438. ServiceTableIndexDesc, SERVICE_TABLE_MAX_INDEX,
  1439. JET_bitTableCreateFixedDDL}
  1440. };
  1441. //
  1442. // The following describes some properties of each defined table in the schema.
  1443. // This is used mainly for initialization.
  1444. //
  1445. // Name RecordFields Flags
  1446. FRS_TABLE_PROPERTIES FrsTableProperties[] = {
  1447. {"INLOGTable", ILChangeOrderRecordFields, FRS_TPF_NONE },
  1448. {"OUTLOGTable", OLChangeOrderRecordFields, FRS_TPF_NONE },
  1449. {"IDTable", IDTableRecordFields , FRS_TPF_NONE },
  1450. {"DIRTable", DIRTableRecordFields , FRS_TPF_NONE },
  1451. {"VVTable", VVTableRecordFields , FRS_TPF_NONE },
  1452. {"CXTIONTable", CXTIONTableRecordFields , FRS_TPF_NONE },
  1453. {"Unused", NULL , 0 }, // Gap between single instance tables.
  1454. {"ConfigTable", ConfigTableRecordFields , FRS_TPF_SINGLE},
  1455. {"ServiceTable", ServiceTableRecordFields , FRS_TPF_SINGLE}
  1456. };
  1457. /******************************************************************************
  1458. *******************************************************************************
  1459. ** **
  1460. ** **
  1461. ** J E T S Y S T E M P A R A M E T E R S T A B L E **
  1462. ** **
  1463. ** **
  1464. *******************************************************************************
  1465. ******************************************************************************/
  1466. //
  1467. // Definition of the Jet system parameters stored in config record.
  1468. // If you add or delete a parameter adjust MAX_JET_SYSTEM_PARAMS accordingly.
  1469. //
  1470. JET_SYSTEM_PARAMS JetSystemParamsDef = {
  1471. sizeof(JET_SYSTEM_PARAMS) ,
  1472. {
  1473. {"SystemPath ", JET_paramSystemPath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, ChkPointFilePath) },
  1474. {"TempPath ", JET_paramTempPath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, TempFilePath) },
  1475. {"LogFilePath ", JET_paramLogFilePath , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, LogFilePath) },
  1476. {"BaseName ", JET_paramBaseName , JPARAM_TYPE_SKIP, 0 },
  1477. {"EventSource ", JET_paramEventSource , JPARAM_TYPE_STRING, OFFSET(JET_SYSTEM_PARAMS, EventSource) },
  1478. {"MaxSessions ", JET_paramMaxSessions , JPARAM_TYPE_LONG, 200 },
  1479. {"MaxOpenTables ", JET_paramMaxOpenTables , JPARAM_TYPE_SKIP, 0 },
  1480. {"PreferredMaxOpenTables", JET_paramPreferredMaxOpenTables, JPARAM_TYPE_SKIP, 0 },
  1481. {"MaxCursors ", JET_paramMaxCursors , JPARAM_TYPE_SKIP, 0 },
  1482. {"MaxVerPages ", JET_paramMaxVerPages , JPARAM_TYPE_SKIP, 0 },
  1483. {"MaxTemporaryTables ", JET_paramMaxTemporaryTables , JPARAM_TYPE_SKIP, 0 },
  1484. {"LogFileSize ", JET_paramLogFileSize , JPARAM_TYPE_SKIP, 0 },
  1485. {"LogBuffers ", JET_paramLogBuffers , JPARAM_TYPE_SKIP, 0 },
  1486. {"WaitLogFlush ", JET_paramWaitLogFlush , JPARAM_TYPE_SKIP, 0 },
  1487. {"LogCheckpointPeriod ", JET_paramLogCheckpointPeriod , JPARAM_TYPE_SKIP, 0 },
  1488. {"LogWaitingUserMax ", JET_paramLogWaitingUserMax , JPARAM_TYPE_SKIP, 0 },
  1489. {"CommitDefault ", JET_paramCommitDefault , JPARAM_TYPE_SKIP, 0 },
  1490. {"CircularLog ", JET_paramCircularLog , JPARAM_TYPE_SKIP, 0 },
  1491. {"DbExtensionSize ", JET_paramDbExtensionSize , JPARAM_TYPE_SKIP, 0 },
  1492. {"PageTempDBMin ", JET_paramPageTempDBMin , JPARAM_TYPE_SKIP, 0 },
  1493. {"PageFragment ", JET_paramPageFragment , JPARAM_TYPE_SKIP, 0 },
  1494. {"PageReadAheadMax ", JET_paramPageReadAheadMax , JPARAM_TYPE_SKIP, 0 },
  1495. {"BatchIOBufferMax ", JET_paramBatchIOBufferMax , JPARAM_TYPE_SKIP, 0 },
  1496. {"CacheSize ", JET_paramCacheSize , JPARAM_TYPE_SKIP, 0 },
  1497. {"CacheSizeMax ", JET_paramCacheSizeMax , JPARAM_TYPE_SKIP, 0 },
  1498. {"CheckpointDepthMax ", JET_paramCheckpointDepthMax , JPARAM_TYPE_SKIP, 0 },
  1499. {"LRUKCorrInterval ", JET_paramLRUKCorrInterval , JPARAM_TYPE_SKIP, 0 },
  1500. {"LRUKHistoryMax ", JET_paramLRUKHistoryMax , JPARAM_TYPE_SKIP, 0 },
  1501. {"LRUKPolicy ", JET_paramLRUKPolicy , JPARAM_TYPE_SKIP, 0 },
  1502. {"LRUKTimeout ", JET_paramLRUKTimeout , JPARAM_TYPE_SKIP, 0 },
  1503. {"LRUKTrxCorrInterval ", JET_paramLRUKTrxCorrInterval , JPARAM_TYPE_SKIP, 0 },
  1504. {"OutstandingIOMax ", JET_paramOutstandingIOMax , JPARAM_TYPE_SKIP, 0 },
  1505. {"StartFlushThreshold ", JET_paramStartFlushThreshold , JPARAM_TYPE_SKIP, 0 },
  1506. {"StopFlushThreshold ", JET_paramStopFlushThreshold , JPARAM_TYPE_SKIP, 0 },
  1507. {"TableClassName ", JET_paramTableClassName , JPARAM_TYPE_SKIP, 0 },
  1508. {"ExceptionAction ", JET_paramExceptionAction , JPARAM_TYPE_SKIP, 0 },
  1509. {"EventLogCache ", JET_paramEventLogCache , JPARAM_TYPE_SKIP, 0 },
  1510. {"end ", 0 , JPARAM_TYPE_LAST, 0 },
  1511. },
  1512. "", // CHAR ChkPointFilePath[MAX_PATH];
  1513. "", // CHAR TempFilePath[MAX_PATH];
  1514. "", // CHAR LogFilePath[MAX_PATH];
  1515. "FileReplSvc " // CHAR EventSource[20];
  1516. };
  1517. #if 0
  1518. //
  1519. // The Jet97 aka Jet500 system parameters and defaults are shown below
  1520. // for reference only. See the Jet header file for the latest info.
  1521. //
  1522. JET_paramSystemPath // path to check point file [".\\"]
  1523. JET_paramTempPath // path to the temporary database [".\\"]
  1524. JET_paramLogFilePath // path to the log file directory [".\\"]
  1525. JET_paramBaseName // base name for all DBMS object names ["edb"]
  1526. JET_paramEventSource // language independant process descriptor string [""]
  1527. //
  1528. // performance parameters
  1529. //
  1530. JET_paramMaxSessions // maximum number of sessions [128]
  1531. JET_paramMaxOpenTables // maximum number of open directories [300]
  1532. // need 1 for each open table index,
  1533. // plus 1 for each open table with no indexes,
  1534. // plus 1 for each table with long column data,
  1535. // plus a few more.
  1536. // for 4.1, 1/3 for regular table, 2/3 for index
  1537. JET_paramPreferredMaxOpenTables // preferred maximum number of open directories [300]
  1538. JET_paramMaxCursors // maximum number of open cursors [1024]
  1539. JET_paramMaxVerPages // maximum version store size in 16kByte units [64]
  1540. JET_paramMaxTemporaryTables // maximum concurrent open temporary
  1541. // table/index creation [20]
  1542. JET_paramLogFileSize // log file size in kBytes [5120]
  1543. JET_paramLogBuffers // log buffers in 512 bytes [21]
  1544. JET_paramWaitLogFlush // log flush wait time in milliseconds [0]
  1545. JET_paramLogCheckpointPeriod // checkpoint period in 512 bytes [1024]
  1546. JET_paramLogWaitingUserMax // maximum sessions waiting log flush [3]
  1547. JET_paramCommitDefault // default grbit for JetCommitTransaction [0]
  1548. JET_paramCircularLog // boolean flag for circular logging [0]
  1549. JET_paramDbExtensionSize // database extension size in pages [16]
  1550. JET_paramPageTempDBMin // minimum size temporary database in pages [0]
  1551. JET_paramPageFragment // maximum disk extent considered fragment in pages [8]
  1552. JET_paramPageReadAheadMax // maximum read-ahead in pages [20]
  1553. //
  1554. // cache performance parameters
  1555. //
  1556. JET_paramBatchIOBufferMax // maximum batch I/O buffers in pages [64]
  1557. JET_paramCacheSize // current cache size in pages [512]
  1558. JET_paramCacheSizeMax // maximum cache size in pages [512]
  1559. JET_paramCheckpointDepthMax // maximum checkpoint depth in bytes [10MB]
  1560. JET_paramLRUKCorrInterval // time (usec) under which page accesses are
  1561. // correlated [10000]
  1562. JET_paramLRUKHistoryMax // maximum LRUK history records [1024]
  1563. // (proportional to cache size max)
  1564. JET_paramLRUKPolicy // K-ness of LRUK page eviction algorithm (1...2) [2]
  1565. JET_paramLRUKTimeout // time (sec) after which cached pages are
  1566. // always evictable [100]
  1567. JET_paramLRUKTrxCorrInterval // time (usec) under which page accesses by the
  1568. // same transaction are correlated [5000000]
  1569. JET_paramOutstandingIOMax // maximum outstanding I/Os [64]
  1570. JET_paramStartFlushThreshold // evictable pages at which to start a flush
  1571. // [100] (proportional to CacheSizeMax)
  1572. JET_paramStopFlushThreshold // evictable pages at which to stop a flush
  1573. // [400] (proportional to CacheSizeMax)
  1574. JET_paramTableClassName // table stats class name (class #, string)
  1575. JET_paramExceptionAction // what to do with exceptions generated within JET
  1576. JET_paramEventLogCache // number of bytes of eventlog records to cache
  1577. // if service is not available [0]
  1578. #endif