00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #pragma once
00028 #ifndef row0mysql_h
00029 #define row0mysql_h
00030
00031 #include "univ.i"
00032 #include "data0data.h"
00033 #include "que0types.h"
00034 #include "dict0types.h"
00035 #include "trx0types.h"
00036 #include "row0types.h"
00037 #include "btr0pcur.h"
00038 #include "trx0types.h"
00039
00040 extern ibool row_rollback_on_timeout;
00041
00042 typedef struct row_prebuilt_struct row_prebuilt_t;
00043
00044
00046 UNIV_INTERN
00047 void
00048 row_mysql_prebuilt_free_blob_heap(
00049
00050 row_prebuilt_t* prebuilt);
00052
00057 UNIV_INTERN
00058 byte*
00059 row_mysql_store_true_var_len(
00060
00061 byte* dest,
00062 ulint len,
00063 ulint lenlen);
00064
00069 UNIV_INTERN
00070 const byte*
00071 row_mysql_read_true_varchar(
00072
00073 ulint* len,
00074 const byte* field,
00075 ulint lenlen);
00077
00079 UNIV_INTERN
00080 void
00081 row_mysql_store_blob_ref(
00082
00083 byte* dest,
00084 ulint col_len,
00088 const void* data,
00090 ulint len);
00094
00097 UNIV_INTERN
00098 const byte*
00099 row_mysql_read_blob_ref(
00100
00101 ulint* len,
00102 const byte* ref,
00104 ulint col_len);
00106
00108 UNIV_INTERN
00109 void
00110 row_mysql_pad_col(
00111
00112 ulint mbminlen,
00114 byte* pad,
00115 ulint len);
00117
00122 UNIV_INTERN
00123 byte*
00124 row_mysql_store_col_in_innobase_format(
00125
00126 dfield_t* dfield,
00129 byte* buf,
00132 ibool row_format_col,
00139 const byte* mysql_data,
00144 ulint col_len,
00150 ulint comp);
00151
00155 UNIV_INTERN
00156 ibool
00157 row_mysql_handle_errors(
00158
00159 ulint* new_err,
00162 trx_t* trx,
00163 que_thr_t* thr,
00164 trx_savept_t* savept);
00165
00168 UNIV_INTERN
00169 row_prebuilt_t*
00170 row_create_prebuilt(
00171
00172 dict_table_t* table);
00173
00175 UNIV_INTERN
00176 void
00177 row_prebuilt_free(
00178
00179 row_prebuilt_t* prebuilt,
00180 ibool dict_locked);
00181
00184 UNIV_INTERN
00185 void
00186 row_update_prebuilt_trx(
00187
00188 row_prebuilt_t* prebuilt,
00190 trx_t* trx);
00191
00195 UNIV_INTERN
00196 void
00197 row_unlock_table_autoinc_for_mysql(
00198
00199 trx_t* trx);
00200
00207 UNIV_INTERN
00208 int
00209 row_lock_table_autoinc_for_mysql(
00210
00211 row_prebuilt_t* prebuilt);
00213
00216 UNIV_INTERN
00217 int
00218 row_lock_table_for_mysql(
00219
00220 row_prebuilt_t* prebuilt,
00222 dict_table_t* table,
00226 ulint mode);
00229
00232 UNIV_INTERN
00233 int
00234 row_insert_for_mysql(
00235
00236 byte* mysql_rec,
00237 row_prebuilt_t* prebuilt);
00239
00241 UNIV_INTERN
00242 void
00243 row_prebuild_sel_graph(
00244
00245 row_prebuilt_t* prebuilt);
00247
00252 UNIV_INTERN
00253 upd_t*
00254 row_get_prebuilt_update_vector(
00255
00256 row_prebuilt_t* prebuilt);
00258
00262 UNIV_INTERN
00263 ibool
00264 row_table_got_default_clust_index(
00265
00266 const dict_table_t* table);
00267
00270 UNIV_INTERN
00271 int
00272 row_update_for_mysql(
00273
00274 byte* mysql_rec,
00276 row_prebuilt_t* prebuilt);
00278
00288 UNIV_INTERN
00289 int
00290 row_unlock_for_mysql(
00291
00292 row_prebuilt_t* prebuilt,
00294 ibool has_latches_on_recs);
00299
00303 UNIV_INTERN
00304 upd_node_t*
00305 row_create_update_node_for_mysql(
00306
00307 dict_table_t* table,
00308 mem_heap_t* heap);
00309
00312 UNIV_INTERN
00313 ulint
00314 row_update_cascade_for_mysql(
00315
00316 que_thr_t* thr,
00317 upd_node_t* node,
00319 dict_table_t* table);
00320
00323 UNIV_INTERN
00324 void
00325 row_mysql_lock_data_dictionary_func(
00326
00327 trx_t* trx,
00328 const char* file,
00329 ulint line);
00330 #define row_mysql_lock_data_dictionary(trx) \
00331 row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
00332
00334 UNIV_INTERN
00335 void
00336 row_mysql_unlock_data_dictionary(
00337
00338 trx_t* trx);
00339
00342 UNIV_INTERN
00343 void
00344 row_mysql_freeze_data_dictionary_func(
00345
00346 trx_t* trx,
00347 const char* file,
00348 ulint line);
00349 #define row_mysql_freeze_data_dictionary(trx) \
00350 row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
00351
00353 UNIV_INTERN
00354 void
00355 row_mysql_unfreeze_data_dictionary(
00356
00357 trx_t* trx);
00358
00365 UNIV_INTERN
00366 int
00367 row_create_table_for_mysql(
00368
00369 dict_table_t* table,
00371 trx_t* trx);
00372
00377 UNIV_INTERN
00378 int
00379 row_create_index_for_mysql(
00380
00381 dict_index_t* index,
00383 trx_t* trx,
00384 const ulint* field_lengths);
00390
00398 UNIV_INTERN
00399 int
00400 row_table_add_foreign_constraints(
00401
00402 trx_t* trx,
00403 const char* sql_string,
00408 size_t sql_length,
00409 const char* name,
00412 ibool reject_fks);
00416
00421 UNIV_INTERN
00422 ulint
00423 row_drop_tables_for_mysql_in_background(void);
00424
00425
00429 UNIV_INTERN
00430 ulint
00431 row_get_background_drop_list_len_low(void);
00432
00433
00436 UNIV_INTERN
00437 int
00438 row_truncate_table_for_mysql(
00439
00440 dict_table_t* table,
00441 trx_t* trx);
00442
00450 UNIV_INTERN
00451 int
00452 row_drop_table_for_mysql(
00453
00454 const char* name,
00455 trx_t* trx,
00456 ibool drop_db);
00457
00459 UNIV_INTERN
00460 void
00461 row_mysql_drop_temp_tables(void);
00462
00463
00464
00469 UNIV_INTERN
00470 int
00471 row_discard_tablespace_for_mysql(
00472
00473 const char* name,
00474 trx_t* trx);
00475
00479 UNIV_INTERN
00480 int
00481 row_import_tablespace_for_mysql(
00482
00483 const char* name,
00484 trx_t* trx);
00485
00488 UNIV_INTERN
00489 int
00490 row_drop_database_for_mysql(
00491
00492 const char* name,
00493 trx_t* trx);
00494
00497 UNIV_INTERN
00498 ulint
00499 row_rename_table_for_mysql(
00500
00501 const char* old_name,
00502 const char* new_name,
00503 trx_t* trx,
00504 ibool commit);
00505
00510 UNIV_INTERN
00511 ulint
00512 row_check_index_for_mysql(
00513
00514 row_prebuilt_t* prebuilt,
00516 const dict_index_t* index,
00517 ulint* n_rows);
00520
00523 UNIV_INTERN
00524 ibool
00525 row_is_magic_monitor_table(
00526
00527 const char* table_name);
00530
00531
00532
00533
00534
00535 typedef struct mysql_row_templ_struct mysql_row_templ_t;
00536 struct mysql_row_templ_struct {
00537 ulint col_no;
00538 ulint rec_field_no;
00542 ulint clust_rec_field_no;
00546 ulint mysql_col_offset;
00548 ulint mysql_col_len;
00550 ulint mysql_null_byte_offset;
00552 ulint mysql_null_bit_mask;
00554 ulint type;
00556 ulint mysql_type;
00558 ulint mysql_length_bytes;
00566 ulint charset;
00568 ulint mbminlen;
00570 ulint mbmaxlen;
00572 ulint is_unsigned;
00575 };
00576
00577 #define MYSQL_FETCH_CACHE_SIZE 8
00578
00579 #define MYSQL_FETCH_CACHE_THRESHOLD 4
00580
00581 #define ROW_PREBUILT_ALLOCATED 78540783
00582 #define ROW_PREBUILT_FREED 26423527
00583
00587 struct row_prebuilt_struct {
00588 ulint magic_n;
00592 dict_table_t* table;
00593 dict_index_t* index;
00595 trx_t* trx;
00596 unsigned sql_stat_start:1;
00600 unsigned mysql_has_locked:1;
00604 unsigned clust_index_was_generated:1;
00611 unsigned index_usable:1;
00613 unsigned read_just_key:1;
00619 unsigned template_type:2;
00623 unsigned n_template:10;
00625 unsigned null_bitmap_len:10;
00628 unsigned need_to_access_clustered:1;
00633 unsigned templ_contains_blob:1;
00639 mysql_row_templ_t* mysql_template;
00643 mem_heap_t* heap;
00646 ins_node_t* ins_node;
00649 byte* ins_upd_rec_buff;
00652 const byte* default_rec;
00654 ulint hint_need_to_fetch_extra_cols;
00663 upd_node_t* upd_node;
00665 que_fork_t* ins_graph;
00667 que_fork_t* upd_graph;
00669 btr_pcur_t* pcur;
00671 btr_pcur_t* clust_pcur;
00673 que_fork_t* sel_graph;
00675 dtuple_t* search_tuple;
00676 byte row_id[DATA_ROW_ID_LEN];
00681 dtuple_t* clust_ref;
00683 ulint select_lock_type;
00684 ulint stored_select_lock_type;
00689 ulint row_read_type;
00714 ulint new_rec_locks;
00728 ulint mysql_prefix_len;
00730 ulint mysql_row_len;
00732 ulint n_rows_fetched;
00734 ulint fetch_direction;
00735 byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE];
00745 ibool keep_other_fields_on_keyread;
00749 ulint fetch_cache_first;
00751 ulint n_fetch_cached;
00753 mem_heap_t* blob_heap;
00755 mem_heap_t* old_vers_heap;
00757
00758 ib_uint64_t autoinc_last_value;
00760 ib_uint64_t autoinc_increment;
00764 ib_uint64_t autoinc_offset;
00765
00766
00767 ulint autoinc_error;
00772
00773 ulint magic_n2;
00775 };
00776
00777 #define ROW_PREBUILT_FETCH_MAGIC_N 465765687
00778
00779 #define ROW_MYSQL_WHOLE_ROW 0
00780 #define ROW_MYSQL_REC_FIELDS 1
00781 #define ROW_MYSQL_NO_TEMPLATE 2
00782 #define ROW_MYSQL_DUMMY_TEMPLATE 3
00783
00784
00785
00786 #define ROW_RETRIEVE_PRIMARY_KEY 1
00787 #define ROW_RETRIEVE_ALL_COLS 2
00788
00789
00790 #define ROW_READ_WITH_LOCKS 0
00791 #define ROW_READ_TRY_SEMI_CONSISTENT 1
00792 #define ROW_READ_DID_SEMI_CONSISTENT 2
00793
00794 #ifndef UNIV_NONINL
00795 #include "row0mysql.ic"
00796 #endif
00797
00798 #endif