diff options
author | unknown <monty@mysql.com/nosik.monty.fi> | 2007-08-13 16:11:25 +0300 |
---|---|---|
committer | unknown <monty@mysql.com/nosik.monty.fi> | 2007-08-13 16:11:25 +0300 |
commit | 09a53f28a73d8000bab902611f609a44d87f329d (patch) | |
tree | a462885d0de8206ed3a0b18affdd892bafca84c8 /sql | |
parent | f338fd010a0a29e4c52c41b3ef4962f36be6a1d1 (diff) | |
download | mariadb-git-09a53f28a73d8000bab902611f609a44d87f329d.tar.gz |
Fixed a lot of compiler warnings and errors detected by Forte C++ on Solaris
Faster thr_alarm()
Added 'Opened_files' status variable to track calls to my_open()
Don't give warnings when running mysql_install_db
Added option --source-install to mysql_install_db
I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
index_read() -> index_read_map()
index_read_idx() -> index_read_idx_map()
index_read_last() -> index_read_last_map()
BUILD/compile-solaris-sparc-forte:
Updated script to current Solaris installations
Now we compile by default for 64 bits
client/mysql.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
client/mysql_upgrade.c:
Fixed compiler warning (on Forte)
client/mysqladmin.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
client/mysqlcheck.c:
Fixed compiler warning (on Forte)
client/mysqldump.c:
Fixed compiler warning (on Forte)
client/mysqlslap.c:
Fixed compiler warning (on Forte)
client/mysqltest.c:
Fixed compiler warning (on Forte)
client/sql_string.cc:
Avoid compiler warnings when using C function pointers in C++
configure.in:
Added detection of mtmalloc and ieeefp.h
extra/replace.c:
Fixed compiler warning (on Forte)
include/m_ctype.h:
Added some typedef's to make it easy to use C function pointers in C++
include/my_sys.h:
Added my_file_total_opened (counter for calls to my_open())
include/myisam.h:
Fixed compiler warning (on Forte)
libmysql/libmysql.c:
Fixed compiler warning (on Forte) by adding casts and change types
libmysql/manager.c:
Fixed compiler warning (on Forte) by adding casts and change types
mysql-test/r/ctype_cp932_binlog_stm.result:
Updated positions
(Needed because we didn't before correctly restore collation_database after running stored procedure
mysys/my_fopen.c:
Count number of opened files
mysys/my_open.c:
Count number of opened files
mysys/my_static.c:
Count number of opened files
mysys/thr_alarm.c:
Optimization to do less alarm() and pthread_sigmask() calls.
Idea is to remember time for next pending alarm and not reschedule a new alarm if it's after the current one.
Before we only did this if there was other pending alarms.
We don't have to use pthread_sigmask() in case of 'USE_ONE_SIGNAL_HAND' as the alarm()
signal will be blocked for the calling thread anyway and no other thread will have the alarm() signal enabled to call process_alarm()
regex/regcomp.c:
Fixed compiler warning (on Forte) by adding casts and change types
scripts/mysql_install_db.sh:
Added option --source-install to allow one to create a mysql database from the source tree without installing MySQL
Don't give (unnecessary) warnings
server-tools/instance-manager/angel.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
server-tools/instance-manager/thread_registry.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/event_db_repository.cc:
index_read() -> index_read_map()
sql/event_queue.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/field.cc:
Fixed compiler warnings about hidden fields
sql/ha_partition.cc:
Fixed compiler warnings about hidden fields
index_read() -> index_read_map()
sql/ha_partition.h:
index_read() -> index_read_map()
sql/handler.cc:
Added PAGE option to row types (to prepare for future)
index_read() -> index_read_map()
sql/handler.h:
Added ROW_TYPE_PAGE (for future)
Added flag to signal if table was to be created transactionally
I had to do the following renames() as used polymorphism didn't work with Forte compiler on 64 bit systems
index_read() -> index_read_map()
index_read_idx() -> index_read_idx_map()
index_read_last() -> index_read_last_map()
sql/item.cc:
Fixed indentation
Renamed local variable to avoid hiding class variable
sql/item_cmpfunc.cc:
Renamed local variable to avoid hiding class variable
sql/item_cmpfunc.h:
Removed not used variable
sql/item_func.cc:
Renamed local variable to avoid hiding class variable
sql/item_strfunc.cc:
Moved functions from Item_strfunc.cc
sql/item_strfunc.h:
Move functions to item_strfunc.cc
Use C function pointer type to avoid compiler warnings (with Forte)
sql/item_subselect.cc:
index_read() -> index_read_map()
sql/item_xmlfunc.cc:
Renamed local variable to avoid hiding class variable
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/key.cc:
Fixed indentation
sql/log.cc:
Renamed local variable to avoid hiding class variable
sql/log_event.cc:
Removed call to my_time() when creating class instance of Log_event() as this may have static instances.
(One can't call my_time() before my_init())
index_read() -> index_read_map()
Renamed local variable to avoid hiding class variable
sql/log_event_old.cc:
Renamed local variable to avoid hiding class variable
sql/mysql_priv.h:
Made all create_backup_ctx() declarations identical.
This lifted up a bug where wrong create_backup_ctx() was called in some cases.
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/mysqld.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
Fixed indentation
Don't call end_thr_alarm() when calling unireg_abort() as unireg_abort() already calls end_thr_alarm()
Added variable 'Opened_files' (number of calls to my_open() or my_fopen())
Don't print 'loose' warnings when using --bootstrap (to avoid warnings when running mysql_install_db)
Fixed compiler warnings
sql/opt_range.cc:
index_read() -> index_read_map()
sql/opt_sum.cc:
index_read() -> index_read_map()
sql/partition_info.cc:
Renamed local variable to avoid hiding class variable
sql/rpl_filter.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/set_var.cc:
Renamed local variable to avoid hiding class variable
Added 'process_key_cache_t' type to avoid compiler warning (on Forte)
sql/set_var.h:
Added 'process_key_cache_t' type to avoid compiler warning (on Forte)
sql/sp.cc:
More debugging
index_read() -> index_read_map()
sql/sp_cache.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sp_head.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
Moved 'saved_creation_ctx' higher up to be able to free objects allocated by create_backup_ctx()
sql/sql_acl.cc:
index_read() -> index_read_map()
sql/sql_class.cc:
Renamed local variable to avoid hiding class variable
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sql_class.h:
Renamed local variable to avoid hiding class variable
sql/sql_db.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
sql/sql_delete.cc:
Renamed local variable to avoid hiding class variable
sql/sql_handler.cc:
index_read() -> index_read_map()
sql/sql_help.cc:
index_read() -> index_read_map()
sql/sql_insert.cc:
index_read() -> index_read_map()
Renamed local variable to avoid hiding class variable
sql/sql_lex.cc:
Renamed local variable to avoid hiding class variable
sql/sql_plugin.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
index_read() -> index_read_map()
Don't give warnings about not used plugins if we are using --warnings=0
sql/sql_select.cc:
index_read() -> index_read_map()
sql-common/client.c:
Fixed compiler warning (on Forte)
sql-common/my_time.c:
Removed never accessed code
Fixed compiler warning (on Forte)
sql/sql_servers.cc:
index_read() -> index_read_map()
sql/sql_show.cc:
Added TRANSACTIONAL to SHOW CREATE
Fixed ROW_TYPE_PAGE
sql/sql_string.cc:
Avoid compiler warnings when using C function pointers in C++
sql/sql_table.cc:
Set create_info->transactional if we used TRANSACTIONAL=1
sql/sql_udf.cc:
index_read() -> index_read_map()
sql/sql_yacc.yy:
Added TRANSACTIONAL=0|1 to CREATE (for future)
Added row type PAGE (was only partionally handled before)
sql/strfunc.cc:
Avoid compiler warnings when using C function pointers in C++
sql/table.cc:
More DBUG statements
Declare all create_backup_ctx() functions identically
Remember if table was created with TRANSACTIONAL flag or not (future safe)
Renamed local variable to avoid hiding class variable
sql/table.h:
Remember if table was created with TRANSACTIONAL=1
sql/tztime.cc:
index_read() -> index_read_map()
sql-common/pack.c:
Fixed compiler warning (on Forte)
storage/archive/archive_reader.c:
Fixed compiler warning (on Forte)
storage/archive/azio.c:
Fixed compiler warning (on Forte)
storage/blackhole/ha_blackhole.cc:
index_read() -> index_read_map()
storage/blackhole/ha_blackhole.h:
index_read() -> index_read_map()
storage/csv/ha_tina.cc:
Declare functions sent to C code with extern "C" to avoid compiler warnings (on Forte)
storage/example/ha_example.cc:
index_read() -> index_read_map()
storage/example/ha_example.h:
index_read() -> index_read_map()
storage/heap/ha_heap.cc:
index_read() -> index_read_map()
storage/heap/ha_heap.h:
index_read() -> index_read_map()
storage/heap/hp_test1.c:
Fixed compiler warning (on Forte)
storage/heap/hp_test2.c:
Fixed compiler warning (on Forte)
storage/myisam/ft_boolean_search.c:
Fixed compiler warning (on Forte)
storage/myisam/ft_nlq_search.c:
Fixed compiler warning (on Forte)
storage/myisam/ft_parser.c:
Fixed compiler warning (on Forte)
storage/myisam/ft_stopwords.c:
Fixed compiler warning (on Forte)
storage/myisam/ha_myisam.cc:
index_read() -> index_read_map()
storage/myisam/ha_myisam.h:
index_read() -> index_read_map()
storage/myisam/mi_check.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_delete.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_dynrec.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_extra.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_key.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_keycache.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_locking.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_log.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_open.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_packrec.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_page.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_rkey.c:
Added comment
storage/myisam/mi_search.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_statrec.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_test1.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_test2.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_test3.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_update.c:
Fixed compiler warning (on Forte)
storage/myisam/mi_write.c:
Fixed compiler warning (on Forte)
storage/myisam/myisamdef.h:
Fixed that file_read/file_write returns type size_t
Changed some functions to use uchar * as argument/return value instead of char*
This fixed some compiler warnings on Forte
storage/myisam/myisamlog.c:
Fixed compiler warning (on Forte)
storage/myisam/myisampack.c:
Fixed compiler warning (on Forte)
storage/myisam/rt_test.c:
Fixed compiler warning (on Forte)
storage/myisam/sort.c:
Fixed compiler warning (on Forte) by adding casts or changing variables to uchar*
storage/myisam/sp_test.c:
Fixed compiler warning (on Forte) by adding casts or changing variables to uchar*
storage/myisammrg/ha_myisammrg.cc:
index_read() -> index_read_map()
storage/myisammrg/ha_myisammrg.h:
index_read() -> index_read_map()
storage/myisammrg/myrg_create.c:
Fixed compiler warning (on Forte) by adding casts or changing variable types
storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp:
Tdummy -> align (as in other part of cluster code)
storage/ndb/src/kernel/vm/DynArr256.cpp:
Removed not used variable
storage/ndb/src/ndbapi/Ndb.cpp:
Removed not used variable
strings/strtod.c:
Include ieeefp.h to avoid compiler warning
tests/bug25714.c:
Fixed compiler warning
tests/mysql_client_test.c:
Remove not used variable
Fixed indentation
Removed never reached code
Fixed compiler warning (on Forte) by adding casts or changing variable types
vio/viosocket.c:
Fixed compiler warning (on Forte) by adding casts or changing variable types
Diffstat (limited to 'sql')
51 files changed, 501 insertions, 386 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index b7bcb6344fd..48477b1ba46 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -390,8 +390,9 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, } key_copy(key_buf, event_table->record[0], key_info, key_len); - if (!(ret= event_table->file->index_read(event_table->record[0], key_buf, - (key_part_map)1, HA_READ_PREFIX))) + if (!(ret= event_table->file->index_read_map(event_table->record[0], key_buf, + (key_part_map)1, + HA_READ_PREFIX))) { DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret)); do @@ -839,8 +840,8 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name, key_copy(key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0], 0, key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { DBUG_PRINT("info", ("Row not found")); DBUG_RETURN(TRUE); diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 95f207844fc..e611432c6a2 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -52,8 +52,9 @@ execute_at.second_part is not considered during comparison */ -static int -event_queue_element_compare_q(void *vptr, uchar* a, uchar *b) +extern "C" int event_queue_element_compare_q(void *, uchar *, uchar *); + +int event_queue_element_compare_q(void *vptr, uchar* a, uchar *b) { my_time_t lhs = ((Event_queue_element *)a)->execute_at; my_time_t rhs = ((Event_queue_element *)b)->execute_at; diff --git a/sql/field.cc b/sql/field.cc index dd0c862d05b..4f85d15f7a9 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6081,12 +6081,12 @@ uint Field::is_equal(Create_field *new_field) /* If one of the fields is binary and the other one isn't return 1 else 0 */ -bool Field_str::compare_str_field_flags(Create_field *new_field, uint32 flags) +bool Field_str::compare_str_field_flags(Create_field *new_field, uint32 flag_arg) { return (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && - !(flags & (BINCMP_FLAG | BINARY_FLAG))) || + !(flag_arg & (BINCMP_FLAG | BINARY_FLAG))) || (!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) && - (flags & (BINCMP_FLAG | BINARY_FLAG)))); + (flag_arg & (BINCMP_FLAG | BINARY_FLAG)))); } diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d46b3a3bb08..6521be1cb9a 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1125,7 +1125,7 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, 0 Success */ -int ha_partition::prepare_new_partition(TABLE *table, +int ha_partition::prepare_new_partition(TABLE *tbl, HA_CREATE_INFO *create_info, handler *file, const char *part_name, partition_element *p_elem) @@ -1134,13 +1134,13 @@ int ha_partition::prepare_new_partition(TABLE *table, bool create_flag= FALSE; DBUG_ENTER("prepare_new_partition"); - if ((error= set_up_table_before_create(table, part_name, create_info, + if ((error= set_up_table_before_create(tbl, part_name, create_info, 0, p_elem))) goto error; - if ((error= file->create(part_name, table, create_info))) + if ((error= file->create(part_name, tbl, create_info))) goto error; create_flag= TRUE; - if ((error= file->ha_open(table, part_name, m_mode, m_open_test_lock))) + if ((error= file->ha_open(tbl, part_name, m_mode, m_open_test_lock))) goto error; /* Note: if you plan to add another call that may return failure, @@ -1776,7 +1776,7 @@ partition_element *ha_partition::find_partition_element(uint part_id) 4) Data file name on partition */ -int ha_partition::set_up_table_before_create(TABLE *table, +int ha_partition::set_up_table_before_create(TABLE *tbl, const char *partition_name_with_path, HA_CREATE_INFO *info, uint part_id, @@ -1793,8 +1793,8 @@ int ha_partition::set_up_table_before_create(TABLE *table, if (!part_elem) DBUG_RETURN(1); // Fatal error } - table->s->max_rows= part_elem->part_max_rows; - table->s->min_rows= part_elem->part_min_rows; + tbl->s->max_rows= part_elem->part_max_rows; + tbl->s->min_rows= part_elem->part_min_rows; partition_name= strrchr(partition_name_with_path, FN_LIBCHAR); if ((part_elem->index_file_name && (error= append_file_to_dir(thd, @@ -3400,11 +3400,11 @@ int ha_partition::index_end() used in conjuntion with multi read ranges. */ -int ha_partition::index_read(uchar * buf, const uchar * key, - key_part_map keypart_map, - enum ha_rkey_function find_flag) +int ha_partition::index_read_map(uchar *buf, const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) { - DBUG_ENTER("ha_partition::index_read"); + DBUG_ENTER("ha_partition::index_read_map"); end_range= 0; m_index_scan_type= partition_index_read; @@ -3566,7 +3566,7 @@ int ha_partition::common_first_last(uchar *buf) index_read_last() buf Read row in MySQL Row Format key Key - keylen Length of key + keypart_map Which part of key is used RETURN VALUE >0 Error code @@ -3577,8 +3577,8 @@ int ha_partition::common_first_last(uchar *buf) Can only be used on indexes supporting HA_READ_ORDER */ -int ha_partition::index_read_last(uchar *buf, const uchar *key, - key_part_map keypart_map) +int ha_partition::index_read_last_map(uchar *buf, const uchar *key, + key_part_map keypart_map) { DBUG_ENTER("ha_partition::index_read_last"); @@ -3929,9 +3929,9 @@ int ha_partition::handle_unordered_scan_next_partition(uchar * buf) switch (m_index_scan_type) { case partition_index_read: DBUG_PRINT("info", ("index_read on partition %d", i)); - error= file->index_read(buf, m_start_key.key, - m_start_key.keypart_map, - m_start_key.flag); + error= file->index_read_map(buf, m_start_key.key, + m_start_key.keypart_map, + m_start_key.flag); break; case partition_index_first: DBUG_PRINT("info", ("index_first on partition %d", i)); @@ -4020,10 +4020,10 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) switch (m_index_scan_type) { case partition_index_read: - error= file->index_read(rec_buf_ptr, - m_start_key.key, - m_start_key.keypart_map, - m_start_key.flag); + error= file->index_read_map(rec_buf_ptr, + m_start_key.key, + m_start_key.keypart_map, + m_start_key.flag); break; case partition_index_first: error= file->index_first(rec_buf_ptr); @@ -4034,9 +4034,9 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) reverse_order= TRUE; break; case partition_index_read_last: - error= file->index_read_last(rec_buf_ptr, - m_start_key.key, - m_start_key.keypart_map); + error= file->index_read_last_map(rec_buf_ptr, + m_start_key.key, + m_start_key.keypart_map); reverse_order= TRUE; break; default: diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 895f001fa6a..555f7a72740 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -387,9 +387,9 @@ public: index_init initializes an index before using it and index_end does any end processing needed. */ - virtual int index_read(uchar * buf, const uchar * key, - key_part_map keypart_map, - enum ha_rkey_function find_flag); + virtual int index_read_map(uchar * buf, const uchar * key, + key_part_map keypart_map, + enum ha_rkey_function find_flag); virtual int index_init(uint idx, bool sorted); virtual int index_end(); @@ -402,8 +402,8 @@ public: virtual int index_first(uchar * buf); virtual int index_last(uchar * buf); virtual int index_next_same(uchar * buf, const uchar * key, uint keylen); - virtual int index_read_last(uchar * buf, const uchar * key, - key_part_map keypart_map); + virtual int index_read_last_map(uchar * buf, const uchar * key, + key_part_map keypart_map); /* read_first_row is virtual method but is only implemented by diff --git a/sql/handler.cc b/sql/handler.cc index bab384e19fd..8c7f9035c23 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -25,8 +25,6 @@ #include "mysql_priv.h" #include "rpl_filter.h" - - #include <myisampack.h> #include <errno.h> @@ -64,7 +62,7 @@ static const LEX_STRING sys_table_aliases[]= }; const char *ha_row_type[] = { - "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "?","?","?" + "", "FIXED", "DYNAMIC", "COMPRESSED", "REDUNDANT", "COMPACT", "PAGE", "?","?","?" }; const char *tx_isolation_names[] = @@ -1988,9 +1986,9 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment, key_copy(key, table->record[0], table->key_info + table->s->next_number_index, table->s->next_number_key_offset); - error= index_read(table->record[1], key, - make_prev_keypart_map(table->s->next_number_keypart), - HA_READ_PREFIX_LAST); + error= index_read_map(table->record[1], key, + make_prev_keypart_map(table->s->next_number_keypart), + HA_READ_PREFIX_LAST); /* MySQL needs to call us for next row: assume we are inserting ("a",null) here, we return 3, and next this statement will want to insert @@ -3213,10 +3211,10 @@ int handler::read_range_first(const key_range *start_key, if (!start_key) // Read first record result= index_first(table->record[0]); else - result= index_read(table->record[0], - start_key->key, - start_key->keypart_map, - start_key->flag); + result= index_read_map(table->record[0], + start_key->key, + start_key->keypart_map, + start_key->flag); if (result) DBUG_RETURN((result == HA_ERR_KEY_NOT_FOUND) ? HA_ERR_END_OF_FILE @@ -3288,15 +3286,15 @@ int handler::compare_key(key_range *range) } -int handler::index_read_idx(uchar * buf, uint index, const uchar * key, - key_part_map keypart_map, - enum ha_rkey_function find_flag) +int handler::index_read_idx_map(uchar * buf, uint index, const uchar * key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) { int error, error1; error= index_init(index, 0); if (!error) { - error= index_read(buf, key, keypart_map, find_flag); + error= index_read_map(buf, key, keypart_map, find_flag); error1= index_end(); } return error ? error : error1; diff --git a/sql/handler.h b/sql/handler.h index 7cf7bfe043d..1b7c106f42c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -278,7 +278,7 @@ enum legacy_db_type enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED, - ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGES }; + ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE }; enum enum_binlog_func { BFN_RESET_LOGS= 1, @@ -321,6 +321,7 @@ enum enum_binlog_command { #define HA_CREATE_USED_PASSWORD (1L << 17) #define HA_CREATE_USED_CONNECTION (1L << 18) #define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19) +#define HA_CREATE_USED_TRANSACTIONAL (1L << 20) typedef ulonglong my_xid; // this line is the same as in log_event.h #define MYSQL_XID_PREFIX "MySQLXid" @@ -759,6 +760,7 @@ class partition_info; struct st_partition_iter; #define NOT_A_PARTITION_ID ((uint32)-1) +enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES }; typedef struct st_ha_create_information { @@ -781,6 +783,8 @@ typedef struct st_ha_create_information uint options; /* OR of HA_CREATE_ options */ uint merge_insert_method; uint extra_size; /* length of extra data segment */ + /* 0 not used, 1 if not transactional, 2 if transactional */ + enum ha_choice transactional; bool table_existed; /* 1 in create if table existed */ bool frm_only; /* 1 if no ha_create_table() */ bool varchar; /* 1 if table has a VARCHAR */ @@ -1248,27 +1252,28 @@ public: enum ha_rkey_function find_flag) { return HA_ERR_WRONG_COMMAND; } public: -/** - @brief - Positions an index cursor to the index specified in the handle. Fetches the - row if available. If the key value is null, begin at the first key of the - index. -*/ - virtual int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, - enum ha_rkey_function find_flag) - { - uint key_len= calculate_key_len(table, active_index, key, keypart_map); - return index_read(buf, key, key_len, find_flag); - } -/** - @brief - Positions an index cursor to the index specified in the handle. Fetches the - row if available. If the key value is null, begin at the first key of the - index. -*/ - virtual int index_read_idx(uchar * buf, uint index, const uchar * key, + /** + @brief + Positions an index cursor to the index specified in the handle. Fetches the + row if available. If the key value is null, begin at the first key of the + index. + */ + virtual int index_read_map(uchar * buf, const uchar * key, key_part_map keypart_map, - enum ha_rkey_function find_flag); + enum ha_rkey_function find_flag) + { + uint key_len= calculate_key_len(table, active_index, key, keypart_map); + return index_read(buf, key, key_len, find_flag); + } + /** + @brief + Positions an index cursor to the index specified in the handle. Fetches the + row if available. If the key value is null, begin at the first key of the + index. + */ + virtual int index_read_idx_map(uchar * buf, uint index, const uchar * key, + key_part_map keypart_map, + enum ha_rkey_function find_flag); virtual int index_next(uchar * buf) { return HA_ERR_WRONG_COMMAND; } virtual int index_prev(uchar * buf) @@ -1282,17 +1287,17 @@ public: virtual int index_read_last(uchar * buf, const uchar * key, uint key_len) { return (my_errno=HA_ERR_WRONG_COMMAND); } public: -/** - @brief - The following functions works like index_read, but it find the last - row with the current key value or prefix. -*/ - virtual int index_read_last(uchar * buf, const uchar * key, - key_part_map keypart_map) - { - uint key_len= calculate_key_len(table, active_index, key, keypart_map); - return index_read_last(buf, key, key_len); - } + /** + @brief + The following functions works like index_read, but it find the last + row with the current key value or prefix. + */ + virtual int index_read_last_map(uchar * buf, const uchar * key, + key_part_map keypart_map) + { + uint key_len= calculate_key_len(table, active_index, key, keypart_map); + return index_read_last(buf, key, key_len); + } virtual int read_multi_range_first(KEY_MULTI_RANGE **found_range_p, KEY_MULTI_RANGE *ranges, uint range_count, bool sorted, HANDLER_BUFFER *buffer); @@ -1835,7 +1840,7 @@ int ha_find_files(THD *thd,const char *db,const char *path, int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); /* key cache */ -int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); +extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); int ha_resize_key_cache(KEY_CACHE *key_cache); int ha_change_key_cache_param(KEY_CACHE *key_cache); int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache); diff --git a/sql/item.cc b/sql/item.cc index 711a21ecbec..79f43da47bf 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3830,15 +3830,15 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if ((*res)->type() == Item::FIELD_ITEM) { /* - It's an Item_field referencing another Item_field in the select - list. - use the field from the Item_field in the select list and leave - the Item_field instance in place. + It's an Item_field referencing another Item_field in the select + list. + Use the field from the Item_field in the select list and leave + the Item_field instance in place. */ - Field *field= (*((Item_field**)res))->field; + Field *new_field= (*((Item_field**)res))->field; - if (field == NULL) + if (new_field == NULL) { /* The column to which we link isn't valid. */ my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name, @@ -3846,7 +3846,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) return(1); } - set_field(field); + set_field(new_field); return 0; } else diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 755e711e383..8f5ff050dd6 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3017,11 +3017,11 @@ uchar *in_longlong::get_value(Item *item) void in_datetime::set(uint pos,Item *item) { - Item **tmp= &item; + Item **tmp_item= &item; bool is_null; struct packed_longlong *buff= &((packed_longlong*) base)[pos]; - buff->val= get_datetime_value(thd, &tmp, 0, warn_item, &is_null); + buff->val= get_datetime_value(thd, &tmp_item, 0, warn_item, &is_null); buff->unsigned_flag= 1L; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 47914c59b4c..35ecfdb0f2c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1158,7 +1158,6 @@ public: class Item_func_in :public Item_func_opt_neg { public: - Item_result cmp_type; /* an array of values when the right hand arguments of IN are all SQL constant and there are no nulls diff --git a/sql/item_func.cc b/sql/item_func.cc index 4012371bedb..6f908eb715e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4383,11 +4383,11 @@ int Item_func_set_user_var::save_in_field(Field *field, bool no_conversions, else if (result_type() == DECIMAL_RESULT) { my_decimal decimal_value; - my_decimal *value= entry->val_decimal(&null_value, &decimal_value); + my_decimal *val= entry->val_decimal(&null_value, &decimal_value); if (null_value) return set_field_to_null(field); field->set_notnull(); - error=field->store_decimal(value); + error=field->store_decimal(val); } else { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d54b9961562..186ec83a4a6 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1049,6 +1049,23 @@ String *Item_str_conv::val_str(String *str) } +void Item_func_lcase::fix_length_and_dec() +{ + collation.set(args[0]->collation); + multiply= collation.collation->casedn_multiply; + converter= collation.collation->cset->casedn; + max_length= args[0]->max_length * multiply; +} + +void Item_func_ucase::fix_length_and_dec() +{ + collation.set(args[0]->collation); + multiply= collation.collation->caseup_multiply; + converter= collation.collation->cset->caseup; + max_length= args[0]->max_length * multiply; +} + + String *Item_func_left::val_str(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 6d2d9c199c9..385a12d372a 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -145,8 +145,7 @@ class Item_str_conv :public Item_str_func { protected: uint multiply; - size_t (*converter)(CHARSET_INFO *cs, char *src, size_t srclen, - char *dst, size_t dstlen); + my_charset_conv_case converter; String tmp_value; public: Item_str_conv(Item *item) :Item_str_func(item) {} @@ -159,13 +158,7 @@ class Item_func_lcase :public Item_str_conv public: Item_func_lcase(Item *item) :Item_str_conv(item) {} const char *func_name() const { return "lcase"; } - void fix_length_and_dec() - { - collation.set(args[0]->collation); - multiply= collation.collation->casedn_multiply; - converter= collation.collation->cset->casedn; - max_length= args[0]->max_length * multiply; - } + void fix_length_and_dec(); }; class Item_func_ucase :public Item_str_conv @@ -173,13 +166,7 @@ class Item_func_ucase :public Item_str_conv public: Item_func_ucase(Item *item) :Item_str_conv(item) {} const char *func_name() const { return "ucase"; } - void fix_length_and_dec() - { - collation.set(args[0]->collation); - multiply= collation.collation->caseup_multiply; - converter= collation.collation->cset->caseup; - max_length= args[0]->max_length * multiply; - } + void fix_length_and_dec(); }; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1d042860d73..a253397e52c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2129,10 +2129,10 @@ int subselect_uniquesubquery_engine::exec() if (!table->file->inited) table->file->ha_index_init(tab->ref.key, 0); - error= table->file->index_read(table->record[0], - tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT); + error= table->file->index_read_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT); if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) error= report_error(table, error); @@ -2239,10 +2239,10 @@ int subselect_indexsubquery_engine::exec() if (!table->file->inited) table->file->ha_index_init(tab->ref.key, 1); - error= table->file->index_read(table->record[0], - tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT); + error= table->file->index_read_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT); if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) error= report_error(table, error); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 067af930d6f..15be9c97b6e 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -570,13 +570,13 @@ String *Item_nodeset_func_rootelement::val_nodeset(String *nodeset) String * Item_nodeset_func_union::val_nodeset(String *nodeset) { - uint numnodes= pxml->length() / sizeof(MY_XML_NODE); + uint num_nodes= pxml->length() / sizeof(MY_XML_NODE); String set0, *s0= args[0]->val_nodeset(&set0); String set1, *s1= args[1]->val_nodeset(&set1); String both_str; - both_str.alloc(numnodes); + both_str.alloc(num_nodes); char *both= (char*) both_str.ptr(); - bzero((void*)both, numnodes); + bzero((void*)both, num_nodes); MY_XPATH_FLT *flt; fltbeg= (MY_XPATH_FLT*) s0->ptr(); @@ -590,7 +590,7 @@ String * Item_nodeset_func_union::val_nodeset(String *nodeset) both[flt->num]= 1; nodeset->length(0); - for (uint i= 0, pos= 0; i < numnodes; i++) + for (uint i= 0, pos= 0; i < num_nodes; i++) { if (both[i]) ((XPathFilter*)nodeset)->append_element(i, pos++); @@ -2656,7 +2656,9 @@ static uint xml_parent_tag(MY_XML_NODE *items, uint nitems, uint level) RETURN Currently only MY_XML_OK */ -static int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len) +extern "C" int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len); + +int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr(); @@ -2687,7 +2689,9 @@ static int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len) RETURN Currently only MY_XML_OK */ -static int xml_value(MY_XML_PARSER *st,const char *attr, size_t len) +extern "C" int xml_value(MY_XML_PARSER *st,const char *attr, size_t len); + +int xml_value(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr(); @@ -2717,7 +2721,9 @@ static int xml_value(MY_XML_PARSER *st,const char *attr, size_t len) RETURN Currently only MY_XML_OK */ -static int xml_leave(MY_XML_PARSER *st,const char *attr, size_t len) +extern "C" int xml_leave(MY_XML_PARSER *st,const char *attr, size_t len); + +int xml_leave(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; DBUG_ASSERT(data->level > 0); diff --git a/sql/key.cc b/sql/key.cc index fee06ec058f..e8354ed2635 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -480,6 +480,7 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length) rec0 Pointer to table->record[0] first_rec Pointer to record compare with second_rec Pointer to record compare against first_rec + DESCRIPTION This method is set-up such that it can be called directly from the priority queue and it is attempted to be optimised as much as possible diff --git a/sql/log.cc b/sql/log.cc index 588a06fa7a4..93d35de4c69 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1932,7 +1932,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, { char buff[32]; uint length= 0; - char time_buff[MAX_TIME_SIZE]; + char local_time_buff[MAX_TIME_SIZE]; struct tm start; uint time_buff_len= 0; @@ -1948,13 +1948,13 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, localtime_r(&event_time, &start); - time_buff_len= my_snprintf(time_buff, MAX_TIME_SIZE, + time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE, "%02d%02d%02d %2d:%02d:%02d", start.tm_year % 100, start.tm_mon + 1, start.tm_mday, start.tm_hour, start.tm_min, start.tm_sec); - if (my_b_write(&log_file, (uchar*) &time_buff, time_buff_len)) + if (my_b_write(&log_file, (uchar*) local_time_buff, time_buff_len)) goto err; } else diff --git a/sql/log_event.cc b/sql/log_event.cc index db8729c8318..3b0e73e650c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -456,7 +456,11 @@ Log_event::Log_event() thd(0) { server_id= ::server_id; - when= my_time(0); + /* + We can't call my_time() here as this would cause a call before + my_init() is called + */ + when= 0; log_pos= 0; } #endif /* !MYSQL_CLIENT */ @@ -637,6 +641,7 @@ void Log_event::init_show_field_list(List<Item>* field_list) bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) { uchar header[LOG_EVENT_HEADER_LEN]; + ulong now; DBUG_ENTER("Log_event::write_header"); /* Store number of bytes that will be written by this event */ @@ -687,6 +692,14 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) log_pos= my_b_safe_tell(file)+data_written; } + /* Set time of we this isn't a query */ + if (!(now= (ulong) when)) + { + THD *thd= current_thd; + /* thd will only be 0 here at time of log creation */ + now= thd ? thd->start_time : my_time(0); + } + /* Header will be of size LOG_EVENT_HEADER_LEN for all events, except for FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT, where it will be @@ -694,7 +707,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) because we read them before knowing the format). */ - int4store(header, (ulong) when); // timestamp + int4store(header, now); // timestamp header[EVENT_TYPE_OFFSET]= get_type_code(); int4store(header+ SERVER_ID_OFFSET, server_id); int4store(header+ EVENT_LEN_OFFSET, data_written); @@ -6867,7 +6880,7 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error) return error? error : local_error; } -int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, +int Write_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *const row_start, uchar const **const row_end) @@ -6878,7 +6891,7 @@ int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, &m_master_reclength, table->write_set, WRITE_ROWS_EVENT)) { - thd->net.last_errno= error; + thd_arg->net.last_errno= error; return error; } bitmap_copy(table->read_set, table->write_set); @@ -7137,10 +7150,10 @@ replace_record(THD *thd, TABLE *table, } key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum, 0); - error= table->file->index_read_idx(table->record[1], keynum, - (const uchar*)key.get(), - HA_WHOLE_KEY, - HA_READ_KEY_EXACT); + error= table->file->index_read_idx_map(table->record[1], keynum, + (const uchar*)key.get(), + HA_WHOLE_KEY, + HA_READ_KEY_EXACT); if (error) { table->file->print_error(error, MYF(0)); @@ -7391,8 +7404,8 @@ static int find_and_fetch_row(TABLE *table, uchar *key) my_ptrdiff_t const pos= table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0; table->record[1][pos]= 0xFF; - if ((error= table->file->index_read(table->record[1], key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT))) + if ((error= table->file->index_read_map(table->record[1], key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT))) { table->file->print_error(error, MYF(0)); table->file->ha_index_end(); @@ -7592,7 +7605,7 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error) return error; } -int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, +int Delete_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *const row_start, uchar const **const row_end) @@ -7607,7 +7620,7 @@ int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, &m_master_reclength, table->read_set, DELETE_ROWS_EVENT)) { - thd->net.last_errno= error; + thd_arg->net.last_errno= error; return error; } @@ -7771,7 +7784,7 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error) return error; } -int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, +int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *const row_start, uchar const **const row_end) @@ -7794,7 +7807,7 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, if ((error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, &m_master_reclength, table->read_set, UPDATE_ROWS_EVENT))) { - thd->net.last_errno= error; + thd_arg->net.last_errno= error; return error; } @@ -7804,7 +7817,7 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, if ((error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end, &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT))) { - thd->net.last_errno= error; + thd_arg->net.last_errno= error; return error; } diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index e6a9dd50c08..d44f9621a42 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -5,7 +5,7 @@ #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) int -Write_rows_log_event_old::do_prepare_row(THD *thd, +Write_rows_log_event_old::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *row_start, @@ -25,7 +25,7 @@ Write_rows_log_event_old::do_prepare_row(THD *thd, int -Delete_rows_log_event_old::do_prepare_row(THD *thd, +Delete_rows_log_event_old::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *row_start, @@ -58,7 +58,7 @@ Delete_rows_log_event_old::do_prepare_row(THD *thd, } -int Update_rows_log_event_old::do_prepare_row(THD *thd, +int Update_rows_log_event_old::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, TABLE *table, uchar const *row_start, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 34d92a13945..805cf23118f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -168,7 +168,7 @@ public: protected: Object_creation_ctx() {} - virtual Object_creation_ctx *create_backup_ctx(THD *thd) = 0; + virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0; virtual void change_env(THD *thd) const = 0; @@ -204,7 +204,7 @@ protected: CHARSET_INFO *connection_cl); protected: - virtual Object_creation_ctx *create_backup_ctx(THD *thd); + virtual Object_creation_ctx *create_backup_ctx(THD *thd) const; virtual void change_env(THD *thd) const; @@ -1643,7 +1643,7 @@ bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length); void key_unpack(String *to,TABLE *form,uint index); bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields); int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length); -int key_rec_cmp(void *key_info, uchar *a, uchar *b); +extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b); bool init_errmessage(void); #endif /* MYSQL_SERVER */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 33cd55170ea..d9f0648b9b3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -693,7 +693,7 @@ struct st_VioSSLFd *ssl_acceptor_fd; pthread_handler_t signal_hand(void *arg); static void mysql_init_variables(void); static void get_options(int *argc,char **argv); -static my_bool get_one_option(int, const struct my_option *, char *); +extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *); static void set_server_version(void); static int init_thread_environment(); static char *get_relative_path(const char *path); @@ -1141,6 +1141,7 @@ void unireg_end(void) extern "C" void unireg_abort(int exit_code) { DBUG_ENTER("unireg_abort"); + if (exit_code) sql_print_error("Aborting\n"); else if (opt_help) @@ -2353,7 +2354,7 @@ static void init_signals(void) sigaddset(&set,SIGTSTP); #endif if (thd_lib_detected != THD_LIB_LT) - sigaddset(&set,THR_SERVER_ALARM); + sigaddset(&set,THR_SERVER_ALARM); if (test_flags & TEST_SIGINT) { // May be SIGINT @@ -2549,7 +2550,9 @@ static void check_data_home(const char *path) /* ARGSUSED */ -static int my_message_sql(uint error, const char *str, myf MyFlags) +extern "C" int my_message_sql(uint error, const char *str, myf MyFlags); + +int my_message_sql(uint error, const char *str, myf MyFlags) { THD *thd; DBUG_ENTER("my_message_sql"); @@ -2612,13 +2615,16 @@ static int my_message_sql(uint error, const char *str, myf MyFlags) #ifndef EMBEDDED_LIBRARY -static void *my_str_malloc_mysqld(size_t size) +extern "C" void *my_str_malloc_mysqld(size_t size); +extern "C" void my_str_free_mysqld(void *ptr); + +void *my_str_malloc_mysqld(size_t size) { return my_malloc(size, MYF(MY_FAE)); } -static void my_str_free_mysqld(void *ptr) +void my_str_free_mysqld(void *ptr) { my_free((uchar*)ptr, MYF(MY_FAE)); } @@ -3418,7 +3424,7 @@ server."); my_getopt_skip_unknown= 0; if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts, - get_one_option))) + mysqld_get_one_option))) unireg_abort(ho_error); if (defaults_argc) @@ -3902,7 +3908,6 @@ we force server id to 2, but this MySQL server will not act as a slave."); */ if (init_slave() && !active_mi) { - end_thr_alarm(1); // Don't allow alarms unireg_abort(1); } @@ -3910,16 +3915,12 @@ we force server id to 2, but this MySQL server will not act as a slave."); { select_thread_in_use= 0; // Allow 'kill' to work bootstrap(stdin); - end_thr_alarm(1); // Don't allow alarms unireg_abort(bootstrap_error ? 1 : 0); } if (opt_init_file) { if (read_init_file(opt_init_file)) - { - end_thr_alarm(1); // Don't allow alarms unireg_abort(1); - } } execute_ddl_log_recovery(); @@ -6872,6 +6873,7 @@ SHOW_VAR status_vars[]= { {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH}, {"Open_table_definitions", (char*) &show_table_definitions, SHOW_FUNC}, {"Open_tables", (char*) &show_open_tables, SHOW_FUNC}, + {"Opened_files", (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH}, {"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS}, {"Prepared_stmt_count", (char*) &show_prepared_stmt_count, SHOW_FUNC}, #ifdef HAVE_QUERY_CACHE @@ -7239,9 +7241,10 @@ static void mysql_init_variables(void) } -static my_bool -get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument) +my_bool +mysqld_get_one_option(int optid, + const struct my_option *opt __attribute__((unused)), + char *argument) { switch(optid) { case '#': @@ -7732,7 +7735,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), /* Handle arguments for multiple key caches */ -static uchar* * +extern "C" uchar **mysql_getopt_value(const char *keyname, uint key_length, + const struct my_option *option); + +uchar* * mysql_getopt_value(const char *keyname, uint key_length, const struct my_option *option) { @@ -7761,11 +7767,19 @@ mysql_getopt_value(const char *keyname, uint key_length, } -static void option_error_reporter(enum loglevel level, const char *format, ...) +extern "C" void option_error_reporter(enum loglevel level, const char *format, ...); + +void option_error_reporter(enum loglevel level, const char *format, ...) { va_list args; va_start(args, format); - vprint_msg_to_log(level, format, args); + + /* Don't print warnings for --loose options during bootstrap */ + if (level == ERROR_LEVEL || !opt_bootstrap || + global_system_variables.log_warnings) + { + vprint_msg_to_log(level, format, args); + } va_end(args); } @@ -7783,7 +7797,7 @@ static void get_options(int *argc,char **argv) my_getopt_skip_unknown= TRUE; if ((ho_error= handle_options(argc, &argv, my_long_options, - get_one_option))) + mysqld_get_one_option))) exit(ho_error); (*argc)++; /* add back one for the progname handle_options removes */ /* no need to do this for argv as we are discarding it. */ @@ -8144,7 +8158,7 @@ void refresh_status(THD *thd) add_to_status(&global_status_var, &thd->status_var); /* Reset thread's status variables */ - bzero((char*) &thd->status_var, sizeof(thd->status_var)); + bzero((uchar*) &thd->status_var, sizeof(thd->status_var)); /* Reset some global variables */ reset_status_vars(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 948b268d9a3..516da13d857 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8375,7 +8375,8 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, { /* Read the next record in the same range with prefix after cur_prefix. */ DBUG_ASSERT(cur_prefix != 0); - result= file->index_read(record, cur_prefix, keypart_map, HA_READ_AFTER_KEY); + result= file->index_read_map(record, cur_prefix, keypart_map, + HA_READ_AFTER_KEY); if (result || (file->compare_key(file->end_range) <= 0)) DBUG_RETURN(result); } @@ -8446,9 +8447,10 @@ int QUICK_RANGE_SELECT_GEOM::get_next() } last_range= *(cur_range++); - result= file->index_read(record, last_range->min_key, - last_range->min_keypart_map, - (ha_rkey_function)(last_range->flag ^ GEOM_FLAG)); + result= file->index_read_map(record, last_range->min_key, + last_range->min_keypart_map, + (ha_rkey_function)(last_range->flag ^ + GEOM_FLAG)); if (result != HA_ERR_KEY_NOT_FOUND && result != HA_ERR_END_OF_FILE) DBUG_RETURN(result); last_range= 0; // Not found, to next range @@ -8579,18 +8581,19 @@ int QUICK_SELECT_DESC::get_next() if (last_range->flag & EQ_RANGE) { - result = file->index_read(record, last_range->max_key, - last_range->max_keypart_map, HA_READ_KEY_EXACT); + result = file->index_read_map(record, last_range->max_key, + last_range->max_keypart_map, + HA_READ_KEY_EXACT); } else { DBUG_ASSERT(last_range->flag & NEAR_MAX || range_reads_after_key(last_range)); - result=file->index_read(record, last_range->max_key, - last_range->max_keypart_map, - ((last_range->flag & NEAR_MAX) ? - HA_READ_BEFORE_KEY : - HA_READ_PREFIX_LAST_OR_PREV)); + result=file->index_read_map(record, last_range->max_key, + last_range->max_keypart_map, + ((last_range->flag & NEAR_MAX) ? + HA_READ_BEFORE_KEY : + HA_READ_PREFIX_LAST_OR_PREV)); } if (result) { @@ -10446,9 +10449,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next() first sub-group with the extended prefix. */ if (!have_min && !have_max && key_infix_len > 0) - result= file->index_read(record, group_prefix, - make_prev_keypart_map(real_key_parts), - HA_READ_KEY_EXACT); + result= file->index_read_map(record, group_prefix, + make_prev_keypart_map(real_key_parts), + HA_READ_KEY_EXACT); result= have_min ? min_res : have_max ? max_res : result; } while ((result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE) && @@ -10510,9 +10513,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min() /* Apply the constant equality conditions to the non-group select fields */ if (key_infix_len > 0) { - if ((result= file->index_read(record, group_prefix, - make_prev_keypart_map(real_key_parts), - HA_READ_KEY_EXACT))) + if ((result= file->index_read_map(record, group_prefix, + make_prev_keypart_map(real_key_parts), + HA_READ_KEY_EXACT))) DBUG_RETURN(result); } @@ -10527,9 +10530,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min() { /* Find the first subsequent record without NULL in the MIN/MAX field. */ key_copy(tmp_record, record, index_info, 0); - result= file->index_read(record, tmp_record, - make_keypart_map(real_key_parts), - HA_READ_AFTER_KEY); + result= file->index_read_map(record, tmp_record, + make_keypart_map(real_key_parts), + HA_READ_AFTER_KEY); /* Check if the new record belongs to the current group by comparing its prefix with the group's prefix. If it is from the next group, then the @@ -10584,9 +10587,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max() if (min_max_ranges.elements > 0) result= next_max_in_range(); else - result= file->index_read(record, group_prefix, - make_prev_keypart_map(real_key_parts), - HA_READ_PREFIX_LAST); + result= file->index_read_map(record, group_prefix, + make_prev_keypart_map(real_key_parts), + HA_READ_PREFIX_LAST); DBUG_RETURN(result); } @@ -10637,9 +10640,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_prefix() else { /* Load the first key in this group into record. */ - result= file->index_read(record, group_prefix, - make_prev_keypart_map(group_key_parts), - HA_READ_AFTER_KEY); + result= file->index_read_map(record, group_prefix, + make_prev_keypart_map(group_key_parts), + HA_READ_AFTER_KEY); if (result) DBUG_RETURN(result); } @@ -10716,7 +10719,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range() HA_READ_AFTER_KEY : HA_READ_KEY_OR_NEXT; } - result= file->index_read(record, group_prefix, keypart_map, find_flag); + result= file->index_read_map(record, group_prefix, keypart_map, find_flag); if (result) { if ((result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE) && @@ -10849,7 +10852,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV; } - result= file->index_read(record, group_prefix, keypart_map, find_flag); + result= file->index_read_map(record, group_prefix, keypart_map, find_flag); if (result) { diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 8851401d21f..6836c53db4e 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -270,9 +270,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) Closed interval: Either The MIN argument is non-nullable, or we have a >= predicate for the MIN argument. */ - error= table->file->index_read(table->record[0], ref.key_buff, - make_prev_keypart_map(ref.key_parts), - HA_READ_KEY_OR_NEXT); + error= table->file->index_read_map(table->record[0], + ref.key_buff, + make_prev_keypart_map(ref.key_parts), + HA_READ_KEY_OR_NEXT); else { /* @@ -281,9 +282,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) 2) there is a > predicate on it, nullability is irrelevant. We need to scan the next bigger record first. */ - error= table->file->index_read(table->record[0], ref.key_buff, - make_prev_keypart_map(ref.key_parts), - HA_READ_AFTER_KEY); + error= table->file->index_read_map(table->record[0], + ref.key_buff, + make_prev_keypart_map(ref.key_parts), + HA_READ_AFTER_KEY); /* If the found record is outside the group formed by the search prefix, or there is no such record at all, check if all @@ -305,9 +307,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) key_cmp_if_same(table, ref.key_buff, ref.key, prefix_len))) { DBUG_ASSERT(item_field->field->real_maybe_null()); - error= table->file->index_read(table->record[0], ref.key_buff, - make_prev_keypart_map(ref.key_parts), - HA_READ_KEY_EXACT); + error= table->file->index_read_map(table->record[0], + ref.key_buff, + make_prev_keypart_map(ref.key_parts), + HA_READ_KEY_EXACT); } } } @@ -394,11 +397,11 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (!ref.key_length) error= table->file->index_last(table->record[0]); else - error= table->file->index_read(table->record[0], key_buff, - make_prev_keypart_map(ref.key_parts), - range_fl & NEAR_MAX ? - HA_READ_BEFORE_KEY : - HA_READ_PREFIX_LAST_OR_PREV); + error= table->file->index_read_map(table->record[0], key_buff, + make_prev_keypart_map(ref.key_parts), + range_fl & NEAR_MAX ? + HA_READ_BEFORE_KEY : + HA_READ_PREFIX_LAST_OR_PREV); if (!error && reckey_in_range(1, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 308b96d84f8..ab887d5dda0 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -91,10 +91,10 @@ partition_info *partition_info::get_clone() #define MAX_PART_NAME_SIZE 8 char *partition_info::create_default_partition_names(uint part_no, - uint no_parts, + uint no_parts_arg, uint start_no) { - char *ptr= (char*) sql_calloc(no_parts*MAX_PART_NAME_SIZE); + char *ptr= (char*) sql_calloc(no_parts_arg*MAX_PART_NAME_SIZE); char *move_ptr= ptr; uint i= 0; DBUG_ENTER("create_default_partition_names"); @@ -105,11 +105,11 @@ char *partition_info::create_default_partition_names(uint part_no, { my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i))); move_ptr+=MAX_PART_NAME_SIZE; - } while (++i < no_parts); + } while (++i < no_parts_arg); } else { - mem_alloc_error(no_parts*MAX_PART_NAME_SIZE); + mem_alloc_error(no_parts_arg*MAX_PART_NAME_SIZE); } DBUG_RETURN(ptr); } diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index bb5db0106eb..fb609e12dcb 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -362,9 +362,11 @@ Rpl_filter::add_ignore_db(const char* table_spec) ignore_db.push_back(db); } +extern "C" uchar *get_table_key(const uchar *, size_t *, my_bool); +extern "C" void free_table_ent(void* a); -static uchar* get_table_key(const uchar* a, size_t *len, - my_bool __attribute__((unused))) +uchar *get_table_key(const uchar* a, size_t *len, + my_bool __attribute__((unused))) { TABLE_RULE_ENT *e= (TABLE_RULE_ENT *) a; @@ -373,7 +375,7 @@ static uchar* get_table_key(const uchar* a, size_t *len, } -static void free_table_ent(void* a) +void free_table_ent(void* a) { TABLE_RULE_ENT *e= (TABLE_RULE_ENT *) a; diff --git a/sql/set_var.cc b/sql/set_var.cc index 97d38cd84ca..7528e3c82f5 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3266,11 +3266,12 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var) var->save_result.plugin= NULL; if (var->value->result_type() == STRING_RESULT) { - LEX_STRING name; + LEX_STRING engine_name; handlerton *hton; if (!(res=var->value->val_str(&str)) || - !(name.str= (char *)res->ptr()) || !(name.length= res->length()) || - !(var->save_result.plugin= ha_resolve_by_name(thd, &name)) || + !(engine_name.str= (char *)res->ptr()) || + !(engine_name.length= res->length()) || + !(var->save_result.plugin= ha_resolve_by_name(thd, &engine_name)) || !(hton= plugin_data(var->save_result.plugin, handlerton *)) || ha_checktype(thd, ha_legacy_type(hton), 1, 0) != hton) { @@ -3292,13 +3293,13 @@ uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, { uchar* result; handlerton *hton; - LEX_STRING *name; + LEX_STRING *engine_name; plugin_ref plugin= thd->variables.*offset; if (type == OPT_GLOBAL) plugin= my_plugin_lock(thd, &(global_system_variables.*offset)); hton= plugin_data(plugin, handlerton*); - name= &hton2plugin[hton->slot]->name; - result= (uchar *) thd->strmake(name->str, name->length); + engine_name= &hton2plugin[hton->slot]->name; + result= (uchar *) thd->strmake(engine_name->str, engine_name->length); if (type == OPT_GLOBAL) plugin_unlock(thd, plugin); return result; @@ -3585,7 +3586,7 @@ void free_key_cache(const char *name, KEY_CACHE *key_cache) } -bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) +bool process_key_caches(process_key_cache_t func) { I_List_iterator<NAMED_LIST> it(key_caches); NAMED_LIST *element; diff --git a/sql/set_var.h b/sql/set_var.h index 67ec449a02f..eb2c893c89e 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -1128,6 +1128,11 @@ public: }; +extern "C" +{ + typedef int (*process_key_cache_t) (const char *, KEY_CACHE *); +} + /* Named lists (used for keycaches) */ class NAMED_LIST :public ilink @@ -1152,8 +1157,7 @@ public: { my_free((uchar*) name, MYF(0)); } - friend bool process_key_caches(int (* func) (const char *name, - KEY_CACHE *)); + friend bool process_key_caches(process_key_cache_t func); friend void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, uchar*)); }; @@ -1201,6 +1205,6 @@ extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path; KEY_CACHE *get_key_cache(LEX_STRING *cache_name); KEY_CACHE *get_or_create_key_cache(const char *name, uint length); void free_key_cache(const char *name, KEY_CACHE *key_cache); -bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); +bool process_key_caches(process_key_cache_t func); void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, uchar*)); diff --git a/sql/sp.cc b/sql/sp.cc index 372aa9c6780..0956561719b 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -97,7 +97,8 @@ public: protected: virtual Object_creation_ctx *create_backup_ctx(THD *thd) const { - return new Stored_routine_creation_ctx(thd); + DBUG_ENTER("Stored_routine_creation_ctx::create_backup_ctx"); + DBUG_RETURN(new Stored_routine_creation_ctx(thd)); } private: @@ -348,8 +349,8 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table) key_copy(key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0], 0, key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) DBUG_RETURN(SP_KEY_NOT_FOUND); DBUG_RETURN(SP_OK); @@ -1182,9 +1183,9 @@ sp_drop_db_routines(THD *thd, char *db) ret= SP_OK; table->file->ha_index_init(0, 1); - if (! table->file->index_read(table->record[0], - (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr, - (key_part_map)1, HA_READ_KEY_EXACT)) + if (! table->file->index_read_map(table->record[0], + (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr, + (key_part_map)1, HA_READ_KEY_EXACT)) { int nxtres; bool deleted= FALSE; diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 84b15ee15c4..cc6ba9ef1d0 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -214,8 +214,12 @@ void sp_cache_flush_obsolete(sp_cache **cp) Internal functions *************************************************************************/ -static uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen, - my_bool first) +extern "C" uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen, + my_bool first); +extern "C" void hash_free_sp_head(void *p); + +uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen, + my_bool first) { sp_head *sp= (sp_head *)ptr; *plen= sp->m_qname.length; @@ -223,8 +227,7 @@ static uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen, } -static void -hash_free_sp_head(void *p) +void hash_free_sp_head(void *p) { sp_head *sp= (sp_head *)p; delete sp; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 9b67a89bed2..cfc21a112db 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -32,6 +32,8 @@ #include <my_user.h> +extern "C" uchar *sp_table_key(const uchar *ptr, size_t *plen, my_bool first); + Item_result sp_map_result_type(enum enum_field_types type) { @@ -483,7 +485,6 @@ sp_head::sp_head() */ m_db= m_name= m_qname= str_reset; - extern uchar *sp_table_key(const uchar *ptr, size_t *plen, my_bool first); DBUG_ENTER("sp_head::sp_head"); m_backpatch.empty(); @@ -1066,6 +1067,12 @@ sp_head::execute(THD *thd) old_arena= thd->stmt_arena; /* + Switch query context. This has to be done early as this is sometimes + allocated trough sql_alloc + */ + saved_creation_ctx= m_creation_ctx->set_n_backup(thd); + + /* We have to save/restore this info when we are changing call level to be able properly do close_thread_tables() in instructions. */ @@ -1110,10 +1117,6 @@ sp_head::execute(THD *thd) */ thd->spcont->callers_arena= &backup_arena; - /* Switch query context. */ - - saved_creation_ctx= m_creation_ctx->set_n_backup(thd); - do { sp_instr *i; @@ -3579,8 +3582,8 @@ typedef struct st_sp_table uint8 trg_event_map; } SP_TABLE; -uchar * -sp_table_key(const uchar *ptr, size_t *plen, my_bool first) + +uchar *sp_table_key(const uchar *ptr, size_t *plen, my_bool first) { SP_TABLE *tab= (SP_TABLE *)ptr; *plen= tab->qname.length; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 91f1570f653..7e017d7d028 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1815,9 +1815,9 @@ static bool update_user_table(THD *thd, TABLE *table, key_copy((uchar *) user_key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0], 0, - (uchar *) user_key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, + (uchar *) user_key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0)); /* purecov: deadcode */ @@ -1908,8 +1908,9 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, key_copy(user_key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0], 0, user_key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, user_key, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { /* what == 'N' means revoke */ if (what == 'N') @@ -2131,8 +2132,9 @@ static int replace_db_table(TABLE *table, const char *db, key_copy(user_key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0],0, user_key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0],0, user_key, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { if (what == 'N') { // no row, no revoke @@ -2348,8 +2350,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) col_privs->field[4]->store("",0, &my_charset_latin1); col_privs->file->ha_index_init(0, 1); - if (col_privs->file->index_read(col_privs->record[0], (uchar*) key, - (key_part_map)15, HA_READ_KEY_EXACT)) + if (col_privs->file->index_read_map(col_privs->record[0], (uchar*) key, + (key_part_map)15, HA_READ_KEY_EXACT)) { cols = 0; /* purecov: deadcode */ col_privs->file->ha_index_end(); @@ -2511,8 +2513,8 @@ static int replace_column_table(GRANT_TABLE *g_t, key_copy(user_key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read(table->record[0], user_key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_map(table->record[0], user_key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { if (revoke_grant) { @@ -2589,8 +2591,9 @@ static int replace_column_table(GRANT_TABLE *g_t, key_copy(user_key, table->record[0], table->key_info, key_prefix_length); - if (table->file->index_read(table->record[0], user_key, (key_part_map)15, - HA_READ_KEY_EXACT)) + if (table->file->index_read_map(table->record[0], user_key, + (key_part_map)15, + HA_READ_KEY_EXACT)) goto end; /* Scan through all rows with the same host,db,user and table */ @@ -2691,8 +2694,9 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, key_copy(user_key, table->record[0], table->key_info, table->key_info->key_length); - if (table->file->index_read_idx(table->record[0], 0, user_key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, user_key, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { /* The following should never happen as we first check the in memory @@ -2816,9 +2820,10 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, TRUE); store_record(table,record[1]); // store at pos 1 - if (table->file->index_read_idx(table->record[0], 0, - (uchar*) table->field[0]->ptr, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (table->file->index_read_idx_map(table->record[0], 0, + (uchar*) table->field[0]->ptr, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { /* The following should never happen as we first check the in memory @@ -5015,9 +5020,9 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, table->key_info->key_part[1].store_length); key_copy(user_key, table->record[0], table->key_info, key_prefix_length); - if ((error= table->file->index_read_idx(table->record[0], 0, - user_key, (key_part_map)3, - HA_READ_KEY_EXACT))) + if ((error= table->file->index_read_idx_map(table->record[0], 0, + user_key, (key_part_map)3, + HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6a082ae3c8b..729a41013c0 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2704,14 +2704,17 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) pthread_mutex_t LOCK_xid_cache; HASH xid_cache; -static uchar *xid_get_hash_key(const uchar *ptr, size_t *length, +extern "C" uchar *xid_get_hash_key(const uchar *, size_t *, my_bool); +extern "C" void xid_free_hash(void *); + +uchar *xid_get_hash_key(const uchar *ptr, size_t *length, my_bool not_used __attribute__((unused))) { *length=((XID_STATE*)ptr)->xid.key_length(); return ((XID_STATE*)ptr)->xid.key(); } -static void xid_free_hash (void *ptr) +void xid_free_hash(void *ptr) { if (!((XID_STATE*)ptr)->in_thd) my_free((uchar*)ptr, MYF(0)); @@ -3245,13 +3248,13 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) RETURN VALUE Error code, or 0 if no error. */ -int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query, +int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, ulong query_len, bool is_trans, bool suppress_use, THD::killed_state killed_status_arg) { DBUG_ENTER("THD::binlog_query"); - DBUG_PRINT("enter", ("qtype=%d, query='%s'", qtype, query)); - DBUG_ASSERT(query && mysql_bin_log.is_open()); + DBUG_PRINT("enter", ("qtype: %d query: '%s'", qtype, query_arg)); + DBUG_ASSERT(query_arg && mysql_bin_log.is_open()); /* If we are not in prelocked mode, mysql_unlock_tables() will be @@ -3307,7 +3310,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query, flush the pending rows event if necessary. */ { - Query_log_event qinfo(this, query, query_len, is_trans, suppress_use, + Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use, killed_status_arg); qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; /* diff --git a/sql/sql_class.h b/sql/sql_class.h index 368d9758b29..b4135511763 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1316,10 +1316,10 @@ public: mode, row-based binlogging is used for such cases where two auto_increment columns are inserted. */ - inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id) + inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg) { if (first_successful_insert_id_in_cur_stmt == 0) - first_successful_insert_id_in_cur_stmt= id; + first_successful_insert_id_in_cur_stmt= id_arg; } inline ulonglong read_first_successful_insert_id_in_prev_stmt(void) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 575db5b80f7..910f4216452 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -59,8 +59,10 @@ typedef struct my_dblock_st lock_db key. */ -static uchar* lock_db_get_key(my_dblock_t *ptr, size_t *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar* lock_db_get_key(my_dblock_t *, size_t *, my_bool not_used); + +uchar* lock_db_get_key(my_dblock_t *ptr, size_t *length, + my_bool not_used __attribute__((unused))) { *length= ptr->name_length; return (uchar*) ptr->name; @@ -71,7 +73,9 @@ static uchar* lock_db_get_key(my_dblock_t *ptr, size_t *length, Free lock_db hash element. */ -static void lock_db_free_element(void *ptr) +extern "C" void lock_db_free_element(void *ptr); + +void lock_db_free_element(void *ptr) { my_free(ptr, MYF(0)); } @@ -155,8 +159,11 @@ typedef struct my_dbopt_st Function we use in the creation of our hash to get key. */ -static uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, + my_bool not_used); + +uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, + my_bool not_used __attribute__((unused))) { *length= opt->name_length; return (uchar*) opt->name; @@ -182,7 +189,9 @@ static inline void write_to_binlog(THD *thd, char *query, uint q_len, Function to free dboptions hash element */ -static void free_dbopt(void *dbopt) +extern "C" void free_dbopt(void *dbopt); + +void free_dbopt(void *dbopt) { my_free((uchar*) dbopt, MYF(0)); } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7d8fc119cf9..e3ee978b964 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -753,7 +753,7 @@ void multi_delete::send_error(uint errcode,const char *err) int multi_delete::do_deletes() { - int local_error= 0, counter= 0, error; + int local_error= 0, counter= 0, tmp_error; bool will_batch; DBUG_ENTER("do_deletes"); DBUG_ASSERT(do_delete); @@ -806,11 +806,11 @@ int multi_delete::do_deletes() break; } } - if (will_batch && (error= table->file->end_bulk_delete())) + if (will_batch && (tmp_error= table->file->end_bulk_delete())) { if (!local_error) { - local_error= error; + local_error= tmp_error; table->file->print_error(local_error,MYF(0)); } } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 300ec7f3c62..0e556f4c551 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -541,8 +541,8 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, table->file->ha_index_or_rnd_end(); table->file->ha_index_init(keyno, 1); key_copy(key, table->record[0], table->key_info + keyno, key_len); - error= table->file->index_read(table->record[0], - key, keypart_map, ha_rkey_mode); + error= table->file->index_read_map(table->record[0], + key, keypart_map, ha_rkey_mode); mode=rkey_to_rnext[(int)ha_rkey_mode]; break; } diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 023bd1fec94..c1962c8c650 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -294,9 +294,9 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, rkey_id->store((longlong) key_id, TRUE); rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW); - int key_res= relations->file->index_read(relations->record[0], - buff, (key_part_map) 1, - HA_READ_KEY_EXACT); + int key_res= relations->file->index_read_map(relations->record[0], + buff, (key_part_map) 1, + HA_READ_KEY_EXACT); for ( ; !key_res && key_id == (int16) rkey_id->val_int() ; @@ -308,8 +308,8 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, field->store((longlong) topic_id, TRUE); field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW); - if (!topics->file->index_read(topics->record[0], topic_id_buff, - (key_part_map)1, HA_READ_KEY_EXACT)) + if (!topics->file->index_read_map(topics->record[0], topic_id_buff, + (key_part_map)1, HA_READ_KEY_EXACT)) { memorize_variant_topic(thd,topics,count,find_fields, names,name,description,example); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 7272d09b575..86a1d15bab4 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1387,9 +1387,9 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } } key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0); - if ((error=(table->file->index_read_idx(table->record[1],key_nr, - (uchar*) key, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)))) + if ((error=(table->file->index_read_idx_map(table->record[1],key_nr, + (uchar*) key, HA_WHOLE_KEY, + HA_READ_KEY_EXACT)))) goto err; } if (info->handle_duplicates == DUP_UPDATE) @@ -3552,13 +3552,13 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) char buf[2048]; String query(buf, sizeof(buf), system_charset_info); int result; - TABLE_LIST table_list; + TABLE_LIST tmp_table_list; - memset(&table_list, 0, sizeof(table_list)); - table_list.table = *tables; + memset(&tmp_table_list, 0, sizeof(tmp_table_list)); + tmp_table_list.table = *tables; query.length(0); // Have to zero it since constructor doesn't - result= store_create_info(thd, &table_list, &query, create_info); + result= store_create_info(thd, &tmp_table_list, &query, create_info); DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */ thd->binlog_query(THD::STMT_QUERY_TYPE, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 055dc1e8424..7c4a3bc3a2f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2822,8 +2822,8 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds, SYNOPSIS set_index_hint_type() - type the kind of hints to be added from now on. - clause the clause to use for hints to be added from now on. + type_arg The kind of hints to be added from now on. + clause The clause to use for hints to be added from now on. DESCRIPTION Used in filling up the tagged hints list. @@ -2832,10 +2832,10 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds, Then the context variable index_hint_type can be reset to the next hint type. */ -void st_select_lex::set_index_hint_type(enum index_hint_type type, +void st_select_lex::set_index_hint_type(enum index_hint_type type_arg, index_clause_map clause) { - current_index_hint_type= type; + current_index_hint_type= type_arg; current_index_hint_clause= clause; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 0d088063462..6da6517b0f5 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1058,8 +1058,12 @@ err: } -static uchar *get_hash_key(const uchar *buff, size_t *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar *get_plugin_hash_key(const uchar *, size_t *, my_bool); +extern "C" uchar *get_bookmark_hash_key(const uchar *, size_t *, my_bool); + + +uchar *get_plugin_hash_key(const uchar *buff, size_t *length, + my_bool not_used __attribute__((unused))) { struct st_plugin_int *plugin= (st_plugin_int *)buff; *length= (uint)plugin->name.length; @@ -1067,8 +1071,8 @@ static uchar *get_hash_key(const uchar *buff, size_t *length, } -static uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, - my_bool not_used __attribute__((unused))) +uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, + my_bool not_used __attribute__((unused))) { struct st_bookmark *var= (st_bookmark *)buff; *length= var->name_len + 1; @@ -1115,7 +1119,7 @@ int plugin_init(int *argc, char **argv, int flags) for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) { if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0, - get_hash_key, NULL, HASH_UNIQUE)) + get_plugin_hash_key, NULL, HASH_UNIQUE)) goto err; } @@ -1702,9 +1706,10 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) table->use_all_columns(); table->field[0]->store(name->str, name->length, system_charset_info); - if (! table->file->index_read_idx(table->record[0], 0, - (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (! table->file->index_read_idx_map(table->record[0], 0, + (uchar *)table->field[0]->ptr, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { int error; if ((error= table->file->ha_delete_row(table->record[0]))) @@ -2769,8 +2774,10 @@ static void plugin_opt_set_limits(struct my_option *options, options->arg_type= OPT_ARG; } +extern "C" my_bool get_one_plugin_option(int optid, const struct my_option *, + char *); -static my_bool get_one_option(int optid __attribute__((unused)), +my_bool get_one_plugin_option(int optid __attribute__((unused)), const struct my_option *opt, char *argument) { @@ -3078,7 +3085,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, DBUG_RETURN(-1); } - error= handle_options(argc, &argv, opts, get_one_option); + error= handle_options(argc, &argv, opts, get_one_plugin_option); (*argc)++; /* add back one for the program name */ if (error) @@ -3140,7 +3147,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, DBUG_RETURN(0); } - if (enabled_saved) + if (enabled_saved && global_system_variables.log_warnings) sql_print_information("Plugin '%s' disabled by command line option", tmp->name.str); DBUG_RETURN(1); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c1c3999bc8e..7cd5d1be8bf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11153,10 +11153,10 @@ int safe_index_read(JOIN_TAB *tab) { int error; TABLE *table= tab->table; - if ((error=table->file->index_read(table->record[0], - tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT))) + if ((error=table->file->index_read_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT))) return report_error(table, error); return 0; } @@ -11292,10 +11292,10 @@ join_read_const(JOIN_TAB *tab) error=HA_ERR_KEY_NOT_FOUND; else { - error=table->file->index_read_idx(table->record[0],tab->ref.key, - (uchar*) tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT); + error=table->file->index_read_idx_map(table->record[0],tab->ref.key, + (uchar*) tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT); } if (error) { @@ -11336,10 +11336,10 @@ join_read_key(JOIN_TAB *tab) table->status=STATUS_NOT_FOUND; return -1; } - error=table->file->index_read(table->record[0], - tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT); + error=table->file->index_read_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT); if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) return report_error(table, error); } @@ -11365,10 +11365,10 @@ join_read_always_key(JOIN_TAB *tab) } if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref)) return -1; - if ((error=table->file->index_read(table->record[0], - tab->ref.key_buff, - make_prev_keypart_map(tab->ref.key_parts), - HA_READ_KEY_EXACT))) + if ((error=table->file->index_read_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts), + HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) return report_error(table, error); @@ -11393,8 +11393,9 @@ join_read_last_key(JOIN_TAB *tab) table->file->ha_index_init(tab->ref.key, tab->sorted); if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref)) return -1; - if ((error=table->file->index_read_last(table->record[0], - tab->ref.key_buff, make_prev_keypart_map(tab->ref.key_parts)))) + if ((error=table->file->index_read_last_map(table->record[0], + tab->ref.key_buff, + make_prev_keypart_map(tab->ref.key_parts)))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) return report_error(table, error); @@ -11934,9 +11935,10 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), if (item->maybe_null) group->buff[-1]= (char) group->field->is_null(); } - if (!table->file->index_read(table->record[1], - join->tmp_table_param.group_buff, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (!table->file->index_read_map(table->record[1], + join->tmp_table_param.group_buff, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { /* Update old record */ restore_record(table,record[1]); update_tmptable_sum_func(join->sum_funcs,table); diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index 911372d5f4e..a780c561ffe 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -516,9 +516,10 @@ int insert_server_record(TABLE *table, FOREIGN_SERVER *server) system_charset_info); /* read index until record is that specified in server_name */ - if ((error= table->file->index_read_idx(table->record[0], 0, - (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, - HA_READ_KEY_EXACT))) + if ((error= table->file->index_read_idx_map(table->record[0], 0, + (uchar *)table->field[0]->ptr, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT))) { /* if not found, err */ if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) @@ -858,9 +859,10 @@ update_server_record(TABLE *table, FOREIGN_SERVER *server) server->server_name_length, system_charset_info); - if ((error= table->file->index_read_idx(table->record[0], 0, - (uchar *)table->field[0]->ptr, ~(longlong)0, - HA_READ_KEY_EXACT))) + if ((error= table->file->index_read_idx_map(table->record[0], 0, + (uchar *)table->field[0]->ptr, + ~(longlong)0, + HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) table->file->print_error(error, MYF(0)); @@ -914,9 +916,10 @@ delete_server_record(TABLE *table, /* set the field that's the PK to the value we're looking for */ table->field[0]->store(server_name, server_name_length, system_charset_info); - if ((error= table->file->index_read_idx(table->record[0], 0, - (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, - HA_READ_KEY_EXACT))) + if ((error= table->file->index_read_idx_map(table->record[0], 0, + (uchar *)table->field[0]->ptr, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) table->file->print_error(error, MYF(0)); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4a863df64d1..a9465a3f0d5 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1347,6 +1347,11 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, packet->append(STRING_WITH_LEN(" ROW_FORMAT=")); packet->append(ha_row_type[(uint) share->row_type]); } + if (share->transactional != HA_CHOICE_UNDEF) + { + packet->append(STRING_WITH_LEN(" TRANSACTIONAL=")); + packet->append(share->transactional == HA_CHOICE_YES ? "1" : "0", 1); + } if (table->s->key_block_size) { char *end; @@ -2899,7 +2904,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, case ROW_TYPE_COMPACT: tmp_buff= "Compact"; break; - case ROW_TYPE_PAGES: + case ROW_TYPE_PAGE: tmp_buff= "Paged"; break; } @@ -2983,6 +2988,12 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, ptr=strxmov(ptr, " row_format=", ha_row_type[(uint) share->row_type], NullS); + if (share->transactional != HA_CHOICE_UNDEF) + { + ptr= strxmov(ptr, " TRANSACTIONAL=", + (share->transactional == HA_CHOICE_YES ? "1" : "0"), + NullS); + } #ifdef WITH_PARTITION_STORAGE_ENGINE if (show_table->s->db_type() == partition_hton && show_table->part_info != NULL && diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 6c7dea6bf22..a8eb7360339 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -795,10 +795,8 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, const uchar *from_end= (const uchar*) from+from_length; char *to_start= to; uchar *to_end= (uchar*) to+to_length; - int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, - const uchar *) = from_cs->cset->mb_wc; - int (*wc_mb)(struct charset_info_st *, my_wc_t, uchar *s, uchar *e)= - to_cs->cset->wc_mb; + my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; + my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; uint error_count= 0; while (1) @@ -940,10 +938,8 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs, { int cnvres; my_wc_t wc; - int (*mb_wc)(struct charset_info_st *, my_wc_t *, - const uchar *, const uchar *)= from_cs->cset->mb_wc; - int (*wc_mb)(struct charset_info_st *, my_wc_t, - uchar *s, uchar *e)= to_cs->cset->wc_mb; + my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; + my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; const uchar *from_end= (const uchar*) from + from_length; uchar *to_end= (uchar*) to + to_length; char *to_start= to; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9746080e9cd..345607810a9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5279,6 +5279,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) create_info->key_block_size= table->s->key_block_size; + if (!(used_fields & HA_CREATE_USED_TRANSACTIONAL)) + create_info->transactional= table->s->transactional; if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY) { diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 10bb7844d88..19582af38f4 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -551,9 +551,10 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) goto err; table->use_all_columns(); table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin); - if (!table->file->index_read_idx(table->record[0], 0, - (uchar*) table->field[0]->ptr, HA_WHOLE_KEY, - HA_READ_KEY_EXACT)) + if (!table->file->index_read_idx_map(table->record[0], 0, + (uchar*) table->field[0]->ptr, + HA_WHOLE_KEY, + HA_READ_KEY_EXACT)) { int error; if ((error = table->file->ha_delete_row(table->record[0]))) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 81bb1c2dae9..5453f783398 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -857,6 +857,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token OUT_SYM /* SQL-2003-R */ %token OWNER_SYM %token PACK_KEYS_SYM +%token PAGE_SYM %token PARAM_MARKER %token PARSER_SYM %token PARTIAL /* SQL-2003-N */ @@ -1009,6 +1010,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TO_SYM /* SQL-2003-R */ %token TRAILING /* SQL-2003-R */ %token TRANSACTION_SYM +%token TRANSACTIONAL_SYM %token TRIGGERS_SYM %token TRIGGER_SYM /* SQL-2003-R */ %token TRIM /* SQL-2003-N */ @@ -4364,6 +4366,12 @@ create_table_option: Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE; Lex->create_info.key_block_size= $3; } + | TRANSACTIONAL_SYM opt_equal ulong_num + { + Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL; + Lex->create_info.transactional= ($3 != 0 ? HA_CHOICE_YES : + HA_CHOICE_NO); + } ; default_charset: @@ -4442,7 +4450,8 @@ row_types: | DYNAMIC_SYM { $$= ROW_TYPE_DYNAMIC; } | COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; } | REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; } - | COMPACT_SYM { $$= ROW_TYPE_COMPACT; }; + | COMPACT_SYM { $$= ROW_TYPE_COMPACT; } + | PAGE_SYM { $$= ROW_TYPE_PAGE; }; merge_insert_types: NO_SYM { $$= MERGE_INSERT_DISABLED; } @@ -10034,6 +10043,7 @@ keyword_sp: | ONE_SHOT_SYM {} | ONE_SYM {} | PACK_KEYS_SYM {} + | PAGE_SYM {} | PARTIAL {} | PARTITIONING_SYM {} | PARTITIONS_SYM {} @@ -10103,6 +10113,7 @@ keyword_sp: | TEXT_SYM {} | THAN_SYM {} | TRANSACTION_SYM {} + | TRANSACTIONAL_SYM {} | TRIGGERS_SYM {} | TIMESTAMP {} | TIMESTAMP_ADD {} diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 9ffc5fd127f..c03365cfc2b 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -265,10 +265,8 @@ uint strconvert(CHARSET_INFO *from_cs, const char *from, my_wc_t wc; char *to_start= to; uchar *to_end= (uchar*) to + to_length - 1; - int (*mb_wc)(struct charset_info_st *, my_wc_t *, const uchar *, - const uchar *)= from_cs->cset->mb_wc; - int (*wc_mb)(struct charset_info_st *, my_wc_t, uchar *s, uchar *e)= - to_cs->cset->wc_mb; + my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; + my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; uint error_count= 0; while (1) diff --git a/sql/table.cc b/sql/table.cc index 7be78e0be98..e6c47a89d21 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -51,11 +51,13 @@ inline bool is_system_table_name(const char *name, uint length); Object_creation_ctx *Object_creation_ctx::set_n_backup(THD *thd) { - Object_creation_ctx *backup_ctx= create_backup_ctx(thd); + Object_creation_ctx *backup_ctx; + DBUG_ENTER("Object_creation_ctx::set_n_backup"); + backup_ctx= create_backup_ctx(thd); change_env(thd); - return backup_ctx; + DBUG_RETURN(backup_ctx); } void Object_creation_ctx::restore_env(THD *thd, Object_creation_ctx *backup_ctx) @@ -84,7 +86,7 @@ Default_object_creation_ctx::Default_object_creation_ctx( { } Object_creation_ctx * -Default_object_creation_ctx::create_backup_ctx(THD *thd) +Default_object_creation_ctx::create_backup_ctx(THD *thd) const { return new Default_object_creation_ctx(thd); } @@ -695,7 +697,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (!head[32]) // New frm file in 3.23 { share->avg_row_length= uint4korr(head+34); - share-> row_type= (row_type) head[40]; + share->transactional= (ha_choice) head[39]; + share->row_type= (row_type) head[40]; share->table_charset= get_charset((uint) head[38],MYF(0)); share->null_field_first= 1; } @@ -2417,6 +2420,7 @@ File create_frm(THD *thd, const char *name, const char *db, int4store(fileinfo+34,create_info->avg_row_length); fileinfo[38]= (create_info->default_table_charset ? create_info->default_table_charset->number : 0); + fileinfo[39]= (uchar) create_info->transactional; fileinfo[40]= (uchar) create_info->row_type; /* Next few bytes were for RAID support */ fileinfo[41]= 0; @@ -4548,11 +4552,11 @@ Item_subselect *TABLE_LIST::containing_subselect() FALSE no errors found TRUE found and reported an error. */ -bool TABLE_LIST::process_index_hints(TABLE *table) +bool TABLE_LIST::process_index_hints(TABLE *tbl) { /* initialize the result variables */ - table->keys_in_use_for_query= table->keys_in_use_for_group_by= - table->keys_in_use_for_order_by= table->s->keys_in_use; + tbl->keys_in_use_for_query= tbl->keys_in_use_for_group_by= + tbl->keys_in_use_for_order_by= tbl->s->keys_in_use; /* index hint list processing */ if (index_hints) @@ -4604,8 +4608,8 @@ bool TABLE_LIST::process_index_hints(TABLE *table) Check if an index with the given name exists and get his offset in the keys bitmask for the table */ - if (table->s->keynames.type_names == 0 || - (pos= find_type(&table->s->keynames, hint->key_name.str, + if (tbl->s->keynames.type_names == 0 || + (pos= find_type(&tbl->s->keynames, hint->key_name.str, hint->key_name.length, 1)) <= 0) { my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), hint->key_name.str, alias); @@ -4641,7 +4645,7 @@ bool TABLE_LIST::process_index_hints(TABLE *table) !index_order[INDEX_HINT_FORCE].is_clear_all() || !index_group[INDEX_HINT_FORCE].is_clear_all()) { - table->force_index= TRUE; + tbl->force_index= TRUE; index_join[INDEX_HINT_USE].merge(index_join[INDEX_HINT_FORCE]); index_order[INDEX_HINT_USE].merge(index_order[INDEX_HINT_FORCE]); index_group[INDEX_HINT_USE].merge(index_group[INDEX_HINT_FORCE]); @@ -4649,20 +4653,20 @@ bool TABLE_LIST::process_index_hints(TABLE *table) /* apply USE INDEX */ if (!index_join[INDEX_HINT_USE].is_clear_all() || have_empty_use_join) - table->keys_in_use_for_query.intersect(index_join[INDEX_HINT_USE]); + tbl->keys_in_use_for_query.intersect(index_join[INDEX_HINT_USE]); if (!index_order[INDEX_HINT_USE].is_clear_all() || have_empty_use_order) - table->keys_in_use_for_order_by.intersect (index_order[INDEX_HINT_USE]); + tbl->keys_in_use_for_order_by.intersect (index_order[INDEX_HINT_USE]); if (!index_group[INDEX_HINT_USE].is_clear_all() || have_empty_use_group) - table->keys_in_use_for_group_by.intersect (index_group[INDEX_HINT_USE]); + tbl->keys_in_use_for_group_by.intersect (index_group[INDEX_HINT_USE]); /* apply IGNORE INDEX */ - table->keys_in_use_for_query.subtract (index_join[INDEX_HINT_IGNORE]); - table->keys_in_use_for_order_by.subtract (index_order[INDEX_HINT_IGNORE]); - table->keys_in_use_for_group_by.subtract (index_group[INDEX_HINT_IGNORE]); + tbl->keys_in_use_for_query.subtract (index_join[INDEX_HINT_IGNORE]); + tbl->keys_in_use_for_order_by.subtract (index_order[INDEX_HINT_IGNORE]); + tbl->keys_in_use_for_group_by.subtract (index_group[INDEX_HINT_IGNORE]); } /* make sure covering_keys don't include indexes disabled with a hint */ - table->covering_keys.intersect(table->keys_in_use_for_query); + tbl->covering_keys.intersect(tbl->keys_in_use_for_query); return 0; } diff --git a/sql/table.h b/sql/table.h index e46036f3ee9..ee2b78bde1a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -310,6 +310,7 @@ typedef struct st_table_share } enum row_type row_type; /* How rows are stored */ enum tmp_table_type tmp_table; + enum ha_choice transactional; uint ref_count; /* How many TABLE objects uses this */ uint open_count; /* Number of tables in open list */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 14192d06978..9eb38e97827 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1854,8 +1854,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ (void)table->file->ha_index_init(0, 1); - if (table->file->index_read(table->record[0], table->field[0]->ptr, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)) + if (table->file->index_read_map(table->record[0], table->field[0]->ptr, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { #ifdef EXTRA_DEBUG /* @@ -1881,8 +1881,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - if (table->file->index_read(table->record[0], table->field[0]->ptr, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)) + if (table->file->index_read_map(table->record[0], table->field[0]->ptr, + HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { sql_print_error("Can't find description of time zone '%u'", tzid); goto end; @@ -1908,8 +1908,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read(table->record[0], table->field[0]->ptr, - (key_part_map)1, HA_READ_KEY_EXACT); + res= table->file->index_read_map(table->record[0], table->field[0]->ptr, + (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { ttid= (uint)table->field[1]->val_int(); @@ -1979,8 +1979,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read(table->record[0], table->field[0]->ptr, - (key_part_map)1, HA_READ_KEY_EXACT); + res= table->file->index_read_map(table->record[0], table->field[0]->ptr, + (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { ttime= (my_time_t)table->field[1]->val_int(); |