1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
1 |
/* Copyright (c) 2005 PrimeBase Technologies GmbH
|
2 |
*
|
|
3 |
* PrimeBase XT
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
8 |
* (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
*
|
|
19 |
* Author: Paul McCullagh
|
|
20 |
*
|
|
21 |
* H&G2JCtL
|
|
22 |
*/
|
|
23 |
#ifndef __xt_defs_h__
|
|
24 |
#define __xt_defs_h__
|
|
25 |
||
26 |
#ifdef XT_WIN
|
|
27 |
#include "win_inttypes.h" |
|
28 |
#else
|
|
29 |
#include <inttypes.h> |
|
30 |
#endif
|
|
31 |
#include <sys/types.h> |
|
32 |
#include <assert.h> |
|
33 |
#include <stddef.h> |
|
34 |
#include <string.h> |
|
35 |
||
36 |
//#include "pthread_xt.h"
|
|
37 |
||
38 |
#ifdef DEBUG
|
|
39 |
//#define DEBUG_LOG_DELETE
|
|
40 |
#endif
|
|
41 |
||
42 |
/* the following macros are used to quote compile-time numeric
|
|
43 |
* constants into strings, e.g. __LINE__
|
|
44 |
*/
|
|
45 |
#define _QUOTE(x) #x
|
|
46 |
#define QUOTE(x) _QUOTE(x)
|
|
47 |
||
48 |
/* ----------------------------------------------------------------------
|
|
49 |
* CRASH DEBUGGING
|
|
50 |
*/
|
|
51 |
||
52 |
/* Define this if crash debug should be on by default:
|
|
53 |
* pbxt_crash_debug set to TRUE by default.
|
|
54 |
* It can be turned off by creating a file called 'no-debug'
|
|
55 |
* in the pbxt database.
|
|
56 |
* It can be turned on by defining the file 'crash-debug'
|
|
57 |
* in the pbxt database.
|
|
58 |
*/
|
|
59 |
//#define XT_CRASH_DEBUG
|
|
60 |
||
61 |
/* These are the things crash debug will do: */
|
|
62 |
/* Create a core dump (windows only): */
|
|
63 |
#define XT_COREDUMP
|
|
64 |
||
65 |
/* Backup the datadir before recovery after a crash: */
|
|
66 |
//#define XT_BACKUP_BEFORE_RECOVERY
|
|
67 |
||
68 |
/* Keep this number of transaction logs around
|
|
69 |
* for analysis after a crash.
|
|
70 |
*/
|
|
71 |
#define XT_NUMBER_OF_LOGS_TO_SAVE 5
|
|
72 |
||
73 |
/* ----------------------------------------------------------------------
|
|
74 |
* GENERIC GLOBAL TYPES
|
|
75 |
*/
|
|
76 |
||
77 |
#ifdef XT_WIN
|
|
78 |
||
79 |
#define xtInt1 __int8
|
|
80 |
#define xtInt2 __int16
|
|
81 |
#define xtInt4 __int32
|
|
82 |
#define xtInt8 __int64
|
|
83 |
||
84 |
#define xtWord1 unsigned __int8
|
|
85 |
#define xtWord2 unsigned __int16
|
|
86 |
#define xtWord4 unsigned __int32
|
|
87 |
#define xtWord8 unsigned __int64
|
|
88 |
||
89 |
#ifndef PATH_MAX
|
|
90 |
#define PATH_MAX MAX_PATH
|
|
91 |
#endif
|
|
92 |
#ifndef NAME_MAX
|
|
93 |
#define NAME_MAX MAX_PATH
|
|
94 |
#endif
|
|
95 |
||
96 |
/* XT actually assumes that off_t is 8 bytes: */
|
|
97 |
#define off_t xtWord8
|
|
98 |
||
99 |
#else // XT_WIN |
|
100 |
||
101 |
#define xtInt1 int8_t
|
|
102 |
#define xtInt2 int16_t
|
|
103 |
#define xtInt4 int32_t
|
|
104 |
#define xtInt8 int64_t
|
|
105 |
||
106 |
#ifdef XT_SOLARIS
|
|
107 |
#define u_int8_t uint8_t
|
|
108 |
#define u_int16_t uint16_t
|
|
109 |
#define u_int32_t uint32_t
|
|
110 |
#define u_int64_t uint64_t
|
|
111 |
#endif
|
|
112 |
||
113 |
#define xtWord1 u_int8_t
|
|
114 |
#define xtWord2 u_int16_t
|
|
115 |
#define xtWord4 u_int32_t
|
|
116 |
#define xtWord8 u_int64_t
|
|
117 |
||
118 |
#endif // XT_WIN |
|
119 |
||
120 |
/* A pointer sized word value: */
|
|
121 |
#define xtWordPS ptrdiff_t
|
|
122 |
||
123 |
#define XT_MAX_INT_1 ((xtInt1) 0x7F)
|
|
124 |
#define XT_MIN_INT_1 ((xtInt1) 0x80)
|
|
125 |
#define XT_MAX_INT_2 ((xtInt2) 0x7FFF)
|
|
126 |
#define XT_MIN_INT_2 ((xtInt2) 0x8000)
|
|
127 |
#define XT_MAX_INT_4 ((xtInt4) 0x7FFFFFFF)
|
|
128 |
#define XT_MIN_INT_4 ((xtInt4) 0x80000000)
|
|
129 |
||
130 |
#define xtReal4 float
|
|
131 |
#define xtReal8 double
|
|
132 |
||
133 |
#ifndef u_int
|
|
134 |
#define u_int unsigned int /* Assumed at least 4 bytes long! */ |
|
135 |
#define u_long unsigned long /* Assumed at least 4 bytes long! */ |
|
136 |
#endif
|
|
137 |
#define llong long long /* Assumed at least 8 bytes long! */ |
|
138 |
#define u_llong unsigned long long /* Assumed at least 8 bytes long! */ |
|
139 |
||
140 |
#define c_char const char
|
|
141 |
||
142 |
#ifndef NULL
|
|
143 |
#define NULL 0
|
|
144 |
#endif
|
|
145 |
||
146 |
#define xtPublic
|
|
147 |
||
148 |
#define xtBool int
|
|
149 |
#define xtBool1 xtWord1 /* A boolean that saves space in structures. */ |
|
150 |
#ifndef TRUE
|
|
151 |
#define TRUE 1
|
|
152 |
#endif
|
|
153 |
#ifndef FALSE
|
|
154 |
#define FALSE 0
|
|
155 |
#endif
|
|
156 |
||
157 |
/* Additional return codes: */
|
|
158 |
#define XT_MAYBE 2
|
|
159 |
#define XT_ERR -1
|
|
160 |
#define XT_NEW -2
|
|
161 |
#define XT_RETRY -3
|
|
162 |
#define XT_REREAD -4
|
|
163 |
||
164 |
#ifdef OK
|
|
165 |
#undef OK
|
|
166 |
#endif
|
|
167 |
#define OK TRUE
|
|
168 |
||
169 |
#ifdef FAILED
|
|
170 |
#undef FAILED
|
|
171 |
#endif
|
|
172 |
#define FAILED FALSE
|
|
173 |
||
174 |
typedef xtWord1 XTDiskValue1[1]; |
|
175 |
typedef xtWord1 XTDiskValue2[2]; |
|
176 |
typedef xtWord1 XTDiskValue3[3]; |
|
177 |
typedef xtWord1 XTDiskValue4[4]; |
|
178 |
typedef xtWord1 XTDiskValue6[6]; |
|
179 |
typedef xtWord1 XTDiskValue8[8]; |
|
180 |
||
181 |
#ifdef DEBUG
|
|
182 |
#define XT_VAR_LENGTH 100
|
|
183 |
#else
|
|
184 |
#define XT_VAR_LENGTH 1
|
|
185 |
#endif
|
|
186 |
||
187 |
typedef struct XTPathStr { |
|
188 |
char ps_path[XT_VAR_LENGTH]; |
|
189 |
} *XTPathStrPtr; |
|
190 |
||
191 |
//#define XT_UNUSED(x) x __attribute__((__unused__))
|
|
192 |
#define XT_UNUSED(x)
|
|
193 |
||
194 |
/* Only used when DEBUG is on: */
|
|
195 |
#ifdef DEBUG
|
|
196 |
#define XT_NDEBUG_UNUSED(x) x
|
|
197 |
#else
|
|
198 |
//#define XT_NDEBUG_UNUSED(x) x __attribute__((__unused__))
|
|
199 |
#define XT_NDEBUG_UNUSED(x)
|
|
200 |
#endif
|
|
201 |
||
202 |
/* ----------------------------------------------------------------------
|
|
203 |
* MAIN CONSTANTS
|
|
204 |
*/
|
|
205 |
||
206 |
/*
|
|
207 |
* Define if there should only be one database per server instance:
|
|
208 |
*/
|
|
209 |
#define XT_USE_GLOBAL_DB
|
|
210 |
||
211 |
/*
|
|
212 |
* The rollover size is the write limit of a log file.
|
|
213 |
* After this size is reached, a thread will start a
|
|
214 |
* new log.
|
|
215 |
*
|
|
216 |
* However, logs can grow much larger than this size.
|
|
217 |
* The reason is, a transaction single transaction
|
|
218 |
* may not span more than one data log file.
|
|
219 |
*
|
|
220 |
* This means the log rollover size is actually a
|
|
221 |
* minimum size.
|
|
222 |
*/
|
|
223 |
||
224 |
#ifdef DEBUG
|
|
225 |
#define XT_USE_GLOBAL_DEBUG_SIZES
|
|
226 |
#endif
|
|
227 |
||
228 |
/*
|
|
229 |
* I believe the MySQL limit is 16. This limit is currently only used for
|
|
230 |
* BLOB streaming.
|
|
231 |
*/
|
|
232 |
#define XT_MAX_COLS_PER_INDEX 32
|
|
233 |
||
234 |
/*
|
|
235 |
* The maximum number of tables that can be created in a PBXT
|
|
236 |
* database. The amount is based on the fact that XT creates
|
|
237 |
* about 5 files per table in the database, and also
|
|
238 |
* uses directory listing to find tables.
|
|
239 |
*/
|
|
240 |
#define XT_MAX_TABLES 10000
|
|
241 |
||
242 |
/*
|
|
243 |
* When the amount of garbage in the file is greater than the
|
|
244 |
* garbage threshold, then compactor is activated.
|
|
245 |
*/
|
|
246 |
#define XT_GARBAGE_THRESHOLD ((double) 50.0)
|
|
247 |
||
248 |
/* A record that does not contain blobs will be handled as a fixed
|
|
249 |
* length record if its maximum size is less than this amount,
|
|
250 |
* regardless of the size of the VARCHAR fields it contains.
|
|
251 |
*/
|
|
252 |
#define XT_TAB_MIN_VAR_REC_LENGTH 320
|
|
253 |
||
254 |
/* No record in the data handle file may exceed this size: */
|
|
255 |
#define XT_TAB_MAX_FIX_REC_LENGTH (16 * 1024)
|
|
256 |
||
257 |
/* No record in the data handle file may exceed this size, if
|
|
258 |
* AVG_ROW_LENGTH is set.
|
|
259 |
*/
|
|
260 |
#define XT_TAB_MAX_FIX_REC_LENGTH_SPEC (64 * 1024)
|
|
261 |
||
262 |
/*
|
|
263 |
* Determines the page size of the indexes. The value is given
|
|
264 |
* in shifts of 1 to the left (e.g. 1 << 11 == 2048,
|
|
265 |
* 1 << 12 == 4096).
|
|
266 |
*
|
|
267 |
* PMC: Note the performance of sysbench is better with 11
|
|
268 |
* than with 12.
|
|
269 |
*
|
|
270 |
* InnoDB uses 16K pages:
|
|
271 |
* 1 << 14 == 16384.
|
|
272 |
*/
|
|
273 |
#define XT_INDEX_PAGE_SHIFTS 14
|
|
274 |
||
275 |
/* The number of RW locks used to scatter locks on the rows
|
|
276 |
* of a table. The locks are only help for a short time during which
|
|
277 |
* the row list is scanned.
|
|
278 |
*
|
|
279 |
* For more details see [(9)].
|
|
280 |
* 223, 1019, 3613
|
|
281 |
*/
|
|
282 |
#define XT_ROW_RWLOCKS 1019
|
|
283 |
//#define XT_ROW_RWLOCKS 223
|
|
284 |
||
285 |
/*
|
|
286 |
* These are the number of row lock "slots" per table.
|
|
287 |
* Row locks are taken on UPDATE/DELETE or SELECT FOR UPDATE.
|
|
288 |
*/
|
|
289 |
#define XT_ROW_LOCK_COUNT (XT_ROW_RWLOCKS * 91)
|
|
290 |
||
291 |
/*
|
|
292 |
* The size of index write buffer. Must be at least as large as the
|
|
293 |
* largest index page, plus overhead.
|
|
294 |
*/
|
|
295 |
#define XT_INDEX_WRITE_BUFFER_SIZE (1024 * 1024)
|
|
296 |
||
297 |
/* This is the time in seconds that a open table in the open
|
|
298 |
* table pool must be on the free list before it
|
|
299 |
* is actually freed from the pool.
|
|
300 |
*
|
|
301 |
* This is to reduce the affect from MySQL with a very low
|
|
302 |
* table cache size, which causes tables to be openned and
|
|
303 |
* closed very rapidly.
|
|
304 |
*/
|
|
305 |
#define XT_OPEN_TABLE_FREE_TIME 30
|
|
306 |
||
307 |
/* Define this in order to use memory mapped files
|
|
308 |
* (record and row pointer files only).
|
|
309 |
*
|
|
310 |
* This makes no difference in sysbench R/W performance
|
|
311 |
* test.
|
|
312 |
*/
|
|
313 |
//#define XT_USE_ROW_REC_MMAP_FILES
|
|
314 |
||
315 |
/* Define this if sequential scan should load data into the
|
|
316 |
* record cache.
|
|
317 |
*
|
|
318 |
* This is the way InnoDB behaves.
|
|
319 |
*/
|
|
320 |
#define XT_SEQ_SCAN_LOADS_CACHE
|
|
321 |
||
322 |
/* Define this in order to use memory mapped files (XT_FT_STANDARD): */
|
|
323 |
//#define XT_USE_DEFAULT_MEMORY_TABS
|
|
324 |
||
325 |
/* Define the default file type used by disk tables: */
|
|
326 |
#ifdef XT_USE_ROW_REC_MMAP_FILES
|
|
327 |
#define XT_REC_FILE_TYPE XT_FT_MEM_MAP
|
|
328 |
#define XT_ROW_FILE_TYPE XT_FT_MEM_MAP
|
|
329 |
#else
|
|
330 |
#define XT_REC_FILE_TYPE XT_FT_STANDARD
|
|
331 |
#define XT_ROW_FILE_TYPE XT_FT_STANDARD
|
|
332 |
#endif
|
|
333 |
#define XT_IND_FILE_TYPE XT_FT_STANDARD
|
|
334 |
||
335 |
/* Define this in order to use direct I/O on index files: */
|
|
336 |
/* NOTE: DO NOT ENABLE!
|
|
337 |
* {DIRECT-IO}
|
|
338 |
* It currently does not work, because of changes to the inde
|
|
339 |
* cache.
|
|
340 |
*/
|
|
341 |
//#define XT_USE_DIRECT_IO_ON_INDEX
|
|
342 |
||
343 |
/*
|
|
344 |
* Define this variable if PBXT should do lazy deleting in indexes
|
|
345 |
* Note, even if the variable is not defined, PBXT will handle
|
|
346 |
* lazy deleted items in an index.
|
|
347 |
*
|
|
348 |
* NOTE: This can cause significant degrade of index scan speed.
|
|
349 |
* 25% on sysbench readonly index scan tests.
|
|
350 |
*/
|
|
351 |
//#define XT_USE_LAZY_DELETE
|
|
352 |
||
353 |
/*
|
|
354 |
* Define this variable if a connection should wait for the
|
|
355 |
* sweeper to clean up previous transactions executed by the
|
|
356 |
* connection, before continuing.
|
|
357 |
*
|
|
358 |
* The number of transactions that the sweeper is aload to
|
|
359 |
* lag can be dynamic, but there is a limit (XT_MAX_XACT_BEHIND)
|
|
360 |
*/
|
|
361 |
#define XT_WAIT_FOR_CLEANUP
|
|
362 |
||
363 |
/*
|
|
364 |
* This seems to be the optimal value, at least according to
|
|
365 |
* sysbench/sysbench run --test=oltp --num-threads=128 --max-requests=50000 --mysql-user=root
|
|
366 |
* --oltp-table-size=100000 --oltp-table-name=sb_pbxt --mysql-engine-trx=yes
|
|
367 |
*
|
|
368 |
* Using 8, 16 and 128 threads.
|
|
369 |
*/
|
|
370 |
#define XT_MAX_XACT_BEHIND 2
|
|
371 |
||
372 |
/* {NO-ACTION-BUG}
|
|
373 |
* Define this to implement NO ACTION correctly
|
|
374 |
* NOTE: this does not work currently because of a bug
|
|
375 |
* in MySQL
|
|
376 |
*
|
|
377 |
* The bug prevent returning of an error in external_lock()
|
|
378 |
* on statement end. In this case an assertion fails.
|
|
379 |
*
|
|
380 |
* set storage_engine = pbxt;
|
|
381 |
* DROP TABLE IF EXISTS t4,t3,t2,t1;
|
|
382 |
* CREATE TABLE t1 (s1 INT PRIMARY KEY);
|
|
383 |
* CREATE TABLE t2 (s1 INT PRIMARY KEY, FOREIGN KEY (s1) REFERENCES t1 (s1) ON DELETE NO ACTION);
|
|
384 |
*
|
|
385 |
* INSERT INTO t1 VALUES (1);
|
|
386 |
* INSERT INTO t2 VALUES (1);
|
|
387 |
*
|
|
388 |
* begin;
|
|
389 |
* INSERT INTO t1 VALUES (2);
|
|
390 |
* DELETE FROM t1 where s1 = 1;
|
|
391 |
* <-- Assertion fails here because this DELETE returns
|
|
392 |
* an error from external_lock()
|
|
393 |
*/
|
|
394 |
//#define XT_IMPLEMENT_NO_ACTION
|
|
395 |
||
396 |
/*
|
|
397 |
* This is the number of rows imported in a single transactions.
|
|
398 |
* Import is done during the ALTER TABLE, CREATE INDEX and
|
|
399 |
* LOAD DATA INFILE statements.
|
|
400 |
*/
|
|
401 |
#define XT_IMPORT_ROW_COUNT 10000
|
|
402 |
||
403 |
/*
|
|
404 |
* Define this if freed records should be clustered together in pages.
|
|
405 |
* This means when a record is freed it is not added to the front of
|
|
406 |
* the free list if there is already a record free on the same page.
|
|
407 |
* Instead it is changed into the list so that free records in the
|
|
408 |
* same page follow one another.
|
|
409 |
*
|
|
410 |
* This should cause updated records to cluster togetger
|
|
411 |
* in pages.
|
|
412 |
*/
|
|
413 |
//#define XT_CLUSTER_FREE_RECORDS
|
|
414 |
||
415 |
/* Define this to add a timer for disk writes.
|
|
416 |
*/
|
|
417 |
#define XT_TIME_DISK_WRITES
|
|
418 |
||
419 |
/* Define this to add a timer to disk reads. Not enabled by default,
|
|
420 |
* because it is considered expensive (?).
|
|
421 |
*/
|
|
422 |
#define XT_TIME_DISK_READS
|
|
423 |
||
424 |
/*
|
|
425 |
* Define the number of bytes that are written by the writer before
|
|
426 |
* it flushes the record and row files.
|
|
427 |
*/
|
|
428 |
#ifdef DEBUG
|
|
429 |
//#define XT_REC_FLUSH_THRESHOLD (500 * 1024)
|
|
430 |
#else
|
|
431 |
//#define XT_REC_FLUSH_THRESHOLD (100 * 1024 * 1024)
|
|
432 |
#endif
|
|
433 |
||
434 |
/*
|
|
435 |
* Define this in order to sort writes to the handle data file.
|
|
436 |
* The number given is the maximum number of writes delayed for
|
|
437 |
* sorting.
|
|
438 |
*/
|
|
439 |
//#define XT_SORT_REC_WRITES
|
|
440 |
||
441 |
#ifdef XT_SORT_REC_WRITES
|
|
442 |
#ifdef DEBUG
|
|
443 |
#define XT_SORT_REC_MAX_BUF_SIZE (64*1024)
|
|
444 |
#else
|
|
445 |
#define XT_SORT_REC_MAX_BUF_SIZE (256*1024)
|
|
446 |
#endif
|
|
447 |
#endif
|
|
448 |
||
449 |
/* Define the variable to cause the sweeper to sort transactions
|
|
450 |
* that need to be sweeped. The affect is that the sweeper will
|
|
451 |
* clean up transaction as soon as possible, not just in
|
|
452 |
* begin order.
|
|
453 |
*/
|
|
454 |
//#define XT_SWEEPER_SORT_XACTS
|
|
455 |
||
456 |
/*
|
|
457 |
* Define this in order to enable BLOB streaming. BLOB streaming
|
|
458 |
* requires the PBMS storage engine. If the engine is not present
|
|
459 |
* then defining this has no affect.
|
|
460 |
*/
|
|
461 |
//#define PBMS_ENABLED
|
|
462 |
||
463 |
/* Define this value if online-backup should be supported.
|
|
464 |
* Note that, online backup is currently only supported
|
|
465 |
* by MySQL 6.0.9 or later
|
|
466 |
*/
|
|
467 |
#define XT_ENABLE_ONLINE_BACKUP
|
|
468 |
||
469 |
/* Define this switch if you don't want to use atomic
|
|
470 |
* synchronisation.
|
|
471 |
*/
|
|
472 |
#ifndef XT_NO_ATOMICS
|
|
473 |
//#define XT_NO_ATOMICS
|
|
474 |
#endif
|
|
475 |
||
476 |
/* When pbxt_flush_log_at_trx_commit != 1, the transaction log is flushed
|
|
477 |
* at regular intervals. Set the interval here.
|
|
478 |
*/
|
|
479 |
#define XT_XLOG_FLUSH_FREQ 1000
|
|
480 |
||
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
481 |
/*
|
482 |
* Define here if you want to check (and correct) the table free list
|
|
483 |
* counts. The free list counts are not durable, because they are not
|
|
484 |
* written to the log.
|
|
485 |
*
|
|
486 |
* The row free count is most critical because it can be used to
|
|
487 |
* estimate the the of rows in the record.
|
|
488 |
*/
|
|
489 |
#define XT_CHECK_ROW_FREE_COUNT
|
|
490 |
#ifdef DEBUG
|
|
491 |
#define XT_CHECK_RECORD_FREE_COUNT
|
|
492 |
#endif
|
|
493 |
#define XT_CORRECT_TABLE_FREE_COUNT
|
|
494 |
||
495 |
#if defined(XT_CHECK_ROW_FREE_COUNT) && defined(XT_CORRECT_TABLE_FREE_COUNT)
|
|
496 |
#define XT_ROW_COUNT_CORRECTED
|
|
497 |
#endif
|
|
498 |
||
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
499 |
/* ----------------------------------------------------------------------
|
500 |
* GLOBAL CONSTANTS
|
|
501 |
*/
|
|
502 |
||
503 |
#define XT_INDEX_PAGE_SIZE (1 << XT_INDEX_PAGE_SHIFTS)
|
|
504 |
#define XT_INDEX_PAGE_MASK (XT_INDEX_PAGE_SIZE - 1)
|
|
505 |
||
506 |
/* The index file uses direct I/O. This is the minimum block.
|
|
507 |
* size that can be used when doing direct I/O.
|
|
508 |
*/
|
|
509 |
#define XT_BLOCK_SIZE_FOR_DIRECT_IO 512
|
|
510 |
||
511 |
/*
|
|
512 |
* The header is currently a fixed size, so the information must
|
|
513 |
* fit in this block!
|
|
514 |
*
|
|
515 |
* This must also be a multiple of XT_INDEX_MIN_BLOCK_SIZE
|
|
516 |
*/
|
|
517 |
#define XT_INDEX_HEAD_SIZE (XT_BLOCK_SIZE_FOR_DIRECT_IO * 8) // 4K |
|
518 |
||
519 |
#define XT_IDENTIFIER_CHAR_COUNT 64
|
|
520 |
||
521 |
#define XT_IDENTIFIER_NAME_SIZE ((XT_IDENTIFIER_CHAR_COUNT * 3) + 1) // The identifier length as UTF-8 |
|
522 |
#define XT_TABLE_NAME_SIZE ((XT_IDENTIFIER_CHAR_COUNT * 5) + 1) // The maximum length of a file name that has been normalized |
|
523 |
||
524 |
#define XT_ADD_PTR(p, l) ((void *) ((char *) (p) + (l)))
|
|
525 |
||
526 |
#define XT_MAX_XA_DATA_SIZE (3*4 + 128) /* Corresponds to the maximum size of struct xid_t in handler.h. */ |
|
527 |
||
528 |
/* ----------------------------------------------------------------------
|
|
529 |
* DEFINES DEPENDENT ON CONSTANTS
|
|
530 |
*/
|
|
531 |
||
532 |
#define XT_ROW_REC_FILE_PTR XTOpenFilePtr
|
|
533 |
#define XT_PREAD_RR_FILE xt_pread_file
|
|
534 |
#define XT_FLUSH_RR_FILE xt_flush_file
|
|
535 |
#define XT_CLOSE_RR_FILE_NS xt_close_file_ns
|
|
536 |
||
537 |
#define XT_LOCK_MEMORY_PTR(x, f, a, s, v, c) do { if (!xt_lock_file_ptr(f, &x, a, s, v, c)) x = NULL; } while (0)
|
|
538 |
#define XT_UNLOCK_MEMORY_PTR(f, d, v) xt_unlock_file_ptr(f, d, v)
|
|
539 |
||
540 |
/* ----------------------------------------------------------------------
|
|
541 |
* DEBUG SIZES!
|
|
542 |
* Reduce the thresholds to make things happen faster.
|
|
543 |
*/
|
|
544 |
||
545 |
#ifdef XT_USE_GLOBAL_DEBUG_SIZES
|
|
546 |
||
547 |
//#undef XT_ROW_RWLOCKS
|
|
548 |
//#define XT_ROW_RWLOCKS 2
|
|
549 |
||
550 |
//#undef XT_TAB_MIN_VAR_REC_LENGTH
|
|
551 |
//#define XT_TAB_MIN_VAR_REC_LENGTH 20
|
|
552 |
||
553 |
//#undef XT_ROW_LOCK_COUNT
|
|
554 |
//#define XT_ROW_LOCK_COUNT (XT_ROW_RWLOCKS * 2)
|
|
555 |
||
556 |
//#undef XT_INDEX_PAGE_SHIFTS
|
|
557 |
//#define XT_INDEX_PAGE_SHIFTS 8 // 256
|
|
558 |
//#undef XT_BLOCK_SIZE_FOR_DIRECT_IO
|
|
559 |
//#define XT_BLOCK_SIZE_FOR_DIRECT_IO 256
|
|
560 |
||
561 |
//#undef XT_INDEX_WRITE_BUFFER_SIZE
|
|
562 |
//#define XT_INDEX_WRITE_BUFFER_SIZE (40 * 1024)
|
|
563 |
||
564 |
//#undef XT_XLOG_FLUSH_FREQ
|
|
565 |
//#define XT_XLOG_FLUSH_FREQ (30 * 1000)
|
|
566 |
||
567 |
//#undef XT_IMPORT_ROW_COUNT
|
|
568 |
//#define XT_IMPORT_ROW_COUNT 12
|
|
569 |
||
570 |
#endif
|
|
571 |
||
572 |
/* ----------------------------------------------------------------------
|
|
573 |
* BYTE ORDER
|
|
574 |
*/
|
|
575 |
||
1531.1.5
by Paul McCullagh
Changed from using a Table to a TableShare |
576 |
/* Missing on some Solaris machines: */
|
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
577 |
/* Drizzle compiles with this stuff defined here.
|
578 |
* Is there a reason why they should not go here?
|
|
579 |
* In general, this should come after the system
|
|
580 |
* headers, just in case they are defined in the
|
|
581 |
* system headers. xt_defs.h should be included
|
|
582 |
* after the system headers. xt_config.h should be
|
|
583 |
* included before the system headers.
|
|
584 |
*/
|
|
1531.1.5
by Paul McCullagh
Changed from using a Table to a TableShare |
585 |
#ifndef BIG_ENDIAN
|
586 |
#define BIG_ENDIAN 4321
|
|
587 |
#endif
|
|
588 |
#ifndef LITTLE_ENDIAN
|
|
589 |
#define LITTLE_ENDIAN 1234
|
|
590 |
#endif
|
|
591 |
#ifndef PDP_ENDIAN
|
|
592 |
#define PDP_ENDIAN 3412
|
|
593 |
#endif
|
|
594 |
||
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
595 |
/*
|
596 |
* Byte order on the disk is little endian! This is the byte order of the i386.
|
|
597 |
* Little endian byte order starts with the least significant byte.
|
|
598 |
*
|
|
599 |
* The reason for choosing this byte order for the disk is 2-fold:
|
|
600 |
* Firstly the i386 is the cheapest and fasted platform today.
|
|
601 |
* Secondly the i386, unlike RISK chips (with big endian) can address
|
|
602 |
* memory that is not aligned!
|
|
603 |
*
|
|
604 |
* Since the disk image of PrimeBase XT is not aligned, the second point
|
|
605 |
* is significant. A RISK chip needs to access it byte-wise, so we might as
|
|
606 |
* well do the byte swapping at the same time.
|
|
607 |
*
|
|
608 |
* The macros below are of 4 general types:
|
|
609 |
*
|
|
610 |
* GET/SET - Get and set 1,2,4,8 byte values (short, int, long, etc).
|
|
611 |
* Values are swapped only on big endian platforms. This makes these
|
|
612 |
* functions very efficient on little-endian platforms.
|
|
613 |
*
|
|
614 |
* COPY - Transfer data without swapping regardless of platform. This
|
|
615 |
* function is a bit more efficient on little-endian platforms
|
|
616 |
* because alignment is not an issue.
|
|
617 |
*
|
|
618 |
* MOVE - Similar to get and set, but the deals with memory instead
|
|
619 |
* of values. Since no swapping is done on little-endian platforms
|
|
620 |
* this function is identical to COPY on little-endian platforms.
|
|
621 |
*
|
|
622 |
* SWAP - Transfer and swap data regardless of the platform type.
|
|
623 |
* Aligment is not assumed.
|
|
624 |
*
|
|
625 |
* The DISK component of the macro names indicates that alignment of
|
|
626 |
* the value cannot be assumed.
|
|
627 |
*
|
|
628 |
*/
|
|
629 |
#if BYTE_ORDER == BIG_ENDIAN
|
|
630 |
/* The native order of the machine is big endian. Since the native disk
|
|
631 |
* disk order of XT is little endian, all data to and from disk
|
|
632 |
* must be swapped.
|
|
633 |
*/
|
|
634 |
#define XT_SET_DISK_1(d, s) ((d)[0] = (xtWord1) (s))
|
|
635 |
||
636 |
#define XT_SET_DISK_2(d, s) do { (d)[0] = (xtWord1) (((xtWord2) (s)) & 0xFF); (d)[1] = (xtWord1) ((((xtWord2) (s)) >> 8 ) & 0xFF); } while (0)
|
|
637 |
||
638 |
#define XT_SET_DISK_3(d, s) do { (d)[0] = (xtWord1) (((xtWord4) (s)) & 0xFF); (d)[1] = (xtWord1) ((((xtWord4) (s)) >> 8 ) & 0xFF); \
|
|
639 |
(d)[2] = (xtWord1) ((((xtWord4) (s)) >> 16) & 0xFF); } while (0)
|
|
640 |
||
641 |
#define XT_SET_DISK_4(d, s) do { (d)[0] = (xtWord1) (((xtWord4) (s)) & 0xFF); (d)[1] = (xtWord1) ((((xtWord4) (s)) >> 8 ) & 0xFF); \
|
|
642 |
(d)[2] = (xtWord1) ((((xtWord4) (s)) >> 16) & 0xFF); (d)[3] = (xtWord1) ((((xtWord4) (s)) >> 24) & 0xFF); } while (0)
|
|
643 |
||
644 |
#define XT_SET_DISK_6(d, s) do { (d)[0] = (xtWord1) (((xtWord8) (s)) & 0xFF); (d)[1] = (xtWord1) ((((xtWord8) (s)) >> 8 ) & 0xFF); \
|
|
645 |
(d)[2] = (xtWord1) ((((xtWord8) (s)) >> 16) & 0xFF); (d)[3] = (xtWord1) ((((xtWord8) (s)) >> 24) & 0xFF); \
|
|
646 |
(d)[4] = (xtWord1) ((((xtWord8) (s)) >> 32) & 0xFF); (d)[5] = (xtWord1) ((((xtWord8) (s)) >> 40) & 0xFF); } while (0)
|
|
647 |
||
648 |
#define XT_SET_DISK_8(d, s) do { (d)[0] = (xtWord1) (((xtWord8) (s)) & 0xFF); (d)[1] = (xtWord1) ((((xtWord8) (s)) >> 8 ) & 0xFF); \
|
|
649 |
(d)[2] = (xtWord1) ((((xtWord8) (s)) >> 16) & 0xFF); (d)[3] = (xtWord1) ((((xtWord8) (s)) >> 24) & 0xFF); \
|
|
650 |
(d)[4] = (xtWord1) ((((xtWord8) (s)) >> 32) & 0xFF); (d)[5] = (xtWord1) ((((xtWord8) (s)) >> 40) & 0xFF); \
|
|
651 |
(d)[6] = (xtWord1) ((((xtWord8) (s)) >> 48) & 0xFF); (d)[7] = (xtWord1) ((((xtWord8) (s)) >> 56) & 0xFF); } while (0)
|
|
652 |
||
653 |
#define XT_GET_DISK_1(s) ((s)[0])
|
|
654 |
||
655 |
#define XT_GET_DISK_2(s) ((xtWord2) (((xtWord2) (s)[0]) | (((xtWord2) (s)[1]) << 8)))
|
|
656 |
||
657 |
#define XT_GET_DISK_3(s) ((xtWord4) (((xtWord4) (s)[0]) | (((xtWord4) (s)[1]) << 8) | (((xtWord4) (s)[2]) << 16)))
|
|
658 |
||
659 |
#define XT_GET_DISK_4(s) (((xtWord4) (s)[0]) | (((xtWord4) (s)[1]) << 8 ) | \
|
|
660 |
(((xtWord4) (s)[2]) << 16) | (((xtWord4) (s)[3]) << 24))
|
|
661 |
||
662 |
#define XT_GET_DISK_6(s) (((xtWord8) (s)[0]) | (((xtWord8) (s)[1]) << 8 ) | \
|
|
663 |
(((xtWord8) (s)[2]) << 16) | (((xtWord8) (s)[3]) << 24) | \
|
|
664 |
(((xtWord8) (s)[4]) << 32) | (((xtWord8) (s)[5]) << 40))
|
|
665 |
||
666 |
#define XT_GET_DISK_8(s) (((xtWord8) (s)[0]) | (((xtWord8) (s)[1]) << 8 ) | \
|
|
667 |
(((xtWord8) (s)[2]) << 16) | (((xtWord8) (s)[3]) << 24) | \
|
|
668 |
(((xtWord8) (s)[4]) << 32) | (((xtWord8) (s)[5]) << 40) | \
|
|
669 |
(((xtWord8) (s)[6]) << 48) | (((xtWord8) (s)[7]) << 56))
|
|
670 |
||
671 |
/* Move will copy memory, and swap the bytes on a big endian machine.
|
|
672 |
* On a little endian machine it is the same as COPY.
|
|
673 |
*/
|
|
674 |
#define XT_MOVE_DISK_1(d, s) ((d)[0] = (s)[0])
|
|
675 |
#define XT_MOVE_DISK_2(d, s) do { (d)[0] = (s)[1]; (d)[1] = (s)[0]; } while (0)
|
|
676 |
#define XT_MOVE_DISK_3(d, s) do { (d)[0] = (s)[2]; (d)[1] = (s)[1]; (d)[2] = (s)[0]; } while (0)
|
|
677 |
#define XT_MOVE_DISK_4(d, s) do { (d)[0] = (s)[3]; (d)[1] = (s)[2]; (d)[2] = (s)[1]; (d)[3] = (s)[0]; } while (0)
|
|
678 |
#define XT_MOVE_DISK_8(d, s) do { (d)[0] = (s)[7]; (d)[1] = (s)[6]; \
|
|
679 |
(d)[2] = (s)[5]; (d)[3] = (s)[4]; \
|
|
680 |
(d)[4] = (s)[3]; (d)[5] = (s)[2]; \
|
|
681 |
(d)[6] = (s)[1]; (d)[7] = (s)[0]; } while (0)
|
|
682 |
||
683 |
/*
|
|
684 |
* Copy just copies the number of bytes assuming the data is not alligned.
|
|
685 |
*/
|
|
686 |
#define XT_COPY_DISK_1(d, s) (d)[0] = s
|
|
687 |
#define XT_COPY_DISK_2(d, s) do { (d)[0] = (s)[0]; (d)[1] = (s)[1]; } while (0)
|
|
688 |
#define XT_COPY_DISK_3(d, s) do { (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; } while (0)
|
|
689 |
#define XT_COPY_DISK_4(d, s) do { (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; } while (0)
|
|
690 |
#define XT_COPY_DISK_6(d, s) memcpy(&((d)[0]), &((s)[0]), 6)
|
|
691 |
#define XT_COPY_DISK_8(d, s) memcpy(&((d)[0]), &((s)[0]), 8)
|
|
692 |
#define XT_COPY_DISK_10(d, s) memcpy(&((d)[0]), &((s)[0]), 10)
|
|
693 |
||
694 |
#define XT_SET_NULL_DISK_1(d) XT_SET_DISK_1(d, 0)
|
|
695 |
#define XT_SET_NULL_DISK_2(d) do { (d)[0] = 0; (d)[1] = 0; } while (0)
|
|
696 |
#define XT_SET_NULL_DISK_4(d) do { (d)[0] = 0; (d)[1] = 0; (d)[2] = 0; (d)[3] = 0; } while (0)
|
|
697 |
#define XT_SET_NULL_DISK_6(d) do { (d)[0] = 0; (d)[1] = 0; (d)[2] = 0; (d)[3] = 0; (d)[4] = 0; (d)[5] = 0; } while (0)
|
|
698 |
#define XT_SET_NULL_DISK_8(d) do { (d)[0] = 0; (d)[1] = 0; (d)[2] = 0; (d)[3] = 0; (d)[4] = 0; (d)[5] = 0; (d)[6] = 0; (d)[7] = 0; } while (0)
|
|
699 |
||
700 |
#define XT_IS_NULL_DISK_1(d) (!(XT_GET_DISK_1(d)))
|
|
701 |
#define XT_IS_NULL_DISK_4(d) (!(d)[0] && !(d)[1] && !(d)[2] && !(d)[3])
|
|
702 |
#define XT_IS_NULL_DISK_8(d) (!(d)[0] && !(d)[1] && !(d)[2] && !(d)[3] && !(d)[4] && !(d)[5] && !(d)[6] && !(7)[3])
|
|
703 |
||
704 |
#define XT_EQ_DISK_4(d, s) ((d)[0] == (s)[0] && (d)[1] == (s)[1] && (d)[2] == (s)[2] && (d)[3] == (s)[3])
|
|
705 |
#define XT_EQ_DISK_8(d, s) ((d)[0] == (s)[0] && (d)[1] == (s)[1] && (d)[2] == (s)[2] && (d)[3] == (s)[3] && \
|
|
706 |
(d)[4] == (s)[4] && (d)[5] == (s)[5] && (d)[6] == (s)[6] && (d)[7] == (s)[7])
|
|
707 |
||
708 |
#define XT_IS_FF_DISK_4(d) ((d)[0] == 0xFF && (d)[1] == 0xFF && (d)[2] == 0xFF && (d)[3] == 0xFF)
|
|
709 |
#else
|
|
710 |
/*
|
|
711 |
* The native order of the machine is little endian. This means the data to
|
|
712 |
* and from disk need not be swapped. In addition to this, since
|
|
713 |
* the i386 can access non-aligned memory we are not required to
|
|
714 |
* handle the data byte-for-byte.
|
|
715 |
*/
|
|
716 |
#define XT_SET_DISK_1(d, s) ((d)[0] = (xtWord1) (s))
|
|
717 |
#define XT_SET_DISK_2(d, s) (*((xtWord2 *) &((d)[0])) = (xtWord2) (s))
|
|
718 |
#define XT_SET_DISK_3(d, s) do { (*((xtWord2 *) &((d)[0])) = (xtWord2) (s)); *((xtWord1 *) &((d)[2])) = (xtWord1) (((xtWord4) (s)) >> 16); } while (0)
|
|
719 |
#define XT_SET_DISK_4(d, s) (*((xtWord4 *) &((d)[0])) = (xtWord4) (s))
|
|
720 |
#define XT_SET_DISK_6(d, s) do { *((xtWord4 *) &((d)[0])) = (xtWord4) (s); *((xtWord2 *) &((d)[4])) = (xtWord2) (((xtWord8) (s)) >> 32); } while (0)
|
|
721 |
#define XT_SET_DISK_8(d, s) (*((xtWord8 *) &((d)[0])) = (xtWord8) (s))
|
|
722 |
||
723 |
#define XT_GET_DISK_1(s) ((s)[0])
|
|
724 |
#define XT_GET_DISK_2(s) *((xtWord2 *) &((s)[0]))
|
|
725 |
#define XT_GET_DISK_3(s) ((xtWord4) *((xtWord2 *) &((s)[0])) | (((xtWord4) *((xtWord1 *) &((s)[2]))) << 16))
|
|
726 |
#define XT_GET_DISK_4(s) *((xtWord4 *) &((s)[0]))
|
|
727 |
#define XT_GET_DISK_6(s) ((xtWord8) *((xtWord4 *) &((s)[0])) | (((xtWord8) *((xtWord2 *) &((s)[4]))) << 32))
|
|
728 |
#define XT_GET_DISK_8(s) *((xtWord8 *) &((s)[0]))
|
|
729 |
||
730 |
#define XT_MOVE_DISK_1(d, s) ((d)[0] = (s)[0])
|
|
731 |
#define XT_MOVE_DISK_2(d, s) XT_COPY_DISK_2(d, s)
|
|
732 |
#define XT_MOVE_DISK_3(d, s) XT_COPY_DISK_3(d, s)
|
|
733 |
#define XT_MOVE_DISK_4(d, s) XT_COPY_DISK_4(d, s)
|
|
734 |
#define XT_MOVE_DISK_8(d, s) XT_COPY_DISK_8(d, s)
|
|
735 |
||
736 |
#define XT_COPY_DISK_1(d, s) (d)[0] = s
|
|
737 |
#define XT_COPY_DISK_2(d, s) (*((xtWord2 *) &((d)[0])) = (*((xtWord2 *) &((s)[0]))))
|
|
738 |
#define XT_COPY_DISK_3(d, s) do { *((xtWord2 *) &((d)[0])) = *((xtWord2 *) &((s)[0])); (d)[2] = (s)[2]; } while (0)
|
|
739 |
#define XT_COPY_DISK_4(d, s) (*((xtWord4 *) &((d)[0])) = (*((xtWord4 *) &((s)[0]))))
|
|
740 |
#define XT_COPY_DISK_6(d, s) do { *((xtWord4 *) &((d)[0])) = *((xtWord4 *) &((s)[0])); *((xtWord2 *) &((d)[4])) = *((xtWord2 *) &((s)[4])); } while (0)
|
|
741 |
#define XT_COPY_DISK_8(d, s) (*((xtWord8 *) &(d[0])) = (*((xtWord8 *) &((s)[0]))))
|
|
742 |
#define XT_COPY_DISK_10(d, s) memcpy(&((d)[0]), &((s)[0]), 10)
|
|
743 |
||
744 |
#define XT_SET_NULL_DISK_1(d) XT_SET_DISK_1(d, 0)
|
|
745 |
#define XT_SET_NULL_DISK_2(d) XT_SET_DISK_2(d, 0)
|
|
746 |
#define XT_SET_NULL_DISK_3(d) XT_SET_DISK_3(d, 0)
|
|
747 |
#define XT_SET_NULL_DISK_4(d) XT_SET_DISK_4(d, 0L)
|
|
748 |
#define XT_SET_NULL_DISK_6(d) XT_SET_DISK_6(d, 0LL)
|
|
749 |
#define XT_SET_NULL_DISK_8(d) XT_SET_DISK_8(d, 0LL)
|
|
750 |
||
751 |
#define XT_IS_NULL_DISK_1(d) (!(XT_GET_DISK_1(d)))
|
|
752 |
#define XT_IS_NULL_DISK_2(d) (!(XT_GET_DISK_2(d)))
|
|
753 |
#define XT_IS_NULL_DISK_3(d) (!(XT_GET_DISK_3(d)))
|
|
754 |
#define XT_IS_NULL_DISK_4(d) (!(XT_GET_DISK_4(d)))
|
|
755 |
#define XT_IS_NULL_DISK_8(d) (!(XT_GET_DISK_8(d)))
|
|
756 |
||
757 |
#define XT_EQ_DISK_4(d, s) (XT_GET_DISK_4(d) == XT_GET_DISK_4(s))
|
|
758 |
#define XT_EQ_DISK_8(d, s) (XT_GET_DISK_8(d) == XT_GET_DISK_8(s))
|
|
759 |
||
760 |
#define XT_IS_FF_DISK_4(d) (XT_GET_DISK_4(d) == 0xFFFFFFFF)
|
|
761 |
#endif
|
|
762 |
||
763 |
#define XT_CMP_DISK_4(a, b) ((xtInt4) XT_GET_DISK_4(a) - (xtInt4) XT_GET_DISK_4(b))
|
|
764 |
#define XT_CMP_DISK_8(d, s) memcmp(&((d)[0]), &((s)[0]), 8)
|
|
765 |
//#define XT_CMP_DISK_8(d, s) (XT_CMP_DISK_4((d).h_number_4, (s).h_number_4) == 0 ? XT_CMP_DISK_4((d).h_file_4, (s).h_file_4) : XT_CMP_DISK_4((d).h_number_4, (s).h_number_4))
|
|
766 |
||
767 |
#define XT_SWAP_DISK_2(d, s) do { (d)[0] = (s)[1]; (d)[1] = (s)[0]; } while (0)
|
|
768 |
#define XT_SWAP_DISK_3(d, s) do { (d)[0] = (s)[2]; (d)[1] = (s)[1]; (d)[2] = (s)[0]; } while (0)
|
|
769 |
#define XT_SWAP_DISK_4(d, s) do { (d)[0] = (s)[3]; (d)[1] = (s)[2]; (d)[2] = (s)[1]; (d)[3] = (s)[0]; } while (0)
|
|
770 |
#define XT_SWAP_DISK_8(d, s) do { (d)[0] = (s)[7]; (d)[1] = (s)[6]; (d)[2] = (s)[5]; (d)[3] = (s)[4]; \
|
|
771 |
(d)[4] = (s)[3]; (d)[5] = (s)[2]; (d)[6] = (s)[1]; (d)[7] = (s)[0]; } while (0)
|
|
772 |
||
773 |
/* ----------------------------------------------------------------------
|
|
774 |
* GLOBAL APPLICATION TYPES & MACROS
|
|
775 |
*/
|
|
776 |
||
777 |
struct XTThread; |
|
778 |
||
779 |
typedef void (*XTFreeFunc)(struct XTThread *self, void *thunk, void *item); |
|
780 |
typedef int (*XTCompareFunc)(struct XTThread *self, register const void *thunk, register const void *a, register const void *b); |
|
781 |
||
782 |
/* Log ID and offset: */
|
|
783 |
#define xtLogID xtWord4
|
|
784 |
#define xtLogOffset off_t
|
|
785 |
||
786 |
#define xtDatabaseID xtWord4
|
|
787 |
#define xtTableID xtWord4
|
|
788 |
#define xtOpSeqNo xtWord4
|
|
789 |
#define xtXactID xtWord4
|
|
790 |
#define xtThreadID xtWord4
|
|
791 |
||
792 |
#ifdef DEBUG
|
|
793 |
//#define XT_USE_NODE_ID_STRUCT
|
|
794 |
#endif
|
|
795 |
||
796 |
#ifdef XT_USE_NODE_ID_STRUCT
|
|
797 |
typedef struct xtIndexNodeID { |
|
798 |
xtWord4 x; |
|
799 |
} xtIndexNodeID; |
|
800 |
#define XT_NODE_TEMP xtWord4 xt_node_temp
|
|
801 |
#define XT_NODE_ID(a) (a).x
|
|
802 |
#define XT_RET_NODE_ID(a) *((xtIndexNodeID *) &(xt_node_temp = (a)))
|
|
803 |
#else
|
|
804 |
#define XT_NODE_TEMP
|
|
805 |
#define xtIndexNodeID xtWord4
|
|
806 |
#define XT_NODE_ID(a) a
|
|
807 |
#define XT_RET_NODE_ID(a) ((xtIndexNodeID) (a))
|
|
808 |
#endif
|
|
809 |
||
810 |
/* Row, Record ID and Record offsets: */
|
|
811 |
#define xtRowID xtWord4
|
|
812 |
#define xtRecordID xtWord4 /* NOTE: Record offset == header-size + record-id * record-size! */ |
|
813 |
#define xtRefID xtWord4 /* Must be big enough to contain a xtRowID and a xtRecordID! */ |
|
814 |
#define xtRecOffset off_t
|
|
815 |
#define xtDiskRecordID4 XTDiskValue4
|
|
816 |
#ifdef XT_WIN
|
|
817 |
#define xtProcID DWORD
|
|
818 |
#else
|
|
819 |
#define xtProcID pid_t
|
|
820 |
#endif
|
|
821 |
||
822 |
#define XT_ROW_ID_SIZE 4
|
|
823 |
#define XT_RECORD_ID_SIZE 4
|
|
824 |
#define XT_REF_ID_SIZE 4 /* max(XT_ROW_ID_SIZE, XT_RECORD_ID_SIZE) */ |
|
825 |
#define XT_RECORD_OFFS_SIZE 4
|
|
826 |
#define XT_RECORD_REF_SIZE (XT_RECORD_ID_SIZE + XT_ROW_ID_SIZE)
|
|
827 |
#define XT_CHECKSUM4_REC(x) (x)
|
|
828 |
||
829 |
#define XT_XACT_ID_SIZE 4
|
|
830 |
#define XT_CHECKSUM4_XACT(x) (x)
|
|
831 |
||
832 |
#ifdef XT_WIN
|
|
833 |
#define __FUNC__ __FUNCTION__
|
|
834 |
#elif defined(XT_SOLARIS)
|
|
835 |
#define __FUNC__ "__func__"
|
|
836 |
#else
|
|
837 |
#define __FUNC__ __PRETTY_FUNCTION__
|
|
838 |
#endif
|
|
839 |
||
840 |
/* ----------------------------------------------------------------------
|
|
841 |
* GLOBAL VARIABLES
|
|
842 |
*/
|
|
843 |
||
844 |
extern bool pbxt_inited; |
|
845 |
extern xtBool pbxt_ignore_case; |
|
846 |
extern const char *pbxt_extensions[]; |
|
847 |
extern xtBool pbxt_crash_debug; |
|
848 |
||
849 |
||
850 |
/* ----------------------------------------------------------------------
|
|
851 |
* DRIZZLE MAPPINGS VARIABLES
|
|
852 |
*/
|
|
853 |
||
854 |
#ifdef DRIZZLED
|
|
855 |
/* Drizzle is stuck at this level: */
|
|
856 |
#define MYSQL_VERSION_ID 60005
|
|
857 |
||
858 |
#define TABLE_LIST TableList
|
|
859 |
#define TABLE Table
|
|
860 |
#define THD Session
|
|
861 |
#define MYSQL_THD Session *
|
|
862 |
#define THR_THD THR_Session
|
|
1531.1.5
by Paul McCullagh
Changed from using a Table to a TableShare |
863 |
#define STRUCT_TABLE class drizzled::TableShare
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
864 |
#define TABLE_SHARE TableShare
|
1531.1.5
by Paul McCullagh
Changed from using a Table to a TableShare |
865 |
#define GET_TABLE_SHARE(x) (x)
|
1730.4.1
by Paul McCullagh
Fixed bug #618758: SHOW CREATE TABLE of PBXT table crashes server |
866 |
#define GET_TABLE_FIELDS(x) ((x)->getFields(true))
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
867 |
|
868 |
#define MYSQL_TYPE_STRING DRIZZLE_TYPE_VARCHAR
|
|
869 |
#define MYSQL_TYPE_VARCHAR DRIZZLE_TYPE_VARCHAR
|
|
870 |
#define MYSQL_TYPE_LONGLONG DRIZZLE_TYPE_LONGLONG
|
|
871 |
#define MYSQL_TYPE_BLOB DRIZZLE_TYPE_BLOB
|
|
872 |
#define MYSQL_TYPE_ENUM DRIZZLE_TYPE_ENUM
|
|
873 |
#define MYSQL_TYPE_LONG DRIZZLE_TYPE_LONG
|
|
874 |
#define MYSQL_PLUGIN_VAR_HEADER DRIZZLE_PLUGIN_VAR_HEADER
|
|
875 |
#define MYSQL_SYSVAR_STR DRIZZLE_SYSVAR_STR
|
|
876 |
#define MYSQL_SYSVAR_INT DRIZZLE_SYSVAR_INT
|
|
877 |
#define MYSQL_SYSVAR_BOOL DRIZZLE_SYSVAR_BOOL
|
|
878 |
#define MYSQL_SYSVAR DRIZZLE_SYSVAR
|
|
879 |
#define MYSQL_STORAGE_ENGINE_PLUGIN DRIZZLE_STORAGE_ENGINE_PLUGIN
|
|
880 |
#define MYSQL_INFORMATION_SCHEMA_PLUGIN DRIZZLE_INFORMATION_SCHEMA_PLUGIN
|
|
881 |
#define memcpy_fixed memcpy
|
|
882 |
#define bfill(m, len, ch) memset(m, ch, len)
|
|
883 |
||
884 |
#define mx_tmp_use_all_columns(x, y) (x)->use_all_columns(y)
|
|
885 |
#define mx_tmp_restore_column_map(x, y) (x)->restore_column_map(y)
|
|
886 |
||
887 |
#define MX_TABLE_TYPES_T StorageEngine::Table_flags
|
|
888 |
#define MX_UINT8_T uint8_t
|
|
889 |
#define MX_ULONG_T uint32_t
|
|
890 |
#define MX_ULONGLONG_T uint64_t
|
|
891 |
#define MX_LONGLONG_T uint64_t
|
|
892 |
#define MX_CHARSET_INFO struct drizzled::charset_info_st
|
|
893 |
#define MX_CONST_CHARSET_INFO const struct drizzled::charset_info_st
|
|
894 |
#define MX_CONST const
|
|
895 |
#define MX_BITMAP drizzled::MyBitmap
|
|
896 |
#define MX_BIT_SIZE() numOfBitsInMap()
|
|
897 |
#define MX_BIT_SET(x, y) (x)->setBit(y)
|
|
898 |
#define MX_BIT_FAST_TEST_AND_SET(x, y) (x)->testAndSet(y)
|
|
899 |
||
900 |
#define my_bool bool
|
|
901 |
//#define int16 int16_t
|
|
902 |
//#define int32 int32_t
|
|
903 |
//#define uint16 uint16_t
|
|
904 |
//#define uint32 uint32_t
|
|
905 |
#define uchar unsigned char
|
|
906 |
#define longlong int64_t
|
|
907 |
#define ulonglong uint64_t
|
|
908 |
#define handler Cursor
|
|
909 |
||
910 |
#define HAVE_LONG_LONG
|
|
911 |
||
912 |
#define my_malloc(x, y) malloc(x)
|
|
913 |
#define my_free(x, y) free(x)
|
|
914 |
||
915 |
#define HA_CAN_SQL_HANDLER 0
|
|
916 |
#define HA_CAN_INSERT_DELAYED 0
|
|
917 |
#define HA_BINLOG_ROW_CAPABLE 0
|
|
918 |
#define HA_BINLOG_STMT_CAPABLE 0
|
|
919 |
#define HA_CACHE_TBL_TRANSACT 0
|
|
920 |
||
921 |
//#define max cmax
|
|
922 |
//#define min cmin
|
|
923 |
||
924 |
#define NullS NULL
|
|
925 |
||
926 |
#define thd_charset session_charset
|
|
927 |
#define thd_slave_thread session_slave_thread
|
|
928 |
#define thd_binlog_format session_binlog_format
|
|
1510.1.5
by Paul McCullagh
Actually, the function name was just changed |
929 |
#define thd_mark_transaction_to_rollback ::drizzled::mark_transaction_to_rollback
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
930 |
#define thd_ha_data session_ha_data
|
931 |
#define current_thd current_session
|
|
932 |
#define thd_sql_command session_sql_command
|
|
933 |
#define thd_test_options session_test_options
|
|
934 |
#define thd_killed session_killed
|
|
935 |
#define thd_tx_isolation session_tx_isolation
|
|
936 |
#define thd_in_lock_tables session_in_lock_tables
|
|
937 |
#define thd_tablespace_op session_tablespace_op
|
|
938 |
#define thd_alloc session_alloc
|
|
939 |
#define thd_make_lex_string session_make_lex_string
|
|
940 |
#define column_bitmaps_signal()
|
|
941 |
||
942 |
#define my_pthread_setspecific_ptr(T, V) pthread_setspecific(T, (void*) (V))
|
|
943 |
||
1786.3.1
by Monty Taylor
Initial working local catalog. |
944 |
#define mysql_real_data_home ::drizzled::getDataHomeCatalog().c_str()
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
945 |
|
946 |
#define mi_int4store(T,A) { uint32_t def_temp= (uint32_t) (A);\
|
|
947 |
((unsigned char*) (T))[3]= (unsigned char) (def_temp);\
|
|
948 |
((unsigned char*) (T))[2]= (unsigned char) (def_temp >> 8);\
|
|
949 |
((unsigned char*) (T))[1]= (unsigned char) (def_temp >> 16);\
|
|
950 |
((unsigned char*) (T))[0]= (unsigned char) (def_temp >> 24); }
|
|
951 |
||
952 |
#define mi_uint4korr(A) ((uint32_t) (((uint32_t) (((const unsigned char*) (A))[3])) +\
|
|
953 |
(((uint32_t) (((const unsigned char*) (A))[2])) << 8) +\
|
|
954 |
(((uint32_t) (((const unsigned char*) (A))[1])) << 16) +\
|
|
955 |
(((uint32_t) (((const unsigned char*) (A))[0])) << 24)))
|
|
956 |
||
957 |
class PBXTStorageEngine; |
|
958 |
typedef PBXTStorageEngine handlerton; |
|
959 |
namespace drizzled { |
|
960 |
class Session; |
|
961 |
}
|
|
962 |
||
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
963 |
#define RECORD_0 getInsertRecord()
|
964 |
#define TABLE_RECORD_0 getTable()->getInsertRecord()
|
|
965 |
#define TABLE_FIELDS table->getFields()
|
|
966 |
#define MYSQL_LOCK(x) x.lock
|
|
967 |
#define MYSQL_UNLOCK(x) x.unlock
|
|
968 |
#define MYSQL_INIT_LOCK(x, y) x.init(y)
|
|
969 |
#define MYSQL_FREE_LOCK(x) x.deinit()
|
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
970 |
|
971 |
#else // DRIZZLED |
|
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
972 |
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
973 |
/* The MySQL case: */
|
974 |
#if MYSQL_VERSION_ID >= 50404
|
|
975 |
#define STRUCT_TABLE struct TABLE
|
|
976 |
#else
|
|
977 |
#define STRUCT_TABLE struct st_table
|
|
978 |
#endif
|
|
1531.1.5
by Paul McCullagh
Changed from using a Table to a TableShare |
979 |
#define GET_TABLE_SHARE(x) (x)->s
|
980 |
#define GET_TABLE_FIELDS(x) (x)->field
|
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
981 |
#if MYSQL_VERSION_ID >= 60009
|
982 |
#define storage_media default_storage_media
|
|
983 |
#endif
|
|
984 |
||
985 |
#define mx_tmp_use_all_columns dbug_tmp_use_all_columns
|
|
986 |
#define mx_tmp_restore_column_map(x, y) dbug_tmp_restore_column_map((x)->read_set, y)
|
|
987 |
#define MX_BIT_FAST_TEST_AND_SET(x, y) bitmap_fast_test_and_set(x, y)
|
|
988 |
||
989 |
#define MX_TABLE_TYPES_T ulonglong
|
|
990 |
#define MX_UINT8_T uint8
|
|
991 |
#define MX_ULONG_T ulong
|
|
992 |
#define MX_ULONGLONG_T ulonglong
|
|
993 |
#define MX_LONGLONG_T longlong
|
|
1510.1.1
by Paul McCullagh
Merged with 1.1 trunk |
994 |
#define MX_CHARSET_INFO struct charset_info_st
|
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
995 |
#ifdef MARIADB_BASE_VERSION
|
996 |
#define MX_CONST_CHARSET_INFO const struct charset_info_st
|
|
997 |
#else
|
|
998 |
#define MX_CONST_CHARSET_INFO struct charset_info_st
|
|
999 |
#endif
|
|
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
1000 |
#define MX_CONST
|
1001 |
#define MX_BITMAP MY_BITMAP
|
|
1002 |
#define MX_BIT_SIZE() n_bits
|
|
1003 |
#define MX_BIT_SET(x, y) bitmap_set_bit(x, y)
|
|
1004 |
||
1753.3.1
by Paul McCullagh
Merged with 1.1 trunk |
1005 |
#define RECORD_0 record[0]
|
1006 |
#define TABLE_RECORD_0 table->record[0]
|
|
1007 |
#define TABLE_FIELDS table->field
|
|
1008 |
#define MYSQL_LOCK(x) pthread_mutex_lock(&x)
|
|
1009 |
#define MYSQL_UNLOCK(x) pthread_mutex_unlock(&x)
|
|
1010 |
#define MYSQL_INIT_LOCK(x, y) thr_lock_data_init(y, &x, NULL);
|
|
1011 |
#define MYSQL_FREE_LOCK(x) thr_lock_delete(&x)
|
|
1012 |
||
1455.3.1
by Vladimir Kolesnikov
lp:drizzle + pbxt 1.1 + test results |
1013 |
#endif // DRIZZLED |
1014 |
||
1015 |
#define MX_BIT_IS_SUBSET(x, y) bitmap_is_subset(x, y)
|
|
1016 |
||
1017 |
#ifndef XT_SCAN_CORE_DEFINED
|
|
1018 |
#define XT_SCAN_CORE_DEFINED
|
|
1019 |
xtBool xt_mm_scan_core(void); |
|
1020 |
#endif
|
|
1021 |
||
1022 |
//#define DEBUG_LOCK_QUEUE
|
|
1023 |
||
1024 |
#endif
|