59
61
#define XT_TAB_STATUS_FREED 0x00 /* On the free list. */
60
62
#define XT_TAB_STATUS_DELETE 0x01 /* A transactional delete record (an "update" that indicates a delete). */
61
63
#define XT_TAB_STATUS_FIXED 0x02
62
#define XT_TAB_STATUS_VARIABLE 0x03
63
#define XT_TAB_STATUS_EXTENDED 0x04
64
#define XT_TAB_STATUS_VARIABLE 0x03 /* Uses one block, but has the variable format. */
65
#define XT_TAB_STATUS_EXT_DLOG 0x04 /* Variable format, and the trailing part of the record in the data log. */
66
#define XT_TAB_STATUS_EXT_HDATA 0x05 /* Variable format, and the trailing part of the record in the handle data file. */
67
#define XT_TAB_STATUS_DATA 0x06 /* A block of data with a next pointer (5 bytes overhead). */
68
#define XT_TAB_STATUS_END_DATA 0x07 /* An block of data without an end pointer (1 byte overhead). */
69
#define XT_TAB_STATUS_MASK 0x0F
65
71
#define XT_TAB_STATUS_DEL_CLEAN (XT_TAB_STATUS_DELETE | XT_TAB_STATUS_CLEANED_BIT)
66
72
#define XT_TAB_STATUS_FIX_CLEAN (XT_TAB_STATUS_FIXED | XT_TAB_STATUS_CLEANED_BIT)
67
73
#define XT_TAB_STATUS_VAR_CLEAN (XT_TAB_STATUS_VARIABLE | XT_TAB_STATUS_CLEANED_BIT)
68
#define XT_TAB_STATUS_EXT_CLEAN (XT_TAB_STATUS_EXTENDED | XT_TAB_STATUS_CLEANED_BIT)
74
#define XT_TAB_STATUS_EXT_CLEAN (XT_TAB_STATUS_EXT_DLOG | XT_TAB_STATUS_CLEANED_BIT)
70
76
#define XT_TAB_STATUS_CLEANED_BIT 0x80 /* This bit is set when the record is cleaned and committed. */
71
#define XT_TAB_STATUS_REMOVED_BIT 0x40 /* This bit is set when the record is removed which means
72
* associated data and index references have been removed,
73
* but the record has not yet been added to the free list.
76
78
#define XT_REC_IS_CLEAN(x) ((x) & XT_TAB_STATUS_CLEANED_BIT)
77
#define XT_REC_IS_REMOVED(x) ((x) & XT_TAB_STATUS_REMOVED_BIT)
78
#define XT_REC_NOT_VISIBLE(x) ((x) <= XT_TAB_STATUS_DELETE || XT_REC_IS_REMOVED(x))
79
#define XT_TAB_IS_DELETED(x) ((x) == XT_TAB_STATUS_FREED || XT_REC_IS_REMOVED(x))
81
#define XT_ROW_LOCK_TABLE_SIZE 221
79
#define XT_REC_IS_FREE(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_FREED)
80
#define XT_REC_IS_DELETE(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_DELETE)
81
#define XT_REC_IS_FIXED(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_FIXED)
82
#define XT_REC_IS_VARIABLE(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_VARIABLE)
83
#define XT_REC_IS_EXT_DLOG(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_EXT_DLOG)
84
#define XT_REC_IS_EXT_HDATA(x) (((x) & XT_TAB_STATUS_MASK) == XT_TAB_STATUS_EXT_HDATA)
85
#define XT_REC_NOT_VALID(x) (XT_REC_IS_FREE(x) || XT_REC_IS_DELETE(x))
83
87
/* Results for xt_use_table_by_id(): */
84
88
#define XT_TAB_OK 0
85
89
#define XT_TAB_NOT_FOUND 1
86
90
#define XT_TAB_NO_DICTIONARY 2
87
91
#define XT_TAB_POOL_CLOSED 3 /* Cannot open table at the moment, the pool is closed. */
92
#define XT_TAB_FAILED 4
89
94
/* ------- TABLE DATA FILE ------- */
94
99
* This header ensures that no record in the data file has the offset 0.
96
typedef struct XTTabDataHead {
97
XTDiskValue4 dh_magic_4;
98
XTDiskValue4 dh_reserved_4;
99
} XTTabDataHeadDRec, *XTTabDataHeadDPtr;
101
typedef struct XTTableHead {
102
XTDiskValue4 th_head_size_4; /* The size of the table header. */
103
XTDiskValue4 th_op_seq_4;
104
XTDiskValue6 th_row_free_6;
105
XTDiskValue6 th_row_eof_6;
106
XTDiskValue6 th_row_fnum_6;
107
XTDiskValue6 th_rec_free_6;
108
XTDiskValue6 th_rec_eof_6;
109
XTDiskValue6 th_rec_fnum_6;
110
} XTTableHeadDRec, *XTTableHeadDPtr;
112
#define XT_FORMAT_DEF_SPACE 512
114
typedef struct XTTableFormat {
115
XTDiskValue4 tf_format_size_4; /* The size of this structure (table format). */
116
XTDiskValue4 tf_tab_head_size_4; /* The offset of the first record in the data handle file. */
117
XTDiskValue2 tf_tab_version_2; /* The table version number. */
118
XTDiskValue2 tf_unused_2; /* - */
119
XTDiskValue4 tf_rec_size_4; /* The maximum size of records in the table. */
120
XTDiskValue1 tf_rec_fixed_1; /* Set to 1 if this table contains fixed length records. */
121
XTDiskValue1 tf_reserved_1; /* - */
122
XTDiskValue8 tf_min_auto_inc_8; /* This is the minimum auto-increment value. */
123
xtWord1 tf_reserved[64]; /* Reserved, set to 0. */
124
char tf_definition[XT_VAR_LENGTH]; /* A cstring, currently it only contains the foreign key information. */
125
} XTTableFormatDRec, *XTTableFormatDPtr;
101
127
#define XT_STAT_ID_MASK(x) ((x) & (u_int) 0x000000FF)
103
129
/* A record that fits completely in the data file record */
104
130
typedef struct XTTabRecHead {
105
xtWord1 tr_rec_type_1; /* 0 means deleted. */
131
xtWord1 tr_rec_type_1;
106
132
xtWord1 tr_stat_id_1;
107
XTDiskValue6 tr_xact_id_6; /* The transaction ID. */
108
XTDiskValue6 tr_prev_var_6; /* The previous variation of this record. */
133
xtDiskRecordID4 tr_prev_rec_id_4; /* The previous variation of this record. */
134
XTDiskValue4 tr_xact_id_4; /* The transaction ID. */
109
135
XTDiskValue4 tr_row_id_4; /* The row ID of this record. */
110
136
} XTTabRecHeadDRec, *XTTabRecHeadDPtr;
112
138
typedef struct XTTabRecFix {
113
xtWord1 tr_rec_type_1; /* 0 means deleted. */
139
xtWord1 tr_rec_type_1; /* XT_TAB_STATUS_FREED, XT_TAB_STATUS_DELETE,
140
* XT_TAB_STATUS_FIXED, XT_TAB_STATUS_VARIABLE */
114
141
xtWord1 tr_stat_id_1;
115
XTDiskValue6 tr_xact_id_6; /* The transaction ID. */
116
XTDiskValue6 tr_prev_var_6; /* The previous variation of this record. */
142
xtDiskRecordID4 tr_prev_rec_id_4; /* The previous variation of this record. */
143
XTDiskValue4 tr_xact_id_4; /* The transaction ID. */
117
144
XTDiskValue4 tr_row_id_4; /* The row ID of this record. */
118
145
xtWord1 rf_data[XT_VAR_LENGTH]; /* NOTE: This data is in RAW MySQL format. */
119
146
} XTTabRecFixDRec, *XTTabRecFixDPtr;
121
148
/* An extended record that overflows into the log file: */
122
149
typedef struct XTTabRecExt {
123
xtWord1 tr_rec_type_1;
150
xtWord1 tr_rec_type_1; /* XT_TAB_STATUS_EXT_DLOG */
124
151
xtWord1 tr_stat_id_1;
125
XTDiskValue6 tr_xact_id_6; /* The transaction ID. */
126
XTDiskValue6 tr_prev_var_6; /* The previous variation of this record. */
152
xtDiskRecordID4 tr_prev_rec_id_4; /* The previous variation of this record. */
153
XTDiskValue4 tr_xact_id_4; /* The transaction ID. */
127
154
XTDiskValue4 tr_row_id_4; /* The row ID of this record. */
128
XTDiskValue6 re_log_rec_6; /* Reference to the overflow area in a log file. */
155
XTDiskValue2 re_log_id_2; /* Reference to overflow area, log ID */
156
XTDiskValue6 re_log_offs_6; /* Reference to the overflow area, log offset */
129
157
XTDiskValue4 re_log_dat_siz_4; /* Size of the overflow data. */
130
158
xtWord1 re_data[XT_VAR_LENGTH]; /* This data is in packed PBXT format. */
131
159
} XTTabRecExtDRec, *XTTabRecExtDPtr;
161
typedef struct XTTabRecExtHdat {
162
xtWord1 tr_rec_type_1; /* XT_TAB_STATUS_EXT_HDATA */
163
xtWord1 tr_stat_id_1;
164
xtDiskRecordID4 tr_prev_rec_id_4; /* The previous variation of this record. */
165
XTDiskValue4 tr_xact_id_4; /* The transaction ID. */
166
XTDiskValue4 tr_row_id_4; /* The row ID of this record. */
167
XTDiskValue4 eh_blk_rec_id_4; /* The record ID of the next block. */
168
XTDiskValue2 eh_blk_siz_2; /* The total size of the data in the trailing blocks */
169
xtWord1 eh_data[XT_VAR_LENGTH]; /* This data is in packed PBXT format. */
170
} XTTabRecExtHdatDRec, *XTTabRecExtHdatDPtr;
172
typedef struct XTTabRecData {
173
xtWord1 tr_rec_type_1; /* XT_TAB_STATUS_DATA */
174
XTDiskValue4 rd_blk_rec_id_4; /* The record ID of the next block. */
175
xtWord1 rd_data[XT_VAR_LENGTH]; /* This data is in packed PBXT format. */
176
} XTTabRecDataDRec, *XTTabRecDataDPtr;
178
typedef struct XTTabRecEndDat {
179
xtWord1 tr_rec_type_1; /* XT_TAB_STATUS_END_DATA */
180
xtWord1 ed_data[XT_VAR_LENGTH]; /* This data is in packed PBXT format. */
181
} XTTabRecEndDatDRec, *XTTabRecEndDatDPtr;
133
183
#define XT_REC_FIX_HEADER_SIZE sizeof(XTTabRecHeadDRec)
134
184
#define XT_REC_EXT_HEADER_SIZE offsetof(XTTabRecExtDRec, re_data)
135
185
#define XT_REC_FIX_EXT_HEADER_DIFF (XT_REC_EXT_HEADER_SIZE - XT_REC_FIX_HEADER_SIZE)
137
187
typedef struct XTTabRecFree {
138
188
xtWord1 tr_rec_type_1;
139
xtWord1 tr_stat_id_1;
140
XTDiskValue6 rf_next_block_6; /* The next block on the free list. */
189
xtWord1 rf_not_used_1;
190
xtDiskRecordID4 rf_next_rec_id_4; /* The next block on the free list. */
141
191
} XTTabRecFreeDRec, *XTTabRecFreeDPtr;
143
193
typedef struct XTTabRecInfo {
144
194
XTTabRecFixDPtr ri_fix_rec_buf; /* This references the start of the buffer (set for all types of records) */
145
195
XTTabRecExtDPtr ri_ext_rec; /* This is only set for extended records. */
146
196
xtWord4 ri_rec_buf_size;
147
XTDataLogBufferDPtr ri_log_buf;
197
XTactExtRecEntryDPtr ri_log_buf;
148
198
xtWord4 ri_log_data_size; /* This size of the data in the log record. */
149
off_t ri_rec_address; /* The address of the record. */
199
xtRecordID ri_rec_id; /* The address of the record. */
150
200
} XTTabRecInfoRec, *XTTabRecInfoPtr;
152
202
/* ------- TABLE ROW FILE ------- */
154
#define XT_TAB_ROW_SHIFTS 3
204
#define XT_TAB_ROW_SHIFTS 2
155
205
#define XT_TAB_ROW_MAGIC 0x4567CDEF
156
#define XT_TAB_ROW_FREE 0
157
#define XT_TAB_ROW_IN_USE 1
206
//#define XT_TAB_ROW_FREE 0
207
//#define XT_TAB_ROW_IN_USE 1
160
210
* NOTE: The shift count assumes the size of a table row
161
* reference is 8 bytes
211
* reference is 8 bytes (XT_TAB_ROW_SHIFTS)
163
213
typedef struct XTTabRowRef {
164
xtWord1 rr_rec_type_1; /* 0 means free. */
165
xtWord1 rr_unused_1; /* Currently unused (set to zero). */
166
XTDiskValue6 rr_variation_6; /* Pointer to the first variation. */
214
XTDiskValue4 rr_ref_id_4; /* 4-byte reference, could be a RowID or a RecordID
215
* If this row is free, then it is a RowID, which
216
* references the next free row.
217
* If it is in use, then it is a RecordID which
218
* points to the first record in the variation
167
221
} XTTabRowRefDRec, *XTTabRowRefDPtr;
170
224
* This is the header for the row file. The size MUST be a
171
* multiple of sizeof(XTTabRowRefDRec)
225
* the same size as sizeof(XTTabRowRefDRec)
173
227
typedef struct XTTabRowHead {
174
228
XTDiskValue4 rh_magic_4;
175
XTDiskValue4 rh_reserved_4;
176
229
} XTTabRowHeadDRec, *XTTabRowHeadDPtr;
178
231
/* ------- TABLE INDEX FILE ------- */
180
typedef struct XTTabPointers {
181
XTDiskValue4 tp_head_size_4;
183
/* These fields reference row IDs (i.e. offset = ID * sizeof(XTTabRowRefRec), zero is invalid!): */
184
XTDiskValue4 tp_tab_eof_4;
185
XTDiskValue4 tp_tab_free_4; /* Free list of records. */
186
XTDiskValue4 tp_tab_fnum_4; /* The number of records on the free list. */
188
XTDiskValue6 tp_data_eof_6;
189
XTDiskValue6 tp_data_free_6;
190
XTDiskValue4 tp_data_fnum_4; /* The number of data records on the free list. */
233
typedef struct XTIndexHead {
234
XTDiskValue4 tp_head_size_4; /* The size of the index header. */
236
XTDiskValue4 tp_rec_log_id_4; /* Index recovery start point. */
237
XTDiskValue6 tp_rec_log_offs_6;
192
239
XTDiskValue6 tp_ind_eof_6;
193
240
XTDiskValue6 tp_ind_free_6;
195
/* The index roots follow. Each is tf_node_ref_size_1 size. */
242
/* The index roots follow. Each is if_node_ref_size_1 size. */
196
243
xtWord1 tp_data[XT_VAR_LENGTH];
197
} XTTabPointersDRec, *XTTabPointersDPtr;
244
} XTIndexHeadDRec, *XTIndexHeadDPtr;
199
typedef struct XTTabFormat {
200
XTDiskValue4 tf_format_size_4; /* The size of this structure. */
201
XTDiskValue2 tf_tab_version_2; /* The table version number. */
202
XTDiskValue2 tf_ind_version_2; /* The index version number. */
203
XTDiskValue1 tf_node_ref_size_1; /* This size of index node reference in indexes (default 6 bytes). */
204
XTDiskValue1 tf_rec_ref_size_1; /* The size of record references in the indexes (default 4 bytes). */
205
XTDiskValue4 tf_rec_size_4; /* The maximum size of records in the table. */
206
XTDiskValue1 tf_rec_fixed_1; /* Set to 1 if this table contains fixed length records. */
207
XTDiskValue8 tf_min_auto_inc_8; /* This is the minimum auto-increment value. */
208
XTDiskValue1 tf_no_of_data_logs_2; /* The number of data logs (currently fixed at 4). */
209
xtWord1 tf_reserved[64]; /* Reserved, set to 0. */
210
char tf_definition[XT_VAR_LENGTH]; /* A cstring, currently it only contains the foreign key information. */
211
} XTTabFormatDRec, *XTTabFormatDPtr;
246
typedef struct XTIndexFormat {
247
XTDiskValue4 if_format_size_4; /* The size of this structure (index format). */
248
XTDiskValue2 if_tab_version_2; /* The table version number. */
249
XTDiskValue2 if_ind_version_2; /* The index version number. */
250
XTDiskValue1 if_node_ref_size_1; /* This size of index node reference in indexes (default 4 bytes). */
251
XTDiskValue1 if_rec_ref_size_1; /* The size of record references in the indexes (default 4 bytes). */
252
} XTIndexFormatDRec, *XTIndexFormatDPtr;
213
254
/* ------- TABLE & OPEN TABLES & TABLE LISTING ------- */
216
257
struct XTDatabase *tab_db; /* Heap pointer */
218
259
xtBool tab_free_locks;
221
262
xtWord8 tab_auto_inc; /* The next value to be issued as an auto-increment value. */
222
263
xt_mutex_type tab_ainc_lock; /* Lock for the auto-increment counter. */
224
size_t tab_head_size;
225
XTTabPointersDPtr tab_pointers;
265
size_t tab_index_head_size;
266
XTIndexHeadDPtr tab_index_head;
267
size_t tab_table_head_size;
226
268
XTDictionaryRec tab_dic;
227
269
xt_mutex_type dic_field_lock; /* Lock for setting field->ptr!. */
229
xt_mutex_type tab_open_lock; /* Lock for the opening tables. */
230
xt_cond_type tab_open_cond; /* Condition for waiting to open a table. */
231
xtBool tab_will_close; /* Set to TRUE when the table is to be closed */
232
u_int tab_open_count; /* Number of open tables. */
233
struct XTOpenTable *tab_open_pool; /* The open table pool. */
235
//D XTTableSeqRec tab_seq; /* The table operation sequence. */
238
off_t tab_row_eof; /* Indicates the EOF of the table row file. */
239
off_t tab_row_free; /* The start of the free list in the table row file. */
271
XTRowLocksRec tab_locks; /* The locks held on this table. */
273
XTTableSeqRec tab_seq; /* The table operation sequence. */
274
XTTabCacheRec tab_rows;
275
XTTabCacheRec tab_recs;
277
/* Used to apply operations to the database in order. */
278
XTSortedListPtr tab_op_list; /* The operation list. Operations to be applied. */
279
/* Values that belong in the header when flushed! */
280
xtBool tab_flush_pending; /* TRUE if the table needs to be flushed */
281
xtOpSeqNo tab_head_op_seq; /* The number of the operation last applied to the database. */
282
xtRowID tab_head_row_free_id;
283
xtRowID tab_head_row_eof_id;
284
xtWord4 tab_head_row_fnum;
285
xtRecordID tab_head_rec_free_id;
286
xtRecordID tab_head_rec_eof_id;
287
xtWord4 tab_head_rec_fnum;
289
xtOpSeqNo tab_co_op_seq; /* The operation last applied by the compactor. */
291
xtBool tab_wr_wake_freeer; /* Set to TRUE if the writer must wake the freeer. */
292
xtOpSeqNo tab_wake_freeer_op; /* Set to the sequence number the freeer is waiting for. */
294
XTFilePtr tab_row_file;
295
xtRowID tab_row_eof_id; /* Indicates the EOF of the table row file. */
296
xtRowID tab_row_free_id; /* The start of the free list in the table row file. */
240
297
xtWord4 tab_row_fnum; /* The count of the number of free rows on the free list. */
241
298
xt_mutex_type tab_row_lock; /* Lock for updating the EOF and free list. */
242
xt_rwlock_type tab_row_locks[XT_ROW_LOCK_TABLE_SIZE]; /* Used to lock a row during update. */
244
xtBool tab_head_dirty; /* TRUE if index header data is updated. */
299
xt_rwlock_type tab_row_rwlock[XT_ROW_RWLOCKS]; /* Used to lock a row during update. */
301
XTFilePtr tab_rec_file;
302
xtRecordID tab_rec_eof_id; /* This value can only grow. */
303
xtRecordID tab_rec_free_id;
304
xtWord4 tab_rec_fnum; /* The count of the number of free rows on the free list. */
305
xt_mutex_type tab_rec_lock; /* Lock for the free list. */
307
xtBool tab_ind_flush_pending; /* TRUE if some part of the index file has been written. */
308
xtBool tab_ind_head_dirty; /* TRUE if index header data is updated. */
309
xtLogID tab_ind_rec_log_id; /* The point before which index entries have been written. */
310
xtLogOffset tab_ind_rec_log_offset; /* The log offset of the write point. */
311
XTFilePtr tab_ind_file;
246
312
off_t tab_ind_eof; /* This value can only grow. */
247
313
off_t tab_ind_free;
248
314
xt_mutex_type tab_ind_lock; /* Lock for reading and writing the buffer. */
250
xt_mutex_type tab_log_lock; /* Lock for the log list for adding, using and removing logs. */
251
u_int tab_log_curr; /* The index of the current log (write log). */
252
XTDataLogRec tab_log_list[XT_NO_OF_DATA_LOGS]; /* Complete list of data logs for the table. */
255
off_t tab_data_eof; /* This value can only grow. */
257
xtWord4 tab_data_fnum; /* The count of the number of free rows on the free list. */
258
xt_mutex_type tab_free_lock; /* Lock for the free list. */
260
u_int tab_buf_size; /* Size of tab_data_buf and ot_read_buf. */
261
u_int tab_buf_offset; /* Current write position in buffer. */
262
xt_rwlock_type tab_buf_rwlock; /* Lock for reading and writing the buffer. */
263
xtWord1 *tab_data_buf; /* The table log write buffer. */
264
315
} XTTableHRec, *XTTableHPtr; /* Heap pointer */
266
317
/* Used for an in-memory list of the tables, ordered by ID. */
267
318
typedef struct XTTableEntry {
269
320
char *te_tab_name;
270
321
XTTableHPtr te_table;
271
322
} XTTableEntryRec, *XTTableEntryPtr;
364
418
char *xt_tab_file_to_name(size_t size, char *tab_name, char *file_name);
366
420
void xt_create_table(struct XTThread *self, char *name, XTDictionaryPtr dic, xtBool delete_if_exists);
367
XTTableHPtr xt_use_table(struct XTThread *self, char *name, xtBool missing_ok);
421
XTTableHPtr xt_use_table(struct XTThread *self, char *name, xtBool no_load, xtBool missing_ok);
422
void xt_flush_table(struct XTThread *self, XTOpenTablePtr ot);
368
423
XTTableHPtr xt_use_table_no_lock(XTThreadPtr self, struct XTDatabase *db, char *name, xtBool no_load, xtBool missing_ok, XTDictionaryPtr dic);
369
int xt_use_table_by_id(struct XTThread *self, XTTableHPtr *tab, struct XTDatabase *db, xtWord4 tab_id);
424
int xt_use_table_by_id(struct XTThread *self, XTTableHPtr *tab, struct XTDatabase *db, xtTableID tab_id);
370
425
XTOpenTablePtr xt_open_table(XTTableHPtr tab);
371
XTOpenTablePtr xt_open_table_by_name(struct XTThread *self, char *name);
372
426
void xt_close_table(XTOpenTablePtr ot);
373
xtBool xt_flush_table(XTOpenTablePtr ot);
427
xtBool xt_flush_table_index(XTOpenTablePtr ot);
374
428
void xt_drop_table(struct XTThread *self, char *name);
429
void xt_check_table(XTThreadPtr self, XTOpenTablePtr tab);
375
430
void xt_rename_table(struct XTThread *self, char *old_name, char *new_name);
376
431
void xt_move_table(struct XTThread *self, char *old_name, struct XTDatabase *new_db, char *new_name);
378
XTOpenTablePtr xt_open_table_from_pool(XTTableHPtr tab, struct XTThread *thread);
379
void xt_return_table_to_pool(XTOpenTablePtr ot);
380
void xt_close_all_open_tables(XTThreadPtr self, XTTableHPtr tab);
382
433
void xt_describe_tables_init(struct XTThread *self, struct XTDatabase *db, XTTableDescPtr td);
383
434
xtBool xt_describe_tables_next(struct XTThread *self, XTTableDescPtr td);
384
435
void xt_describe_tables_exit(struct XTThread *self, XTTableDescPtr td);
388
439
void xt_enum_tables_init(u_int *edx);
389
440
XTTableEntryPtr xt_enum_tables_next(struct XTThread *self, struct XTDatabase *db, u_int *edx);
391
void xt_enum_files_of_tables_init(struct XTDatabase *db, char *tab_name, xtWord4 tab_id, XTFilesOfTablePtr ft);
442
void xt_enum_files_of_tables_init(struct XTDatabase *db, char *tab_name, xtTableID tab_id, XTFilesOfTablePtr ft);
392
443
xtBool xt_enum_files_of_tables_next(XTFilesOfTablePtr ft);
394
445
xtBool xt_tab_seq_init(XTOpenTablePtr ot);
446
void xt_tab_seq_reset(XTOpenTablePtr ot);
447
void xt_tab_seq_exit(XTOpenTablePtr ot);
395
448
xtBool xt_tab_seq_next(XTOpenTablePtr ot, xtWord1 *buffer, xtBool *eof);
397
xtBool xt_tab_flush_data(XTOpenTablePtr ot);
398
450
xtBool xt_tab_new_record(XTOpenTablePtr ot, xtWord1 *buffer);
399
451
xtBool xt_tab_delete_record(XTOpenTablePtr ot, xtWord1 *buffer);
400
452
xtBool xt_tab_update_record(XTOpenTablePtr ot, xtWord1 *before_buf, xtWord1 *after_buf);
401
453
int xt_tab_visible(XTOpenTablePtr ot);
402
454
int xt_tab_read_record(register XTOpenTablePtr ot, xtWord1 *buffer);
403
xtBool xt_tab_load_record(register XTOpenTablePtr ot, off_t address, XTInfoBufferPtr rec_buf);
404
int xt_tab_remove_record(XTOpenTablePtr ot, off_t address, xtWord1 *rec_data, off_t *prev_var, xtBool clean_delete);
405
int xt_tab_maybe_committed(XTOpenTablePtr ot, off_t record, xtWord8 *tn_id, xtWord4 *out_rowid, xtBool *out_updated);
406
xtBool xt_tab_free_record(XTOpenTablePtr ot, off_t address);
408
xtBool xt_tab_get_row(register XTOpenTablePtr ot, xtWord4 row_id, off_t *variation);
409
xtBool xt_tab_set_row(XTOpenTablePtr ot, xtWord4 row_id, off_t variation, xtBool write_thru);
410
xtBool xt_tab_free_row(XTOpenTablePtr ot, XTTableHPtr tab, xtWord4 row_id);
412
xtBool xt_tab_put_data(XTOpenTablePtr ot, off_t address, u_int size, xtWord1 *buffer);
413
xtBool xt_tab_get_data(register XTOpenTablePtr ot, off_t address, u_int size, xtWord1 *buffer, u_int *red_size);
414
xtBool xt_tab_get_record(register XTOpenTablePtr ot, off_t address, u_int size, xtWord1 *buffer);
416
void xt_tab_load_index_roots(XTTableHPtr tab);
418
void xt_tab_get_stats(struct XTThread *self, XTTableHPtr tab, xtWord4 *file_size, xtWord4 *free_count);
419
void xt_tab_io_failed(XTOpenFilePtr of);
455
int xt_tab_dirty_read_record(register XTOpenTablePtr ot, xtWord1 *buffer);
456
void xt_tab_load_row_pointers(XTThreadPtr self, XTOpenTablePtr ot);
457
xtBool xt_tab_load_record(register XTOpenTablePtr ot, xtRecordID rec_id, XTInfoBufferPtr rec_buf);
458
int xt_tab_remove_record(XTOpenTablePtr ot, xtRecordID rec_id, xtWord1 *rec_data, xtRecordID *prev_var_rec_id, xtBool clean_delete, xtRowID row_id, xtXactID xn_id);
459
int xt_tab_maybe_committed(XTOpenTablePtr ot, xtRecordID rec_id, xtXactID *xn_id, xtRowID *out_rowid, xtBool *out_updated);
460
xtBool xt_tab_free_record(XTOpenTablePtr ot, u_int status, xtRecordID rec_id, xtBool clean_delete);
461
void xt_tab_store_header(struct XTThread *self, XTOpenTablePtr ot);
463
xtBool xt_tab_get_row(register XTOpenTablePtr ot, xtRowID row_id, xtRecordID *var_rec_id);
464
xtBool xt_tab_set_row(XTOpenTablePtr ot, u_int status, xtRowID row_id, xtRecordID var_rec_id);
465
xtBool xt_tab_free_row(XTOpenTablePtr ot, XTTableHPtr tab, xtRowID row_id);
467
xtBool xt_tab_load_ext_data(XTOpenTablePtr ot, xtRecordID load_rec_id, xtWord1 *buffer, u_int cols_req);
468
xtBool xt_tab_put_rec_data(XTOpenTablePtr ot, xtRecordID rec_id, size_t size, xtWord1 *buffer, xtOpSeqNo *op_seq);
469
xtBool xt_tab_put_log_op_rec_data(XTOpenTablePtr ot, u_int status, xtRecordID free_rec_id, xtRecordID rec_id, size_t size, xtWord1 *buffer);
470
xtBool xt_tab_put_log_rec_data(XTOpenTablePtr ot, u_int status, xtRecordID free_rec_id, xtRecordID rec_id, size_t size, xtWord1 *buffer, xtOpSeqNo *op_seq);
471
xtBool xt_tab_get_rec_data(register XTOpenTablePtr ot, xtRecordID rec_id, size_t size, xtWord1 *buffer);
473
inline off_t xt_row_id_to_row_offset(register XTTableHPtr tab, xtRowID row_id)
475
return (off_t) tab->tab_rows.tci_header_size + (off_t) (row_id - 1) * (off_t) tab->tab_rows.tci_rec_size;
478
inline xtRowID xt_row_offset_row_id(register XTTableHPtr tab, off_t rec_offs)
481
if (((rec_offs - (off_t) tab->tab_rows.tci_header_size) % (off_t) tab->tab_rows.tci_rec_size) != 0) {
482
printf("ERROR! Not a valid record offset!\n");
485
return (xtRowID) ((rec_offs - (off_t) tab->tab_rows.tci_header_size) / (off_t) tab->tab_rows.tci_rec_size) + 1;
488
inline off_t xt_rec_id_to_rec_offset(register XTTableHPtr tab, xtRefID ref_id)
492
return (off_t) tab->tab_recs.tci_header_size + (off_t) (ref_id-1) * (off_t) tab->tab_recs.tci_rec_size;
495
inline xtRefID xt_rec_offset_rec_id(register XTTableHPtr tab, off_t ref_offs)
500
if (((ref_offs - (off_t) tab->tab_recs.tci_header_size) % (off_t) tab->tab_recs.tci_rec_size) != 0) {
501
printf("ERROR! Not a valid record offset!\n");
505
return (xtRefID) ((ref_offs - (off_t) tab->tab_recs.tci_header_size) / (off_t) tab->tab_recs.tci_rec_size)+1;
421
509
#define XT_RESIZE_ROW_BUFFER(thr, rb, size) \