MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
row0mysql.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
27 #ifndef row0mysql_h
28 #define row0mysql_h
29 
30 #include "univ.i"
31 #include "data0data.h"
32 #include "que0types.h"
33 #include "dict0types.h"
34 #include "trx0types.h"
35 #include "row0types.h"
36 #include "btr0pcur.h"
37 #include "trx0types.h"
38 
39 // Forward declaration
40 struct SysIndexCallback;
41 
42 extern ibool row_rollback_on_timeout;
43 
44 struct row_prebuilt_t;
45 
46 /*******************************************************************/
48 UNIV_INTERN
49 void
51 /*==============================*/
52  row_prebuilt_t* prebuilt);
54 /*******************************************************************/
59 UNIV_INTERN
60 byte*
62 /*=========================*/
63  byte* dest,
64  ulint len,
65  ulint lenlen);
66 /*******************************************************************/
71 UNIV_INTERN
72 const byte*
74 /*========================*/
75  ulint* len,
76  const byte* field,
77  ulint lenlen);
79 /*******************************************************************/
81 UNIV_INTERN
82 void
84 /*=====================*/
85  byte* dest,
86  ulint col_len,
90  const void* data,
92  ulint len);
96 /*******************************************************************/
99 UNIV_INTERN
100 const byte*
102 /*====================*/
103  ulint* len,
104  const byte* ref,
106  ulint col_len);
108 /**************************************************************/
110 UNIV_INTERN
111 void
113 /*==============*/
114  ulint mbminlen,
116  byte* pad,
117  ulint len);
119 /**************************************************************/
124 UNIV_INTERN
125 byte*
127 /*===================================*/
128  dfield_t* dfield,
131  byte* buf,
137  ibool row_format_col,
144  const byte* mysql_data,
149  ulint col_len,
155  ulint comp);
156 /****************************************************************/
160 UNIV_INTERN
161 bool
163 /*====================*/
164  dberr_t* new_err,
167  trx_t* trx,
168  que_thr_t* thr,
169  trx_savept_t* savept)
170  __attribute__((nonnull(1,2)));
171 /********************************************************************/
174 UNIV_INTERN
177 /*================*/
179  ulint mysql_row_len);
181 /********************************************************************/
183 UNIV_INTERN
184 void
186 /*==============*/
187  row_prebuilt_t* prebuilt,
188  ibool dict_locked);
189 /*********************************************************************/
192 UNIV_INTERN
193 void
195 /*====================*/
196  row_prebuilt_t* prebuilt,
198  trx_t* trx);
199 /*********************************************************************/
206 UNIV_INTERN
207 dberr_t
209 /*=============================*/
210  row_prebuilt_t* prebuilt)
212  __attribute__((nonnull, warn_unused_result));
213 /*********************************************************************/
216 UNIV_INTERN
217 dberr_t
219 /*=====================*/
220  row_prebuilt_t* prebuilt,
226  ulint mode)
228  __attribute__((nonnull(1)));
229 /*********************************************************************/
232 UNIV_INTERN
233 dberr_t
235 /*=================*/
236  byte* mysql_rec,
237  row_prebuilt_t* prebuilt)
239  __attribute__((nonnull, warn_unused_result));
240 /*********************************************************************/
242 UNIV_INTERN
243 void
245 /*===================*/
246  row_prebuilt_t* prebuilt);
248 /*********************************************************************/
253 UNIV_INTERN
254 upd_t*
256 /*===========================*/
257  row_prebuilt_t* prebuilt);
259 /*********************************************************************/
263 UNIV_INTERN
264 ibool
266 /*==============================*/
267  const dict_table_t* table);
268 /*********************************************************************/
271 UNIV_INTERN
272 dberr_t
274 /*=================*/
275  byte* mysql_rec,
277  row_prebuilt_t* prebuilt)
279  __attribute__((nonnull, warn_unused_result));
280 /*********************************************************************/
289 UNIV_INTERN
290 void
292 /*=================*/
293  row_prebuilt_t* prebuilt,
295  ibool has_latches_on_recs)
300  __attribute__((nonnull));
301 /*********************************************************************/
305 UNIV_INTERN
306 bool
308 /*========================*/
309  const char* name) __attribute__((warn_unused_result));
313 /*********************************************************************/
317 UNIV_INTERN
318 upd_node_t*
320 /*=============================*/
322  mem_heap_t* heap);
323 /**********************************************************************/
326 UNIV_INTERN
327 dberr_t
329 /*=========================*/
330  que_thr_t* thr,
331  upd_node_t* node,
334  __attribute__((nonnull, warn_unused_result));
335 /*********************************************************************/
338 UNIV_INTERN
339 void
341 /*================================*/
342  trx_t* trx,
343  const char* file,
344  ulint line);
345 #define row_mysql_lock_data_dictionary(trx) \
346  row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__)
347 /*********************************************************************/
349 UNIV_INTERN
350 void
352 /*=============================*/
353  trx_t* trx);
354 /*********************************************************************/
357 UNIV_INTERN
358 void
360 /*==================================*/
361  trx_t* trx,
362  const char* file,
363  ulint line);
364 #define row_mysql_freeze_data_dictionary(trx) \
365  row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__)
366 /*********************************************************************/
368 UNIV_INTERN
369 void
371 /*===============================*/
372  trx_t* trx);
373 /*********************************************************************/
381 UNIV_INTERN
382 dberr_t
384 /*=======================*/
388  trx_t* trx,
389  bool commit)
390  __attribute__((nonnull, warn_unused_result));
391 /*********************************************************************/
396 UNIV_INTERN
397 dberr_t
399 /*=======================*/
402  trx_t* trx,
403  const ulint* field_lengths)
409  __attribute__((nonnull(1,2), warn_unused_result));
410 /*********************************************************************/
418 UNIV_INTERN
419 dberr_t
421 /*==============================*/
422  trx_t* trx,
423  const char* sql_string,
428  size_t sql_length,
429  const char* name,
432  ibool reject_fks)
435  __attribute__((nonnull, warn_unused_result));
436 /*********************************************************************/
441 UNIV_INTERN
442 ulint
444 /*=========================================*/
445 /*********************************************************************/
449 UNIV_INTERN
450 ulint
452 /*======================================*/
453 /*********************************************************************/
456 UNIV_INTERN
457 dberr_t
459 /*=================*/
460  trx_t* trx,
462  enum lock_mode mode,
463  const char* op_info)
464  __attribute__((nonnull, warn_unused_result));
465 
466 /*********************************************************************/
469 UNIV_INTERN
470 dberr_t
472 /*=========================*/
474  trx_t* trx)
475  __attribute__((nonnull, warn_unused_result));
476 /*********************************************************************/
484 UNIV_INTERN
485 dberr_t
487 /*=====================*/
488  const char* name,
489  trx_t* trx,
490  bool drop_db,
491  bool nonatomic = true)
494  __attribute__((nonnull));
495 /*********************************************************************/
497 UNIV_INTERN
498 void
500 /*============================*/
501 
502 /*********************************************************************/
507 UNIV_INTERN
508 dberr_t
510 /*=============================*/
511  const char* name,
512  trx_t* trx)
513  __attribute__((nonnull, warn_unused_result));
514 /*****************************************************************/
518 UNIV_INTERN
519 dberr_t
521 /*============================*/
523  row_prebuilt_t* prebuilt)
524  __attribute__((nonnull, warn_unused_result));
525 /*********************************************************************/
528 UNIV_INTERN
529 dberr_t
531 /*========================*/
532  const char* name,
533  trx_t* trx)
534  __attribute__((nonnull));
535 /*********************************************************************/
538 UNIV_INTERN
539 dberr_t
541 /*=======================*/
542  const char* old_name,
543  const char* new_name,
544  trx_t* trx,
545  bool commit)
546  __attribute__((nonnull, warn_unused_result));
547 /*********************************************************************/
552 UNIV_INTERN
553 bool
555 /*======================*/
556  row_prebuilt_t* prebuilt,
558  const dict_index_t* index,
559  ulint* n_rows)
561  __attribute__((nonnull, warn_unused_result));
562 /*********************************************************************/
565 UNIV_INTERN
566 bool
568 /*=======================*/
569  const char* table_name)
571  __attribute__((nonnull, warn_unused_result));
572 /*********************************************************************/
574 UNIV_INTERN
575 void
576 row_mysql_init(void);
577 /*================*/
578 
579 /*********************************************************************/
581 UNIV_INTERN
582 void
583 row_mysql_close(void);
584 /*=================*/
585 
586 /*********************************************************************/
589 UNIV_INTERN
590 dberr_t
592 /*========================*/
593  dict_table_t* table,
594  trx_t* trx,
595  table_id_t* new_id)
596  __attribute__((nonnull, warn_unused_result));
597 
598 /* A struct describing a place for an individual column in the MySQL
599 row format which is presented to the table handler in ha_innobase.
600 This template struct is used to speed up row transformations between
601 Innobase and MySQL. */
602 
604  ulint col_no;
605  ulint rec_field_no;
609  ulint clust_rec_field_no;
613  ulint icp_rec_field_no;
617  ulint mysql_col_offset;
619  ulint mysql_col_len;
621  ulint mysql_null_byte_offset;
623  ulint mysql_null_bit_mask;
625  ulint type;
627  ulint mysql_type;
629  ulint mysql_length_bytes;
637  ulint charset;
639  ulint mbminlen;
641  ulint mbmaxlen;
643  ulint is_unsigned;
646 };
647 
648 #define MYSQL_FETCH_CACHE_SIZE 8
649 /* After fetching this many rows, we start caching them in fetch_cache */
650 #define MYSQL_FETCH_CACHE_THRESHOLD 4
651 
652 #define ROW_PREBUILT_ALLOCATED 78540783
653 #define ROW_PREBUILT_FREED 26423527
654 
659  ulint magic_n;
667  unsigned sql_stat_start:1;
671  unsigned mysql_has_locked:1;
675  unsigned clust_index_was_generated:1;
682  unsigned index_usable:1;
684  unsigned read_just_key:1;
690  unsigned used_in_HANDLER:1;
697  unsigned template_type:2;
701  unsigned n_template:10;
703  unsigned null_bitmap_len:10;
730  const byte* default_rec;
757  byte row_id[DATA_ROW_ID_LEN];
762  doc_id_t fts_doc_id; /* if the table has an FTS index on
763  it then we fetch the doc_id.
764  FTS-FIXME: Currently we fetch it always
765  but in the future we must only fetch
766  it when FTS columns are being
767  updated */
822  byte* fetch_cache[MYSQL_FETCH_CACHE_SIZE];
845  /*----------------------*/
846  ulonglong autoinc_last_value;
848  ulonglong autoinc_increment;
852  ulonglong autoinc_offset;
860  /*----------------------*/
861  void* idx_cond;
867  /*----------------------*/
868  ulint magic_n2;
870  /*----------------------*/
871  unsigned innodb_api:1;
873  const rec_t* innodb_api_rec;
874 };
875 
878  virtual ~SysIndexCallback() { }
879 
883  virtual void operator()(mtr_t* mtr, btr_pcur_t* pcur) throw() = 0;
884 };
885 
886 #define ROW_PREBUILT_FETCH_MAGIC_N 465765687
887 
888 #define ROW_MYSQL_WHOLE_ROW 0
889 #define ROW_MYSQL_REC_FIELDS 1
890 #define ROW_MYSQL_NO_TEMPLATE 2
891 #define ROW_MYSQL_DUMMY_TEMPLATE 3 /* dummy template used in
892  row_scan_and_check_index */
893 
894 /* Values for hint_need_to_fetch_extra_cols */
895 #define ROW_RETRIEVE_PRIMARY_KEY 1
896 #define ROW_RETRIEVE_ALL_COLS 2
897 
898 /* Values for row_read_type */
899 #define ROW_READ_WITH_LOCKS 0
900 #define ROW_READ_TRY_SEMI_CONSISTENT 1
901 #define ROW_READ_DID_SEMI_CONSISTENT 2
902 
903 #ifndef UNIV_NONINL
904 #include "row0mysql.ic"
905 #endif
906 
907 #endif /* row0mysql.h */