#include "mysql_priv.h"#include <my_bitmap.h>#include "log_event.h"#include <m_ctype.h>#include <sys/stat.h>#include <thr_alarm.h>#include <mysys_err.h>#include "sp_rcontext.h"#include "sp_cache.h"Include dependency graph for sql_class.cc:

Go to the source code of this file.
Classes | |
| struct | Item_change_record |
Functions | |
| byte * | get_var_key (user_var_entry *entry, uint *length, my_bool not_used __attribute__((unused))) |
| void | free_user_var (user_var_entry *entry) |
| bool | foreign_key_prefix (Key *a, Key *b) |
| my_bool | thd_in_lock_tables (const THD *thd) |
| my_bool | thd_tablespace_op (const THD *thd) |
| const char * | thd_proc_info (THD *thd, const char *info) |
| void ** | thd_ha_data (const THD *thd, const struct handlerton *hton) |
| void | add_to_status (STATUS_VAR *to_var, STATUS_VAR *from_var) |
| void | add_diff_to_status (STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var) |
| static void | list_include (CHANGED_TABLE_LIST **prev, CHANGED_TABLE_LIST *curr, CHANGED_TABLE_LIST *new_table) |
| static File | create_file (THD *thd, char *path, sql_exchange *exchange, IO_CACHE *cache) |
| static C_MODE_START byte * | get_statement_id_as_hash_key (const byte *record, uint *key_length, my_bool not_used __attribute__((unused))) |
| static void | delete_statement_as_hash_key (void *key) |
| static byte * | get_stmt_name_hash_key (Statement *entry, uint *length, my_bool not_used __attribute__((unused))) |
| void | thd_increment_bytes_sent (ulong length) |
| void | thd_increment_bytes_received (ulong length) |
| void | thd_increment_net_big_packet_count (ulong length) |
| static byte * | xid_get_hash_key (const byte *ptr, uint *length, my_bool not_used __attribute__((unused))) |
| static void | xid_free_hash (void *ptr) |
| bool | xid_cache_init () |
| void | xid_cache_free () |
| XID_STATE * | xid_cache_search (XID *xid) |
| bool | xid_cache_insert (XID *xid, enum xa_states xa_state) |
| bool | xid_cache_insert (XID_STATE *xid_state) |
| void | xid_cache_delete (XID_STATE *xid_state) |
Variables | |
| char | internal_table_name [2] = "*" |
| char | empty_c_string [1] = {0} |
| static String | default_line_term ("\n", default_charset_info) |
| static String | default_escaped ("\\", default_charset_info) |
| static String | default_field_term ("\t", default_charset_info) |
| pthread_mutex_t | LOCK_xid_cache |
| HASH | xid_cache |
| void add_diff_to_status | ( | STATUS_VAR * | to_var, | |
| STATUS_VAR * | from_var, | |||
| STATUS_VAR * | dec_var | |||
| ) |
Definition at line 538 of file sql_class.cc.
References from, last_system_status_var, offsetof, and to.
Referenced by mysql_execute_command().
00540 { 00541 ulong *end= (ulong*) ((byte*) to_var + offsetof(STATUS_VAR, 00542 last_system_status_var) + 00543 sizeof(ulong)); 00544 ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var; 00545 00546 while (to != end) 00547 *(to++)+= *(from++) - *(dec++); 00548 }
Here is the caller graph for this function:

| void add_to_status | ( | STATUS_VAR * | to_var, | |
| STATUS_VAR * | from_var | |||
| ) |
Definition at line 513 of file sql_class.cc.
References from, last_system_status_var, offsetof, and to.
Referenced by calc_sum_of_all_status(), and refresh_status().
00514 { 00515 ulong *end= (ulong*) ((byte*) to_var + offsetof(STATUS_VAR, 00516 last_system_status_var) + 00517 sizeof(ulong)); 00518 ulong *to= (ulong*) to_var, *from= (ulong*) from_var; 00519 00520 while (to != end) 00521 *(to++)+= *(from++); 00522 /* it doesn't make sense to add last_query_cost values */ 00523 }
Here is the caller graph for this function:

