Drizzled Public API Documentation

row0mysql.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 2000, 2010, Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
27 #pragma once
28 #ifndef row0mysql_h
29 #define row0mysql_h
30 
31 #include "univ.i"
32 #include "data0data.h"
33 #include "que0types.h"
34 #include "dict0types.h"
35 #include "trx0types.h"
36 #include "row0types.h"
37 #include "btr0pcur.h"
38 #include "trx0types.h"
39 
40 extern ibool row_rollback_on_timeout;
41 
42 typedef struct row_prebuilt_struct row_prebuilt_t;
43 
44 /*******************************************************************/
46 UNIV_INTERN
47 void
49 /*==============================*/
50  row_prebuilt_t* prebuilt);
52 /*******************************************************************/
57 UNIV_INTERN
58 byte*
60 /*=========================*/
61  byte* dest,
62  ulint len,
63  ulint lenlen);
64 /*******************************************************************/
69 UNIV_INTERN
70 const byte*
72 /*========================*/
73  ulint* len,
74  const byte* field,
75  ulint lenlen);
77 /*******************************************************************/
79 UNIV_INTERN
80 void
82 /*=====================*/
83  byte* dest,
84  ulint col_len,
88  const void* data,
90  ulint len);
94 /*******************************************************************/
97 UNIV_INTERN
98 const byte*
100 /*====================*/
101  ulint* len,
102  const byte* ref,
104  ulint col_len);
106 /**************************************************************/
108 UNIV_INTERN
109 void
111 /*==============*/
112  ulint mbminlen,
114  byte* pad,
115  ulint len);
117 /**************************************************************/
122 UNIV_INTERN
123 byte*
125 /*===================================*/
126  dfield_t* dfield,
129  byte* buf,
132  ibool row_format_col,
139  const byte* mysql_data,
144  ulint col_len,
150  ulint comp);
151 /****************************************************************/
155 UNIV_INTERN
156 ibool
158 /*====================*/
159  ulint* new_err,
162  trx_t* trx,
163  que_thr_t* thr,
164  trx_savept_t* savept);
165 /********************************************************************/
168 UNIV_INTERN
171 /*================*/
172  dict_table_t* table);
173 /********************************************************************/
175 UNIV_INTERN
176 void
178 /*==============*/
179  row_prebuilt_t* prebuilt,
180  ibool dict_locked);
181 /*********************************************************************/
184 UNIV_INTERN
185 void
187 /*====================*/
188  row_prebuilt_t* prebuilt,
190  trx_t* trx);
191 /*********************************************************************/
195 UNIV_INTERN
196 void
198 /*===============================*/
199  trx_t* trx);
200 /*********************************************************************/
207 UNIV_INTERN
208 int
210 /*=============================*/
211  row_prebuilt_t* prebuilt);
213 /*********************************************************************/
216 UNIV_INTERN
217 int
219 /*=====================*/
220  row_prebuilt_t* prebuilt,
226  ulint mode);
229 /*********************************************************************/
232 UNIV_INTERN
233 int
235 /*=================*/
236  byte* mysql_rec,
237  row_prebuilt_t* prebuilt);
239 /*********************************************************************/
241 UNIV_INTERN
242 void
244 /*===================*/
245  row_prebuilt_t* prebuilt);
247 /*********************************************************************/
252 UNIV_INTERN
253 upd_t*
255 /*===========================*/
256  row_prebuilt_t* prebuilt);
258 /*********************************************************************/
262 UNIV_INTERN
263 ibool
265 /*==============================*/
266  const dict_table_t* table);
267 /*********************************************************************/
270 UNIV_INTERN
271 int
273 /*=================*/
274  byte* mysql_rec,
276  row_prebuilt_t* prebuilt);
278 /*********************************************************************/
288 UNIV_INTERN
289 int
291 /*=================*/
292  row_prebuilt_t* prebuilt,
294  ibool has_latches_on_recs);
299 /*********************************************************************/
303 UNIV_INTERN
304 upd_node_t*
306 /*=============================*/
308  mem_heap_t* heap);
309 /**********************************************************************/
312 UNIV_INTERN
313 ulint
315 /*=========================*/
316  que_thr_t* thr,
317  upd_node_t* node,
319  dict_table_t* table);
320 /*********************************************************************/
323 UNIV_INTERN
324 void
326 /*================================*/
327  trx_t* trx,
328  const char* file,
329  ulint line);
330 #define row_mysql_lock_data_dictionary(trx) \
331  row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
332 /*********************************************************************/
334 UNIV_INTERN
335 void
337 /*=============================*/
338  trx_t* trx);
339 /*********************************************************************/
342 UNIV_INTERN
343 void
345 /*==================================*/
346  trx_t* trx,
347  const char* file,
348  ulint line);
349 #define row_mysql_freeze_data_dictionary(trx) \
350  row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
351 /*********************************************************************/
353 UNIV_INTERN
354 void
356 /*===============================*/
357  trx_t* trx);
358 /*********************************************************************/
365 UNIV_INTERN
366 int
368 /*=======================*/
371  trx_t* trx);
372 /*********************************************************************/
377 UNIV_INTERN
378 int
380 /*=======================*/
383  trx_t* trx,
384  const ulint* field_lengths);
390 /*********************************************************************/
398 UNIV_INTERN
399 int
401 /*==============================*/
402  trx_t* trx,
403  const char* sql_string,
408  size_t sql_length,
409  const char* name,
412  ibool reject_fks);
416 /*********************************************************************/
421 UNIV_INTERN
422 ulint
424 /*=========================================*/
425 /*********************************************************************/
429 UNIV_INTERN
430 ulint
432 /*======================================*/
433 /*********************************************************************/
436 UNIV_INTERN
437 int
439 /*=========================*/
441  trx_t* trx);
442 /*********************************************************************/
450 UNIV_INTERN
451 int
453 /*=====================*/
454  const char* name,
455  trx_t* trx,
456  ibool drop_db);
457 /*********************************************************************/
459 UNIV_INTERN
460 void
462 /*============================*/
463 
464 /*********************************************************************/
469 UNIV_INTERN
470 int
472 /*=============================*/
473  const char* name,
474  trx_t* trx);
475 /*****************************************************************/
479 UNIV_INTERN
480 int
482 /*============================*/
483  const char* name,
484  trx_t* trx);
485 /*********************************************************************/
488 UNIV_INTERN
489 int
491 /*========================*/
492  const char* name,
493  trx_t* trx);
494 /*********************************************************************/
497 UNIV_INTERN
498 ulint
500 /*=======================*/
501  const char* old_name,
502  const char* new_name,
503  trx_t* trx,
504  ibool commit);
505 /*********************************************************************/
510 UNIV_INTERN
511 ulint
513 /*======================*/
514  row_prebuilt_t* prebuilt,
516  const dict_index_t* index,
517  ulint* n_rows);
520 /*********************************************************************/
523 UNIV_INTERN
524 ibool
526 /*=======================*/
527  const char* table_name);
530 /* A struct describing a place for an individual column in the MySQL
531 row format which is presented to the table handler in ha_innobase.
532 This template struct is used to speed up row transformations between
533 Innobase and MySQL. */
534 
537  ulint col_no;
538  ulint rec_field_no;
554  ulint type;
556  ulint mysql_type;
566  ulint charset;
568  ulint mbminlen;
570  ulint mbmaxlen;
572  ulint is_unsigned;
575 };
576 
577 #define MYSQL_FETCH_CACHE_SIZE 8
578 /* After fetching this many rows, we start caching them in fetch_cache */
579 #define MYSQL_FETCH_CACHE_THRESHOLD 4
580 
581 #define ROW_PREBUILT_ALLOCATED 78540783
582 #define ROW_PREBUILT_FREED 26423527
583 
588  ulint magic_n;
596  unsigned sql_stat_start:1;
600  unsigned mysql_has_locked:1;
611  unsigned index_usable:1;
613  unsigned read_just_key:1;
619  unsigned template_type:2;
623  unsigned n_template:10;
625  unsigned null_bitmap_len:10;
652  const byte* default_rec;
676  byte row_id[DATA_ROW_ID_LEN];
735  byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE];
757  /*----------------------*/
758  ib_uint64_t autoinc_last_value;
760  ib_uint64_t autoinc_increment;
764  ib_uint64_t autoinc_offset; /* The offset passed to
765  get_auto_increment() by MySQL. Required
766  to calculate the next value */
772  /*----------------------*/
773  ulint magic_n2;
775 };
776 
777 #define ROW_PREBUILT_FETCH_MAGIC_N 465765687
778 
779 #define ROW_MYSQL_WHOLE_ROW 0
780 #define ROW_MYSQL_REC_FIELDS 1
781 #define ROW_MYSQL_NO_TEMPLATE 2
782 #define ROW_MYSQL_DUMMY_TEMPLATE 3 /* dummy template used in
783  row_scan_and_check_index */
784 
785 /* Values for hint_need_to_fetch_extra_cols */
786 #define ROW_RETRIEVE_PRIMARY_KEY 1
787 #define ROW_RETRIEVE_ALL_COLS 2
788 
789 /* Values for row_read_type */
790 #define ROW_READ_WITH_LOCKS 0
791 #define ROW_READ_TRY_SEMI_CONSISTENT 1
792 #define ROW_READ_DID_SEMI_CONSISTENT 2
793 
794 #ifndef UNIV_NONINL
795 #include "row0mysql.ic"
796 #endif
797 
798 #endif
UNIV_INTERN void row_mysql_store_blob_ref(byte *dest, ulint col_len, const void *data, ulint len)
Definition: row0mysql.cc:196
UNIV_INTERN void row_mysql_freeze_data_dictionary_func(trx_t *trx, const char *file, ulint line)
Definition: row0mysql.cc:1735
UNIV_INTERN void row_prebuild_sel_graph(row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:1234
unsigned clust_index_was_generated
Definition: row0mysql.h:604
dict_table_t * table
Definition: row0mysql.h:592
dict_index_t * index
Definition: row0mysql.h:593
unsigned read_just_key
Definition: row0mysql.h:613
UNIV_INTERN int row_create_table_for_mysql(dict_table_t *table, trx_t *trx)
Definition: row0mysql.cc:1814
unsigned templ_contains_blob
Definition: row0mysql.h:633
ins_node_t * ins_node
Definition: row0mysql.h:646
ibool row_rollback_on_timeout
Definition: row0mysql.cc:58
UNIV_INTERN upd_t * row_get_prebuilt_update_vector(row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:1299
byte * ins_upd_rec_buff
Definition: row0mysql.h:649
UNIV_INTERN ibool row_mysql_handle_errors(ulint *new_err, trx_t *trx, que_thr_t *thr, trx_savept_t *savept)
Definition: row0mysql.cc:533
que_fork_t * ins_graph
Definition: row0mysql.h:665
UNIV_INTERN ibool row_is_magic_monitor_table(const char *table_name)
Definition: row0mysql.cc:4223
unsigned sql_stat_start
Definition: row0mysql.h:596
unsigned index_usable
Definition: row0mysql.h:611
UNIV_INTERN void row_mysql_prebuilt_free_blob_heap(row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:127
UNIV_INTERN byte * row_mysql_store_col_in_innobase_format(dfield_t *dfield, byte *buf, ibool row_format_col, const byte *mysql_data, ulint col_len, ulint comp)
Definition: row0mysql.cc:301
UNIV_INTERN void row_unlock_table_autoinc_for_mysql(trx_t *trx)
Definition: row0mysql.cc:928
UNIV_INTERN void row_mysql_pad_col(ulint mbminlen, byte *pad, ulint len)
Definition: row0mysql.cc:255
UNIV_INTERN void row_mysql_unfreeze_data_dictionary(trx_t *trx)
Definition: row0mysql.cc:1752
UNIV_INTERN int row_table_add_foreign_constraints(trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks)
Definition: row0mysql.cc:2096
que_fork_t * sel_graph
Definition: row0mysql.h:673
UNIV_INTERN int row_discard_tablespace_for_mysql(const char *name, trx_t *trx)
Definition: row0mysql.cc:2351
dtuple_t * clust_ref
Definition: row0mysql.h:681
UNIV_INTERN const byte * row_mysql_read_blob_ref(ulint *len, const byte *ref, ulint col_len)
Definition: row0mysql.cc:234
unsigned mysql_has_locked
Definition: row0mysql.h:600
unsigned need_to_access_clustered
Definition: row0mysql.h:628
UNIV_INTERN ulint row_check_index_for_mysql(row_prebuilt_t *prebuilt, const dict_index_t *index, ulint *n_rows)
Definition: row0mysql.cc:4071
mem_heap_t * blob_heap
Definition: row0mysql.h:753
UNIV_INTERN void row_prebuilt_free(row_prebuilt_t *prebuilt, ibool dict_locked)
Definition: row0mysql.cc:712
UNIV_INTERN ulint row_update_cascade_for_mysql(que_thr_t *thr, upd_node_t *node, dict_table_t *table)
Definition: row0mysql.cc:1634
const byte * default_rec
Definition: row0mysql.h:652
UNIV_INTERN int row_unlock_for_mysql(row_prebuilt_t *prebuilt, ibool has_latches_on_recs)
Definition: row0mysql.cc:1510
UNIV_INTERN int row_truncate_table_for_mysql(dict_table_t *table, trx_t *trx)
Definition: row0mysql.cc:2679
mysql_row_templ_t * mysql_template
Definition: row0mysql.h:639
UNIV_INTERN upd_node_t * row_create_update_node_for_mysql(dict_table_t *table, mem_heap_t *heap)
Definition: row0mysql.cc:1262
unsigned null_bitmap_len
Definition: row0mysql.h:625
ulint hint_need_to_fetch_extra_cols
Definition: row0mysql.h:654
ib_uint64_t autoinc_increment
Definition: row0mysql.h:760
UNIV_INTERN void row_mysql_lock_data_dictionary_func(trx_t *trx, const char *file, ulint line)
Definition: row0mysql.cc:1768
btr_pcur_t * pcur
Definition: row0mysql.h:669
UNIV_INTERN int row_import_tablespace_for_mysql(const char *name, trx_t *trx)
Definition: row0mysql.cc:2542
UNIV_INTERN row_prebuilt_t * row_create_prebuilt(dict_table_t *table)
Definition: row0mysql.cc:650
dtuple_t * search_tuple
Definition: row0mysql.h:675
unsigned template_type
Definition: row0mysql.h:619
byte row_id[DATA_ROW_ID_LEN]
Definition: row0mysql.h:676
UNIV_INTERN int row_update_for_mysql(byte *mysql_rec, row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:1333
UNIV_INTERN int row_lock_table_for_mysql(row_prebuilt_t *prebuilt, dict_table_t *table, ulint mode)
Definition: row0mysql.cc:1026
ib_uint64_t autoinc_last_value
Definition: row0mysql.h:758
UNIV_INTERN ulint row_drop_tables_for_mysql_in_background(void)
Definition: row0mysql.cc:2203
ibool keep_other_fields_on_keyread
Definition: row0mysql.h:745
UNIV_INTERN int row_create_index_for_mysql(dict_index_t *index, trx_t *trx, const ulint *field_lengths)
Definition: row0mysql.cc:1965
mem_heap_t * old_vers_heap
Definition: row0mysql.h:755
upd_node_t * upd_node
Definition: row0mysql.h:663
UNIV_INTERN ulint row_rename_table_for_mysql(const char *old_name, const char *new_name, trx_t *trx, ibool commit)
Definition: row0mysql.cc:3754
unsigned n_template
Definition: row0mysql.h:623
btr_pcur_t * clust_pcur
Definition: row0mysql.h:671
UNIV_INTERN int row_insert_for_mysql(byte *mysql_rec, row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:1103
byte * fetch_cache[MYSQL_FETCH_CACHE_SIZE]
Definition: row0mysql.h:735
UNIV_INTERN const byte * row_mysql_read_true_varchar(ulint *len, const byte *field, ulint lenlen)
Definition: row0mysql.cc:172
que_fork_t * upd_graph
Definition: row0mysql.h:667
UNIV_INTERN void row_mysql_drop_temp_tables(void)
Definition: row0mysql.cc:3440
mem_heap_t * heap
Definition: row0mysql.h:643
UNIV_INTERN byte * row_mysql_store_true_var_len(byte *dest, ulint len, ulint lenlen)
Definition: row0mysql.cc:143
UNIV_INTERN void row_update_prebuilt_trx(row_prebuilt_t *prebuilt, trx_t *trx)
Definition: row0mysql.cc:798
UNIV_INTERN ulint row_get_background_drop_list_len_low(void)
Definition: row0mysql.cc:2277
UNIV_INTERN int row_drop_database_for_mysql(const char *name, trx_t *trx)
Definition: row0mysql.cc:3585
UNIV_INTERN void row_mysql_unlock_data_dictionary(trx_t *trx)
Definition: row0mysql.cc:1790
ulint stored_select_lock_type
Definition: row0mysql.h:684
UNIV_INTERN int row_drop_table_for_mysql(const char *name, trx_t *trx, ibool drop_db)
Definition: row0mysql.cc:3033
UNIV_INTERN int row_lock_table_autoinc_for_mysql(row_prebuilt_t *prebuilt)
Definition: row0mysql.cc:950
UNIV_INTERN ibool row_table_got_default_clust_index(const dict_table_t *table)
Definition: row0mysql.cc:1719