Drizzled Public API Documentation

row0upd.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 2009, 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 /**************************************************/
26 #pragma once
27 #ifndef row0upd_h
28 #define row0upd_h
29 
30 #include "univ.i"
31 #include "data0data.h"
32 #include "row0types.h"
33 #include "btr0types.h"
34 #include "dict0types.h"
35 #include "trx0types.h"
36 
37 #ifndef UNIV_HOTBACKUP
38 # include "btr0pcur.h"
39 # include "que0types.h"
40 # include "pars0types.h"
41 #endif /* !UNIV_HOTBACKUP */
42 
43 /*********************************************************************/
46 UNIV_INLINE
47 upd_t*
49 /*=======*/
50  ulint n,
51  mem_heap_t* heap);
52 /*********************************************************************/
56 UNIV_INLINE
57 ulint
59 /*=============*/
60  const upd_t* update);
61 #ifdef UNIV_DEBUG
62 /*********************************************************************/
65 UNIV_INLINE
67 upd_get_nth_field(
68 /*==============*/
69  const upd_t* update,
70  ulint n);
71 #else
72 # define upd_get_nth_field(update, n) ((update)->fields + (n))
73 #endif
74 #ifndef UNIV_HOTBACKUP
75 /*********************************************************************/
77 UNIV_INLINE
78 void
80 /*===================*/
81  upd_field_t* upd_field,
82  ulint field_no,
84  dict_index_t* index,
85  trx_t* trx);
86 /*********************************************************************/
89 UNIV_INLINE
90 const upd_field_t*
92 /*======================*/
93  const upd_t* update,
94  ulint no)
95  __attribute__((nonnull, pure));
96 /*********************************************************************/
100 UNIV_INTERN
101 byte*
103 /*==========================*/
104  dict_index_t* index,
105  trx_t* trx,
106  roll_ptr_t roll_ptr,
107  byte* log_ptr,
109  mtr_t* mtr);
110 /*********************************************************************/
113 UNIV_INLINE
114 void
116 /*===================*/
117  rec_t* rec,
118  page_zip_des_t* page_zip,
120  dict_index_t* index,
121  const ulint* offsets,
122  trx_t* trx,
123  roll_ptr_t roll_ptr);
124 /*********************************************************************/
126 UNIV_INTERN
127 void
129 /*==========================*/
130  dtuple_t* entry,
134  dict_index_t* index,
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 /*===================================*/
166  dict_index_t* index,
167  const ulint* offsets,
168  const upd_t* update);
169 #endif /* !UNIV_HOTBACKUP */
170 /***********************************************************/
176 UNIV_INTERN
177 void
179 /*=================*/
180  rec_t* rec,
181  dict_index_t* index,
182  const ulint* offsets,
183  const upd_t* update,
184  page_zip_des_t* page_zip);
186 #ifndef UNIV_HOTBACKUP
187 /***************************************************************/
192 UNIV_INTERN
193 upd_t*
195 /*====================================*/
196  dict_index_t* index,
197  const dtuple_t* entry,
198  const rec_t* rec,
199  trx_t* trx,
200  mem_heap_t* heap);
201 /***************************************************************/
207 UNIV_INTERN
208 upd_t*
210 /*============================*/
211  dict_index_t* index,
212  const dtuple_t* entry,
213  const rec_t* rec,
214  trx_t* trx,
215  mem_heap_t* heap);
216 /***********************************************************/
219 UNIV_INTERN
220 void
222 /*=========================================*/
223  dtuple_t* entry,
227  dict_index_t* index,
229  const upd_t* update,
232  ibool order_only,
236  mem_heap_t* heap)
238  __attribute__((nonnull));
239 /***********************************************************/
242 UNIV_INTERN
243 void
245 /*===============================*/
246  dtuple_t* entry,
250  dict_index_t* index,
252  const upd_t* update,
255  mem_heap_t* heap)
257  __attribute__((nonnull));
258 /***********************************************************/
260 UNIV_INTERN
261 void
263 /*============*/
264  dtuple_t* row,
269  row_ext_t** ext,
271  const dict_index_t* index,
272  const upd_t* update,
274  mem_heap_t* heap);
275 /***********************************************************/
282 UNIV_INTERN
283 ibool
285 /*==================================*/
286  dict_index_t* index,
287  const upd_t* update,
290 #ifdef UNIV_DEBUG
291  const que_thr_t*thr,
292 #endif /* UNIV_DEBUG */
293  const dtuple_t* row,
297  const row_ext_t*ext)
299  __attribute__((nonnull(1,2), warn_unused_result));
300 #ifdef UNIV_DEBUG
301 # define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
302  row_upd_changes_ord_field_binary_func(index,update,thr,row,ext)
303 #else /* UNIV_DEBUG */
304 # define row_upd_changes_ord_field_binary(index,update,thr,row,ext) \
305  row_upd_changes_ord_field_binary_func(index,update,row,ext)
306 #endif /* UNIV_DEBUG */
307 /***********************************************************/
314 UNIV_INTERN
315 ibool
317 /*========================================*/
318  const dict_table_t* table,
319  const upd_t* update);
320 /***********************************************************/
324 UNIV_INTERN
325 que_thr_t*
327 /*=========*/
328  que_thr_t* thr);
329 #endif /* !UNIV_HOTBACKUP */
330 /*********************************************************************/
333 UNIV_INTERN
334 byte*
336 /*===================*/
337  byte* ptr,
338  byte* end_ptr,
339  ulint* pos,
340  trx_id_t* trx_id,
341  roll_ptr_t* roll_ptr);
342 /*********************************************************************/
345 UNIV_INTERN
346 void
348 /*===============================*/
349  rec_t* rec,
350  page_zip_des_t* page_zip,
351  const ulint* offsets,
352  ulint pos,
353  trx_id_t trx_id,
354  roll_ptr_t roll_ptr);
355 /*********************************************************************/
358 UNIV_INTERN
359 byte*
361 /*================*/
362  byte* ptr,
363  byte* end_ptr,
364  mem_heap_t* heap,
366  upd_t** update_out);
369 /* Update vector field */
371  unsigned field_no:16;
376 #ifndef UNIV_HOTBACKUP
377  unsigned orig_len:16;
380  que_node_t* exp;
384 #endif /* !UNIV_HOTBACKUP */
386 };
387 
388 /* Update vector structure */
389 struct upd_struct{
390  ulint info_bits;
392  ulint n_fields;
394 };
395 
396 #ifndef UNIV_HOTBACKUP
397 /* Update node structure which also implements the delete operation
398 of a row */
399 
402  ibool is_delete;/* TRUE if delete, FALSE if update */
403  ibool searched_update;
404  /* TRUE if searched update, FALSE if
405  positioned */
406  ibool in_mysql_interface;
407  /* TRUE if the update node was created
408  for the MySQL interface */
409  dict_foreign_t* foreign;/* NULL or pointer to a foreign key
410  constraint if this update node is used in
411  doing an ON DELETE or ON UPDATE operation */
412  upd_node_t* cascade_node;/* NULL or an update node template which
413  is used to implement ON DELETE/UPDATE CASCADE
414  or ... SET NULL for foreign keys */
415  mem_heap_t* cascade_heap;/* NULL or a mem heap where the cascade
416  node is created */
427  ulint update_n_fields;
428  /* when this struct is used to implement
429  a cascade operation for foreign keys, we store
430  here the size of the buffer allocated for use
431  as the update vector */
432  sym_node_list_t columns;/* symbol table nodes for the columns
433  to retrieve from the table */
434  ibool has_clust_rec_x_lock;
435  /* TRUE if the select which retrieves the
436  records to update already sets an x-lock on
437  the clustered record; note that it must always
438  set at least an s-lock */
439  ulint cmpl_info;/* information extracted during query
440  compilation; speeds up execution:
441  UPD_NODE_NO_ORD_CHANGE and
442  UPD_NODE_NO_SIZE_CHANGE, ORed */
443  /*----------------------*/
444  /* Local storage for this graph node */
445  ulint state;
453  dtuple_t* upd_row;/* NULL, or a copy of the updated row */
454  row_ext_t* upd_ext;/* NULL, or prefixes of the externally
455  stored columns in upd_row */
459  /*----------------------*/
460  sym_node_t* table_sym;/* table node in symbol table */
461  que_node_t* col_assign_list;
462  /* column assignment list */
463  ulint magic_n;
464 };
465 
466 #define UPD_NODE_MAGIC_N 1579975
467 
468 /* Node execution states */
469 #define UPD_NODE_SET_IX_LOCK 1 /* execution came to the node from
470  a node above and if the field
471  has_clust_rec_x_lock is FALSE, we
472  should set an intention x-lock on
473  the table */
474 #define UPD_NODE_UPDATE_CLUSTERED 2 /* clustered index record should be
475  updated */
476 #define UPD_NODE_INSERT_CLUSTERED 3 /* clustered index record should be
477  inserted, old record is already delete
478  marked */
479 #define UPD_NODE_INSERT_BLOB 4 /* clustered index record should be
480  inserted, old record is already
481  delete-marked; non-updated BLOBs
482  should be inherited by the new record
483  and disowned by the old record */
484 #define UPD_NODE_UPDATE_ALL_SEC 5 /* an ordering field of the clustered
485  index record was changed, or this is
486  a delete operation: should update
487  all the secondary index records */
488 #define UPD_NODE_UPDATE_SOME_SEC 6 /* secondary index entries should be
489  looked at and updated if an ordering
490  field changed */
491 
492 /* Compilation info flags: these must fit within 3 bits; see trx0rec.h */
493 #define UPD_NODE_NO_ORD_CHANGE 1 /* no secondary index record will be
494  changed in the update and no ordering
495  field of the clustered index */
496 #define UPD_NODE_NO_SIZE_CHANGE 2 /* no record field size will be
497  changed in the update */
498 
499 #endif /* !UNIV_HOTBACKUP */
500 
501 #ifndef UNIV_NONINL
502 #include "row0upd.ic"
503 #endif
504 
505 #endif
UNIV_INTERN void row_upd_replace(dtuple_t *row, row_ext_t **ext, const dict_index_t *index, const upd_t *update, mem_heap_t *heap)
Definition: row0upd.cc:1152
ulint n_fields
Definition: row0upd.h:392
ib_id_t roll_ptr_t
Definition: trx0types.h:87
dict_index_t * index
Definition: row0upd.h:446
row_ext_t * ext
Definition: row0upd.h:451
UNIV_INTERN void row_upd_rec_sys_fields_in_recovery(rec_t *rec, page_zip_des_t *page_zip, const ulint *offsets, ulint pos, trx_id_t trx_id, roll_ptr_t roll_ptr)
Definition: row0upd.cc:349
dtuple_t * row
Definition: row0upd.h:448
btr_pcur_t * pcur
Definition: row0upd.h:420
dict_table_t * table
Definition: row0upd.h:425
que_common_t common
Definition: row0upd.h:401
UNIV_INTERN void row_upd_index_write_log(const upd_t *update, byte *log_ptr, mtr_t *mtr)
Definition: row0upd.cc:631
unsigned orig_len
Definition: row0upd.h:377
mem_heap_t * heap
Definition: row0upd.h:456
UNIV_INTERN byte * row_upd_parse_sys_vals(byte *ptr, byte *end_ptr, ulint *pos, trx_id_t *trx_id, roll_ptr_t *roll_ptr)
Definition: row0upd.cc:598
UNIV_INTERN byte * row_upd_index_parse(byte *ptr, byte *end_ptr, mem_heap_t *heap, upd_t **update_out)
Definition: row0upd.cc:704
UNIV_INTERN void row_upd_rec_in_place(rec_t *rec, dict_index_t *index, const ulint *offsets, const upd_t *update, page_zip_des_t *page_zip)
Definition: row0upd.cc:486
upd_field_t * fields
Definition: row0upd.h:393
UNIV_INTERN ibool row_upd_changes_field_size_or_external(dict_index_t *index, const ulint *offsets, const upd_t *update)
Definition: row0upd.cc:418
UNIV_INTERN void row_upd_index_replace_new_col_vals(dtuple_t *entry, dict_index_t *index, const upd_t *update, mem_heap_t *heap) __attribute__((nonnull))
Definition: row0upd.cc:1108
UNIV_INTERN void row_upd_index_entry_sys_field(dtuple_t *entry, dict_index_t *index, ulint type, ib_uint64_t val)
Definition: row0upd.cc:382
UNIV_INTERN upd_node_t * upd_node_create(mem_heap_t *heap)
Definition: row0upd.cc:310
dfield_t new_val
Definition: row0upd.h:385
que_node_t * exp
Definition: row0upd.h:380
UNIV_INTERN upd_t * row_upd_build_difference_binary(dict_index_t *index, const dtuple_t *entry, const rec_t *rec, trx_t *trx, mem_heap_t *heap)
Definition: row0upd.cc:856
ulint info_bits
Definition: row0upd.h:390
UNIV_INTERN ibool row_upd_changes_ord_field_binary_func(dict_index_t *index, const upd_t *update, const dtuple_t *row, const row_ext_t *ext) __attribute__((nonnull(1
ib_id_t trx_id_t
Definition: trx0types.h:85
UNIV_INLINE void upd_field_set_field_no(upd_field_t *upd_field, ulint field_no, dict_index_t *index, trx_t *trx)
UNIV_INLINE const upd_field_t * upd_get_field_by_field_no(const upd_t *update, ulint no) __attribute__((nonnull
UNIV_INTERN que_thr_t * row_upd_step(que_thr_t *thr)
Definition: row0upd.cc:2354
upd_t * update
Definition: row0upd.h:426
UNIV_INTERN ibool row_upd_changes_some_index_ord_field_binary(const dict_table_t *table, const upd_t *update)
Definition: row0upd.cc:1362
UNIV_INTERN upd_t * row_upd_build_sec_rec_difference_binary(dict_index_t *index, const dtuple_t *entry, const rec_t *rec, trx_t *trx, mem_heap_t *heap)
Definition: row0upd.cc:786
UNIV_INLINE void row_upd_rec_sys_fields(rec_t *rec, page_zip_des_t *page_zip, dict_index_t *index, const ulint *offsets, trx_t *trx, roll_ptr_t roll_ptr)
UNIV_INTERN void row_upd_index_replace_new_col_vals_index_pos(dtuple_t *entry, dict_index_t *index, const upd_t *update, ibool order_only, mem_heap_t *heap) __attribute__((nonnull))
Definition: row0upd.cc:1054
sel_node_t * select
Definition: row0upd.h:417
unsigned field_no
Definition: row0upd.h:371
UNIV_INLINE ulint upd_get_n_fields(const upd_t *update)
UNIV_INLINE upd_t * upd_create(ulint n, mem_heap_t *heap)
UNIV_INTERN byte * row_upd_write_sys_vals_to_log(dict_index_t *index, trx_t *trx, roll_ptr_t roll_ptr, byte *log_ptr, mtr_t *mtr)
Definition: row0upd.cc:568