| static File create_file | ( | THD * | thd, | |
| char * | path, | |||
| sql_exchange * | exchange, | |||
| IO_CACHE * | cache | |||
| ) | [static] |
Definition at line 1160 of file sql_class.cc.
References access, dirname_length(), ER_FILE_EXISTS_ERROR, F_OK, fn_format(), FN_REFLEN, init_io_cache(), my_close(), my_create(), my_delete(), my_error(), MY_REPLACE_DIR, MY_UNPACK_FILENAME, MY_WME, MYF, mysql_real_data_home, NullS, strxnmov(), and WRITE_CACHE.
Referenced by ha_tina::create(), and ha_archive::create().
01162 { 01163 File file; 01164 uint option= MY_UNPACK_FILENAME; 01165 01166 #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS 01167 option|= MY_REPLACE_DIR; // Force use of db directory 01168 #endif 01169 01170 if (!dirname_length(exchange->file_name)) 01171 { 01172 strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->db ? thd->db : "", 01173 NullS); 01174 (void) fn_format(path, exchange->file_name, path, "", option); 01175 } 01176 else 01177 (void) fn_format(path, exchange->file_name, mysql_real_data_home, "", option); 01178 01179 if (!access(path, F_OK)) 01180 { 01181 my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name); 01182 return -1; 01183 } 01184 /* Create the file world readable */ 01185 if ((file= my_create(path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0) 01186 return file; 01187 #ifdef HAVE_FCHMOD 01188 (void) fchmod(file, 0666); // Because of umask() 01189 #else 01190 (void) chmod(path, 0666); 01191 #endif 01192 if (init_io_cache(cache, file, 0L, WRITE_CACHE, 0L, 1, MYF(MY_WME))) 01193 { 01194 my_close(file, MYF(0)); 01195 my_delete(path, MYF(0)); // Delete file on error, it was just created 01196 return -1; 01197 } 01198 return file; 01199 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void delete_statement_as_hash_key | ( | void * | key | ) | [static] |
Definition at line 109 of file sql_class.cc.
References Key::columns, base_list::elements, FALSE, Key::generated, List_iterator< T >::rewind(), swap_variables, and TRUE.
00110 { 00111 /* Ensure that 'a' is the generated key */ 00112 if (a->generated) 00113 { 00114 if (b->generated && a->columns.elements > b->columns.elements) 00115 swap_variables(Key*, a, b); // Put shorter key in 'a' 00116 } 00117 else 00118 { 00119 if (!b->generated) 00120 return TRUE; // No foreign key 00121 swap_variables(Key*, a, b); // Put generated key in 'a' 00122 } 00123 00124 /* Test if 'a' is a prefix of 'b' */ 00125 if (a->columns.elements > b->columns.elements) 00126 return TRUE; // Can't be prefix 00127 00128 List_iterator<key_part_spec> col_it1(a->columns); 00129 List_iterator<key_part_spec> col_it2(b->columns); 00130 const key_part_spec *col1, *col2; 00131 00132 #ifdef ENABLE_WHEN_INNODB_CAN_HANDLE_SWAPED_FOREIGN_KEY_COLUMNS 00133 while ((col1= col_it1++)) 00134 { 00135 bool found= 0; 00136 col_it2.rewind(); 00137 while ((col2= col_it2++)) 00138 { 00139 if (*col1 == *col2) 00140 { 00141 found= TRUE; 00142 break; 00143 } 00144 } 00145 if (!found) 00146 return TRUE; // Error 00147 } 00148 return FALSE; // Is prefix 00149 #else 00150 while ((col1= col_it1++)) 00151 { 00152 col2= col_it2++; 00153 if (!(*col1 == *col2)) 00154 return TRUE; 00155 } 00156 return FALSE; // Is prefix 00157 #endif 00158 }
Here is the call graph for this function:

| void free_user_var | ( | user_var_entry * | entry | ) |
Definition at line 80 of file sql_class.cc.
References ALIGN_SIZE, my_free, MYF, and pos().
00081 { 00082 char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry)); 00083 if (entry->value && entry->value != pos) 00084 my_free(entry->value, MYF(0)); 00085 my_free((char*) entry,MYF(0)); 00086 }
Here is the call graph for this function:

| static C_MODE_START byte* get_statement_id_as_hash_key | ( | const byte * | record, | |
| uint * | key_length, | |||
| my_bool not_used | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 1791 of file sql_class.cc.
01793 { 01794 const Statement *statement= (const Statement *) record; 01795 *key_length= sizeof(statement->id); 01796 return (byte *) &((const Statement *) statement)->id; 01797 }
| static void list_include | ( | CHANGED_TABLE_LIST ** | prev, | |
| CHANGED_TABLE_LIST * | curr, | |||
| CHANGED_TABLE_LIST * | new_table | |||
| ) | [inline, static] |
Definition at line 743 of file sql_class.cc.
References st_changed_table_list::next.
00746 { 00747 if (new_table) 00748 { 00749 *prev = new_table; 00750 (*prev)->next = curr; 00751 } 00752 }
| void** thd_ha_data | ( | const THD * | thd, | |
| const struct handlerton * | hton | |||
| ) |
Definition at line 190 of file sql_class.cc.
References handlerton::slot.
00191 { 00192 return (void **) thd->ha_data + hton->slot; 00193 }
| my_bool thd_in_lock_tables | ( | const THD * | thd | ) |
| void thd_increment_bytes_received | ( | ulong | length | ) |
Definition at line 2030 of file sql_class.cc.
References current_thd.
02031 { 02032 current_thd->status_var.bytes_received+= length; 02033 }
| void thd_increment_bytes_sent | ( | ulong | length | ) |
Definition at line 2020 of file sql_class.cc.
References current_thd, and likely.
02021 { 02022 THD *thd=current_thd; 02023 if (likely(thd != 0)) 02024 { /* current_thd==0 when close_connection() calls net_send_error() */ 02025 thd->status_var.bytes_sent+= length; 02026 } 02027 }
| void thd_increment_net_big_packet_count | ( | ulong | length | ) |
Definition at line 2036 of file sql_class.cc.
References current_thd.
02037 { 02038 current_thd->status_var.net_big_packet_count+= length; 02039 }
| const char* thd_proc_info | ( | THD * | thd, | |
| const char * | info | |||
| ) |
Definition at line 183 of file sql_class.cc.
00184 { 00185 const char *old_info= thd->proc_info; 00186 thd->proc_info= info; 00187 return old_info; 00188 }
| my_bool thd_tablespace_op | ( | const THD * | thd | ) |
| void xid_cache_delete | ( | XID_STATE * | xid_state | ) |
Definition at line 2303 of file sql_class.cc.
References hash_delete(), pthread_mutex_lock, pthread_mutex_unlock, and xid_cache.
Referenced by mysql_execute_command().
02304 { 02305 pthread_mutex_lock(&LOCK_xid_cache); 02306 hash_delete(&xid_cache, (byte *)xid_state); 02307 pthread_mutex_unlock(&LOCK_xid_cache); 02308 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void xid_cache_free | ( | ) |
Definition at line 2253 of file sql_class.cc.
References hash_free(), hash_inited, pthread_mutex_destroy, and xid_cache.
Referenced by clean_up().
02254 { 02255 if (hash_inited(&xid_cache)) 02256 { 02257 hash_free(&xid_cache); 02258 pthread_mutex_destroy(&LOCK_xid_cache); 02259 } 02260 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool xid_cache_init | ( | ) |
Definition at line 2246 of file sql_class.cc.
References hash_init, my_charset_bin, MY_MUTEX_INIT_FAST, pthread_mutex_init, xid_cache, xid_free_hash(), and xid_get_hash_key().
Referenced by init_server_components().
02247 { 02248 pthread_mutex_init(&LOCK_xid_cache, MY_MUTEX_INIT_FAST); 02249 return hash_init(&xid_cache, &my_charset_bin, 100, 0, 0, 02250 xid_get_hash_key, xid_free_hash, 0) != 0; 02251 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool xid_cache_insert | ( | XID_STATE * | xid_state | ) |
Definition at line 2292 of file sql_class.cc.
References DBUG_ASSERT, hash_search(), st_hash::key_length, my_hash_insert(), pthread_mutex_lock, pthread_mutex_unlock, and xid_cache.
02293 { 02294 pthread_mutex_lock(&LOCK_xid_cache); 02295 DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(), 02296 xid_state->xid.key_length())==0); 02297 my_bool res=my_hash_insert(&xid_cache, (byte*)xid_state); 02298 pthread_mutex_unlock(&LOCK_xid_cache); 02299 return res; 02300 }
Here is the call graph for this function:

Definition at line 2271 of file sql_class.cc.
References hash_search(), xid_t::key(), xid_t::key_length(), my_hash_insert(), my_malloc(), MY_WME, MYF, pthread_mutex_lock, pthread_mutex_unlock, and xid_cache.
Referenced by mysql_execute_command(), and xarecover_handlerton().
02272 { 02273 XID_STATE *xs; 02274 my_bool res; 02275 pthread_mutex_lock(&LOCK_xid_cache); 02276 if (hash_search(&xid_cache, xid->key(), xid->key_length())) 02277 res=0; 02278 else if (!(xs=(XID_STATE *)my_malloc(sizeof(*xs), MYF(MY_WME)))) 02279 res=1; 02280 else 02281 { 02282 xs->xa_state=xa_state; 02283 xs->xid.set(xid); 02284 xs->in_thd=0; 02285 res=my_hash_insert(&xid_cache, (byte*)xs); 02286 } 02287 pthread_mutex_unlock(&LOCK_xid_cache); 02288 return res; 02289 }
Here is the call graph for this function:

Here is the caller graph for this function:

| XID_STATE* xid_cache_search | ( | XID * | xid | ) |
Definition at line 2262 of file sql_class.cc.
References hash_search(), xid_t::key(), xid_t::key_length(), pthread_mutex_lock, pthread_mutex_unlock, and xid_cache.
Referenced by mysql_execute_command().
02263 { 02264 pthread_mutex_lock(&LOCK_xid_cache); 02265 XID_STATE *res=(XID_STATE *)hash_search(&xid_cache, xid->key(), xid->key_length()); 02266 pthread_mutex_unlock(&LOCK_xid_cache); 02267 return res; 02268 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void xid_free_hash | ( | void * | ptr | ) | [static] |
Definition at line 2240 of file sql_class.cc.
Referenced by xid_cache_init().
Here is the caller graph for this function:

| static byte* xid_get_hash_key | ( | const byte * | ptr, | |
| uint * | length, | |||
| my_bool not_used | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 2233 of file sql_class.cc.
Referenced by xid_cache_init().
02235 { 02236 *length=((XID_STATE*)ptr)->xid.key_length(); 02237 return ((XID_STATE*)ptr)->xid.key(); 02238 }
Here is the caller graph for this function:

String default_escaped("\\", default_charset_info) [static] |
String default_field_term("\t", default_charset_info) [static] |
String default_line_term("\n", default_charset_info) [static] |
| char empty_c_string[1] = {0} |
| char internal_table_name[2] = "*" |
Definition at line 47 of file sql_class.cc.
| pthread_mutex_t LOCK_xid_cache |
Definition at line 2231 of file sql_class.cc.
Referenced by mysql_xa_recover(), xid_cache_delete(), xid_cache_free(), xid_cache_init(), xid_cache_insert(), and xid_cache_search().
1.4.7

