1/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
15
16
17/*
18 Static variables for MARIA library. All definied here for easy making of
19 a shared library
20*/
21
22#ifndef MY_GLOBAL_INCLUDED
23#include "maria_def.h"
24#include "trnman.h"
25#endif
26
27LIST *maria_open_list=0;
28uchar maria_file_magic[]=
29{ (uchar) 254, (uchar) 254, (uchar) 9, '\003', };
30uchar maria_pack_file_magic[]=
31{ (uchar) 254, (uchar) 254, (uchar) 10, '\001', };
32/* Unique number for this maria instance */
33uchar maria_uuid[MY_UUID_SIZE];
34uint maria_quick_table_bits=9;
35ulong maria_block_size= MARIA_KEY_BLOCK_LENGTH;
36my_bool maria_flush= 0, maria_single_user= 0;
37my_bool maria_delay_key_write= 0, maria_page_checksums= 1;
38my_bool maria_inited= FALSE;
39my_bool maria_in_ha_maria= FALSE; /* If used from ha_maria or not */
40my_bool maria_recovery_changed_data= 0, maria_recovery_verbose= 0;
41my_bool maria_assert_if_crashed_table= 0;
42my_bool maria_checkpoint_disabled= 0;
43my_bool maria_encrypt_tables= 0;
44
45mysql_mutex_t THR_LOCK_maria;
46#ifdef DONT_USE_RW_LOCKS
47ulong maria_concurrent_insert= 0;
48#else
49/* Do concurrent inserts at file end or in old holes */
50ulong maria_concurrent_insert= 2;
51#endif
52
53my_off_t maria_max_temp_length= MAX_FILE_SIZE;
54ulong maria_bulk_insert_tree_size=8192*1024;
55ulong maria_data_pointer_size= 6;
56
57PAGECACHE maria_pagecache_var;
58PAGECACHE *maria_pagecache= &maria_pagecache_var;
59
60PAGECACHE maria_log_pagecache_var;
61PAGECACHE *maria_log_pagecache= &maria_log_pagecache_var;
62MY_TMPDIR *maria_tmpdir; /* Tempdir for redo */
63char *maria_data_root;
64HASH maria_stored_state;
65int (*maria_create_trn_hook)(MARIA_HA *);
66
67/**
68 @brief when transactionality does not matter we can use this transaction
69
70 Used in external programs like ma_test*, and also internally inside
71 libmaria when there is no transaction around and the operation isn't
72 transactional (CREATE/DROP/RENAME/OPTIMIZE/REPAIR).
73*/
74TRN dummy_transaction_object;
75
76/* a WT_RESOURCE_TYPE for transactions waiting on a unique key conflict */
77WT_RESOURCE_TYPE ma_rc_dup_unique={ wt_resource_id_memcmp, 0};
78
79/* Enough for comparing if number is zero */
80uchar maria_zero_string[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
81
82/*
83 read_vec[] is used for converting between P_READ_KEY.. and SEARCH_
84 Position is , == , >= , <= , > , <
85*/
86
87uint32 maria_read_vec[]=
88{
89 SEARCH_FIND, /* HA_READ_KEY_EXACT */
90 SEARCH_FIND | SEARCH_BIGGER, /* HA_READ_KEY_OR_NEXT */
91 SEARCH_FIND | SEARCH_SMALLER, /* HA_READ_KEY_OR_PREV */
92 SEARCH_NO_FIND | SEARCH_BIGGER, /* HA_READ_AFTER_KEY */
93 SEARCH_NO_FIND | SEARCH_SMALLER, /* HA_READ_BEFORE_KEY */
94 SEARCH_FIND | SEARCH_PART_KEY, /* HA_READ_PREFIX */
95 SEARCH_LAST, /* HA_READ_PREFIX_LAST */
96 SEARCH_LAST | SEARCH_SMALLER, /* HA_READ_PREFIX_LAST_OR_PREV */
97 MBR_CONTAIN, /* HA_READ_MBR_CONTAIN */
98 MBR_INTERSECT, /* HA_READ_MBR_INTERSECT */
99 MBR_WITHIN, /* HA_READ_MBR_WITHIN */
100 MBR_DISJOINT, /* HA_READ_MBR_DISJOINT */
101 MBR_EQUAL /* HA_READ_MBR_EQUAL */
102};
103
104uint32 maria_readnext_vec[]=
105{
106 SEARCH_BIGGER, SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_BIGGER, SEARCH_SMALLER,
107 SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
108};
109
110my_bool (*ma_killed)(MARIA_HA *)= ma_killed_standalone;
111
112#ifdef HAVE_PSI_INTERFACE
113
114PSI_mutex_key key_SHARE_BITMAP_lock, key_SORT_INFO_mutex,
115 key_THR_LOCK_maria, key_TRANSLOG_BUFFER_mutex,
116 key_LOCK_soft_sync,
117 key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock,
118 key_TRANSLOG_DESCRIPTOR_sent_to_disk_lock,
119 key_TRANSLOG_DESCRIPTOR_log_flush_lock,
120 key_TRANSLOG_DESCRIPTOR_file_header_lock,
121 key_TRANSLOG_DESCRIPTOR_unfinished_files_lock,
122 key_TRANSLOG_DESCRIPTOR_purger_lock,
123 key_SHARE_intern_lock, key_SHARE_key_del_lock,
124 key_SHARE_close_lock, key_PAGECACHE_cache_lock,
125 key_SERVICE_THREAD_CONTROL_lock,
126 key_LOCK_trn_list, key_TRN_state_lock;
127
128PSI_cond_key key_SHARE_key_del_cond, key_SERVICE_THREAD_CONTROL_cond,
129 key_SORT_INFO_cond, key_SHARE_BITMAP_cond,
130 key_COND_soft_sync, key_TRANSLOG_BUFFER_waiting_filling_buffer,
131 key_TRANSLOG_BUFFER_prev_sent_to_disk_cond,
132 key_TRANSLOG_DESCRIPTOR_log_flush_cond,
133 key_TRANSLOG_DESCRIPTOR_new_goal_cond;
134
135PSI_rwlock_key key_KEYINFO_root_lock, key_SHARE_mmap_lock,
136 key_TRANSLOG_DESCRIPTOR_open_files_lock;
137
138PSI_thread_key key_thread_checkpoint, key_thread_find_all_keys,
139 key_thread_soft_sync;
140
141PSI_file_key key_file_translog, key_file_kfile, key_file_dfile,
142 key_file_control, key_file_tmp;
143
144#endif /* HAVE_PSI_INTERFACE */
145
146/* Note that PSI_stage_info globals must always be declared. */
147PSI_stage_info stage_waiting_for_a_resource= { 0, "Waiting for a resource", 0};
148