~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/trx0sys.h

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "fut0lst.h"
24
24
#include "fsp0fsp.h"
25
25
#include "read0types.h"
26
 
#include "page0types.h"
27
26
 
28
27
/* In a MySQL replication slave, in crash recovery we store the master log
29
28
file name and position here. We have successfully got the updates to InnoDB
31
30
or there was no master log position info inside InnoDB. */
32
31
 
33
32
extern char             trx_sys_mysql_master_log_name[];
34
 
extern ib_int64_t       trx_sys_mysql_master_log_pos;
 
33
extern ib_longlong      trx_sys_mysql_master_log_pos;
35
34
 
36
35
/* If this MySQL server uses binary logging, after InnoDB has been inited
37
36
and if it has done a crash recovery, we store the binlog file name and position
39
38
InnoDB. */
40
39
 
41
40
extern char             trx_sys_mysql_bin_log_name[];
42
 
extern ib_int64_t       trx_sys_mysql_bin_log_pos;
 
41
extern ib_longlong      trx_sys_mysql_bin_log_pos;
43
42
 
44
43
/* The transaction system */
45
44
extern trx_sys_t*       trx_sys;
52
51
/********************************************************************
53
52
Creates the doublewrite buffer to a new InnoDB installation. The header of the
54
53
doublewrite buffer is placed on the trx system header page. */
55
 
UNIV_INTERN
 
54
 
56
55
void
57
56
trx_sys_create_doublewrite_buf(void);
58
57
/*================================*/
63
62
function performs the necessary update operations. If we are in a crash
64
63
recovery, this function uses a possible doublewrite buffer to restore
65
64
half-written pages in the data files. */
66
 
UNIV_INTERN
 
65
 
