00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef dict0dict_h
00028 #define dict0dict_h
00029
00030 #include "univ.i"
00031 #include "dict0types.h"
00032 #include "dict0mem.h"
00033 #include "data0type.h"
00034 #include "data0data.h"
00035 #include "mem0mem.h"
00036 #include "rem0types.h"
00037 #include "ut0mem.h"
00038 #include "ut0lst.h"
00039 #include "hash0hash.h"
00040 #include "ut0rnd.h"
00041 #include "ut0byte.h"
00042 #include "trx0types.h"
00043
00044 #ifndef UNIV_HOTBACKUP
00045 # include "sync0sync.h"
00046 # include "sync0rw.h"
00047
00049 UNIV_INTERN
00050 void
00051 dict_casedn_str(
00052
00053 char* a);
00054
00057 UNIV_INTERN
00058 ulint
00059 dict_get_db_name_len(
00060
00061 const char* name);
00063
00067 const char*
00068 dict_remove_db_name(
00069
00070 const char* name);
00072
00075 UNIV_INTERN
00076 dict_table_t*
00077 dict_table_get_on_id(
00078
00079 table_id_t table_id,
00080 trx_t* trx);
00081
00083 UNIV_INTERN
00084 void
00085 dict_table_decrement_handle_count(
00086
00087 dict_table_t* table,
00088 ibool dict_locked);
00089
00091 UNIV_INTERN
00092 void
00093 dict_init(void);
00094
00095
00101 UNIV_INTERN
00102 void
00103 dict_load_space_id_list(void);
00104
00105
00108 UNIV_INLINE
00109 ulint
00110 dict_col_get_mbminlen(
00111
00112 const dict_col_t* col);
00113
00116 UNIV_INLINE
00117 ulint
00118 dict_col_get_mbmaxlen(
00119
00120 const dict_col_t* col);
00121
00123 UNIV_INLINE
00124 void
00125 dict_col_set_mbminmaxlen(
00126
00127 dict_col_t* col,
00128 ulint mbminlen,
00130 ulint mbmaxlen);
00132
00134 UNIV_INLINE
00135 void
00136 dict_col_copy_type(
00137
00138 const dict_col_t* col,
00139 dtype_t* type);
00140 #endif
00141 #ifdef UNIV_DEBUG
00142
00145 UNIV_INLINE
00146 ibool
00147 dict_col_type_assert_equal(
00148
00149 const dict_col_t* col,
00150 const dtype_t* type);
00151 #endif
00152 #ifndef UNIV_HOTBACKUP
00153
00156 UNIV_INLINE
00157 ulint
00158 dict_col_get_min_size(
00159
00160 const dict_col_t* col);
00161
00164 UNIV_INLINE
00165 ulint
00166 dict_col_get_max_size(
00167
00168 const dict_col_t* col);
00169
00172 UNIV_INLINE
00173 ulint
00174 dict_col_get_fixed_size(
00175
00176 const dict_col_t* col,
00177 ulint comp);
00178
00182 UNIV_INLINE
00183 ulint
00184 dict_col_get_sql_null_size(
00185
00186 const dict_col_t* col,
00187 ulint comp);
00189
00192 UNIV_INLINE
00193 ulint
00194 dict_col_get_no(
00195
00196 const dict_col_t* col);
00197
00199 UNIV_INLINE
00200 ulint
00201 dict_col_get_clust_pos(
00202
00203 const dict_col_t* col,
00204 const dict_index_t* clust_index);
00205
00209 UNIV_INTERN
00210 ibool
00211 dict_col_name_is_reserved(
00212
00213 const char* name);
00214
00216 UNIV_INTERN
00217 void
00218 dict_table_autoinc_lock(
00219
00220 dict_table_t* table);
00221
00223 UNIV_INTERN
00224 void
00225 dict_table_autoinc_initialize(
00226
00227 dict_table_t* table,
00228 ib_uint64_t value);
00229
00233 UNIV_INTERN
00234 ib_uint64_t
00235 dict_table_autoinc_read(
00236
00237 const dict_table_t* table);
00238
00241 UNIV_INTERN
00242 void
00243 dict_table_autoinc_update_if_greater(
00244
00245
00246 dict_table_t* table,
00247 ib_uint64_t value);
00248
00250 UNIV_INTERN
00251 void
00252 dict_table_autoinc_unlock(
00253
00254 dict_table_t* table);
00255 #endif
00256
00258 UNIV_INTERN
00259 void
00260 dict_table_add_system_columns(
00261
00262 dict_table_t* table,
00263 mem_heap_t* heap);
00264 #ifndef UNIV_HOTBACKUP
00265
00267 UNIV_INTERN
00268 void
00269 dict_table_add_to_cache(
00270
00271 dict_table_t* table,
00272 mem_heap_t* heap);
00273
00275 UNIV_INTERN
00276 void
00277 dict_table_remove_from_cache(
00278
00279 dict_table_t* table);
00280
00283 UNIV_INTERN
00284 ibool
00285 dict_table_rename_in_cache(
00286
00287 dict_table_t* table,
00288 const char* new_name,
00289 ibool rename_also_foreigns);
00292
00295 UNIV_INTERN
00296 void
00297 dict_table_change_id_in_cache(
00298
00299 dict_table_t* table,
00300 table_id_t new_id);
00301
00307 UNIV_INTERN
00308 ulint
00309 dict_foreign_add_to_cache(
00310
00311 dict_foreign_t* foreign,
00312 ibool check_charsets);
00314
00319 UNIV_INTERN
00320 dict_foreign_t*
00321 dict_table_get_referenced_constraint(
00322
00323 dict_table_t* table,
00324 dict_index_t* index);
00325
00328 UNIV_INTERN
00329 ibool
00330 dict_table_is_referenced_by_foreign_key(
00331
00332 const dict_table_t* table);
00333
00336 UNIV_INTERN
00337 void
00338 dict_table_replace_index_in_foreign_list(
00339
00340 dict_table_t* table,
00341 dict_index_t* index,
00342 const trx_t* trx);
00343
00349 UNIV_INTERN
00350 dict_foreign_t*
00351 dict_table_get_foreign_constraint(
00352
00353 dict_table_t* table,
00354 dict_index_t* index);
00355
00363 UNIV_INTERN
00364 ulint
00365 dict_create_foreign_constraints(
00366
00367 trx_t* trx,
00368 const char* sql_string,
00376 size_t sql_length,
00377 const char* name,
00380 ibool reject_fks);
00383
00387 UNIV_INTERN
00388 ulint
00389 dict_foreign_parse_drop_constraints(
00390
00391 mem_heap_t* heap,
00393 trx_t* trx,
00394 dict_table_t* table,
00395 ulint* n,
00397 const char*** constraints_to_drop);
00399
00405 UNIV_INTERN
00406 dict_table_t*
00407 dict_table_get(
00408
00409 const char* table_name,
00410 ibool inc_mysql_count);
00413
00416 UNIV_INTERN
00417 dict_index_t*
00418 dict_index_get_on_id_low(
00419
00420 dict_table_t* table,
00421 index_id_t index_id);
00422
00426 UNIV_INLINE
00427 dict_table_t*
00428 dict_table_check_if_in_cache_low(
00429
00430 const char* table_name);
00431
00435 UNIV_INLINE
00436 dict_table_t*
00437 dict_table_get_low(
00438
00439 const char* table_name);
00440
00443 UNIV_INLINE
00444 dict_table_t*
00445 dict_table_get_on_id_low(
00446
00447 table_id_t table_id);
00448
00452 UNIV_INTERN
00453 dict_index_t*
00454 dict_foreign_find_equiv_index(
00455
00456 dict_foreign_t* foreign);
00457
00461 UNIV_INTERN
00462 dict_index_t*
00463 dict_table_get_index_by_max_id(
00464
00465 dict_table_t* table,
00466 const char* name,
00467 const char** columns,
00468 ulint n_cols);
00469
00473 UNIV_INTERN
00474 const char*
00475 dict_table_get_col_name(
00476
00477 const dict_table_t* table,
00478 ulint col_nr);
00480
00482 UNIV_INTERN
00483 void
00484 dict_table_print(
00485
00486 dict_table_t* table);
00487
00489 UNIV_INTERN
00490 void
00491 dict_table_print_low(
00492
00493 dict_table_t* table);
00494
00496 UNIV_INTERN
00497 void
00498 dict_table_print_by_name(
00499
00500 const char* name);
00501
00503 UNIV_INTERN
00504 void
00505 dict_print_info_on_foreign_keys(
00506
00507 ibool create_table_format,
00511 FILE* file,
00512 trx_t* trx,
00513 dict_table_t* table);
00514
00517 UNIV_INTERN
00518 void
00519 dict_print_info_on_foreign_key_in_create_format(
00520
00521 FILE* file,
00522 trx_t* trx,
00523 dict_foreign_t* foreign,
00524 ibool add_newline);
00525
00527 UNIV_INTERN
00528 void
00529 dict_index_name_print(
00530
00531 FILE* file,
00532 trx_t* trx,
00533 const dict_index_t* index);
00534 #ifdef UNIV_DEBUG
00535
00538 UNIV_INLINE
00539 dict_index_t*
00540 dict_table_get_first_index(
00541
00542 const dict_table_t* table);
00543
00546 UNIV_INLINE
00547 dict_index_t*
00548 dict_table_get_next_index(
00549
00550 const dict_index_t* index);
00551 #else
00552 # define dict_table_get_first_index(table) UT_LIST_GET_FIRST((table)->indexes)
00553 # define dict_table_get_next_index(index) UT_LIST_GET_NEXT(indexes, index)
00554 #endif
00555 #endif
00556
00559 UNIV_INLINE
00560 ulint
00561 dict_index_is_clust(
00562
00563 const dict_index_t* index)
00564 __attribute__((pure));
00565
00568 UNIV_INLINE
00569 ulint
00570 dict_index_is_unique(
00571
00572 const dict_index_t* index)
00573 __attribute__((pure));
00574
00577 UNIV_INLINE
00578 ulint
00579 dict_index_is_ibuf(
00580
00581 const dict_index_t* index)
00582 __attribute__((pure));
00583
00586 UNIV_INLINE
00587 ulint
00588 dict_index_is_sec_or_ibuf(
00589
00590 const dict_index_t* index)
00591 __attribute__((pure));
00592
00593
00597 UNIV_INLINE
00598 ulint
00599 dict_table_get_n_user_cols(
00600
00601 const dict_table_t* table);
00602
00605 UNIV_INLINE
00606 ulint
00607 dict_table_get_n_sys_cols(
00608
00609 const dict_table_t* table);
00610
00614 UNIV_INLINE
00615 ulint
00616 dict_table_get_n_cols(
00617
00618 const dict_table_t* table);
00619 #ifdef UNIV_DEBUG
00620
00623 UNIV_INLINE
00624 dict_col_t*
00625 dict_table_get_nth_col(
00626
00627 const dict_table_t* table,
00628 ulint pos);
00629
00632 UNIV_INLINE
00633 dict_col_t*
00634 dict_table_get_sys_col(
00635
00636 const dict_table_t* table,
00637 ulint sys);
00638 #else
00639 #define dict_table_get_nth_col(table, pos) \
00640 ((table)->cols + (pos))
00641 #define dict_table_get_sys_col(table, sys) \
00642 ((table)->cols + (table)->n_cols + (sys) - DATA_N_SYS_COLS)
00643 #endif
00644
00647 UNIV_INLINE
00648 ulint
00649 dict_table_get_sys_col_no(
00650
00651 const dict_table_t* table,
00652 ulint sys);
00653 #ifndef UNIV_HOTBACKUP
00654
00657 UNIV_INLINE
00658 ulint
00659 dict_index_get_min_size(
00660
00661 const dict_index_t* index);
00662 #endif
00663
00666 UNIV_INLINE
00667 ibool
00668 dict_table_is_comp(
00669
00670 const dict_table_t* table);
00671
00674 UNIV_INLINE
00675 ulint
00676 dict_table_get_format(
00677
00678 const dict_table_t* table);
00679
00681 UNIV_INLINE
00682 void
00683 dict_table_set_format(
00684
00685 dict_table_t* table,
00686 ulint format);
00687
00690 UNIV_INLINE
00691 ulint
00692 dict_table_flags_to_zip_size(
00693
00694 ulint flags)
00695 __attribute__((const));
00696
00699 UNIV_INLINE
00700 ulint
00701 dict_table_zip_size(
00702
00703 const dict_table_t* table);
00704
00708 UNIV_INLINE
00709 void
00710 dict_table_x_lock_indexes(
00711
00712 dict_table_t* table);
00713
00715 UNIV_INLINE
00716 void
00717 dict_table_x_unlock_indexes(
00718
00719 dict_table_t* table);
00720
00724 UNIV_INTERN
00725 ibool
00726 dict_table_col_in_clustered_key(
00727
00728 const dict_table_t* table,
00729 ulint n);
00730 #ifndef UNIV_HOTBACKUP
00731
00735 UNIV_INTERN
00736 void
00737 dict_table_copy_types(
00738
00739 dtuple_t* tuple,
00740 const dict_table_t* table);
00741
00746 UNIV_INTERN
00747 dict_index_t*
00748 dict_index_find_on_id_low(
00749
00750 index_id_t id);
00751
00754 UNIV_INTERN
00755 ulint
00756 dict_index_add_to_cache(
00757
00758 dict_table_t* table,
00759 dict_index_t* index,
00761 ulint page_no,
00762 ibool strict);
00765 #endif
00766
00770 UNIV_INLINE
00771 ulint
00772 dict_index_get_n_fields(
00773
00774 const dict_index_t* index);
00777
00783 UNIV_INLINE
00784 ulint
00785 dict_index_get_n_unique(
00786
00787 const dict_index_t* index);
00789
00794 UNIV_INLINE
00795 ulint
00796 dict_index_get_n_unique_in_tree(
00797
00798 const dict_index_t* index);
00800
00806 UNIV_INLINE
00807 ulint
00808 dict_index_get_n_ordering_defined_by_user(
00809
00810 const dict_index_t* index);
00812 #ifdef UNIV_DEBUG
00813
00816 UNIV_INLINE
00817 dict_field_t*
00818 dict_index_get_nth_field(
00819
00820 const dict_index_t* index,
00821 ulint pos);
00822 #else
00823 # define dict_index_get_nth_field(index, pos) ((index)->fields + (pos))
00824 #endif
00825
00828 UNIV_INLINE
00829 const dict_col_t*
00830 dict_index_get_nth_col(
00831
00832 const dict_index_t* index,
00833 ulint pos);
00834
00837 UNIV_INLINE
00838 ulint
00839 dict_index_get_nth_col_no(
00840
00841 const dict_index_t* index,
00842 ulint pos);
00843
00847 UNIV_INTERN
00848 ulint
00849 dict_index_get_nth_col_pos(
00850
00851 const dict_index_t* index,
00852 ulint n);
00853
00856 UNIV_INTERN
00857 ibool
00858 dict_index_contains_col_or_prefix(
00859
00860 const dict_index_t* index,
00861 ulint n);
00862
00869 UNIV_INTERN
00870 ulint
00871 dict_index_get_nth_field_pos(
00872
00873 const dict_index_t* index,
00874 const dict_index_t* index2,
00875 ulint n);
00876
00879 UNIV_INTERN
00880 ulint
00881 dict_table_get_nth_col_pos(
00882
00883 const dict_table_t* table,
00884 ulint n);
00885
00888 UNIV_INLINE
00889 ulint
00890 dict_index_get_sys_col_pos(
00891
00892 const dict_index_t* index,
00893 ulint type);
00894
00896 UNIV_INTERN
00897 void
00898 dict_index_add_col(
00899
00900 dict_index_t* index,
00901 const dict_table_t* table,
00902 dict_col_t* col,
00903 ulint prefix_len);
00904 #ifndef UNIV_HOTBACKUP
00905
00907 UNIV_INTERN
00908 void
00909 dict_index_copy_types(
00910
00911 dtuple_t* tuple,
00912 const dict_index_t* index,
00913 ulint n_fields);
00915 #endif
00916
00919 UNIV_INLINE
00920 const dict_col_t*
00921 dict_field_get_col(
00922
00923 const dict_field_t* field);
00924 #ifndef UNIV_HOTBACKUP
00925
00929 UNIV_INTERN
00930 dict_index_t*
00931 dict_index_get_if_in_cache_low(
00932
00933 index_id_t index_id);
00934 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
00935
00938 UNIV_INTERN
00939 dict_index_t*
00940 dict_index_get_if_in_cache(
00941
00942 index_id_t index_id);
00943 #endif
00944 #ifdef UNIV_DEBUG
00945
00949 UNIV_INTERN
00950 ibool
00951 dict_index_check_search_tuple(
00952
00953 const dict_index_t* index,
00954 const dtuple_t* tuple);
00955
00957 UNIV_INTERN
00958 void
00959 dict_table_check_for_dup_indexes(
00960
00961 const dict_table_t* table,
00963 ibool tmp_ok);
00965 #endif
00966
00969 UNIV_INTERN
00970 dtuple_t*
00971 dict_index_build_node_ptr(
00972
00973 const dict_index_t* index,
00974 const rec_t* rec,
00976 ulint page_no,
00978 mem_heap_t* heap,
00980 ulint level);
00982
00986 UNIV_INTERN
00987 rec_t*
00988 dict_index_copy_rec_order_prefix(
00989
00990 const dict_index_t* index,
00991 const rec_t* rec,
00993 ulint* n_fields,
00994 byte** buf,
00996 ulint* buf_size);
00997
01000 UNIV_INTERN
01001 dtuple_t*
01002 dict_index_build_data_tuple(
01003
01004 dict_index_t* index,
01005 rec_t* rec,
01006 ulint n_fields,
01007 mem_heap_t* heap);
01008
01011 UNIV_INLINE
01012 ulint
01013 dict_index_get_space(
01014
01015 const dict_index_t* index);
01016
01018 UNIV_INLINE
01019 void
01020 dict_index_set_space(
01021
01022 dict_index_t* index,
01023 ulint space);
01024
01027 UNIV_INLINE
01028 ulint
01029 dict_index_get_page(
01030
01031 const dict_index_t* tree);
01032
01034 UNIV_INLINE
01035 void
01036 dict_index_set_page(
01037
01038 dict_index_t* index,
01039 ulint page);
01040
01043 UNIV_INLINE
01044 rw_lock_t*
01045 dict_index_get_lock(
01046
01047 dict_index_t* index);
01048
01053 UNIV_INLINE
01054 ulint
01055 dict_index_get_space_reserve(void);
01056
01057
01059 UNIV_INTERN
01060 ulint
01061 dict_index_calc_min_rec_len(
01062
01063 const dict_index_t* index);
01064
01067 UNIV_INTERN
01068 void
01069 dict_update_statistics(
01070
01071 dict_table_t* table,
01072 ibool only_calc_if_missing_stats);
01076
01078 UNIV_INTERN
01079 void
01080 dict_mutex_enter_for_mysql(void);
01081
01082
01084 UNIV_INTERN
01085 void
01086 dict_mutex_exit_for_mysql(void);
01087
01088
01092 UNIV_INTERN
01093 void
01094 dict_table_stats_lock(
01095
01096 const dict_table_t* table,
01097 ulint latch_mode);
01099
01101 UNIV_INTERN
01102 void
01103 dict_table_stats_unlock(
01104
01105 const dict_table_t* table,
01106 ulint latch_mode);
01108
01111 UNIV_INTERN
01112 ibool
01113 dict_tables_have_same_db(
01114
01115 const char* name1,
01117 const char* name2);
01119
01121 UNIV_INTERN
01122 void
01123 dict_index_remove_from_cache(
01124
01125 dict_table_t* table,
01126 dict_index_t* index);
01127
01130 UNIV_INTERN
01131 dict_index_t*
01132 dict_table_get_index_on_name(
01133
01134 dict_table_t* table,
01135 const char* name);
01136
01140 UNIV_INTERN
01141 dict_index_t*
01142 dict_table_get_index_on_name_and_min_id(
01143
01144 dict_table_t* table,
01145 const char* name);
01146
01147
01148 extern FILE* dict_foreign_err_file;
01149 extern mutex_t dict_foreign_err_mutex;
01150
01152 extern dict_sys_t* dict_sys;
01154 extern rw_lock_t dict_operation_lock;
01155
01156
01157 struct dict_sys_struct{
01158 mutex_t mutex;
01165 row_id_t row_id;
01171 hash_table_t* table_hash;
01173 hash_table_t* table_id_hash;
01175 UT_LIST_BASE_NODE_T(dict_table_t)
01176 table_LRU;
01177 ulint size;
01180 dict_table_t* sys_tables;
01181 dict_table_t* sys_columns;
01182 dict_table_t* sys_indexes;
01183 dict_table_t* sys_fields;
01184 };
01185 #endif
01186
01188 extern dict_index_t* dict_ind_redundant;
01190 extern dict_index_t* dict_ind_compact;
01191
01192
01194 UNIV_INTERN
01195 void
01196 dict_ind_init(void);
01197
01198
01199
01201 UNIV_INTERN
01202 void
01203 dict_close(void);
01204
01205
01206 #ifndef UNIV_NONINL
01207 #include "dict0dict.ic"
01208 #endif
01209
01210 #endif