1
/******************************************************
6
Created 1/8/1996 Heikki Tuuri
7
*******************************************************/
13
#include "dict0types.h"
15
#include "data0type.h"
16
#include "data0data.h"
17
#include "sync0sync.h"
20
#include "rem0types.h"
21
#include "btr0types.h"
24
#include "hash0hash.h"
27
#include "trx0types.h"
29
#ifndef UNIV_HOTBACKUP
30
/**********************************************************************
31
Makes all characters in a NUL-terminated UTF-8 string lower case. */
36
char* a); /* in/out: string to put in lower case */
37
#endif /* !UNIV_HOTBACKUP */
38
/************************************************************************
39
Get the database name length in a table name. */
44
/* out: database name length */
45
const char* name); /* in: table name in the form
46
dbname '/' tablename */
47
/************************************************************************
48
Return the end of table name where we have removed dbname and '/'. */
54
const char* name); /* in: table name in the form
55
dbname '/' tablename */
56
/************************************************************************
57
Decrements the count of open MySQL handles to a table. */
60
dict_table_decrement_handle_count(
61
/*==============================*/
62
dict_table_t* table); /* in: table */
63
/**************************************************************************
64
Inits the data dictionary module. */
69
/************************************************************************
70
Gets the space id of every table of the data dictionary and makes a linear
71
list and a hash table of them to the data dictionary cache. This function
72
can be called at database startup if we did not need to do a crash recovery.
73
In crash recovery we must scan the space id's from the .ibd files in MySQL
74
database directories. */
77
dict_load_space_id_list(void);
78
/*=========================*/
79
/*************************************************************************
80
Gets the column data type. */
85
const dict_col_t* col, /* in: column */
86
dtype_t* type); /* out: data type */
87
/*************************************************************************
88
Gets the column data type. */
91
dict_col_copy_type_noninline(
92
/*=========================*/
93
const dict_col_t* col, /* in: column */
94
dtype_t* type); /* out: data type */
96
/*************************************************************************
97
Assert that a column and a data type match. */
100
dict_col_type_assert_equal(
101
/*=======================*/
103
const dict_col_t* col, /* in: column */
104
const dtype_t* type); /* in: data type */
105
#endif /* UNIV_DEBUG */
106
/***************************************************************************
107
Returns the minimum size of the column. */
110
dict_col_get_min_size(
111
/*==================*/
112
/* out: minimum size */
113
const dict_col_t* col); /* in: column */
114
/***************************************************************************
115
Returns the maximum size of the column. */
118
dict_col_get_max_size(
119
/*==================*/
120
/* out: maximum size */
121
const dict_col_t* col); /* in: column */
122
/***************************************************************************
123
Returns the size of a fixed size column, 0 if not a fixed size column. */
126
dict_col_get_fixed_size(
127
/*====================*/
128
/* out: fixed size, or 0 */
129
const dict_col_t* col); /* in: column */
130
/***************************************************************************
131
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
132
For fixed length types it is the fixed length of the type, otherwise 0. */
135
dict_col_get_sql_null_size(
136
/*=======================*/
137
/* out: SQL null storage size
138
in ROW_FORMAT=REDUNDANT */
139
const dict_col_t* col); /* in: column */
141
/*************************************************************************
142
Gets the column number. */
147
const dict_col_t* col);
148
/*************************************************************************
149
Gets the column position in the clustered index. */
152
dict_col_get_clust_pos(
153
/*===================*/
154
const dict_col_t* col, /* in: table column */
155
const dict_index_t* clust_index); /* in: clustered index */
156
/*************************************************************************
157
Gets the column position in the clustered index. */
160
dict_col_get_clust_pos_noninline(
161
/*=============================*/
162
const dict_col_t* col, /* in: table column */
163
const dict_index_t* clust_index); /* in: clustered index */
164
/********************************************************************
165
If the given column name is reserved for InnoDB system columns, return
169
dict_col_name_is_reserved(
170
/*======================*/
171
/* out: TRUE if name is reserved */
172
const char* name); /* in: column name */
173
/************************************************************************
174
Acquire the autoinc lock.*/
177
dict_table_autoinc_lock(
178
/*====================*/
179
dict_table_t* table); /* in: table */
180
/************************************************************************
181
Initializes the autoinc counter. It is not an error to initialize an already
182
initialized counter. */
185
dict_table_autoinc_initialize(
186
/*==========================*/
187
dict_table_t* table, /* in: table */
188
ib_longlong value); /* in: next value to assign to a row */
189
/************************************************************************
190
Reads the next autoinc value (== autoinc counter value), 0 if not yet
194
dict_table_autoinc_read(
195
/*====================*/
196
/* out: value for a new row, or 0 */
197
dict_table_t* table); /* in: table */
198
/************************************************************************
199
Updates the autoinc counter if the value supplied is equal or bigger than the
200
current value. If not inited, does nothing. */
203
dict_table_autoinc_update(
204
/*======================*/
206
dict_table_t* table, /* in: table */
207
ib_longlong value); /* in: value which was assigned to a row */
208
/************************************************************************
209
Release the autoinc lock.*/
212
dict_table_autoinc_unlock(
213
/*======================*/
214
dict_table_t* table); /* in: table */
215
/**************************************************************************
216
Adds system columns to a table object. */
219
dict_table_add_system_columns(
220
/*==========================*/
221
dict_table_t* table, /* in/out: table */
222
mem_heap_t* heap); /* in: temporary heap */
223
/**************************************************************************
224
Adds a table object to the dictionary cache. */
227
dict_table_add_to_cache(
228
/*====================*/
229
dict_table_t* table, /* in: table */
230
mem_heap_t* heap); /* in: temporary heap */
231
/**************************************************************************
232
Removes a table object from the dictionary cache. */
235
dict_table_remove_from_cache(
236
/*=========================*/
237
dict_table_t* table); /* in, own: table */
238
/**************************************************************************
239
Renames a table object. */
242
dict_table_rename_in_cache(
243
/*=======================*/
244
/* out: TRUE if success */
245
dict_table_t* table, /* in: table */
246
const char* new_name, /* in: new name */
247
ibool rename_also_foreigns);/* in: in ALTER TABLE we want
248
to preserve the original table name
249
in constraints which reference it */
250
/**************************************************************************
251
Change the id of a table object in the dictionary cache. This is used in
252
DISCARD TABLESPACE. */
255
dict_table_change_id_in_cache(
256
/*==========================*/
257
dict_table_t* table, /* in: table object already in cache */
258
dulint new_id);/* in: new id to set */
259
/**************************************************************************
260
Adds a foreign key constraint object to the dictionary cache. May free
261
the object if there already is an object with the same identifier in.
262
At least one of foreign table or referenced table must already be in
263
the dictionary cache! */
266
dict_foreign_add_to_cache(
267
/*======================*/
268
/* out: DB_SUCCESS or error code */
269
dict_foreign_t* foreign, /* in, own: foreign key constraint */
270
ibool check_charsets);/* in: TRUE=check charset
272
/*************************************************************************
273
Checks if a table is referenced by foreign keys. */
276
dict_table_referenced_by_foreign_key(
277
/*=================================*/
278
/* out: TRUE if table is referenced by a
280
dict_table_t* table); /* in: InnoDB table */
281
/**************************************************************************
282
Determines whether a string starts with the specified keyword. */
285
dict_str_starts_with_keyword(
286
/*=========================*/
287
/* out: TRUE if str starts
289
void* mysql_thd, /* in: MySQL thread handle */
290
const char* str, /* in: string to scan for keyword */
291
const char* keyword); /* in: keyword to look for */
292
/*************************************************************************
293
Scans a table create SQL string and adds to the data dictionary
294
the foreign key constraints declared in the string. This function
295
should be called after the indexes for a table have been created.
296
Each foreign key constraint must be accompanied with indexes in
297
bot participating tables. The indexes are allowed to contain more
298
fields than mentioned in the constraint. */
301
dict_create_foreign_constraints(
302
/*============================*/
303
/* out: error code or DB_SUCCESS */
304
trx_t* trx, /* in: transaction */
305
const char* sql_string, /* in: table create statement where
306
foreign keys are declared like:
307
FOREIGN KEY (a, b) REFERENCES
308
table2(c, d), table2 can be written
309
also with the database
310
name before it: test.table2; the
311
default database id the database of
313
const char* name, /* in: table full name in the
315
database_name/table_name */
316
ibool reject_fks); /* in: if TRUE, fail with error
317
code DB_CANNOT_ADD_CONSTRAINT if
318
any foreign keys are found. */
319
/**************************************************************************
320
Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. */
323
dict_foreign_parse_drop_constraints(
324
/*================================*/
325
/* out: DB_SUCCESS or
326
DB_CANNOT_DROP_CONSTRAINT if
327
syntax error or the constraint
329
mem_heap_t* heap, /* in: heap from which we can
331
trx_t* trx, /* in: transaction */
332
dict_table_t* table, /* in: table */
333
ulint* n, /* out: number of constraints
335
const char*** constraints_to_drop); /* out: id's of the
336
constraints to drop */
337
/**************************************************************************
338
Returns a table object and optionally increment its MySQL open handle count.
339
NOTE! This is a high-level function to be used mainly from outside the
340
'dict' directory. Inside this directory dict_table_get_low is usually the
341
appropriate function. */
346
/* out: table, NULL if
348
const char* table_name, /* in: table name */
349
ibool inc_mysql_count);
350
/* in: whether to increment the open
351
handle count on the table */
352
/**************************************************************************
353
Returns a table object based on table id. */
356
dict_table_get_on_id(
357
/*=================*/
358
/* out: table, NULL if does not exist */
359
dulint table_id, /* in: table id */
360
trx_t* trx); /* in: transaction handle */
361
/**************************************************************************
362
Returns a table object based on table id. */
365
dict_table_get_on_id_low(
366
/*=====================*/
367
/* out: table, NULL if does not exist */
368
dulint table_id); /* in: table id */
369
/**************************************************************************
370
Checks if a table is in the dictionary cache. */
373
dict_table_check_if_in_cache_low(
374
/*=============================*/
375
/* out: table, NULL if not found */
376
const char* table_name); /* in: table name */
377
/**************************************************************************
378
Gets a table; loads it to the dictionary cache if necessary. A low-level
384
/* out: table, NULL if not found */
385
const char* table_name); /* in: table name */
386
/**************************************************************************
387
A noninlined version of dict_table_get_low. */
390
dict_table_get_low_noninlined(
391
/*==========================*/
392
/* out: table, NULL if not found */
393
const char* table_name); /* in: table name */
394
/**************************************************************************
395
Returns an index object. */
398
dict_table_get_index(
399
/*=================*/
400
/* out: index, NULL if does not exist */
401
dict_table_t* table, /* in: table */
402
const char* name); /* in: index name */
403
/**************************************************************************
404
Returns an index object. */
407
dict_table_get_index_noninline(
408
/*===========================*/
409
/* out: index, NULL if does not exist */
410
dict_table_t* table, /* in: table */
411
const char* name); /* in: index name */
412
/**************************************************************************
413
Returns a column's name. */
416
dict_table_get_col_name(
417
/*====================*/
418
/* out: column name. NOTE: not
419
guaranteed to stay valid if table is
420
modified in any way (columns added,
422
const dict_table_t* table, /* in: table */
423
ulint col_nr);/* in: column number */
425
/**************************************************************************
426
Prints a table definition. */
431
dict_table_t* table); /* in: table */
432
/**************************************************************************
433
Prints a table data. */
436
dict_table_print_low(
437
/*=================*/
438
dict_table_t* table); /* in: table */
439
/**************************************************************************
440
Prints a table data when we know the table name. */
443
dict_table_print_by_name(
444
/*=====================*/
446
/**************************************************************************
447
Outputs info on foreign keys of a table. */
450
dict_print_info_on_foreign_keys(
451
/*============================*/
452
ibool create_table_format, /* in: if TRUE then print in
453
a format suitable to be inserted into
454
a CREATE TABLE, otherwise in the format
455
of SHOW TABLE STATUS */
456
FILE* file, /* in: file where to print */
457
trx_t* trx, /* in: transaction */
458
dict_table_t* table); /* in: table */
459
/**************************************************************************
460
Outputs info on a foreign key of a table in a format suitable for
463
dict_print_info_on_foreign_key_in_create_format(
464
/*============================================*/
465
FILE* file, /* in: file where to print */
466
trx_t* trx, /* in: transaction */
467
dict_foreign_t* foreign, /* in: foreign key constraint */
468
ibool add_newline); /* in: whether to add a newline */
469
/************************************************************************
470
Displays the names of the index and the table. */
472
dict_index_name_print(
473
/*==================*/
474
FILE* file, /* in: output stream */
475
trx_t* trx, /* in: transaction */
476
const dict_index_t* index); /* in: index to print */
477
/************************************************************************
478
Gets the first index on the table (the clustered index). */
481
dict_table_get_first_index(
482
/*=======================*/
483
/* out: index, NULL if none exists */
484
dict_table_t* table); /* in: table */
485
/************************************************************************
486
Gets the first index on the table (the clustered index). */
489
dict_table_get_first_index_noninline(
490
/*=================================*/
491
/* out: index, NULL if none exists */
492
dict_table_t* table); /* in: table */
493
/************************************************************************
494
Gets the next index on the table. */
497
dict_table_get_next_index(
498
/*======================*/
499
/* out: index, NULL if none left */
500
dict_index_t* index); /* in: index */
501
/************************************************************************
502
Gets the next index on the table. */
505
dict_table_get_next_index_noninline(
506
/*================================*/
507
/* out: index, NULL if none left */
508
dict_index_t* index); /* in: index */
509
/************************************************************************
510
Gets the number of user-defined columns in a table in the dictionary
514
dict_table_get_n_user_cols(
515
/*=======================*/
516
/* out: number of user-defined (e.g., not
517
ROW_ID) columns of a table */
518
dict_table_t* table); /* in: table */
519
/************************************************************************
520
Gets the number of system columns in a table in the dictionary cache. */
523
dict_table_get_n_sys_cols(
524
/*======================*/
525
/* out: number of system (e.g.,
526
ROW_ID) columns of a table */
527
dict_table_t* table); /* in: table */
528
/************************************************************************
529
Gets the number of all columns (also system) in a table in the dictionary
533
dict_table_get_n_cols(
534
/*==================*/
535
/* out: number of columns of a table */
536
dict_table_t* table); /* in: table */
537
/************************************************************************
538
Gets the nth column of a table. */
541
dict_table_get_nth_col(
542
/*===================*/
543
/* out: pointer to column object */
544
const dict_table_t* table, /* in: table */
545
ulint pos); /* in: position of column */
546
/************************************************************************
547
Gets the nth column of a table. */
550
dict_table_get_nth_col_noninline(
551
/*=============================*/
552
/* out: pointer to column object */
553
const dict_table_t* table, /* in: table */
554
ulint pos); /* in: position of column */
555
/************************************************************************
556
Gets the given system column of a table. */
559
dict_table_get_sys_col(
560
/*===================*/
561
/* out: pointer to column object */
562
const dict_table_t* table, /* in: table */
563
ulint sys); /* in: DATA_ROW_ID, ... */
564
/************************************************************************
565
Gets the given system column number of a table. */
568
dict_table_get_sys_col_no(
569
/*======================*/
570
/* out: column number */
571
dict_table_t* table, /* in: table */
572
ulint sys); /* in: DATA_ROW_ID, ... */
573
/************************************************************************
574
Check whether the table uses the compact page format. */
579
/* out: TRUE if table uses the
580
compact page format */
581
const dict_table_t* table); /* in: table */
582
/************************************************************************
583
Check whether the table uses the compact page format. */
586
dict_table_is_comp_noninline(
587
/*=========================*/
588
/* out: TRUE if table uses the
589
compact page format */
590
const dict_table_t* table); /* in: table */
591
/************************************************************************
592
Checks if a column is in the ordering columns of the clustered index of a
593
table. Column prefixes are treated like whole columns. */
596
dict_table_col_in_clustered_key(
597
/*============================*/
598
/* out: TRUE if the column, or its prefix, is
599
in the clustered key */
600
dict_table_t* table, /* in: table */
601
ulint n); /* in: column number */
602
/***********************************************************************
603
Copies types of columns contained in table to tuple. */
606
dict_table_copy_types(
607
/*==================*/
608
dtuple_t* tuple, /* in: data tuple */
609
dict_table_t* table); /* in: index */
610
/**************************************************************************
611
Looks for an index with the given id. NOTE that we do not reserve
612
the dictionary mutex: this function is for emergency purposes like
613
printing info of a corrupt database page! */
616
dict_index_find_on_id_low(
617
/*======================*/
618
/* out: index or NULL if not found from cache */
619
dulint id); /* in: index id */
620
/**************************************************************************
621
Adds an index to the dictionary cache. */
624
dict_index_add_to_cache(
625
/*====================*/
626
dict_table_t* table, /* in: table on which the index is */
627
dict_index_t* index, /* in, own: index; NOTE! The index memory
628
object is freed in this function! */
629
ulint page_no);/* in: root page number of the index */
630
/************************************************************************
631
Gets the number of fields in the internal representation of an index,
632
including fields added by the dictionary system. */
635
dict_index_get_n_fields(
636
/*====================*/
637
/* out: number of fields */
638
dict_index_t* index); /* in: an internal representation of index
639
(in the dictionary cache) */
640
/************************************************************************
641
Gets the number of fields in the internal representation of an index
642
that uniquely determine the position of an index entry in the index, if
643
we do not take multiversioning into account: in the B-tree use the value
644
returned by dict_index_get_n_unique_in_tree. */
647
dict_index_get_n_unique(
648
/*====================*/
649
/* out: number of fields */
650
dict_index_t* index); /* in: an internal representation of index
651
(in the dictionary cache) */
652
/************************************************************************
653
Gets the number of fields in the internal representation of an index
654
which uniquely determine the position of an index entry in the index, if
655
we also take multiversioning into account. */
658
dict_index_get_n_unique_in_tree(
659
/*============================*/
660
/* out: number of fields */
661
dict_index_t* index); /* in: an internal representation of index
662
(in the dictionary cache) */
663
/************************************************************************
664
Gets the number of user-defined ordering fields in the index. In the internal
665
representation we add the row id to the ordering fields to make all indexes
666
unique, but this function returns the number of fields the user defined
667
in the index as ordering fields. */
670
dict_index_get_n_ordering_defined_by_user(
671
/*======================================*/
672
/* out: number of fields */
673
dict_index_t* index); /* in: an internal representation of index
674
(in the dictionary cache) */
675
/************************************************************************
676
Gets the nth field of an index. */
679
dict_index_get_nth_field(
680
/*=====================*/
681
/* out: pointer to field object */
682
const dict_index_t* index, /* in: index */
683
ulint pos); /* in: position of field */
684
/************************************************************************
685
Gets pointer to the nth column in an index. */
688
dict_index_get_nth_col(
689
/*===================*/
691
const dict_index_t* index, /* in: index */
692
ulint pos); /* in: position of the field */
693
/************************************************************************
694
Gets the column number of the nth field in an index. */
697
dict_index_get_nth_col_no(
698
/*======================*/
699
/* out: column number */
700
const dict_index_t* index, /* in: index */
701
ulint pos); /* in: position of the field */
702
/************************************************************************
703
Looks for column n in an index. */
706
dict_index_get_nth_col_pos(
707
/*=======================*/
708
/* out: position in internal representation
709
of the index; if not contained, returns
711
dict_index_t* index, /* in: index */
712
ulint n); /* in: column number */
713
/************************************************************************
714
Returns TRUE if the index contains a column or a prefix of that column. */
717
dict_index_contains_col_or_prefix(
718
/*==============================*/
719
/* out: TRUE if contains the column or its
721
dict_index_t* index, /* in: index */
722
ulint n); /* in: column number */
723
/************************************************************************
724
Looks for a matching field in an index. The column has to be the same. The
725
column in index must be complete, or must contain a prefix longer than the
726
column in index2. That is, we must be able to construct the prefix in index2
727
from the prefix in index. */
730
dict_index_get_nth_field_pos(
731
/*=========================*/
732
/* out: position in internal representation
733
of the index; if not contained, returns
735
dict_index_t* index, /* in: index from which to search */
736
dict_index_t* index2, /* in: index */
737
ulint n); /* in: field number in index2 */
738
/************************************************************************
739
Looks for column n position in the clustered index. */
742
dict_table_get_nth_col_pos(
743
/*=======================*/
744
/* out: position in internal representation
745
of the clustered index */
746
dict_table_t* table, /* in: table */
747
ulint n); /* in: column number */
748
/************************************************************************
749
Returns the position of a system column in an index. */
752
dict_index_get_sys_col_pos(
753
/*=======================*/
754
/* out: position, ULINT_UNDEFINED if not
756
dict_index_t* index, /* in: index */
757
ulint type); /* in: DATA_ROW_ID, ... */
758
/***********************************************************************
759
Adds a column to index. */
764
dict_index_t* index, /* in: index */
765
dict_table_t* table, /* in: table */
766
dict_col_t* col, /* in: column */
767
ulint prefix_len); /* in: column prefix length */
768
/***********************************************************************
769
Copies types of fields contained in index to tuple. */
772
dict_index_copy_types(
773
/*==================*/
774
dtuple_t* tuple, /* in: data tuple */
775
dict_index_t* index, /* in: index */
776
ulint n_fields); /* in: number of field types to copy */
777
/*************************************************************************
778
Gets the field column. */
783
const dict_field_t* field);
786
/**************************************************************************
787
Returns an index object if it is found in the dictionary cache. */
790
dict_index_get_if_in_cache(
791
/*=======================*/
792
/* out: index, NULL if not found */
793
dulint index_id); /* in: index id */
794
/**************************************************************************
795
Checks that a tuple has n_fields_cmp value in a sensible range, so that
796
no comparison can occur with the page number field in a node pointer. */
799
dict_index_check_search_tuple(
800
/*==========================*/
801
/* out: TRUE if ok */
802
dict_index_t* index, /* in: index */
803
dtuple_t* tuple); /* in: tuple used in a search */
804
#endif /* UNIV_DEBUG */
805
/**************************************************************************
806
Builds a node pointer out of a physical record and a page number. */
809
dict_index_build_node_ptr(
810
/*======================*/
811
/* out, own: node pointer */
812
dict_index_t* index, /* in: index */
813
rec_t* rec, /* in: record for which to build node
815
ulint page_no,/* in: page number to put in node pointer */
816
mem_heap_t* heap, /* in: memory heap where pointer created */
817
ulint level); /* in: level of rec in tree: 0 means leaf
819
/**************************************************************************
820
Copies an initial segment of a physical record, long enough to specify an
821
index entry uniquely. */
824
dict_index_copy_rec_order_prefix(
825
/*=============================*/
826
/* out: pointer to the prefix record */
827
dict_index_t* index, /* in: index */
828
rec_t* rec, /* in: record for which to copy prefix */
829
ulint* n_fields,/* out: number of fields copied */
830
byte** buf, /* in/out: memory buffer for the copied prefix,
832
ulint* buf_size);/* in/out: buffer size */
833
/**************************************************************************
834
Builds a typed data tuple out of a physical record. */
837
dict_index_build_data_tuple(
838
/*========================*/
839
/* out, own: data tuple */
840
dict_index_t* index, /* in: index */
841
rec_t* rec, /* in: record for which to build data tuple */
842
ulint n_fields,/* in: number of data fields */
843
mem_heap_t* heap); /* in: memory heap where tuple created */
844
/*************************************************************************
845
Gets the space id of the root of the index tree. */
848
dict_index_get_space(
849
/*=================*/
851
dict_index_t* index); /* in: index */
852
/*************************************************************************
853
Sets the space id of the root of the index tree. */
856
dict_index_set_space(
857
/*=================*/
858
dict_index_t* index, /* in: index */
859
ulint space); /* in: space id */
860
/*************************************************************************
861
Gets the page number of the root of the index tree. */
866
/* out: page number */
867
dict_index_t* tree); /* in: index */
868
/*************************************************************************
869
Sets the page number of the root of index tree. */
874
dict_index_t* index, /* in: index */
875
ulint page); /* in: page number */
876
/*************************************************************************
877
Gets the type of the index tree. */
883
dict_index_t* index); /* in: index */
884
/*************************************************************************
885
Gets the read-write lock of the index tree. */
890
/* out: read-write lock */
891
dict_index_t* index); /* in: index */
892
/************************************************************************
893
Returns free space reserved for future updates of records. This is
894
relevant only in the case of many consecutive inserts, as updates
895
which make the records bigger might fragment the index. */
898
dict_index_get_space_reserve(void);
899
/*==============================*/
900
/* out: number of free bytes on page,
901
reserved for updates */
902
/*************************************************************************
903
Calculates the minimum record length in an index. */
906
dict_index_calc_min_rec_len(
907
/*========================*/
908
dict_index_t* index); /* in: index */
909
/*************************************************************************
910
Calculates new estimates for table and index statistics. The statistics
911
are used in query optimization. */
914
dict_update_statistics_low(
915
/*=======================*/
916
dict_table_t* table, /* in: table */
917
ibool has_dict_mutex);/* in: TRUE if the caller has the
919
/*************************************************************************
920
Calculates new estimates for table and index statistics. The statistics
921
are used in query optimization. */
924
dict_update_statistics(
925
/*===================*/
926
dict_table_t* table); /* in: table */
927
/************************************************************************
928
Reserves the dictionary system mutex for MySQL. */
931
dict_mutex_enter_for_mysql(void);
932
/*============================*/
933
/************************************************************************
934
Releases the dictionary system mutex for MySQL. */
937
dict_mutex_exit_for_mysql(void);
938
/*===========================*/
939
/************************************************************************
940
Checks if the database name in two table names is the same. */
943
dict_tables_have_same_db(
944
/*=====================*/
945
/* out: TRUE if same db name */
946
const char* name1, /* in: table name in the form
947
dbname '/' tablename */
948
const char* name2); /* in: table name in the form
949
dbname '/' tablename */
950
/*************************************************************************
951
Scans from pointer onwards. Stops if is at the start of a copy of
952
'string' where characters are compared without case sensitivity. Stops
958
/* out: scanned up to this */
959
const char* ptr, /* in: scan from */
960
const char* string);/* in: look for this */
961
/* Buffers for storing detailed information about the latest foreign key
962
and unique key errors */
963
extern FILE* dict_foreign_err_file;
964
extern mutex_t dict_foreign_err_mutex; /* mutex protecting the buffers */
966
extern dict_sys_t* dict_sys; /* the dictionary system */
967
extern rw_lock_t dict_operation_lock;
969
/* Dictionary system struct */
970
struct dict_sys_struct{
971
mutex_t mutex; /* mutex protecting the data
972
dictionary; protects also the
973
disk-based dictionary system tables;
974
this mutex serializes CREATE TABLE
975
and DROP TABLE, as well as reading
976
the dictionary data for a table from
978
dulint row_id; /* the next row id to assign;
979
NOTE that at a checkpoint this
980
must be written to the dict system
981
header and flushed to a file; in
982
recovery this must be derived from
984
hash_table_t* table_hash; /* hash table of the tables, based
986
hash_table_t* table_id_hash; /* hash table of the tables, based
988
UT_LIST_BASE_NODE_T(dict_table_t)
989
table_LRU; /* LRU list of tables */
990
ulint size; /* varying space in bytes occupied
991
by the data dictionary table and
993
dict_table_t* sys_tables; /* SYS_TABLES table */
994
dict_table_t* sys_columns; /* SYS_COLUMNS table */
995
dict_table_t* sys_indexes; /* SYS_INDEXES table */
996
dict_table_t* sys_fields; /* SYS_FIELDS table */
1000
#include "dict0dict.ic"