52
53
TABLE_CATEGORY get_table_category(const LEX_STRING *db,
53
54
const LEX_STRING *name);
56
This structure is shared between different table objects. There is one
57
instance of table share per one table in the database.
60
typedef struct st_table_share
62
st_table_share() {} /* Remove gcc warning */
64
/** Category of this table. */
65
TABLE_CATEGORY table_category;
67
/* hash of field names (contains pointers to elements of field array) */
68
HASH name_hash; /* hash of field names */
70
TYPELIB keynames; /* Pointers to keynames */
71
TYPELIB fieldnames; /* Pointer to fieldnames */
72
TYPELIB *intervals; /* pointer to interval info */
73
pthread_mutex_t mutex; /* For locking the share */
74
pthread_cond_t cond; /* To signal that share is ready */
75
struct st_table_share *next, /* Link to unused shares */
78
/* The following is copied to each Table on OPEN */
80
Field **found_next_number_field;
81
Field *timestamp_field; /* Used only during open */
82
KEY *key_info; /* data of keys in database */
83
uint *blob_field; /* Index to blobs in Field arrray*/
85
unsigned char *default_values; /* row with default values */
86
LEX_STRING comment; /* Comment about table */
87
const CHARSET_INFO *table_charset; /* Default charset of string fields */
91
Key which is used for looking-up table in table cache and in the list
92
of thread's temporary tables. Has the form of:
93
"database_name\0table_name\0" + optional part for temporary tables.
95
Note that all three 'table_cache_key', 'db' and 'table_name' members
96
must be set (and be non-zero) for tables in table cache. They also
97
should correspond to each other.
98
To ensure this one can use set_table_cache() methods.
100
LEX_STRING table_cache_key;
101
LEX_STRING db; /* Pointer to db */
102
LEX_STRING table_name; /* Table name (for open) */
103
LEX_STRING path; /* Path to .frm file (from datadir) */
104
LEX_STRING normalized_path; /* unpack_filename(path) */
105
LEX_STRING connect_string;
108
Set of keys in use, implemented as a Bitmap.
109
Excludes keys disabled by ALTER Table ... DISABLE KEYS.
112
key_map keys_for_keyread;
113
ha_rows min_rows, max_rows; /* create information */
114
uint32_t avg_row_length; /* create information */
115
uint32_t block_size; /* create information */
116
uint32_t version, mysql_version;
117
uint32_t timestamp_offset; /* Set to offset+1 of record */
118
uint32_t reclength; /* Recordlength */
119
uint32_t stored_rec_length; /* Stored record length
120
(no generated-only virtual fields) */
122
plugin_ref db_plugin; /* storage engine plugin */
123
inline handlerton *db_type() const /* table_type for handler */
125
// assert(db_plugin);
126
return db_plugin ? plugin_data(db_plugin, handlerton*) : NULL;
128
enum row_type row_type; /* How rows are stored */
129
enum tmp_table_type tmp_table;
130
enum ha_choice transactional;
131
enum ha_choice page_checksum;
133
uint32_t ref_count; /* How many Table objects uses this */
134
uint32_t open_count; /* Number of tables in open list */
135
uint32_t blob_ptr_size; /* 4 or 8 */
136
uint32_t key_block_size; /* create key_block_size, if used */
138
uint32_t last_null_bit_pos;
139
uint32_t fields; /* Number of fields */
140
uint32_t stored_fields; /* Number of stored fields
141
(i.e. without generated-only ones) */
142
uint32_t rec_buff_length; /* Size of table->record[] buffer */
143
uint32_t keys, key_parts;
144
uint32_t max_key_length, max_unique_length, total_key_length;
145
uint32_t uniques; /* Number of UNIQUE index */
146
uint32_t null_fields; /* number of null fields */
147
uint32_t blob_fields; /* number of blob fields */
148
uint32_t timestamp_field_offset; /* Field number for timestamp field */
149
uint32_t varchar_fields; /* number of varchar fields */
150
uint32_t db_create_options; /* Create options from database */
151
uint32_t db_options_in_use; /* Options in use */
152
uint32_t db_record_offset; /* if HA_REC_IN_SEQ */
153
uint32_t rowid_field_offset; /* Field_nr +1 to rowid field */
154
/* Index of auto-updated TIMESTAMP field in field array */
155
uint32_t primary_key;
156
uint32_t next_number_index; /* autoincrement key number */
157
uint32_t next_number_key_offset; /* autoinc keypart offset in a key */
158
uint32_t next_number_keypart; /* autoinc keypart number in a key */
159
uint32_t error, open_errno, errarg; /* error from open_table_def() */
160
uint32_t column_bitmap_size;
162
uint32_t vfields; /* Number of virtual fields */
163
bool null_field_first;
164
bool db_low_byte_first; /* Portable row format */
166
bool name_lock, replace_with_name_lock;
167
bool waiting_on_cond; /* Protection against free */
168
uint32_t table_map_id; /* for row-based replication */
169
uint64_t table_map_version;
172
Cache for row-based replication table share checks that does not
173
need to be repeated. Possible values are: -1 when cache value is
174
not calculated yet, 0 when table *shall not* be replicated, 1 when
175
table *may* be replicated.
177
int cached_row_logging_check;
180
Set share's table cache key and update its db and table name appropriately.
183
set_table_cache_key()
184
key_buff Buffer with already built table cache key to be
185
referenced from share.
186
key_length Key length.
189
Since 'key_buff' buffer will be referenced from share it should has same
190
life-time as share itself.
191
This method automatically ensures that TABLE_SHARE::table_name/db have
192
appropriate values by using table cache key as their source.
195
void set_table_cache_key(char *key_buff, uint32_t key_length)
197
table_cache_key.str= key_buff;
198
table_cache_key.length= key_length;
200
Let us use the fact that the key is "db/0/table_name/0" + optional
201
part for temporary tables.
203
db.str= table_cache_key.str;
204
db.length= strlen(db.str);
205
table_name.str= db.str + db.length + 1;
206
table_name.length= strlen(table_name.str);
211
Set share's table cache key and update its db and table name appropriately.
214
set_table_cache_key()
215
key_buff Buffer to be used as storage for table cache key
216
(should be at least key_length bytes).
217
key Value for table cache key.
218
key_length Key length.
221
Since 'key_buff' buffer will be used as storage for table cache key
222
it should has same life-time as share itself.
225
void set_table_cache_key(char *key_buff, const char *key, uint32_t key_length)
227
memcpy(key_buff, key, key_length);
228
set_table_cache_key(key_buff, key_length);
231
inline bool honor_global_locks()
233
return (table_category == TABLE_CATEGORY_USER);
236
inline uint32_t get_table_def_version()
244
57
extern uint32_t refresh_version;