67
66
void
68
67
trx_sys_doublewrite_init_or_restore_pages(
69
68
/*======================================*/
71
70
/********************************************************************
72
71
Marks the trx sys header when we have successfully upgraded to the >= 4.1.x
73
72
multiple tablespace format. */
74
 
UNIV_INTERN
 
73
 
75
74
void
76
75
trx_sys_mark_upgraded_to_multiple_tablespaces(void);
77
76
/*===============================================*/
78
77
/********************************************************************
79
78
Determines if a page number is located inside the doublewrite buffer. */
80
 
UNIV_INTERN
 
79
 
81
80
ibool
82
81
trx_doublewrite_page_inside(
83
82
/*========================*/
96
95
/*********************************************************************
97
96
Creates and initializes the central memory structures for the transaction
98
97
system. This is called when the database is started. */
99
 
UNIV_INTERN
 
98
 
100
99
void
101
100
trx_sys_init_at_db_start(void);
102
101
/*==========================*/
103
102
/*********************************************************************
104
103
Creates and initializes the transaction system at the database creation. */
105
 
UNIV_INTERN
 
104
 
106
105
void
107
106
trx_sys_create(void);
108
107
/*================*/
109
108
/********************************************************************
110
109
Looks for a free slot for a rollback segment in the trx system file copy. */
111
 
UNIV_INTERN
 
110
 
112
111
ulint
113
112
trx_sysf_rseg_find_free(
114
113
/*====================*/
221
220
dulint
222
221
trx_read_trx_id(
223
222
/*============*/
224
 
                                /* out: id */
225
 
        const byte*     ptr);   /* in: pointer to memory from where to read */
 
223
                        /* out: id */
 
224
        byte*   ptr);   /* in: pointer to memory from where to read */
226
225
/********************************************************************
227
226
Looks for the trx handle with the given id in trx_list. */
228
227
UNIV_INLINE
252
251
        dulint  trx_id);/* in: trx id of the transaction */
253
252
/********************************************************************
254
253
Checks that trx is in the trx list. */
255
 
UNIV_INTERN
 
254
 
256
255
ibool
257
256
trx_in_trx_list(
258
257
/*============*/
263
262
which corresponds to the transaction just being committed. In a MySQL
264
263
replication slave updates the latest master binlog position up to which
265
264
replication has proceeded. */
266
 
UNIV_INTERN
 
265
 
267
266
void
268
267
trx_sys_update_mysql_binlog_offset(
269
268
/*===============================*/
270
269
        const char*     file_name,/* in: MySQL log file name */
271
 
        ib_int64_t      offset, /* in: position in that log file */
 
270
        ib_longlong     offset, /* in: position in that log file */
272
271
        ulint           field,  /* in: offset of the MySQL log info field in
273
272
                                the trx sys header */
274
273
        mtr_t*          mtr);   /* in: mtr */
275
274
/*********************************************************************
276
275
Prints to stderr the MySQL binlog offset info in the trx system header if
277
276
the magic number shows it valid. */
278
 
UNIV_INTERN
 
277
 
279
278
void
280
279
trx_sys_print_mysql_binlog_offset(void);
281
280
/*===================================*/
283
282
/*********************************************************************
284
283
Prints to stderr the MySQL binlog info in the system header if the
285
284
magic number shows it valid. */
286
 
UNIV_INTERN
 
285
 
287
286
void
288
287
trx_sys_print_mysql_binlog_offset_from_page(
289
288
/*========================================*/
290
 
        const byte*     page);  /* in: buffer containing the trx
291
 
                                system header page, i.e., page number
292
 
                                TRX_SYS_PAGE_NO in the tablespace */
 
289
        byte*   page);  /* in: buffer containing the trx system header page,
 
290
                        i.e., page number TRX_SYS_PAGE_NO in the tablespace */
293
291
#endif /* UNIV_HOTBACKUP */
294
292
/*********************************************************************
295
293
Prints to stderr the MySQL master log offset info in the trx system header if
296
294
the magic number shows it valid. */
297
 
UNIV_INTERN
 
295
 
298
296
void
299
297
trx_sys_print_mysql_master_log_pos(void);
300
298
/*====================================*/
301
 
/*********************************************************************
302
 
Initializes the tablespace tag system. */
303
 
UNIV_INTERN
304
 
void
305
 
trx_sys_file_format_init(void);
306
 
/*==========================*/
307
 
/*********************************************************************
308
 
Closes the tablespace tag system. */
309
 
UNIV_INTERN
310
 
void
311
 
trx_sys_file_format_close(void);
312
 
/*===========================*/
313
 
/*********************************************************************
314
 
Get the name representation of the file format from its id. */
315
 
UNIV_INTERN
316
 
const char*
317
 
trx_sys_file_format_id_to_name(
318
 
/*===========================*/
319
 
                                        /* out: pointer to the name */
320
 
        const uint      id);            /* in: id of the file format */
321
 
/*********************************************************************
322
 
Set the file format tag unconditonally. */
323
 
UNIV_INTERN
324
 
ibool
325
 
trx_sys_file_format_max_set(
326
 
/*===========================*/
327
 
                                        /* out: TRUE if value updated */
328
 
        ulint           file_format,    /* in: file format id */
329
 
        char**          name);          /* out: max format name */
330
 
/*********************************************************************
331
 
Get the name representation of the file format from its id. */
332
 
UNIV_INTERN
333
 
const char*
334
 
trx_sys_file_format_max_get(void);
335
 
/*=============================*/
336
 
                                /* out: pointer to the max format name */
337
 
/*********************************************************************
338
 
Check for the max file format tag stored on disk. */
339
 
UNIV_INTERN
340
 
ulint
341
 
trx_sys_file_format_max_check(
342
 
/*==========================*/
343
 
                                        /* out: DB_SUCCESS or error code */
344
 
        ulint           max_format_id); /* in: the max format id to check */
345
 
/************************************************************************
346
 
Update the file format tag in the tablespace to the max value. */
347
 
UNIV_INTERN
348
 
ibool
349
 
trx_sys_file_format_max_update(
350
 
/*===========================*/
351
 
                                        /* out: TRUE if value updated */
352
 
        uint            flags,          /* in: flags of the table */
353
 
        char**          name);          /* out: max format name */
 
299
 
354
300
/* The automatically created system rollback segment has this id */
355
301
#define TRX_SYS_SYSTEM_RSEG_ID  0
356
302
 
384
330
therefore 256; each slot is currently 8 bytes in size */
385
331
#define TRX_SYS_N_RSEGS         256
386
332
 
387
 
#define TRX_SYS_MYSQL_LOG_NAME_LEN      512
388
 
#define TRX_SYS_MYSQL_LOG_MAGIC_N       873422344
 
333
#define TRX_SYS_DRIZZLE_LOG_NAME_LEN    512
 
334
#define TRX_SYS_DRIZZLE_LOG_MAGIC_N     873422344
389
335
 
390
 
#if UNIV_PAGE_SIZE < 4096
391
 
# error "UNIV_PAGE_SIZE < 4096"
392
 
#endif
393
336
/* The offset of the MySQL replication info in the trx system header;
394
 
this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */
395
 
#define TRX_SYS_MYSQL_MASTER_LOG_INFO   (UNIV_PAGE_SIZE - 2000)
 
337
this contains the same fields as TRX_SYS_DRIZZLE_LOG_INFO below */
 
338
#define TRX_SYS_DRIZZLE_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
396
339
 
397
340
/* The offset of the MySQL binlog offset info in the trx system header */
398
 
#define TRX_SYS_MYSQL_LOG_INFO          (UNIV_PAGE_SIZE - 1000)
399
 
#define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD   0       /* magic number which shows
 
341
#define TRX_SYS_DRIZZLE_LOG_INFO                (UNIV_PAGE_SIZE - 1000)
 
342
#define TRX_SYS_DRIZZLE_LOG_MAGIC_N_FLD 0       /* magic number which shows
400
343
                                                if we have valid data in the
401
344
                                                MySQL binlog info; the value
402
345
                                                is ..._MAGIC_N if yes */
403
 
#define TRX_SYS_MYSQL_LOG_OFFSET_HIGH   4       /* high 4 bytes of the offset
404
 
                                                within that file */
405
 
#define TRX_SYS_MYSQL_LOG_OFFSET_LOW    8       /* low 4 bytes of the offset
406
 
                                                within that file */
407
 
#define TRX_SYS_MYSQL_LOG_NAME          12      /* MySQL log file name */
 
346
#define TRX_SYS_DRIZZLE_LOG_OFFSET_HIGH 4       /* high 4 bytes of the offset
 
347
                                                within that file */
 
348
#define TRX_SYS_DRIZZLE_LOG_OFFSET_LOW  8       /* low 4 bytes of the offset
 
349
                                                within that file */
 
350
#define TRX_SYS_DRIZZLE_LOG_NAME                12      /* MySQL log file name */
408
351
 
409
352
/* The offset of the doublewrite buffer header on the trx system header page */
410
353
#define TRX_SYS_DOUBLEWRITE             (UNIV_PAGE_SIZE - 200)
449
392
 
450
393
#define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE  FSP_EXTENT_SIZE
451
394
 
452
 
/* The offset of the file format tag on the trx system header page */
453
 
#define TRX_SYS_FILE_FORMAT_TAG         (UNIV_PAGE_SIZE - 16)
454
 
 
455
 
/* We use these random constants to reduce the probability of reading
456
 
garbage (from previous versions) that maps to an actual format id. We
457
 
use these as bit masks at the time of  reading and writing from/to disk. */
458
 
#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW     3645922177UL
459
 
#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH    2745987765UL
460
 
 
461
395
/* Doublewrite control struct */
462
396
struct trx_doublewrite_struct{
463
397
        mutex_t mutex;          /* mutex protecting the first_free field and
472
406
                                address divisible by UNIV_PAGE_SIZE
473
407
                                (which is required by Windows aio) */
474
408
        byte*   write_buf_unaligned; /* pointer to write_buf, but unaligned */
475
 
        buf_page_t**
 
409
        buf_block_t**
476
410
                buf_block_arr;  /* array to store pointers to the buffer
477
411
                                blocks which have been cached to write_buf */
478
412
};