MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
row0upd.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 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 /**************************************************/
26 #ifndef row0upd_h
27 #define row0upd_h
28 
29 #include "univ.i"
30 #include "data0data.h"
31 #include "row0types.h"
32 #include "btr0types.h"
33 #include "dict0types.h"
34 #include "trx0types.h"
35 
36 #ifndef UNIV_HOTBACKUP
37 # include "btr0pcur.h"
38 # include "que0types.h"
39 # include "pars0types.h"
40 #endif /* !UNIV_HOTBACKUP */
41 
42 /*********************************************************************/
45 UNIV_INLINE
46 upd_t*
48 /*=======*/
49  ulint n,
50  mem_heap_t* heap);
51 /*********************************************************************/
55 UNIV_INLINE
56 ulint
58 /*=============*/
59  const upd_t* update);
60 #ifdef UNIV_DEBUG
61 /*********************************************************************/
64 UNIV_INLINE
66 upd_get_nth_field(
67 /*==============*/
68  const upd_t* update,
69  ulint n);
70 #else
71 # define upd_get_nth_field(update, n) ((update)->fields + (n))
72 #endif
73 #ifndef UNIV_HOTBACKUP
74 /*********************************************************************/
76 UNIV_INLINE
77 void
79 /*===================*/
80  upd_field_t* upd_field,
81  ulint field_no,
84  trx_t* trx);
85 /*********************************************************************/
88 UNIV_INLINE
89 const upd_field_t*
91 /*======================*/
92  const upd_t* update,
93  ulint no)
94  __attribute__((nonnull, pure));
95 /*********************************************************************/
99 UNIV_INTERN
100 byte*
102 /*==========================*/
104  trx_id_t trx_id,
105  roll_ptr_t roll_ptr,
106  byte* log_ptr,
108  mtr_t* mtr);
109 /*********************************************************************/
112 UNIV_INLINE
113 void
115 /*===================*/
116  rec_t* rec,
117  page_zip_des_t* page_zip,
120  const ulint* offsets,
121  const trx_t* trx,
122  roll_ptr_t roll_ptr);
124 /*********************************************************************/
126 UNIV_INTERN
127 void
129 /*==========================*/
130  dtuple_t* entry,
135  ulint type,
136  ib_uint64_t val);
137 /*********************************************************************/
140 UNIV_INTERN
141 upd_node_t*
143 /*============*/
144  mem_heap_t* heap);
145 /***********************************************************/
147 UNIV_INTERN
148 void
150 /*====================*/
151  const upd_t* update,
152  byte* log_ptr,
156  mtr_t* mtr);
157 /***********************************************************/
162 UNIV_INTERN
163 ibool
165 /*===================================*/
167  const ulint* offsets,
168  const upd_t* update);
169 /***********************************************************/
172 UNIV_INTERN
173 bool
175 /*==============================*/
176  const upd_t* update)
177  __attribute__((nonnull, warn_unused_result));
178 #endif /* !UNIV_HOTBACKUP */
179 /***********************************************************/
185 UNIV_INTERN
186 void
188 /*=================*/
189  rec_t* rec,
191  const ulint* offsets,
192  const upd_t* update,
193  page_zip_des_t* page_zip);
195 #ifndef UNIV_HOTBACKUP
196 /***************************************************************/
201 UNIV_INTERN
202 upd_t*
204 /*====================================*/
205  const rec_t* rec,
207  const ulint* offsets,
208  const dtuple_t* entry,
209  mem_heap_t* heap)
210  __attribute__((warn_unused_result, nonnull));
211 /***************************************************************/
217 UNIV_INTERN
218 const upd_t*
220 /*============================*/
222  const dtuple_t* entry,
223  const rec_t* rec,
224  const ulint* offsets,
225  bool no_sys,
227  trx_t* trx,
229  mem_heap_t* heap)
230  __attribute__((nonnull(1,2,3,7), warn_unused_result));
231 /***********************************************************/
234 UNIV_INTERN
235 void
237 /*=========================================*/
238  dtuple_t* entry,
244  const upd_t* update,
247  ibool order_only,
251  mem_heap_t* heap)
253  __attribute__((nonnull));
254 /***********************************************************/
257 UNIV_INTERN
258 void
260 /*===============================*/
261  dtuple_t* entry,
267  const upd_t* update,
270  mem_heap_t* heap)
272  __attribute__((nonnull));
273 /***********************************************************/
275 UNIV_INTERN
276 void
278 /*============*/
279  dtuple_t* row,
284  row_ext_t** ext,
286  const dict_index_t* index,
287  const upd_t* update,
289  mem_heap_t* heap);
290 /***********************************************************/
297 UNIV_INTERN
298 ibool
300 /*==================================*/
302  const upd_t* update,
305 #ifdef UNIV_DEBUG
306  const que_thr_t*thr,
307 #endif /* UNIV_DEBUG */
308  const dtuple_t* row,
312  const row_ext_t*ext)
314  __attribute__((nonnull(1,2), warn_unused_result));
315 #ifdef UNIV_DEBUG
316 # define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
317  row_upd_changes_ord_field_binary_func(index,update,thr,row,ext)
318 #else /* UNIV_DEBUG */
319 # define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
320  row_upd_changes_ord_field_binary_func(index,update,row,ext)
321 #endif /* UNIV_DEBUG */
322 /***********************************************************/
326 UNIV_INTERN
327 ulint
329 /*=======================*/
331  upd_field_t* upd_field);
332 /***********************************************************/
335 UNIV_INTERN
336 bool
338 /*===================*/
340  upd_field_t* upd_field)
341  __attribute__((nonnull, warn_unused_result));
342 /***********************************************************/
349 UNIV_INTERN
350 ibool
352 /*========================================*/
353  const dict_table_t* table,
354  const upd_t* update);
355 /***********************************************************/
359 UNIV_INTERN
360 que_thr_t*
362 /*=========*/
363  que_thr_t* thr);
364 #endif /* !UNIV_HOTBACKUP */
365 /*********************************************************************/
368 UNIV_INTERN
369 byte*
371 /*===================*/
372  byte* ptr,
373  byte* end_ptr,
374  ulint* pos,
375  trx_id_t* trx_id,
376  roll_ptr_t* roll_ptr);
377 /*********************************************************************/
380 UNIV_INTERN
381 void
383 /*===============================*/
384  rec_t* rec,
385  page_zip_des_t* page_zip,
386  const ulint* offsets,
387  ulint pos,
388  trx_id_t trx_id,
389  roll_ptr_t roll_ptr);
390 /*********************************************************************/
393 UNIV_INTERN
394 byte*
396 /*================*/
397  byte* ptr,
398  byte* end_ptr,
399  mem_heap_t* heap,
401  upd_t** update_out);
404 /* Update vector field */
405 struct upd_field_t{
406  unsigned field_no:16;
411 #ifndef UNIV_HOTBACKUP
412  unsigned orig_len:16;
415  que_node_t* exp;
419 #endif /* !UNIV_HOTBACKUP */
421 };
422 
423 /* Update vector structure */
424 struct upd_t{
425  ulint info_bits;
427  ulint n_fields;
429 };
430 
431 #ifndef UNIV_HOTBACKUP
432 /* Update node structure which also implements the delete operation
433 of a row */
434 
435 struct upd_node_t{
437  ibool is_delete;/* TRUE if delete, FALSE if update */
438  ibool searched_update;
439  /* TRUE if searched update, FALSE if
440  positioned */
441  ibool in_mysql_interface;
442  /* TRUE if the update node was created
443  for the MySQL interface */
444  dict_foreign_t* foreign;/* NULL or pointer to a foreign key
445  constraint if this update node is used in
446  doing an ON DELETE or ON UPDATE operation */
447  upd_node_t* cascade_node;/* NULL or an update node template which
448  is used to implement ON DELETE/UPDATE CASCADE
449  or ... SET NULL for foreign keys */
450  mem_heap_t* cascade_heap;/* NULL or a mem heap where the cascade
451  node is created */
462  ulint update_n_fields;
463  /* when this struct is used to implement
464  a cascade operation for foreign keys, we store
465  here the size of the buffer allocated for use
466  as the update vector */
467  sym_node_list_t columns;/* symbol table nodes for the columns
468  to retrieve from the table */
469  ibool has_clust_rec_x_lock;
470  /* TRUE if the select which retrieves the
471  records to update already sets an x-lock on
472  the clustered record; note that it must always
473  set at least an s-lock */
474  ulint cmpl_info;/* information extracted during query
475  compilation; speeds up execution:
476  UPD_NODE_NO_ORD_CHANGE and
477  UPD_NODE_NO_SIZE_CHANGE, ORed */
478  /*----------------------*/
479  /* Local storage for this graph node */
480  ulint state;
488  dtuple_t* upd_row;/* NULL, or a copy of the updated row */
489  row_ext_t* upd_ext;/* NULL, or prefixes of the externally
490  stored columns in upd_row */
494  /*----------------------*/
495  sym_node_t* table_sym;/* table node in symbol table */
496  que_node_t* col_assign_list;
497  /* column assignment list */
498  ulint magic_n;
499 };
500 
501 #define UPD_NODE_MAGIC_N 1579975
502 
503 /* Node execution states */
504 #define UPD_NODE_SET_IX_LOCK 1 /* execution came to the node from
505  a node above and if the field
506  has_clust_rec_x_lock is FALSE, we
507  should set an intention x-lock on
508  the table */
509 #define UPD_NODE_UPDATE_CLUSTERED 2 /* clustered index record should be
510  updated */
511 #define UPD_NODE_INSERT_CLUSTERED 3 /* clustered index record should be
512  inserted, old record is already delete
513  marked */
514 #define UPD_NODE_INSERT_BLOB 4 /* clustered index record should be
515  inserted, old record is already
516  delete-marked; non-updated BLOBs
517  should be inherited by the new record
518  and disowned by the old record */
519 #define UPD_NODE_UPDATE_ALL_SEC 5 /* an ordering field of the clustered
520  index record was changed, or this is
521  a delete operation: should update
522  all the secondary index records */
523 #define UPD_NODE_UPDATE_SOME_SEC 6 /* secondary index entries should be
524  looked at and updated if an ordering
525  field changed */
526 
527 /* Compilation info flags: these must fit within 3 bits; see trx0rec.h */
528 #define UPD_NODE_NO_ORD_CHANGE 1 /* no secondary index record will be
529  changed in the update and no ordering
530  field of the clustered index */
531 #define UPD_NODE_NO_SIZE_CHANGE 2 /* no record field size will be
532  changed in the update */
533 
534 #endif /* !UNIV_HOTBACKUP */
535 
536 #ifndef UNIV_NONINL
537 #include "row0upd.ic"
538 #endif
539 
540 #endif