Drizzled Public API Documentation

row0upd.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef row0upd_h
00028 #define row0upd_h
00029 
00030 #include "univ.i"
00031 #include "data0data.h"
00032 #include "row0types.h"
00033 #include "btr0types.h"
00034 #include "dict0types.h"
00035 #include "trx0types.h"
00036 
00037 #ifndef UNIV_HOTBACKUP
00038 # include "btr0pcur.h"
00039 # include "que0types.h"
00040 # include "pars0types.h"
00041 #endif /* !UNIV_HOTBACKUP */
00042 
00043 /*********************************************************************/
00046 UNIV_INLINE
00047 upd_t*
00048 upd_create(
00049 /*=======*/
00050   ulint   n,  
00051   mem_heap_t* heap);  
00052 /*********************************************************************/
00056 UNIV_INLINE
00057 ulint
00058 upd_get_n_fields(
00059 /*=============*/
00060   const upd_t*  update);  
00061 #ifdef UNIV_DEBUG
00062 /*********************************************************************/
00065 UNIV_INLINE
00066 upd_field_t*
00067 upd_get_nth_field(
00068 /*==============*/
00069   const upd_t*  update, 
00070   ulint   n); 
00071 #else
00072 # define upd_get_nth_field(update, n) ((update)->fields + (n))
00073 #endif
00074 #ifndef UNIV_HOTBACKUP
00075 /*********************************************************************/
00077 UNIV_INLINE
00078 void
00079 upd_field_set_field_no(
00080 /*===================*/
00081   upd_field_t*  upd_field,  
00082   ulint   field_no, 
00084   dict_index_t* index,    
00085   trx_t*    trx);   
00086 /*********************************************************************/
00089 UNIV_INLINE
00090 const upd_field_t*
00091 upd_get_field_by_field_no(
00092 /*======================*/
00093   const upd_t*  update, 
00094   ulint   no) 
00095   __attribute__((nonnull, pure));
00096 /*********************************************************************/
00100 UNIV_INTERN
00101 byte*
00102 row_upd_write_sys_vals_to_log(
00103 /*==========================*/
00104   dict_index_t* index,  
00105   trx_t*    trx,  
00106   roll_ptr_t  roll_ptr,
00107   byte*   log_ptr,
00109   mtr_t*    mtr); 
00110 /*********************************************************************/
00113 UNIV_INLINE
00114 void
00115 row_upd_rec_sys_fields(
00116 /*===================*/
00117   rec_t*    rec,  
00118   page_zip_des_t* page_zip,
00120   dict_index_t* index,  
00121   const ulint*  offsets,
00122   trx_t*    trx,  
00123   roll_ptr_t  roll_ptr);
00124 /*********************************************************************/
00126 UNIV_INTERN
00127 void
00128 row_upd_index_entry_sys_field(
00129 /*==========================*/
00130   dtuple_t* entry,  
00134   dict_index_t* index,  
00135   ulint   type, 
00136   ib_uint64_t val); 
00137 /*********************************************************************/
00140 UNIV_INTERN
00141 upd_node_t*
00142 upd_node_create(
00143 /*============*/
00144   mem_heap_t* heap);  
00145 /***********************************************************/
00147 UNIV_INTERN
00148 void
00149 row_upd_index_write_log(
00150 /*====================*/
00151   const upd_t*  update, 
00152   byte*   log_ptr,
00156   mtr_t*    mtr); 
00157 /***********************************************************/
00162 UNIV_INTERN
00163 ibool
00164 row_upd_changes_field_size_or_external(
00165 /*===================================*/
00166   dict_index_t* index,  
00167   const ulint*  offsets,
00168   const upd_t*  update);
00169 #endif /* !UNIV_HOTBACKUP */
00170 /***********************************************************/
00176 UNIV_INTERN
00177 void
00178 row_upd_rec_in_place(
00179 /*=================*/
00180   rec_t*    rec,  
00181   dict_index_t* index,  
00182   const ulint*  offsets,
00183   const upd_t*  update, 
00184   page_zip_des_t* page_zip);
00186 #ifndef UNIV_HOTBACKUP
00187 /***************************************************************/
00192 UNIV_INTERN
00193 upd_t*
00194 row_upd_build_sec_rec_difference_binary(
00195 /*====================================*/
00196   dict_index_t* index,  
00197   const dtuple_t* entry,  
00198   const rec_t*  rec,  
00199   trx_t*    trx,  
00200   mem_heap_t* heap);  
00201 /***************************************************************/
00207 UNIV_INTERN
00208 upd_t*
00209 row_upd_build_difference_binary(
00210 /*============================*/
00211   dict_index_t* index,  
00212   const dtuple_t* entry,  
00213   const rec_t*  rec,  
00214   trx_t*    trx,  
00215   mem_heap_t* heap);  
00216 /***********************************************************/
00219 UNIV_INTERN
00220 void
00221 row_upd_index_replace_new_col_vals_index_pos(
00222 /*=========================================*/
00223   dtuple_t* entry,  
00227   dict_index_t* index,  
00229   const upd_t*  update, 
00232   ibool   order_only,
00236   mem_heap_t* heap) 
00238   __attribute__((nonnull));
00239 /***********************************************************/
00242 UNIV_INTERN
00243 void
00244 row_upd_index_replace_new_col_vals(
00245 /*===============================*/
00246   dtuple_t* entry,  
00250   dict_index_t* index,  
00252   const upd_t*  update, 
00255   mem_heap_t* heap) 
00257   __attribute__((nonnull));
00258 /***********************************************************/
00260 UNIV_INTERN
00261 void
00262 row_upd_replace(
00263 /*============*/
00264   dtuple_t*   row,  
00269   row_ext_t**   ext,  
00271   const dict_index_t* index,  
00272   const upd_t*    update, 
00274   mem_heap_t*   heap);  
00275 /***********************************************************/
00282 UNIV_INTERN
00283 ibool
00284 row_upd_changes_ord_field_binary(
00285 /*=============================*/
00286   const dtuple_t* row,  
00290   dict_index_t* index,  
00291   const upd_t*  update);
00294 /***********************************************************/
00301 UNIV_INTERN
00302 ibool
00303 row_upd_changes_some_index_ord_field_binary(
00304 /*========================================*/
00305   const dict_table_t* table,  
00306   const upd_t*    update);
00307 /***********************************************************/
00311 UNIV_INTERN
00312 que_thr_t*
00313 row_upd_step(
00314 /*=========*/
00315   que_thr_t*  thr); 
00316 #endif /* !UNIV_HOTBACKUP */
00317 /*********************************************************************/
00320 UNIV_INTERN
00321 byte*
00322 row_upd_parse_sys_vals(
00323 /*===================*/
00324   byte*   ptr,  
00325   byte*   end_ptr,
00326   ulint*    pos,  
00327   trx_id_t* trx_id, 
00328   roll_ptr_t* roll_ptr);
00329 /*********************************************************************/
00332 UNIV_INTERN
00333 void
00334 row_upd_rec_sys_fields_in_recovery(
00335 /*===============================*/
00336   rec_t*    rec,  
00337   page_zip_des_t* page_zip,
00338   const ulint*  offsets,
00339   ulint   pos,  
00340   trx_id_t  trx_id, 
00341   roll_ptr_t  roll_ptr);
00342 /*********************************************************************/
00345 UNIV_INTERN
00346 byte*
00347 row_upd_index_parse(
00348 /*================*/
00349   byte*   ptr,  
00350   byte*   end_ptr,
00351   mem_heap_t* heap, 
00353   upd_t**   update_out);
00356 /* Update vector field */
00357 struct upd_field_struct{
00358   unsigned  field_no:16;  
00363 #ifndef UNIV_HOTBACKUP
00364   unsigned  orig_len:16;  
00367   que_node_t* exp;    
00371 #endif /* !UNIV_HOTBACKUP */
00372   dfield_t  new_val;  
00373 };
00374 
00375 /* Update vector structure */
00376 struct upd_struct{
00377   ulint   info_bits;  
00379   ulint   n_fields; 
00380   upd_field_t*  fields;   
00381 };
00382 
00383 #ifndef UNIV_HOTBACKUP
00384 /* Update node structure which also implements the delete operation
00385 of a row */
00386 
00387 struct upd_node_struct{
00388   que_common_t  common; 
00389   ibool   is_delete;/* TRUE if delete, FALSE if update */
00390   ibool   searched_update;
00391         /* TRUE if searched update, FALSE if
00392         positioned */
00393   ibool   in_mysql_interface;
00394         /* TRUE if the update node was created
00395         for the MySQL interface */
00396   dict_foreign_t* foreign;/* NULL or pointer to a foreign key
00397         constraint if this update node is used in
00398         doing an ON DELETE or ON UPDATE operation */
00399   upd_node_t* cascade_node;/* NULL or an update node template which
00400         is used to implement ON DELETE/UPDATE CASCADE
00401         or ... SET NULL for foreign keys */
00402   mem_heap_t* cascade_heap;/* NULL or a mem heap where the cascade
00403         node is created */
00404   sel_node_t* select; 
00407   btr_pcur_t* pcur; 
00412   dict_table_t* table;  
00413   upd_t*    update; 
00414   ulint   update_n_fields;
00415         /* when this struct is used to implement
00416         a cascade operation for foreign keys, we store
00417         here the size of the buffer allocated for use
00418         as the update vector */
00419   sym_node_list_t columns;/* symbol table nodes for the columns
00420         to retrieve from the table */
00421   ibool   has_clust_rec_x_lock;
00422         /* TRUE if the select which retrieves the
00423         records to update already sets an x-lock on
00424         the clustered record; note that it must always
00425         set at least an s-lock */
00426   ulint   cmpl_info;/* information extracted during query
00427         compilation; speeds up execution:
00428         UPD_NODE_NO_ORD_CHANGE and
00429         UPD_NODE_NO_SIZE_CHANGE, ORed */
00430   /*----------------------*/
00431   /* Local storage for this graph node */
00432   ulint   state;  
00433   dict_index_t* index;  
00435   dtuple_t* row;  
00438   row_ext_t*  ext;  
00440   dtuple_t* upd_row;/* NULL, or a copy of the updated row */
00441   row_ext_t*  upd_ext;/* NULL, or prefixes of the externally
00442         stored columns in upd_row */
00443   mem_heap_t* heap; 
00446   /*----------------------*/
00447   sym_node_t* table_sym;/* table node in symbol table */
00448   que_node_t* col_assign_list;
00449         /* column assignment list */
00450   ulint   magic_n;
00451 };
00452 
00453 #define UPD_NODE_MAGIC_N  1579975
00454 
00455 /* Node execution states */
00456 #define UPD_NODE_SET_IX_LOCK     1  /* execution came to the node from
00457           a node above and if the field
00458           has_clust_rec_x_lock is FALSE, we
00459           should set an intention x-lock on
00460           the table */
00461 #define UPD_NODE_UPDATE_CLUSTERED  2  /* clustered index record should be
00462           updated */
00463 #define UPD_NODE_INSERT_CLUSTERED  3  /* clustered index record should be
00464           inserted, old record is already delete
00465           marked */
00466 #define UPD_NODE_UPDATE_ALL_SEC    4  /* an ordering field of the clustered
00467           index record was changed, or this is
00468           a delete operation: should update
00469           all the secondary index records */
00470 #define UPD_NODE_UPDATE_SOME_SEC   5  /* secondary index entries should be
00471           looked at and updated if an ordering
00472           field changed */
00473 
00474 /* Compilation info flags: these must fit within 3 bits; see trx0rec.h */
00475 #define UPD_NODE_NO_ORD_CHANGE  1 /* no secondary index record will be
00476           changed in the update and no ordering
00477           field of the clustered index */
00478 #define UPD_NODE_NO_SIZE_CHANGE 2 /* no record field size will be
00479           changed in the update */
00480 
00481 #endif /* !UNIV_HOTBACKUP */
00482 
00483 #ifndef UNIV_NONINL
00484 #include "row0upd.ic"
00485 #endif
00486 
00487 #endif