Drizzled Public API Documentation

trx0i_s.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 2007, 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 /**************************************************/
00028 #pragma once
00029 #ifndef trx0i_s_h
00030 #define trx0i_s_h
00031 
00032 #include "univ.i"
00033 #include "trx0types.h"
00034 #include "dict0types.h"
00035 #include "ut0ut.h"
00036 
00039 #define TRX_I_S_MEM_LIMIT   16777216 /* 16 MiB */
00040 
00043 #define TRX_I_S_LOCK_DATA_MAX_LEN 8192
00044 
00047 #define TRX_I_S_TRX_QUERY_MAX_LEN 1024
00048 
00051 #define TRX_I_S_TRX_OP_STATE_MAX_LEN  64
00052 
00055 #define TRX_I_S_TRX_FK_ERROR_MAX_LEN  256
00056 
00059 #define TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN 16
00060 
00063 #define TRX_I_S_STRING_COPY(data, field, constraint, tcache)  \
00064 do {                \
00065   if (strlen(data) > constraint) {      \
00066     char  buff[constraint + 1];     \
00067     strncpy(buff, data, constraint);    \
00068     buff[constraint] = '\0';      \
00069                 \
00070     field = static_cast<const char *>(ha_storage_put_memlim(      \
00071       (tcache)->storage, buff, constraint + 1,\
00072       MAX_ALLOWED_FOR_STORAGE(tcache)));  \
00073   } else {            \
00074     field = static_cast<const char *>(ha_storage_put_str_memlim(    \
00075       (tcache)->storage, data,    \
00076       MAX_ALLOWED_FOR_STORAGE(tcache)));  \
00077   }             \
00078 } while (0)
00079 
00081 typedef struct i_s_locks_row_struct i_s_locks_row_t;
00083 typedef struct i_s_trx_row_struct i_s_trx_row_t;
00085 typedef struct i_s_lock_waits_row_struct i_s_lock_waits_row_t;
00086 
00088 typedef struct i_s_hash_chain_struct  i_s_hash_chain_t;
00089 
00092 struct i_s_hash_chain_struct {
00093   i_s_locks_row_t*  value;  
00095   i_s_hash_chain_t* next; 
00096 };
00097 
00099 struct i_s_locks_row_struct {
00100   trx_id_t  lock_trx_id;  
00101   const char* lock_mode;  
00103   const char* lock_type;  
00105   const char* lock_table; 
00107   const char* lock_index; 
00111   /* @{ */
00112   ulint   lock_space; 
00113   ulint   lock_page;  
00114   ulint   lock_rec; 
00116   const char* lock_data;  
00117   /* @} */
00118 
00120   /* @{ */
00121   table_id_t  lock_table_id;
00124   i_s_hash_chain_t hash_chain;  
00126   /* @} */
00127 };
00128 
00130 struct i_s_trx_row_struct {
00131   trx_id_t    trx_id;   
00132   const char*   trx_state;  
00134   ib_time_t   trx_started;  
00135   const i_s_locks_row_t*  requested_lock_row;
00139   ib_time_t trx_wait_started; 
00140   ullint    trx_weight; 
00141   ulint   trx_mysql_thread_id; 
00142   const char* trx_query;  
00144   const char* trx_operation_state; 
00145   ulint   trx_tables_in_use;
00147   ulint   trx_tables_locked;
00150   ulint   trx_lock_structs;
00152   ulint   trx_lock_memory_bytes;
00155   ulint   trx_rows_locked;
00156   ullint    trx_rows_modified;
00157   ulint   trx_concurrency_tickets;
00160   const char* trx_isolation_level;
00162   ibool   trx_unique_checks;
00165   ibool   trx_foreign_key_checks;
00167   const char* trx_foreign_key_error;
00169   ibool   trx_has_search_latch;
00171   ulint   trx_search_latch_timeout;
00174 };
00175 
00177 struct i_s_lock_waits_row_struct {
00178   const i_s_locks_row_t*  requested_lock_row; 
00179   const i_s_locks_row_t*  blocking_lock_row;  
00180 };
00181 
00183 typedef struct trx_i_s_cache_struct trx_i_s_cache_t;
00184 
00187 enum i_s_table {
00188   I_S_INNODB_TRX,   
00189   I_S_INNODB_LOCKS, 
00190   I_S_INNODB_LOCK_WAITS 
00191 };
00192 
00196 extern trx_i_s_cache_t* trx_i_s_cache;
00197 
00198 /*******************************************************************/
00200 UNIV_INTERN
00201 void
00202 trx_i_s_cache_init(
00203 /*===============*/
00204   trx_i_s_cache_t*  cache); 
00205 /*******************************************************************/
00207 UNIV_INTERN
00208 void
00209 trx_i_s_cache_free(
00210 /*===============*/
00211   trx_i_s_cache_t*  cache); 
00213 /*******************************************************************/
00215 UNIV_INTERN
00216 void
00217 trx_i_s_cache_start_read(
00218 /*=====================*/
00219   trx_i_s_cache_t*  cache); 
00221 /*******************************************************************/
00223 UNIV_INTERN
00224 void
00225 trx_i_s_cache_end_read(
00226 /*===================*/
00227   trx_i_s_cache_t*  cache); 
00229 /*******************************************************************/
00231 UNIV_INTERN
00232 void
00233 trx_i_s_cache_start_write(
00234 /*======================*/
00235   trx_i_s_cache_t*  cache); 
00237 /*******************************************************************/
00239 UNIV_INTERN
00240 void
00241 trx_i_s_cache_end_write(
00242 /*====================*/
00243   trx_i_s_cache_t*  cache); 
00246 /*******************************************************************/
00250 UNIV_INTERN
00251 ulint
00252 trx_i_s_cache_get_rows_used(
00253 /*========================*/
00254   trx_i_s_cache_t*  cache,  
00255   enum i_s_table    table); 
00257 /*******************************************************************/
00261 UNIV_INTERN
00262 void*
00263 trx_i_s_cache_get_nth_row(
00264 /*======================*/
00265   trx_i_s_cache_t*  cache,  
00266   enum i_s_table    table,  
00267   ulint     n); 
00269 /*******************************************************************/
00272 UNIV_INTERN
00273 int
00274 trx_i_s_possibly_fetch_data_into_cache(
00275 /*===================================*/
00276   trx_i_s_cache_t*  cache); 
00278 /*******************************************************************/
00282 UNIV_INTERN
00283 ibool
00284 trx_i_s_cache_is_truncated(
00285 /*=======================*/
00286   trx_i_s_cache_t*  cache); 
00291 #define TRX_I_S_LOCK_ID_MAX_LEN (TRX_ID_MAX_LEN + 63)
00292 
00293 /*******************************************************************/
00299 UNIV_INTERN
00300 char*
00301 trx_i_s_create_lock_id(
00302 /*===================*/
00303   const i_s_locks_row_t*  row,  
00304   char*     lock_id,
00305   ulint     lock_id_size);
00308 #endif /* trx0i_s_h */