diff options
author | unknown <jani@labbari.dsl.inet.fi> | 2007-07-07 18:33:43 +0300 |
---|---|---|
committer | unknown <jani@labbari.dsl.inet.fi> | 2007-07-07 18:33:43 +0300 |
commit | ebd53ca2e62f85422afe1be0d57eb7aed1642bb1 (patch) | |
tree | 623b353a97b3365385e155d0555fb04f42e8a802 /sql | |
parent | d4e6d4b2c1fba6d198c1f02967dd1b038a092068 (diff) | |
parent | 1ea806b1748c4ffc0904021d7d1e938fe837d73e (diff) | |
download | mariadb-git-ebd53ca2e62f85422afe1be0d57eb7aed1642bb1.tar.gz |
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into labbari.dsl.inet.fi:/home/my/bk/mysql-maria.prod
BitKeeper/etc/ignore:
auto-union
client/mysqldump.c:
Auto merged
include/my_base.h:
Auto merged
include/my_sys.h:
Auto merged
mysql-test/lib/mtr_cases.pl:
Auto merged
mysql-test/lib/mtr_report.pl:
Auto merged
mysql-test/r/ps_2myisam.result:
Auto merged
mysql-test/r/ps_3innodb.result:
Auto merged
mysql-test/r/ps_4heap.result:
Auto merged
mysql-test/r/ps_5merge.result:
Auto merged
mysql-test/r/ps_7ndb.result:
Auto merged
mysql-test/r/view.result:
Auto merged
mysql-test/t/disabled.def:
Auto merged
mysql-test/t/view.test:
Auto merged
sql/Makefile.am:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/handler.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/share/errmsg.txt:
Auto merged
sql/table.cc:
Auto merged
sql/table.h:
Auto merged
storage/myisam/mi_key.c:
Auto merged
storage/myisam/mi_open.c:
Merged with main 5.1.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 12 | ||||
-rw-r--r-- | sql/gen_lex_hash.cc | 4 | ||||
-rw-r--r-- | sql/handler.cc | 104 | ||||
-rw-r--r-- | sql/handler.h | 22 | ||||
-rw-r--r-- | sql/item_func.cc | 1 | ||||
-rw-r--r-- | sql/item_func.h | 1 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 2 | ||||
-rw-r--r-- | sql/lex.h | 2 | ||||
-rw-r--r-- | sql/lock.cc | 4 | ||||
-rw-r--r-- | sql/log.cc | 5 | ||||
-rw-r--r-- | sql/mysql_priv.h | 7 | ||||
-rw-r--r-- | sql/mysqld.cc | 168 | ||||
-rw-r--r-- | sql/opt_range.cc | 1 | ||||
-rw-r--r-- | sql/set_var.cc | 192 | ||||
-rw-r--r-- | sql/set_var.h | 41 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sql_class.h | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 5 | ||||
-rw-r--r-- | sql/sql_show.cc | 9 | ||||
-rw-r--r-- | sql/sql_sort.h | 11 | ||||
-rw-r--r-- | sql/sql_table.cc | 3 | ||||
-rw-r--r-- | sql/sql_test.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 13 | ||||
-rw-r--r-- | sql/table.cc | 8 | ||||
-rw-r--r-- | sql/table.h | 1 | ||||
-rw-r--r-- | sql/uniques.cc | 2 | ||||
-rw-r--r-- | sql/unireg.cc | 6 |
28 files changed, 558 insertions, 80 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index b1dfb4d5e71..0012bebf688 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -457,7 +457,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ref_pos= ref_buff; quick_select=select && select->quick; record=0; - flag= ((!indexfile && file->ha_table_flags() & HA_REC_NOT_IN_SEQ) + flag= ((!indexfile && (file->ha_table_flags() & HA_REC_NOT_IN_SEQ)) || quick_select); if (indexfile || flag) ref_pos= &file->ref[0]; @@ -1146,7 +1146,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, offset= rec_length-res_length; maxcount= (ulong) (param->keys/((uint) (Tb-Fb) +1)); to_start_filepos= my_b_tell(to_file); - strpos= (uchar*) sort_buffer; + strpos= sort_buffer; org_max_rows=max_rows= param->max_rows; /* The following will fire if there is not enough space in sort_buffer */ @@ -1158,10 +1158,10 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, DBUG_RETURN(1); /* purecov: inspected */ for (buffpek= Fb ; buffpek <= Tb ; buffpek++) { - buffpek->base= strpos; + buffpek->base= (uchar*) strpos; buffpek->max_keys= maxcount; strpos+= (uint) (error= (int) read_to_buffer(from_file, buffpek, - rec_length)); + rec_length)); if (error == -1) goto err; /* purecov: inspected */ buffpek->max_keys= buffpek->mem_count; // If less data in buffers than expected @@ -1250,7 +1250,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, } } buffpek= (BUFFPEK*) queue_top(&queue); - buffpek->base= sort_buffer; + buffpek->base= (uchar*) sort_buffer; buffpek->max_keys= param->keys; /* @@ -1285,7 +1285,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, else { register uchar *end; - strpos= buffpek->key+offset; + strpos= (uchar*) buffpek->key+offset; for (end= strpos+buffpek->mem_count*rec_length ; strpos != end ; strpos+= rec_length) diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 36b7f30dc64..18f80e11a15 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -481,8 +481,8 @@ int main(int argc,char **argv) printf("\nstatic unsigned int symbols_max_len=%d;\n\n", max_len2); printf("\ -static inline SYMBOL *get_hash_symbol(const char *s,\n\ - unsigned int len,bool function)\n\ +static SYMBOL *get_hash_symbol(const char *s,\n\ + unsigned int len,bool function)\n\ {\n\ register uchar *hash_map;\n\ register const char *cur_str= s;\n\ diff --git a/sql/handler.cc b/sql/handler.cc index 2d836b30862..cbe32dd4529 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -30,6 +30,10 @@ #include <myisampack.h> #include <errno.h> +#ifdef WITH_MARIA_STORAGE_ENGINE +#include <maria.h> +#endif + #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" #endif @@ -64,7 +68,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[] = @@ -292,7 +296,8 @@ handler *get_ha_partition(partition_info *part_info) 0 OK != 0 Error */ -static int ha_init_errors(void) + +int ha_init_errors(void) { #define SETMSG(nr, msg) errmsgs[(nr) - HA_ERR_FIRST]= (msg) const char **errmsgs; @@ -507,9 +512,6 @@ int ha_init() int error= 0; DBUG_ENTER("ha_init"); - if (ha_init_errors()) - DBUG_RETURN(1); - DBUG_ASSERT(total_ha < MAX_HA); /* Check if there is a transaction-capable storage engine besides the @@ -2789,6 +2791,98 @@ int ha_change_key_cache(KEY_CACHE *old_key_cache, } +/***************************************************************************** + pagecache handling. + + This code is only relevant for maria tables + + pagecache->cache may be 0 only in the case where a key cache is not + initialized or when we where not able to init the key cache in a previous + call to ha_init_pagecache() (probably out of memory) +*****************************************************************************/ + + +#ifdef WITH_MARIA_STORAGE_ENGINE + +/* Init a pagecache if it has not been initied before */ + +int ha_init_pagecache(const char *name, PAGECACHE *pagecache) +{ + DBUG_ENTER("ha_init_key_cache"); + + if (!pagecache->inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp_buff_size= (long) pagecache->param_buff_size; + uint division_limit= pagecache->param_division_limit; + uint age_threshold= pagecache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + DBUG_RETURN(!init_pagecache(pagecache, + tmp_buff_size, division_limit, age_threshold, + MARIA_KEY_BLOCK_LENGTH)); + } + DBUG_RETURN(0); +} + + +/* Resize key cache */ +/* +TODO: uncomment when resize will be implemented +int ha_resize_pagecache(PAGECACHE *pagecache) +{ + DBUG_ENTER("ha_resize_pagecache"); + + if (pagecache->inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp_buff_size= (long) pagecache->param_buff_size; + long tmp_block_size= (long) pagecache->param_block_size; + uint division_limit= pagecache->param_division_limit; + uint age_threshold= pagecache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + DBUG_RETURN(!resize_pagecache(pagecache, tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); + } + DBUG_RETURN(0); +} +*/ + + +/* Change parameters for key cache (like size) */ + +int ha_change_pagecache_param(PAGECACHE *pagecache) +{ + if (pagecache->inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + uint division_limit= pagecache->param_division_limit; + uint age_threshold= pagecache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + change_pagecache_param(pagecache, division_limit, age_threshold); + } + return 0; +} + +/* Free memory allocated by a key cache */ + +int ha_end_pagecache(PAGECACHE *pagecache) +{ + end_pagecache(pagecache, 1); // Can never fail + return 0; +} + +/* Move all tables from one key cache to another one */ + +int ha_change_pagecache(PAGECACHE *old_pagecache, + PAGECACHE *new_pagecache) +{ + maria_change_pagecache(old_pagecache, new_pagecache); + return 0; +} + +#endif /* WITH_MARIA_STORAGE_ENGINE */ + /** @brief Try to discover one table from handler(s) diff --git a/sql/handler.h b/sql/handler.h index 4095a2f4cb1..6805876ff49 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -20,8 +20,10 @@ #pragma interface /* gcc class implementation */ #endif +#include <my_handler.h> #include <ft_global.h> #include <keycache.h> +#include "../storage/maria/ma_pagecache.h" #ifndef NO_HASH #define NO_HASH /* Not yet implemented */ @@ -272,13 +274,14 @@ enum legacy_db_type DB_TYPE_TABLE_FUNCTION, DB_TYPE_MEMCACHE, DB_TYPE_FALCON, + DB_TYPE_MARIA, DB_TYPE_FIRST_DYNAMIC=42, DB_TYPE_DEFAULT=127 // Must be last }; 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 +324,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" @@ -751,6 +755,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 { @@ -773,6 +778,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 */ @@ -851,7 +858,8 @@ typedef struct st_ha_check_opt ulong sort_buffer_size; uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ - KEY_CACHE *key_cache; /* new key cache when changing key cache */ + KEY_CACHE *key_cache; /* new key cache when changing key cache */ + PAGECACHE *pagecache; /* new pagecache when changing pagecache */ void init(); } HA_CHECK_OPT; @@ -1775,6 +1783,7 @@ static inline bool ha_storage_engine_is_enabled(const handlerton *db_type) } /* basic stuff */ +int ha_init_errors(void); int ha_init(void); int ha_end(void); int ha_initialize_handlerton(st_plugin_int *plugin); @@ -1809,6 +1818,15 @@ 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); int ha_end_key_cache(KEY_CACHE *key_cache); +/* pagecache */ +int ha_init_pagecache(const char *name, PAGECACHE *pagecache); +/* +TODO: uncomment when resizing will be implemented +int ha_resize_pagecache(PAGECACHE *pagecache); +*/ +int ha_change_pagecache_param(PAGECACHE *pagecache); +int ha_change_pagecache(PAGECACHE *old_pagecache, PAGECACHE *new_pagecache); +int ha_end_pagecache(PAGECACHE *pagecache); /* report to InnoDB that control passes to the client */ int ha_release_temporary_latches(THD *thd); diff --git a/sql/item_func.cc b/sql/item_func.cc index f14091b4592..5a41aa3e9da 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -27,6 +27,7 @@ #include <hash.h> #include <time.h> #include <ft_global.h> +#include <my_bit.h> #include "sp_head.h" #include "sp_rcontext.h" diff --git a/sql/item_func.h b/sql/item_func.h index 8fc68f93e12..347a4a1f084 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1368,7 +1368,6 @@ public: /* for fulltext search */ -#include <ft_global.h> class Item_func_match :public Item_real_func { diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index f8457a1ae50..6bc73f49a5a 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2767,7 +2767,7 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) { char buf[128]; - my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s", + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %u: %s", my_xml_error_lineno(&p) + 1, my_xml_error_pos(&p) + 1, my_xml_error_string(&p)); diff --git a/sql/lex.h b/sql/lex.h index e311379120d..5f24b06cf05 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -380,6 +380,7 @@ static SYMBOL symbols[] = { { "OWNER", SYM(OWNER_SYM)}, { "PACK_KEYS", SYM(PACK_KEYS_SYM)}, { "PARSER", SYM(PARSER_SYM)}, + { "PAGE", SYM(PAGE_SYM)}, { "PARTIAL", SYM(PARTIAL)}, { "PARTITION", SYM(PARTITION_SYM)}, { "PARTITIONING", SYM(PARTITIONING_SYM)}, @@ -529,6 +530,7 @@ static SYMBOL symbols[] = { { "TO", SYM(TO_SYM)}, { "TRAILING", SYM(TRAILING)}, { "TRANSACTION", SYM(TRANSACTION_SYM)}, + { "TRANSACTIONAL", SYM(TRANSACTIONAL_SYM)}, { "TRIGGER", SYM(TRIGGER_SYM)}, { "TRIGGERS", SYM(TRIGGERS_SYM)}, { "TRUE", SYM(TRUE_SYM)}, diff --git a/sql/lock.cc b/sql/lock.cc index 50922a682a2..e129da27005 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -289,10 +289,10 @@ static int lock_external(THD *thd, TABLE **tables, uint count) void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock) { DBUG_ENTER("mysql_unlock_tables"); - if (sql_lock->lock_count) - thr_multi_unlock(sql_lock->locks,sql_lock->lock_count); if (sql_lock->table_count) VOID(unlock_external(thd,sql_lock->table,sql_lock->table_count)); + if (sql_lock->lock_count) + thr_multi_unlock(sql_lock->locks,sql_lock->lock_count); my_free((uchar*) sql_lock,MYF(0)); DBUG_VOID_RETURN; } diff --git a/sql/log.cc b/sql/log.cc index 6dc204265b0..1a7ec087c51 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2413,6 +2413,11 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, my_seek(index_file_nr,0L,MY_SEEK_END,MYF(0)), 0, MYF(MY_WME | MY_WAIT_IF_FULL))) { + /* + TODO: all operations creating/deleting the index file or a log, should + call my_sync_dir() or my_sync_dir_by_file() to be durable. + TODO: file creation should be done with my_create() not my_open(). + */ if (index_file_nr >= 0) my_close(index_file_nr,MYF(0)); return TRUE; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index ae7c4ca5f3f..dfcd86a4758 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1726,7 +1726,7 @@ extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout, slave_trans_retries; extern uint max_user_connections; extern ulong what_to_log,flush_time; -extern ulong query_buff_size, thread_stack; +extern ulong query_buff_size; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; extern ulong max_binlog_size, max_relay_log_size; @@ -1800,6 +1800,9 @@ extern pthread_cond_t COND_global_read_lock; extern pthread_attr_t connection_attrib; extern I_List<THD> threads; extern I_List<NAMED_LIST> key_caches; +#ifdef WITH_MARIA_STORAGE_ENGINE +extern I_List<NAMED_LIST> pagecaches; +#endif /* WITH_MARIA_STORAGE_ENGINE */ extern MY_BITMAP temp_pool; extern String my_empty_string; extern const String my_null_string; @@ -1825,7 +1828,7 @@ extern uint sql_command_flags[]; extern TYPELIB log_output_typelib; /* optional things, have_* variables */ - +extern SHOW_COMP_OPTION have_maria_db; extern handlerton *partition_hton; extern handlerton *myisam_hton; extern handlerton *heap_hton; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 39a7c4e9095..57d8a89a3c1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -16,6 +16,7 @@ #include "mysql_priv.h" #include <m_ctype.h> #include <my_dir.h> +#include <my_bit.h> #include "slave.h" #include "rpl_mi.h" #include "sql_repl.h" @@ -27,6 +28,9 @@ #include "events.h" #include "../storage/myisam/ha_myisam.h" +#ifdef WITH_MARIA_STORAGE_ENGINE +#include "../storage/maria/ha_maria.h" +#endif #include "rpl_injector.h" @@ -439,7 +443,7 @@ uint volatile thread_count, thread_running; ulonglong thd_startup_options; ulong back_log, connect_timeout, concurrency, server_id; ulong table_cache_size, table_def_size; -ulong thread_stack, what_to_log; +ulong what_to_log; ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_net_timeout, slave_trans_retries; @@ -500,6 +504,7 @@ char *mysqld_unix_port, *opt_mysql_tmpdir; const char **errmesg; /* Error messages */ const char *myisam_recover_options_str="OFF"; const char *myisam_stats_method_str="nulls_unequal"; +const char *maria_stats_method_str="nulls_unequal"; /* name of reference on left espression in rewritten IN subquery */ const char *in_left_expr_name= "<left expr>"; @@ -522,6 +527,9 @@ FILE *stderror_file=0; I_List<THD> threads; I_List<NAMED_LIST> key_caches; +#ifdef WITH_MARIA_STORAGE_ENGINE +I_List<NAMED_LIST> pagecaches; +#endif /* WITH_MARIA_STORAGE_ENGINE */ Rpl_filter* rpl_filter; Rpl_filter* binlog_filter; @@ -540,7 +548,7 @@ MY_LOCALE *my_default_lc_time_names; SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen, have_query_cache; SHOW_COMP_OPTION have_geometry, have_rtree_keys; -SHOW_COMP_OPTION have_crypt, have_compress; +SHOW_COMP_OPTION have_crypt, have_compress, have_maria_db; /* Thread specific variables */ @@ -1201,7 +1209,13 @@ void clean_up(bool print_message) tc_log->close(); xid_cache_free(); delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache); +#ifdef WITH_MARIA_STORAGE_ENGINE + delete_elements(&pagecaches, (void (*)(const char*, uchar*)) free_pagecache); +#endif /* WITH_MARIA_STORAGE_ENGINE */ multi_keycache_free(); +#ifdef WITH_MARIA_STORAGE_ENGINE + multi_pagecache_free(); +#endif free_status_vars(); end_thr_alarm(1); /* Free allocated memory */ my_free_open_file_info(); @@ -2190,6 +2204,10 @@ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", (ulong) dflt_key_cache->key_cache_mem_size); +#ifdef WITH_MARIA_STORAGE_ENGINE + fprintf(stderr, "page_buffer_size=%lu\n", + (ulong) maria_pagecache->mem_size); +#endif /* WITH_MARIA_STORAGE_ENGINE */ fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%lu\n", max_used_connections); fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads); @@ -2197,6 +2215,9 @@ and this may fail.\n\n"); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\ bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + +#ifdef WITH_MARIA_STORAGE_ENGINE + (ulong) maria_pagecache->mem_size + +#endif /* WITH_MARIA_STORAGE_ENGINE */ (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * thread_scheduler.max_threads + @@ -2220,7 +2241,7 @@ the thread stack. Please read http://www.mysql.com/doc/en/Linux.html\n\n", { fprintf(stderr,"thd: 0x%lx\n",(long) thd); print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0, - thread_stack); + my_thread_stack_size); } if (thd) { @@ -2379,9 +2400,9 @@ static void start_signal_handler(void) Peculiar things with ia64 platforms - it seems we only have half the stack size in reality, so we have to double it here */ - pthread_attr_setstacksize(&thr_attr,thread_stack*2); + pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2); #else - pthread_attr_setstacksize(&thr_attr,thread_stack); + pthread_attr_setstacksize(&thr_attr,my_thread_stack_size); #endif #endif @@ -2780,6 +2801,16 @@ static int init_common_variables(const char *conf_file_name, int argc, get_options(&defaults_argc, defaults_argv); set_server_version(); +#ifdef WITH_MARIA_STORAGE_ENGINE + if (!(maria_pagecache= get_or_create_pagecache(maria_pagecache_base.str, + maria_pagecache_base.length))) + exit(1); +/* + maria_pagecache->param_buff_size= maria_pagecache_var.param_buff_size; + maria_pagecache->param_block_size= maria_block_size; +*/ +#endif + DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, server_version, SYSTEM_TYPE,MACHINE_TYPE)); @@ -3386,6 +3417,10 @@ server."); using_update_log=1; } + /* Allow storage engine to give real error messages */ + if (ha_init_errors()) + DBUG_RETURN(1); + if (plugin_init(&defaults_argc, defaults_argv, (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) | (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0))) @@ -3554,6 +3589,9 @@ server."); /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache); +#ifdef WITH_MARIA_STORAGE_ENGINE + process_pagecaches(&ha_init_pagecache); +#endif /* WITH_MARIA_STORAGE_ENGINE */ #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY) if (locked_in_memory && !getuid()) @@ -3744,9 +3782,9 @@ int main(int argc, char **argv) Peculiar things with ia64 platforms - it seems we only have half the stack size in reality, so we have to double it here */ - pthread_attr_setstacksize(&connection_attrib,thread_stack*2); + pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2); #else - pthread_attr_setstacksize(&connection_attrib,thread_stack); + pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size); #endif #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE { @@ -3757,15 +3795,15 @@ int main(int argc, char **argv) stack_size/= 2; #endif /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ - if (stack_size && stack_size < thread_stack) + if (stack_size && stack_size < my_thread_stack_size) { if (global_system_variables.log_warnings) sql_print_warning("Asked for %lu thread stack, but got %ld", - thread_stack, (long) stack_size); + my_thread_stack_size, (long) stack_size); #if defined(__ia64__) || defined(__ia64) - thread_stack= stack_size*2; + my_thread_stack_size= stack_size*2; #else - thread_stack= stack_size; + my_thread_stack_size= stack_size; #endif } } @@ -5009,10 +5047,17 @@ enum options_mysqld OPT_MAX_LENGTH_FOR_SORT_DATA, OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE, OPT_MAX_ERROR_COUNT, OPT_MULTI_RANGE_COUNT, OPT_MYISAM_DATA_POINTER_SIZE, + OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE, - OPT_MYISAM_USE_MMAP, + OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS, OPT_MYISAM_STATS_METHOD, + + OPT_MARIA_BLOCK_SIZE, + OPT_MARIA_MAX_SORT_FILE_SIZE, OPT_MARIA_SORT_BUFFER_SIZE, + OPT_MARIA_USE_MMAP, OPT_MARIA_REPAIR_THREADS, + OPT_MARIA_STATS_METHOD, + OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT, OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT, OPT_OPEN_FILES_LIMIT, @@ -5026,7 +5071,7 @@ enum options_mysqld OPT_SORT_BUFFER, OPT_TABLE_OPEN_CACHE, OPT_TABLE_DEF_CACHE, OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE, OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK, - OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS, + OPT_WAIT_TIMEOUT, OPT_ERROR_LOG_FILE, OPT_DEFAULT_WEEK_FORMAT, OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_ALLOW_SUSPICIOUS_UDFS, @@ -5980,6 +6025,40 @@ log and this option does nothing anymore.", 0 #endif , 0, 2, 0, 1, 0}, +#ifdef WITH_MARIA_STORAGE_ENGINE + {"maria_block_size", OPT_MARIA_BLOCK_SIZE, + "Block size to be used for MARIA index pages.", + (uchar**) &maria_block_size, + (uchar**) &maria_block_size, 0, GET_ULONG, REQUIRED_ARG, + MARIA_KEY_BLOCK_LENGTH, MARIA_MIN_KEY_BLOCK_LENGTH, + MARIA_MAX_KEY_BLOCK_LENGTH, + 0, MARIA_MIN_KEY_BLOCK_LENGTH, 0}, + {"maria_max_sort_file_size", OPT_MARIA_MAX_SORT_FILE_SIZE, + "Don't use the fast sort index method to created index if the temporary " + "file would get bigger than this.", + (uchar**) &global_system_variables.maria_max_sort_file_size, + (uchar**) &max_system_variables.maria_max_sort_file_size, 0, + GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE, + 0, 1024*1024, 0}, + {"maria_repair_threads", OPT_MARIA_REPAIR_THREADS, + "Number of threads to use when repairing maria tables. The value of 1 " + "disables parallel repair.", + (uchar**) &global_system_variables.maria_repair_threads, + (uchar**) &max_system_variables.maria_repair_threads, 0, + GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0}, + {"maria_sort_buffer_size", OPT_MARIA_SORT_BUFFER_SIZE, + "The buffer that is allocated when sorting the index when doing a REPAIR " + "or when creating indexes with CREATE INDEX or ALTER TABLE.", + (uchar**) &global_system_variables.maria_sort_buff_size, + (uchar**) &max_system_variables.maria_sort_buff_size, 0, + GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, + {"maria_stats_method", OPT_MARIA_STATS_METHOD, + "Specifies how maria index statistics collection code should threat NULLs. " + "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " + "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", + (uchar**) &maria_stats_method_str, (uchar**) &maria_stats_method_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, +#endif {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "Max packetlength to send/receive from to server.", (uchar**) &global_system_variables.max_allowed_packet, @@ -6083,12 +6162,6 @@ The minimum value for this variable is 4096.", (uchar**) &myisam_data_pointer_size, (uchar**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, 6, 2, 7, 0, 1, 0}, - {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, - "Deprecated option", - (uchar**) &global_system_variables.myisam_max_extra_sort_file_size, - (uchar**) &max_system_variables.myisam_max_extra_sort_file_size, - 0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH, - 0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0}, {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE, "Don't use the fast sort index method to created index if the temporary file would get bigger than this.", (uchar**) &global_system_variables.myisam_max_sort_file_size, @@ -6136,7 +6209,7 @@ The minimum value for this variable is 4096.", (uchar**) &global_system_variables.net_write_timeout, (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, - { "old", OPT_OLD_MODE, "Use compatible behavior.", + {"old", OPT_OLD_MODE, "Use compatible behavior.", (uchar**) &global_system_variables.old_mode, (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -6154,6 +6227,24 @@ The minimum value for this variable is 4096.", (uchar**) &global_system_variables.optimizer_search_depth, (uchar**) &max_system_variables.optimizer_search_depth, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, +#ifdef WITH_MARIA_STORAGE_ENGINE + {"pagecache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, + "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", + (uchar**) &maria_pagecache_var.param_age_threshold, + (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, + 300, 100, ~0L, 0, 100, 0}, + {"pagecache_buffer_size", OPT_KEY_BUFFER_SIZE, + "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", + (uchar**) &maria_pagecache_var.param_buff_size, + (uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, + KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0}, + {"pagecache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, + "The minimum percentage of warm blocks in key cache", + (uchar**) &maria_pagecache_var.param_division_limit, + (uchar**) 0, + 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, + 1, 100, 0, 1, 0}, +#endif /* WITH_MARIA_STORAGE_ENGINE */ {"plugin_dir", OPT_PLUGIN_DIR, "Directory for plugins.", (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0, @@ -6164,10 +6255,10 @@ The minimum value for this variable is 4096.", (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, - "The size of the buffer that is allocated when preloading indexes", - (uchar**) &global_system_variables.preload_buff_size, - (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG, - REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0}, + "The size of the buffer that is allocated when preloading indexes", + (uchar**) &global_system_variables.preload_buff_size, + (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG, + REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0}, {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE, "Allocation block size for query parsing and execution", (uchar**) &global_system_variables.query_alloc_block_size, @@ -6310,8 +6401,8 @@ The minimum value for this variable is 4096.", REQUIRED_ARG, 20, 1, 16384, 0, 1, 0}, #endif {"thread_stack", OPT_THREAD_STACK, - "The stack size for each thread.", (uchar**) &thread_stack, - (uchar**) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, + "The stack size for each thread.", (uchar**) &my_thread_stack_size, + (uchar**) &my_thread_stack_size, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, 1024L*128L, ~0L, 0, 1024, 0}, { "time_format", OPT_TIME_FORMAT, "The TIME format (for future).", @@ -6324,12 +6415,12 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL, REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0}, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, - "Allocation block size for various transaction-related structures", + "Allocation block size for transactions to be stored in binary log", (uchar**) &global_system_variables.trans_alloc_block_size, (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE, - "Persistent buffer for various transaction-related structures", + "Persistent buffer for transactions to be stored in binary log", (uchar**) &global_system_variables.trans_prealloc_size, (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, @@ -7075,15 +7166,25 @@ static void mysql_init_variables(void) global_query_id= thread_id= 1L; strmov(server_version, MYSQL_SERVER_VERSION); myisam_recover_options_str= sql_mode_str= "OFF"; - myisam_stats_method_str= "nulls_unequal"; + myisam_stats_method_str= maria_stats_method_str= "nulls_unequal"; my_bind_addr = htonl(INADDR_ANY); threads.empty(); thread_cache.empty(); key_caches.empty(); +#ifdef WITH_MARIA_STORAGE_ENGINE + pagecaches.empty(); +#endif /* WITH_MARIA_STORAGE_ENGINE */ if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str, - default_key_cache_base.length))) + default_key_cache_base.length))) exit(1); - multi_keycache_init(); /* set key_cache_hash.default_value = dflt_key_cache */ + + /* set key_cache_hash.default_value = dflt_key_cache */ + multi_keycache_init(); + +#ifdef WITH_MARIA_STORAGE_ENGINE + /* set pagecache_hash.default_value = maria_pagecache */ + multi_pagecache_init(); +#endif /* Set directory paths */ strmake(language, LANGUAGE, sizeof(language)-1); @@ -7126,6 +7227,7 @@ static void mysql_init_variables(void) when collecting index statistics for MyISAM tables. */ global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL; + global_system_variables.maria_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL; /* Variables that depends on compile options */ #ifndef DBUG_OFF @@ -7657,7 +7759,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), int method; LINT_INIT(method_conv); - myisam_stats_method_str= argument; method= find_type_or_exit(argument, &myisam_stats_method_typelib, opt->name); switch (method-1) { @@ -8131,6 +8232,9 @@ void refresh_status(THD *thd) /* Reset the counters of all key caches (default and named). */ process_key_caches(reset_key_cache_counters); +#ifdef WITH_MARIA_STORAGE_ENGINE + process_pagecaches(reset_pagecache_counters); +#endif /* WITH_MARIA_STORAGE_ENGINE */ pthread_mutex_unlock(&LOCK_status); /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 4944c994d3d..3ee7e8ee813 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4299,7 +4299,6 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info, } info->out_rows *= selectivity_mult; - DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost)); if (is_cpk_scan) { diff --git a/sql/set_var.cc b/sql/set_var.cc index d9869ce6809..ea47f2f557b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -54,6 +54,9 @@ #include <thr_alarm.h> #include <myisam.h> #include <my_dir.h> +#ifdef WITH_MARIA_STORAGE_ENGINE +#include <maria.h> +#endif #include "events.h" @@ -113,6 +116,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type); static void fix_query_cache_size(THD *thd, enum_var_type type); static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type); static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); +static void fix_maria_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); @@ -121,6 +125,9 @@ static void fix_thd_mem_root(THD *thd, enum_var_type type); static void fix_trans_mem_root(THD *thd, enum_var_type type); static void fix_server_id(THD *thd, enum_var_type type); static KEY_CACHE *create_key_cache(const char *name, uint length); +#ifdef WITH_MARIA_STORAGE_ENGINE +static PAGECACHE *create_pagecache(const char *name, uint length); +#endif /* WITH_MARIA_STORAGE_ENGINE */ void fix_sql_mode_var(THD *thd, enum_var_type type); static uchar *get_error_count(THD *thd); static uchar *get_warning_count(THD *thd); @@ -238,6 +245,14 @@ static sys_var_key_cache_long sys_key_cache_division_limit(&vars, "key_cache_div static sys_var_key_cache_long sys_key_cache_age_threshold(&vars, "key_cache_age_threshold", offsetof(KEY_CACHE, param_age_threshold)); +#ifdef WITH_MARIA_STORAGE_ENGINE +sys_var_pagecache_long sys_pagecache_division_limit("pagecache_division_limit", + offsetof(PAGECACHE, + param_division_limit)); +sys_var_pagecache_long sys_pagecache_age_threshold("pagecache_age_threshold", + offsetof(KEY_CACHE, + param_age_threshold)); +#endif /* WITH_MARIA_STORAGE_ENGINE */ static sys_var_bool_ptr sys_local_infile(&vars, "local_infile", &opt_local_infile); static sys_var_trust_routine_creators @@ -330,6 +345,14 @@ static sys_var_thd_enum sys_myisam_stats_method(&vars, "myisam_stats_met &myisam_stats_method_typelib, NULL); +static sys_var_thd_ulonglong sys_maria_max_sort_file_size(&vars, "maria_max_sort_file_size", &SV::maria_max_sort_file_size, fix_maria_max_sort_file_size, 1); +static sys_var_thd_ulong sys_maria_repair_threads(&vars, "maria_repair_threads", &SV::maria_repair_threads); +static sys_var_thd_ulong sys_maria_sort_buffer_size(&vars, "maria_sort_buffer_size", &SV::maria_sort_buff_size); +static sys_var_thd_enum sys_maria_stats_method(&vars, "maria_stats_method", + &SV::maria_stats_method, + &myisam_stats_method_typelib, + NULL); + static sys_var_thd_ulong sys_net_buffer_length(&vars, "net_buffer_length", &SV::net_buffer_length); static sys_var_thd_ulong sys_net_read_timeout(&vars, "net_read_timeout", @@ -624,6 +647,7 @@ static sys_var_have_plugin sys_have_csv(&vars, "have_csv", C_STRING_WITH_LEN("cs static sys_var_have_variable sys_have_dlopen(&vars, "have_dynamic_loading", &have_dlopen); static sys_var_have_variable sys_have_geometry(&vars, "have_geometry", &have_geometry); static sys_var_have_plugin sys_have_innodb(&vars, "have_innodb", C_STRING_WITH_LEN("innodb"), MYSQL_STORAGE_ENGINE_PLUGIN); +static sys_var_have_variable sys_have_maria_db(&vars, "have_maria", &have_maria_db); static sys_var_have_plugin sys_have_ndbcluster(&vars, "have_ndbcluster", C_STRING_WITH_LEN("ndbcluster"), MYSQL_STORAGE_ENGINE_PLUGIN); static sys_var_have_variable sys_have_openssl(&vars, "have_openssl", &have_ssl); static sys_var_have_variable sys_have_ssl(&vars, "have_ssl", &have_ssl); @@ -702,7 +726,7 @@ static SHOW_VAR fixed_vars[]= { #ifdef HAVE_THR_SETCONCURRENCY {"thread_concurrency", (char*) &concurrency, SHOW_LONG}, #endif - {"thread_stack", (char*) &thread_stack, SHOW_LONG}, + {"thread_stack", (char*) &my_thread_stack_size, SHOW_LONG}, }; @@ -839,6 +863,16 @@ fix_myisam_max_sort_file_size(THD *thd, enum_var_type type) (my_off_t) global_system_variables.myisam_max_sort_file_size; } +static void +fix_maria_max_sort_file_size(THD *thd, enum_var_type type) +{ +#ifdef WITH_MARIA_STORAGE_ENGINE + maria_max_temp_length= + (my_off_t) global_system_variables.myisam_max_sort_file_size; +#endif +} + + /* Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR */ @@ -1893,15 +1927,30 @@ LEX_STRING default_key_cache_base= {(char *) "default", 7 }; static KEY_CACHE zero_key_cache; +#ifdef WITH_MARIA_STORAGE_ENGINE +LEX_STRING maria_pagecache_base= {(char *) "default", 7 }; +static PAGECACHE zero_pagecache; +#endif /* WITH_MARIA_STORAGE_ENGINE */ + KEY_CACHE *get_key_cache(LEX_STRING *cache_name) { safe_mutex_assert_owner(&LOCK_global_system_variables); if (!cache_name || ! cache_name->length) cache_name= &default_key_cache_base; return ((KEY_CACHE*) find_named(&key_caches, - cache_name->str, cache_name->length, 0)); + cache_name->str, cache_name->length, 0)); } +#ifdef WITH_MARIA_STORAGE_ENGINE +PAGECACHE *get_pagecache(LEX_STRING *cache_name) +{ + safe_mutex_assert_owner(&LOCK_global_system_variables); + if (!cache_name || ! cache_name->length) + cache_name= &default_key_cache_base; + return ((PAGECACHE*) find_named(&pagecaches, + cache_name->str, cache_name->length, 0)); +} +#endif /* WITH_MARIA_STORAGE_ENGINE */ uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) @@ -1913,6 +1962,18 @@ uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, } +#ifdef WITH_MARIA_STORAGE_ENGINE +uchar *sys_var_pagecache_param::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) +{ + PAGECACHE *pagecache= get_pagecache(base); + if (!pagecache) + pagecache= &zero_pagecache; + return (uchar*) pagecache + offset ; +} +#endif /* WITH_MARIA_STORAGE_ENGINE */ + + bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; @@ -2049,6 +2110,60 @@ end: } +#ifdef WITH_MARIA_STORAGE_ENGINE +bool sys_var_pagecache_long::update(THD *thd, set_var *var) +{ + ulong tmp= (ulong) var->value->val_int(); + LEX_STRING *base_name= &var->base; + bool error= 0; + + if (!base_name->length) + base_name= &maria_pagecache_base; + + pthread_mutex_lock(&LOCK_global_system_variables); + PAGECACHE *pagecache= get_pagecache(base_name); + + if (!pagecache && !(pagecache= create_pagecache(base_name->str, + base_name->length))) + { + error= 1; + goto end; + } + + /* + Abort if some other thread is changing the key cache + TODO: This should be changed so that we wait until the previous + assignment is done and then do the new assign + */ + if (pagecache->in_init) + goto end; + + *((ulong*) (((char*) pagecache) + offset))= + (ulong) getopt_ull_limit_value(tmp, option_limits); + + /* + Don't create a new key cache if it didn't exist + (pagecaches are created only when the user sets block_size) + */ + pagecache->in_init= 1; + + pthread_mutex_unlock(&LOCK_global_system_variables); + + /* + TODO: uncomment whan it will be implemented + error= (bool) (ha_resize_pagecache(pagecache)); + */ + + pthread_mutex_lock(&LOCK_global_system_variables); + pagecache->in_init= 0; + +end: + pthread_mutex_unlock(&LOCK_global_system_variables); + return error; +} +#endif /* WITH_MARIA_STORAGE_ENGINE */ + + bool sys_var_log_state::update(THD *thd, set_var *var) { bool res= 0; @@ -3538,12 +3653,85 @@ bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) } +#ifdef WITH_MARIA_STORAGE_ENGINE + +static PAGECACHE *create_pagecache(const char *name, uint length) +{ + PAGECACHE *pagecache; + DBUG_ENTER("create_pagecache"); + DBUG_PRINT("enter",("name: %.*s", length, name)); + + if ((pagecache= (PAGECACHE*) my_malloc(sizeof(PAGECACHE), + MYF(MY_ZEROFILL | MY_WME)))) + { + if (!new NAMED_LIST(&pagecaches, name, length, (uchar*) pagecache)) + { + my_free((char*) pagecache, MYF(0)); + pagecache= 0; + } + else + { + /* + Set default values for a key cache + The values in maria_pagecache_var is set by my_getopt() at startup + We don't set 'buff_size' as this is used to enable the key cache + */ + pagecache->param_buff_size= (maria_pagecache_var.param_buff_size ? + maria_pagecache_var.param_buff_size: + KEY_CACHE_SIZE); + pagecache->param_division_limit= maria_pagecache_var.param_division_limit; + pagecache->param_age_threshold= maria_pagecache_var.param_age_threshold; + } + } + DBUG_RETURN(pagecache); +} + + +PAGECACHE *get_or_create_pagecache(const char *name, uint length) +{ + LEX_STRING pagecache_name; + PAGECACHE *pagecache; + + pagecache_name.str= (char *) name; + pagecache_name.length= length; + pthread_mutex_lock(&LOCK_global_system_variables); + if (!(pagecache= get_pagecache(&pagecache_name))) + pagecache= create_pagecache(name, length); + pthread_mutex_unlock(&LOCK_global_system_variables); + return pagecache; +} + + +void free_pagecache(const char *name, PAGECACHE *pagecache) +{ + ha_end_pagecache(pagecache); + my_free((char*) pagecache, MYF(0)); +} + + +bool process_pagecaches(int (* func) (const char *name, PAGECACHE *)) +{ + I_List_iterator<NAMED_LIST> it(pagecaches); + NAMED_LIST *element; + + while ((element= it++)) + { + PAGECACHE *pagecache= (PAGECACHE *) element->data; + func(element->name, pagecache); + } + return 0; +} + +#endif /* WITH_MARIA_STORAGE_ENGINE */ + + void sys_var_trust_routine_creators::warn_deprecated(THD *thd) { WARN_DEPRECATED(thd, "5.2", "log_bin_trust_routine_creators", "'log_bin_trust_function_creators'"); } + void sys_var_trust_routine_creators::set_default(THD *thd, enum_var_type type) { warn_deprecated(thd); diff --git a/sql/set_var.h b/sql/set_var.h index a998dc93b84..3c8c06b34df 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -733,6 +733,33 @@ public: }; +#ifdef WITH_MARIA_STORAGE_ENGINE +class sys_var_pagecache_param :public sys_var +{ +protected: + size_t offset; +public: + sys_var_pagecache_param(const char *name_arg, size_t offset_arg) + :sys_var(name_arg), offset(offset_arg) + {} + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + bool check_default(enum_var_type type) { return 1; } + bool is_struct() { return 1; } +}; + + +class sys_var_pagecache_long :public sys_var_pagecache_param +{ +public: + sys_var_pagecache_long(const char *name_arg, size_t offset_arg) + :sys_var_pagecache_param(name_arg, offset_arg) + {} + bool update(THD *thd, set_var *var); + SHOW_TYPE type() { return SHOW_LONG; } +}; +#endif /* WITH_MARIA_STORAGE_ENGINE */ + + class sys_var_thd_date_time_format :public sys_var_thd { DATE_TIME_FORMAT *SV::*offset; @@ -1131,7 +1158,11 @@ public: my_free((uchar*) name, MYF(0)); } friend bool process_key_caches(int (* func) (const char *name, - KEY_CACHE *)); + KEY_CACHE *)); +#ifdef WITH_MARIA_STORAGE_ENGINE + friend bool process_pagecaches(int (* func) (const char *name, + PAGECACHE *)); +#endif /* WITH_MARIA_STORAGE_ENGINE */ friend void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, uchar*)); }; @@ -1141,6 +1172,9 @@ public: extern sys_var_thd_bool sys_old_alter_table; extern sys_var_thd_bool sys_old_passwords; extern LEX_STRING default_key_cache_base; +#ifdef WITH_MARIA_STORAGE_ENGINE +extern LEX_STRING maria_pagecache_base; +#endif /* WITH_MARIA_STORAGE_ENGINE */ /* For sql_yacc */ struct sys_var_with_base @@ -1182,3 +1216,8 @@ void free_key_cache(const char *name, KEY_CACHE *key_cache); bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, uchar*)); +#ifdef WITH_MARIA_STORAGE_ENGINE +PAGECACHE *get_or_create_pagecache(const char *name, uint length); +void free_pagecache(const char *name, PAGECACHE *pagecache); +bool process_pagecaches(int (* func) (const char *name, PAGECACHE *)); +#endif /* WITH_MARIA_STORAGE_ENGINE */ diff --git a/sql/slave.cc b/sql/slave.cc index 6c7968c2b3f..512c4bc8d12 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -28,6 +28,8 @@ #include <sql_common.h> #include <errmsg.h> +static Log_event* next_event(RELAY_LOG_INFO* rli); + #ifdef HAVE_REPLICATION #include "rpl_tblmap.h" diff --git a/sql/sql_class.h b/sql/sql_class.h index a8d62d93b21..0a518e860e5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -236,6 +236,7 @@ struct system_variables uint dynamic_variables_size; /* how many bytes are in use */ ulonglong myisam_max_extra_sort_file_size; + ulonglong maria_max_sort_file_size; ulonglong myisam_max_sort_file_size; ulonglong max_heap_table_size; ulonglong tmp_table_size; @@ -251,6 +252,9 @@ struct system_variables ulong max_sort_length; ulong max_tmp_tables; ulong max_insert_delayed_threads; + ulong maria_repair_threads; + ulong maria_sort_buff_size; + ulong maria_stats_method; ulong multi_range_count; ulong myisam_repair_threads; ulong myisam_sort_buff_size; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bd151dc2028..a49f560d8d4 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5060,10 +5060,10 @@ bool check_stack_overrun(THD *thd, long margin, long stack_used; DBUG_ASSERT(thd == current_thd); if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= - (long) (thread_stack - margin)) + (long) (my_thread_stack_size - margin)) { sprintf(errbuff[0],ER(ER_STACK_OVERRUN_NEED_MORE), - stack_used,thread_stack,margin); + stack_used,my_thread_stack_size,margin); my_message(ER_STACK_OVERRUN_NEED_MORE,errbuff[0],MYF(0)); thd->fatal_error(); return 1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3cda4029161..a855e536fec 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -25,6 +25,7 @@ #include "sql_cursor.h" #include <m_ctype.h> +#include <my_bit.h> #include <hash.h> #include <ft_global.h> @@ -9545,7 +9546,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, table->s= share; init_tmp_table_share(share, "", 0, tmpname, tmppath); share->blob_field= blob_field; - share->blob_ptr_size= mi_portable_sizeof_char_ptr; + share->blob_ptr_size= portable_sizeof_char_ptr; share->db_low_byte_first=1; // True for HEAP and MyISAM share->table_charset= param->table_charset; share->primary_key= MAX_KEY; // Indicate no primary key @@ -10110,7 +10111,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list) table->s= share; share->blob_field= blob_field; share->fields= field_count; - share->blob_ptr_size= mi_portable_sizeof_char_ptr; + share->blob_ptr_size= portable_sizeof_char_ptr; setup_tmp_table_column_bitmaps(table, bitmaps); /* Create all fields and calculate the total length of record */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f66897df671..8906c5654c7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1346,6 +1346,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; @@ -2920,8 +2925,8 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, case ROW_TYPE_COMPACT: tmp_buff= "Compact"; break; - case ROW_TYPE_PAGES: - tmp_buff= "Paged"; + case ROW_TYPE_PAGE: + tmp_buff= "Page"; break; } table->field[6]->store(tmp_buff, strlen(tmp_buff), cs); diff --git a/sql/sql_sort.h b/sql/sql_sort.h index da28ca07e2c..1572f6304e1 100644 --- a/sql/sql_sort.h +++ b/sql/sql_sort.h @@ -34,7 +34,9 @@ the callback function 'unpack_addon_fields'. */ -typedef struct st_sort_addon_field { /* Sort addon packed field */ +typedef struct st_sort_addon_field +{ + /* Sort addon packed field */ Field *field; /* Original field */ uint offset; /* Offset from the last sorted field */ uint null_offset; /* Offset to to null bit from the last sorted field */ @@ -42,13 +44,6 @@ typedef struct st_sort_addon_field { /* Sort addon packed field */ uint8 null_bit; /* Null bit mask for the field */ } SORT_ADDON_FIELD; -typedef struct st_buffpek { /* Struktur om sorteringsbuffrarna */ - my_off_t file_pos; /* Where we are in the sort file */ - uchar *base,*key; /* key pointers */ - ha_rows count; /* Number of rows in table */ - ulong mem_count; /* numbers of keys in memory */ - ulong max_keys; /* Max keys in buffert */ -} BUFFPEK; typedef struct st_sort_param { uint rec_length; /* Length of sorted records */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 047c210d6a5..6fc1c235ebf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5334,6 +5334,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) { @@ -6989,7 +6991,6 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list) DBUG_ENTER("mysql_recreate_table"); bzero((char*) &create_info, sizeof(create_info)); - create_info.db_type= 0; create_info.row_type=ROW_TYPE_NOT_USED; create_info.default_table_charset=default_charset_info; /* Force alter table to recreate table */ diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 5bd01eea68c..6d75c90eb1d 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -459,7 +459,7 @@ void mysql_print_status() VOID(my_getwd(current_dir, sizeof(current_dir),MYF(0))); printf("Current dir: %s\n", current_dir); printf("Running threads: %d Stack size: %ld\n", thread_count, - (long) thread_stack); + (long) my_thread_stack_size); thr_print_locks(); // Write some debug info #ifndef DBUG_OFF print_cached_tables(); @@ -536,7 +536,7 @@ Estimated memory (with thread stack): %ld\n", (int) info.uordblks, (int) info.fordblks, (int) info.keepcost, - (long) (thread_count * thread_stack + info.hblkhd + info.arena)); + (long) (thread_count * my_thread_stack_size + info.hblkhd + info.arena)); #endif Events::dump_internal_status(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3bd930f6041..8def8a43249 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; } @@ -10036,6 +10045,7 @@ keyword_sp: | ONE_SHOT_SYM {} | ONE_SYM {} | PACK_KEYS_SYM {} + | PAGE_SYM {} | PARTIAL {} | PARTITIONING_SYM {} | PARTITIONS_SYM {} @@ -10105,6 +10115,7 @@ keyword_sp: | TEXT_SYM {} | THAN_SYM {} | TRANSACTION_SYM {} + | TRANSACTIONAL_SYM {} | TRIGGERS_SYM {} | TIMESTAMP {} | TIMESTAMP_ADD {} diff --git a/sql/table.cc b/sql/table.cc index 27a93b85fb5..35a60dd8527 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -655,7 +655,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; } @@ -2362,7 +2363,9 @@ File create_frm(THD *thd, const char *name, const char *db, int2store(fileinfo+16,reclength); int4store(fileinfo+18,create_info->max_rows); int4store(fileinfo+22,create_info->min_rows); + /* fileinfo[26] is set in mysql_create_frm() */ fileinfo[27]=2; // Use long pack-fields + /* fileinfo[28 & 29] is set to key_info_length in mysql_create_frm() */ create_info->table_options|=HA_OPTION_LONG_BLOB_PTR; // Use portable blob pointers int2store(fileinfo+30,create_info->table_options); fileinfo[32]=0; // No filename anymore @@ -2370,8 +2373,9 @@ 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 */ + /* Next few bytes where for RAID support */ fileinfo[41]= 0; fileinfo[42]= 0; fileinfo[43]= 0; diff --git a/sql/table.h b/sql/table.h index 4c98f5146ab..47b2cbd3075 100644 --- a/sql/table.h +++ b/sql/table.h @@ -203,6 +203,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/uniques.cc b/sql/uniques.cc index 7a05ceaddfc..6bcffbd53de 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -448,7 +448,7 @@ static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size, */ for (top= begin; top != end; ++top) { - top->base= merge_buffer + (top - begin) * piece_size; + top->base= (uchar*) (merge_buffer + (top - begin) * piece_size); top->max_keys= max_key_count_per_piece; bytes_read= read_to_buffer(file, top, key_length); if (bytes_read == (uint) (-1)) diff --git a/sql/unireg.cc b/sql/unireg.cc index 57847bc70c6..c74e046b133 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -284,8 +284,10 @@ bool mysql_create_frm(THD *thd, const char *file_name, my_free(keybuff, MYF(0)); if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) && - my_sync(file, MYF(MY_WME))) - goto err2; + (my_sync(file, MYF(MY_WME)) || + my_sync_dir_by_file(file_name, MYF(MY_WME)))) + goto err2; + if (my_close(file,MYF(MY_WME))) goto err3; |