From 21b6aa5c2d1ec8f69ecd0f010b621588512b01fc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jun 2004 23:33:28 +0200 Subject: [PATCH 01/22] Fixes for gcc-3.4.0 --- ndb/src/kernel/vm/ArrayPool.hpp | 24 ++++++++++++------------ ndb/src/kernel/vm/DLFifoList.hpp | 4 ++-- ndb/src/kernel/vm/DLList.hpp | 4 ++-- ndb/src/kernel/vm/DataBuffer.hpp | 4 ++-- ndb/src/kernel/vm/SLList.hpp | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ndb/src/kernel/vm/ArrayPool.hpp b/ndb/src/kernel/vm/ArrayPool.hpp index 284d29dcefa..4fc6bb97f73 100644 --- a/ndb/src/kernel/vm/ArrayPool.hpp +++ b/ndb/src/kernel/vm/ArrayPool.hpp @@ -795,8 +795,8 @@ inline void UnsafeArrayPool::getPtrForce(Ptr & ptr){ Uint32 i = ptr.i; - if(i < size){ - ptr.p = &theArray[i]; + if(i < this->size){ + ptr.p = &this->theArray[i]; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", __FILE__, __LINE__); @@ -808,8 +808,8 @@ inline void UnsafeArrayPool::getPtrForce(ConstPtr & ptr) const{ Uint32 i = ptr.i; - if(i < size){ - ptr.p = &theArray[i]; + if(i < this->size){ + ptr.p = &this->theArray[i]; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", __FILE__, __LINE__); @@ -820,8 +820,8 @@ template inline T * UnsafeArrayPool::getPtrForce(Uint32 i){ - if(i < size){ - return &theArray[i]; + if(i < this->size){ + return &this->theArray[i]; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", __FILE__, __LINE__); @@ -833,8 +833,8 @@ template inline const T * UnsafeArrayPool::getConstPtrForce(Uint32 i) const { - if(i < size){ - return &theArray[i]; + if(i < this->size){ + return &this->theArray[i]; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", __FILE__, __LINE__); @@ -847,8 +847,8 @@ inline void UnsafeArrayPool::getPtrForce(Ptr & ptr, Uint32 i){ ptr.i = i; - if(i < size){ - ptr.p = &theArray[i]; + if(i < this->size){ + ptr.p = &this->theArray[i]; return ; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", @@ -861,8 +861,8 @@ inline void UnsafeArrayPool::getPtrForce(ConstPtr & ptr, Uint32 i) const{ ptr.i = i; - if(i < size){ - ptr.p = &theArray[i]; + if(i < this->size){ + ptr.p = &this->theArray[i]; return ; } else { ErrorReporter::handleAssert("UnsafeArrayPool::getPtr", diff --git a/ndb/src/kernel/vm/DLFifoList.hpp b/ndb/src/kernel/vm/DLFifoList.hpp index 91b5b421b0c..b139ade831d 100644 --- a/ndb/src/kernel/vm/DLFifoList.hpp +++ b/ndb/src/kernel/vm/DLFifoList.hpp @@ -153,11 +153,11 @@ public: LocalDLFifoList(ArrayPool & thePool, typename DLFifoList::Head & _src) : DLFifoList(thePool), src(_src) { - head = src; + this->head = src; } ~LocalDLFifoList(){ - src = head; + src = this->head; } private: typename DLFifoList::Head & src; diff --git a/ndb/src/kernel/vm/DLList.hpp b/ndb/src/kernel/vm/DLList.hpp index f16ccd312f7..b7820eb9229 100644 --- a/ndb/src/kernel/vm/DLList.hpp +++ b/ndb/src/kernel/vm/DLList.hpp @@ -169,11 +169,11 @@ public: LocalDLList(ArrayPool & thePool, typename DLList::Head & _src) : DLList(thePool), src(_src) { - head = src; + this->head = src; } ~LocalDLList(){ - src = head; + src = this->head; } private: typename DLList::Head & src; diff --git a/ndb/src/kernel/vm/DataBuffer.hpp b/ndb/src/kernel/vm/DataBuffer.hpp index 3425fca76a3..7dc89aa638c 100644 --- a/ndb/src/kernel/vm/DataBuffer.hpp +++ b/ndb/src/kernel/vm/DataBuffer.hpp @@ -174,11 +174,11 @@ public: typename DataBuffer::Head & _src) : DataBuffer(thePool), src(_src) { - head = src; + this->head = src; } ~LocalDataBuffer(){ - src = head; + src = this->head; } private: typename DataBuffer::Head & src; diff --git a/ndb/src/kernel/vm/SLList.hpp b/ndb/src/kernel/vm/SLList.hpp index 47bc7b8b241..5fde41aa3e0 100644 --- a/ndb/src/kernel/vm/SLList.hpp +++ b/ndb/src/kernel/vm/SLList.hpp @@ -137,11 +137,11 @@ public: LocalSLList(ArrayPool & thePool, typename SLList::Head & _src) : SLList(thePool), src(_src) { - head = src; + this->head = src; } ~LocalSLList(){ - src = head; + src = this->head; } private: typename SLList::Head & src; From 7b1b7bc6669eeeffc107ecb80cbd5513106bd098 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jun 2004 10:40:15 +0200 Subject: [PATCH 02/22] fowwlowup fixes for index_flags() --- sql/ha_berkeley.h | 3 +-- sql/handler.h | 2 +- sql/opt_sum.cc | 13 +++++++------ sql/sql_select.cc | 11 +++++++---- sql/sql_show.cc | 2 +- sql/table.cc | 15 ++++++--------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 52116710726..efc85d3928e 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -97,8 +97,7 @@ class ha_berkeley: public handler ulong index_flags(uint idx, uint part) const { ulong flags=HA_READ_NEXT | HA_READ_PREV; - if (part == (uint)~0 || - table->key_info[idx].key_part[part].field->key_type() != HA_KEYTYPE_TEXT) + if (table->key_info[idx].key_part[part].field->key_type() != HA_KEYTYPE_TEXT) flags|= HA_READ_ORDER | HA_KEYREAD_ONLY | HA_READ_RANGE; return flags; } diff --git a/sql/handler.h b/sql/handler.h index ca452b6dedf..7274dd023f3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -449,7 +449,7 @@ public: virtual const char *table_type() const =0; virtual const char **bas_ext() const =0; virtual ulong table_flags(void) const =0; - virtual ulong index_flags(uint idx, uint part=~0) const =0; + virtual ulong index_flags(uint idx, uint part=0) const =0; virtual ulong index_ddl_flags(KEY *wanted_index) const { return (HA_DDL_SUPPORT); } virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 75b00b97ce7..27f3f476fe7 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -629,7 +629,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, if (!(field->flags & PART_KEY_FLAG)) return 0; // Not key field *prefix_len= 0; - + TABLE *table= field->table; uint idx= 0; @@ -637,16 +637,17 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, for (keyinfo= table->key_info, keyinfo_end= keyinfo+table->keys ; keyinfo != keyinfo_end; keyinfo++,idx++) - { - if (!(table->file->index_flags(idx) & HA_READ_ORDER)) - break; - + { KEY_PART_INFO *part,*part_end; key_part_map key_part_to_use= 0; + uint jdx= 0; for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ; part != part_end ; - part++, key_part_to_use= (key_part_to_use << 1) | 1) + part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1) { + if (!(table->file->index_flags(idx, jdx) & HA_READ_ORDER)) + return 0; + if (field->eq(part->field)) { ref->key= idx; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2f8ede4b4cb..90636364459 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2825,7 +2825,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, Set tmp to (previous record count) * (records / combination) */ if ((found_part & 1) && - (!(table->file->index_flags(key) & HA_ONLY_WHOLE_INDEX) || + (!(table->file->index_flags(key,0) & HA_ONLY_WHOLE_INDEX) || found_part == PREV_BITS(uint,keyinfo->key_parts))) { max_key_part=max_part_bit(found_part); @@ -7171,7 +7171,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ if (!select->quick->reverse_sorted()) { - if (!(table->file->index_flags(ref_key) & HA_READ_PREV)) + // here used_key_parts >0 + if (!(table->file->index_flags(ref_key,used_key_parts-1) + & HA_READ_PREV)) DBUG_RETURN(0); // Use filesort // ORDER BY range_key DESC QUICK_SELECT_DESC *tmp=new QUICK_SELECT_DESC(select->quick, @@ -7193,8 +7195,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, Use a traversal function that starts by reading the last row with key part (A) and then traverse the index backwards. */ - if (!(table->file->index_flags(ref_key) & HA_READ_PREV)) - DBUG_RETURN(0); // Use filesort + if (!(table->file->index_flags(ref_key,used_key_parts-1) + & HA_READ_PREV)) + DBUG_RETURN(0); // Use filesort tab->read_first_record= join_read_last_key; tab->read_record.read_record= join_read_prev_same; /* fall through */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 823552be3a4..467c774c2e1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -995,7 +995,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) str=(key_part->field ? key_part->field->field_name : "?unknown field?"); protocol->store(str, system_charset_info); - if (table->file->index_flags(i) & HA_READ_ORDER) + if (table->file->index_flags(i,j) & HA_READ_ORDER) protocol->store(((key_part->key_part_flag & HA_REVERSE_SORT) ? "D" : "A"), 1, system_charset_info); else diff --git a/sql/table.cc b/sql/table.cc index 5024015c382..2b92583e777 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -167,9 +167,9 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, outparam->keys= keys= disk_buff[0]; outparam->key_parts= key_parts= disk_buff[1]; } - outparam->keys_for_keyread.init(keys); + outparam->keys_for_keyread.init(0); outparam->keys_in_use.init(keys); - outparam->read_only_keys.init(0); + outparam->read_only_keys.init(keys); outparam->quick_keys.init(); outparam->used_keys.init(); outparam->keys_in_use_for_query.init(); @@ -500,13 +500,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (outparam->key_info[key].flags & HA_FULLTEXT) outparam->key_info[key].algorithm= HA_KEY_ALG_FULLTEXT; - /* This has to be done after the above fulltext correction */ - if (!(outparam->file->index_flags(key) & HA_KEYREAD_ONLY)) - { - outparam->read_only_keys.set_bit(key); - outparam->keys_for_keyread.clear_bit(key); - } - if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME)) { /* @@ -577,7 +570,11 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, !(field->flags & BLOB_FLAG)) { if (outparam->file->index_flags(key, i) & HA_KEYREAD_ONLY) + { + outparam->read_only_keys.clear_bit(key); + outparam->keys_for_keyread.set_bit(key); field->part_of_key.set_bit(key); + } if (outparam->file->index_flags(key, i) & HA_READ_ORDER) field->part_of_sortkey.set_bit(key); } From a44942a74b5c8863903bac13f59f252c5ead2e9a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Jul 2004 11:02:21 +0200 Subject: [PATCH 03/22] unused (and unnecessary) mysqltest commands removed client/mysqltest.c: unused (and unnecessary) commands removed --- client/mysqltest.c | 68 ++-------------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 5ba4ad7336c..8747f4f82eb 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -224,7 +224,6 @@ Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER, Q_WAIT_FOR_SLAVE_TO_STOP, -Q_REQUIRE_VERSION, Q_REQUIRE_OS, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_METADATA, Q_DISABLE_METADATA, @@ -297,8 +296,6 @@ const char *command_names[]= "server_stop", "require_manager", "wait_for_slave_to_stop", - "require_version", - "require_os", "enable_warnings", "disable_warnings", "enable_info", @@ -818,63 +815,6 @@ int do_server_op(struct st_query* q,const char* op) } #endif -int do_require_version(struct st_query* q) -{ - MYSQL* mysql = &cur_con->mysql; - MYSQL_RES* res; - MYSQL_ROW row; - char* p=q->first_argument, *ver_arg; - uint ver_arg_len,ver_len; - LINT_INIT(res); - - if (!*p) - die("Missing version argument in require_version\n"); - ver_arg = p; - while (*p && !my_isspace(charset_info,*p)) - p++; - *p = 0; - ver_arg_len = p - ver_arg; - - if (mysql_query(mysql, "select version()") || - !(res=mysql_store_result(mysql))) - die("Query failed while check server version: %s", - mysql_error(mysql)); - if (!(row=mysql_fetch_row(res)) || !row[0]) - { - mysql_free_result(res); - die("Strange result from query while checking version"); - } - ver_len = strlen(row[0]); - if (ver_len < ver_arg_len || memcmp(row[0],ver_arg,ver_arg_len)) - { - mysql_free_result(res); - abort_not_supported_test(); - } - mysql_free_result(res); - return 0; -} - -int do_require_os(struct st_query* q) -{ - char *p=q->first_argument, *os_arg; - DBUG_ENTER("do_require_os"); - - if (!*p) - die("Missing version argument in require_os\n"); - os_arg= p; - while (*p && !my_isspace(charset_info,*p)) - p++; - *p = 0; - - if (strcmp(os_arg, "unix")) - die("For now only testing of os=unix is implemented\n"); - -#if defined(__NETWARE__) || defined(__WIN__) || defined(__OS2__) - abort_not_supported_test(); -#endif - DBUG_RETURN(0); -} - int do_source(struct st_query* q) { char* p=q->first_argument, *name; @@ -2729,15 +2669,13 @@ int main(int argc, char **argv) case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; case Q_DISABLE_WARNINGS: disable_warnings=1; break; - case Q_ENABLE_INFO: disable_info=0; break; - case Q_DISABLE_INFO: disable_info=1; break; + case Q_ENABLE_INFO: disable_info=0; break; + case Q_DISABLE_INFO: disable_info=1; break; case Q_ENABLE_METADATA: display_metadata=1; break; - case Q_DISABLE_METADATA: display_metadata=0; break; + case Q_DISABLE_METADATA: display_metadata=0; break; case Q_SOURCE: do_source(q); break; case Q_SLEEP: do_sleep(q, 0); break; case Q_REAL_SLEEP: do_sleep(q, 1); break; - case Q_REQUIRE_VERSION: do_require_version(q); break; - case Q_REQUIRE_OS: do_require_os(q); break; case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(q); break; case Q_REQUIRE_MANAGER: do_require_manager(q); break; #ifndef EMBEDDED_LIBRARY From 3214bf81174e30b35d92c0c5b789cc36b43355f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Jul 2004 20:01:34 +0200 Subject: [PATCH 04/22] Added comments to the PS test files, to prevent modifications which may destroy the tests . mysql-test/include/ps_create.inc: Added comments mysql-test/include/ps_modify.inc: added comments mysql-test/include/ps_modify1.inc: Added comments mysql-test/include/ps_query.inc: Added and modified comments mysql-test/t/ps_1general.test: Description of the test structure and rules how to extend the tests added and one comment modified . mysql-test/t/ps_2myisam.test: Added comments mysql-test/t/ps_3innodb.test: added comments mysql-test/t/ps_4heap.test: added and altered comments mysql-test/t/ps_5merge.test: added comments mysql-test/t/ps_6bdb.test: added comments --- mysql-test/include/ps_create.inc | 14 ++++ mysql-test/include/ps_modify.inc | 32 +++++++++ mysql-test/include/ps_modify1.inc | 37 ++++++++++ mysql-test/include/ps_query.inc | 35 +++++++++- mysql-test/t/ps_1general.test | 110 +++++++++++++++++++++++++++--- mysql-test/t/ps_2myisam.test | 4 ++ mysql-test/t/ps_3innodb.test | 4 ++ mysql-test/t/ps_4heap.test | 7 +- mysql-test/t/ps_5merge.test | 4 ++ mysql-test/t/ps_6bdb.test | 4 ++ 10 files changed, 238 insertions(+), 13 deletions(-) diff --git a/mysql-test/include/ps_create.inc b/mysql-test/include/ps_create.inc index 7c457572d61..77844c99d77 100644 --- a/mysql-test/include/ps_create.inc +++ b/mysql-test/include/ps_create.inc @@ -1,9 +1,23 @@ ############### include/ps_create.inc ################## # # # drop + create the tables used in most PS test cases # +# t/ps_*.test # # # ######################################################## +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TABLES HERE !!! +# +# Please be aware, that this file will be sourced by several +# test case files stored within the subdirectory 't'. +# So every change here will affect several test cases. + +#----------- Please insert your table definitions here ----------# + + +#---- Please do not alter the following table definitions -------# + --disable_warnings drop table if exists t1, t_many_col_types ; --enable_warnings diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc index 85e9690cf04..04c5cbaad6b 100644 --- a/mysql-test/include/ps_modify.inc +++ b/mysql-test/include/ps_modify.inc @@ -4,6 +4,38 @@ # # ############################################################## +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + +# +# Please be aware, that this file will be sourced by several test case files +# stored within the subdirectory 't'. So every change here will affect +# several test cases. +# +# Please do not modify the structure (DROP/ALTER..) of the tables +# 't1' and 't_many_col_types'. +# +# But you are encouraged to use these two tables within your statements +# whenever possible. +# t1 - very simple table +# t_many_col_types - table with nearly all available column types +# +# The structure and the content of these tables can be found in +# include/ps_create.inc CREATE TABLE ... +# include/ps_renew.inc DELETE all rows and INSERT some rows +# +# Both tables are managed by the same storage engine. +# The type of the storage engine is stored in the variable '$type' . + + + +#------------------- Please insert your test cases here -------------------# + + + +#-------- Please be very carefull when editing behind this line ----------# + --disable_query_log select '------ delete tests ------' as test_sequence ; --enable_query_log diff --git a/mysql-test/include/ps_modify1.inc b/mysql-test/include/ps_modify1.inc index 3608e726648..0b192a52625 100644 --- a/mysql-test/include/ps_modify1.inc +++ b/mysql-test/include/ps_modify1.inc @@ -4,6 +4,43 @@ # # ############################################################## +# +# NOTE: THESE TESTS CANNOT BE APPLIED TO TABLES OF TYPE MERGE. +# Test which can be applied to MERGE tables should be stored in +# include/ps_modify.inc . +# + +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + +# +# Please be aware, that this file will be sourced by several test case files +# stored within the subdirectory 't'. So every change here will affect +# several test cases. +# +# Please do not modify the structure (DROP/ALTER..) of the tables +# 't1' and 't_many_col_types'. +# +# But you are encouraged to use these two tables within your statements +# (DELETE/UPDATE/...) whenever possible. +# t1 - very simple table +# t_many_col_types - table with nearly all available column types +# +# The structure and the content of these tables can be found in +# include/ps_create.inc CREATE TABLE ... +# include/ps_renew.inc DELETE all rows and INSERT some rows +# +# Both tables are managed by the same storage engine. +# The type of the storage engine is stored in the variable '$type' . + + + +#------------------- Please insert your test cases here -------------------# + + +#-------- Please be very carefull when editing behind this line ----------# + ## big insert select statements set @duplicate='duplicate ' ; set @1000=1000 ; diff --git a/mysql-test/include/ps_query.inc b/mysql-test/include/ps_query.inc index 819ec4add06..e22f168dcd7 100644 --- a/mysql-test/include/ps_query.inc +++ b/mysql-test/include/ps_query.inc @@ -4,10 +4,39 @@ # # ############################################################## +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! -# Please do not modify (INSERT/UPDATE/DELETE) the content of the tables -# t1 and t_many_col_types. -# Such tests should be done in include/ps_modify.inc +# +# Please be aware, that this file will be sourced by several test case files +# stored within the subdirectory 't'. So every change here will affect +# several test cases. +# +# Please do not modify (INSERT/UPDATE/DELETE) the content or the +# structure (DROP/ALTER..) of the tables +# 't1' and 't_many_col_types'. +# Such tests should be done in include/ps_modify.inc . +# +# But you are encouraged to use these two tables within your SELECT statements +# whenever possible. +# t1 - very simple table +# t_many_col_types - table with nearly all available column types +# +# The structure and the content of these tables can be found in +# include/ps_create.inc CREATE TABLE ... +# include/ps_renew.inc DELETE all rows and INSERT some rows +# +# Both tables are managed by the same storage engine. +# The type of the storage engine is stored in the variable '$type' . + + + +#------------------- Please insert your test cases here -------------------# + + + +#-------- Please be very carefull when editing behind this line ----------# --disable_query_log select '------ simple select tests ------' as test_sequence ; diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index b7686bbd26a..5f0ff528b2b 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -4,15 +4,9 @@ # # ############################################################## - -# Please do not -# - modify (INSERT/UPDATE/DELETE) the content of the tables -# t1 and t_many_col_types. Such tests should be done in -# include/ps_modify.inc -# - insert test cases where the results depend on the -# table type. Such tests should be done in the files -# include/ps_query.inc, include/ps_modify ... -# +# +# NOTE: PLEASE SEE THE DETAILED DESCRIPTION AT THE BOTTOM OF THIS FILE +# BEFORE ADDING NEW TEST CASES HERE !!! use test; --disable_query_log @@ -737,3 +731,101 @@ execute stmt1 using @arg60, @arg61 ; drop table t1 ; + +##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES ##### +# +# 0. You don't have the time to +# - read and pay attention to these rules of thumb +# - accept that QA may move your test case to a different place +# (I will not change your code!!) . +# Please append your test case to +# t/ps.test +# +# 1. You have more time and want to get as much value from you test case as +# possible. Please try to make the following decisions: +# +# Will the execution or result of the sub test case depend on the +# properties of a storage engine ? +# +# NO --> alter t/ps_1general.test (Example: Command with syntax error) +# If you need a table, please try to use +# t1 - very simple table +# t_many_col_types - table with nearly all available column types +# whenever possible. +# +# The structure and the content of these tables can be found in +# include/ps_create.inc CREATE TABLE ... +# include/ps_renew.inc DELETE all rows and INSERT some rows +# +# Both tables are managed by the same storage engine. +# The type of the storage engine is stored in the variable +# '$type' . In ps_1general.test $type is set to 'MYISAM'. +# +# Please feel free to source ps_create.inc or ps_renew.inc +# whenever you think it helps. But please restore the original +# state of these tables after your tests, because the following +# statements may depend on it. +# +# YES +# | +# | +# Is it possible to apply the sub test case to all table types ? +# YES --> alter include/ps_query.inc (for SELECTs) +# include/ps_modify.inc (for INSERT/UPDATE/DELETE) +# include/ps_modify1.inc (also for INSERT/UPDATE/DELETE, +# but t/ps_5merge.test will not source that file) +# Please try to find an appropriate place within the file. +# It would be nice if we have some systematics in the +# order of the sub test cases (if possible). +# +# Please be aware, that +# include: ps_query.inc, ps_modify.inc, ps_modify1.inc +# will be sourced by several test case files stored within the +# subdirectory 't'. So every change here will affect several test +# cases. +# +# NO +# | +# | +# Append the sub test case to the appropriate +# ps_.test . +# +# 2. The current structure of the PS tests +# +# t/ps_1general.test Check of basic PS features, SHOW commands and DDL +# The tests should not depend on the table type. +# +# t/ps_2myisam Check of PS on tables of type MYISAM . +# t/ps_3innodb Check of PS on tables of type InnoDB . +# ... +# t/ps_6bdb Check of PS on tables of type BDB . +# All storage engine related tests use the variable $type to hold the +# name of the storage engine. +# +# include/ps_query.inc test cases with SELECT/... +# These test cases should not modify the content or +# the structure (DROP/ALTER..) of the tables +# 't1' and 't_many_col_types'. +# include/ps_modify.inc test cases with INSERT/UPDATE/... +# These test cases should not modify the structure +# (DROP/ALTER..) of the tables +# 't1' and 't_many_col_types'. +# These two test sequences will be applied to all table types . +# +# include/ps_modify1.inc test cases with INSERT/UPDATE/... +# This test sequences will be applied to all table types +# except MERGE tables. +# +# include/ps_create.inc DROP and CREATE of the tables +# 't1' and 't_many_col_types' . +# include/ps_renew.inc DELETE all rows and INSERT some rows, that means +# recreate the original content of these tables. +# Please do not alter the commands concerning these two tables. +# +# Please feel free and encouraged to exploit the current code sharing +# mechanism of the 'ps_
' test cases. It is an convenient +# way to check all storage engines. +# +# Thank you for reading these rules of thumb. +# +# Matthias diff --git a/mysql-test/t/ps_2myisam.test b/mysql-test/t/ps_2myisam.test index 3bb8b01cf87..c7e4746762b 100644 --- a/mysql-test/t/ps_2myisam.test +++ b/mysql-test/t/ps_2myisam.test @@ -4,6 +4,10 @@ # # ############################################### +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + use test; let $type= 'MYISAM' ; diff --git a/mysql-test/t/ps_3innodb.test b/mysql-test/t/ps_3innodb.test index 71acf3b76f1..e6d3e239ff9 100644 --- a/mysql-test/t/ps_3innodb.test +++ b/mysql-test/t/ps_3innodb.test @@ -4,6 +4,10 @@ # # ############################################### +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + use test; let $type= 'InnoDB' ; diff --git a/mysql-test/t/ps_4heap.test b/mysql-test/t/ps_4heap.test index 8aa715b095e..d1c81d95cd7 100644 --- a/mysql-test/t/ps_4heap.test +++ b/mysql-test/t/ps_4heap.test @@ -4,6 +4,10 @@ # # ############################################### +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + use test; let $type= 'HEAP' ; @@ -19,7 +23,8 @@ eval create table t1 --disable_warnings drop table if exists t_many_col_types; --enable_warnings -# The used table type doesn't support BLOB/TEXT columns (error 1163) +# The used table type doesn't support BLOB/TEXT columns. +# (The server would send error 1163 .) # So we use char(100) instead. eval create table t_many_col_types ( diff --git a/mysql-test/t/ps_5merge.test b/mysql-test/t/ps_5merge.test index ee4beea78c4..ff48a50f331 100644 --- a/mysql-test/t/ps_5merge.test +++ b/mysql-test/t/ps_5merge.test @@ -4,6 +4,10 @@ # # ############################################### +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + use test; --disable_warnings diff --git a/mysql-test/t/ps_6bdb.test b/mysql-test/t/ps_6bdb.test index dde6a05268e..7dbd08f5baa 100644 --- a/mysql-test/t/ps_6bdb.test +++ b/mysql-test/t/ps_6bdb.test @@ -4,6 +4,10 @@ # # ############################################### +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + use test; -- source include/have_bdb.inc From 41b04a9b1eea5828179be8316364c681388fce95 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jul 2004 07:14:45 +0200 Subject: [PATCH 05/22] Fix mysql-test-run ndb order by/endian issue --- mysql-test/r/ndb_index_ordered.result | 4 ++-- mysql-test/t/ndb_index_ordered.test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 79472c70e8e..0e3bd555b0a 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -175,10 +175,10 @@ insert into t1 values (19,4, 0); select * from t1 where b<=5 and c=0; a b c 19 4 0 -select * from t1 where b=4 and c<=5; +select * from t1 where b=4 and c<=5 order by a; a b c -19 4 0 17 4 4 +19 4 0 select * from t1 where b<=4 and c<=5 order by a; a b c 7 2 1 diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 79686fce0e1..feb4476f5e7 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -106,7 +106,7 @@ select * from t1 where b<=5 order by a; select * from t1 where b<=5 and c=0; insert into t1 values (19,4, 0); select * from t1 where b<=5 and c=0; -select * from t1 where b=4 and c<=5; +select * from t1 where b=4 and c<=5 order by a; select * from t1 where b<=4 and c<=5 order by a; select * from t1 where b<=5 and c=0 or b<=5 and c=2; drop table t1; From 298ce27e9290058e4ebee49e751f54426d39f549 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jul 2004 07:48:09 +0200 Subject: [PATCH 06/22] - fixed typo in mysql-test/ndb/ndbcluster.sh that caused a "test: argument expected" error when trying to run the NDB test suite on Solaris mysql-test/ndb/ndbcluster.sh: - fixed typo that caused a "test: argument expected" error when trying to run the NDB test suite on Solaris --- mysql-test/ndb/ndbcluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index e51f6f6b076..4afbe5cf3d7 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -98,7 +98,7 @@ if [ ! -x $exec_ndb ]; then echo "$exec_ndb missing" exit 1 fi -if [ ! -x $exec_mgmtsrv ]; then +if [ ! -x $exec_mgmtsrvr ]; then echo "$exec_mgmtsrvr missing" exit 1 fi From 1042c0e86b6211212de8d74e7be7d10307085e54 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jul 2004 07:52:20 +0200 Subject: [PATCH 07/22] BUG#4384 ndb/src/common/util/ConfigValues.cpp: BUG#4384 Compute pointers manually instead of using ptr[-x] Changed return type from "*&" to "**" BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + ndb/include/util/ConfigValues.hpp | 8 ++--- ndb/src/common/util/ConfigValues.cpp | 44 ++++++++++++++++------------ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index c5919a58b7f..99ee1c5182b 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -123,6 +123,7 @@ mwagner@work.mysql.com mydev@mysql.com mysql@home.(none) mysqldev@build.mysql2.com +mysqldev@melody.local mysqldev@mysql.com ndbdev@ndbmaster.mysql.com nick@mysql.com diff --git a/ndb/include/util/ConfigValues.hpp b/ndb/include/util/ConfigValues.hpp index 48e1363bf4a..3fbeedb25a0 100644 --- a/ndb/include/util/ConfigValues.hpp +++ b/ndb/include/util/ConfigValues.hpp @@ -24,8 +24,8 @@ public: ValueType m_type; union { Uint32 m_int; - const char * m_string; Uint64 m_int64; + const char * m_string; }; }; @@ -72,14 +72,14 @@ private: friend class ConstIterator; bool getByPos(Uint32 pos, Entry *) const; - Uint64 & get64(Uint32 index) const; - char * & getString(Uint32 index) const; + Uint64 * get64(Uint32 index) const; + char ** getString(Uint32 index) const; Uint32 m_size; Uint32 m_dataSize; Uint32 m_stringCount; Uint32 m_int64Count; - + Uint32 m_values[1]; void * m_data[1]; }; diff --git a/ndb/src/common/util/ConfigValues.cpp b/ndb/src/common/util/ConfigValues.cpp index 18ecf4bcdc4..7fc99bc526c 100644 --- a/ndb/src/common/util/ConfigValues.cpp +++ b/ndb/src/common/util/ConfigValues.cpp @@ -60,7 +60,7 @@ ConfigValues::ConfigValues(Uint32 sz, Uint32 dsz){ ConfigValues::~ConfigValues(){ for(Uint32 i = 0; im_int = val; break; case StringType: - result->m_string = getString(val); + result->m_string = * getString(val); break; case Int64Type: - result->m_int64 = get64(val); + result->m_int64 = * get64(val); break; case InvalidType: default: @@ -102,18 +102,23 @@ ConfigValues::getByPos(Uint32 pos, Entry * result) const { return true; } -Uint64 & +Uint64 * ConfigValues::get64(Uint32 index) const { assert(index < m_int64Count); - Uint64 * ptr = (Uint64*)(&m_values[m_size << 1]); - return ptr[index]; + const Uint32 * data = m_values + (m_size << 1); + Uint64 * ptr = (Uint64*)data; + ptr += index; + return ptr; } -char * & +char ** ConfigValues::getString(Uint32 index) const { - assert(index < m_stringCount); - char ** ptr = (char**)(((char *)&(m_values[m_size << 1])) + m_dataSize); - return ptr[-index]; + assert(index < m_stringCount); + const Uint32 * data = m_values + (m_size << 1); + char * ptr = (char*)data; + ptr += m_dataSize; + ptr -= (index * sizeof(char *)); + return (char**)ptr; } bool @@ -176,7 +181,7 @@ ConfigValues::Iterator::set(Uint32 key, Uint64 value){ return false; } - m_cfg.get64(m_cfg.m_values[pos+1]) = value; + * m_cfg.get64(m_cfg.m_values[pos+1]) = value; return true; } @@ -191,9 +196,9 @@ ConfigValues::Iterator::set(Uint32 key, const char * value){ return false; } - char * & str = m_cfg.getString(m_cfg.m_values[pos+1]); - free(str); - str = strdup(value ? value : ""); + char ** str = m_cfg.getString(m_cfg.m_values[pos+1]); + free(* str); + * str = strdup(value ? value : ""); return true; } @@ -457,7 +462,8 @@ ConfigValuesFactory::put(const ConfigValues::Entry & entry){ case ConfigValues::StringType:{ Uint32 index = m_cfg->m_stringCount++; m_cfg->m_values[pos+1] = index; - m_cfg->getString(index) = strdup(entry.m_string ? entry.m_string : ""); + char ** ref = m_cfg->getString(index); + * ref = strdup(entry.m_string ? entry.m_string : ""); m_freeKeys--; m_freeData -= sizeof(char *); DEBUG printf("Putting at: %d(%d) (loop = %d) key: %d value(%d): %s\n", @@ -470,7 +476,7 @@ ConfigValuesFactory::put(const ConfigValues::Entry & entry){ case ConfigValues::Int64Type:{ Uint32 index = m_cfg->m_int64Count++; m_cfg->m_values[pos+1] = index; - m_cfg->get64(index) = entry.m_int64; + * m_cfg->get64(index) = entry.m_int64; m_freeKeys--; m_freeData -= 8; DEBUG printf("Putting at: %d(%d) (loop = %d) key: %d value64(%d): %lld\n", @@ -558,7 +564,7 @@ ConfigValues::getPackedSize() const { break; case StringType: size += 8; // key + len - size += mod4(strlen(getString(m_values[i+1])) + 1); + size += mod4(strlen(* getString(m_values[i+1])) + 1); break; case InvalidType: default: @@ -587,7 +593,7 @@ ConfigValues::pack(void * _dst, Uint32 _len) const { * (Uint32*)dst = htonl(val); dst += 4; break; case Int64Type:{ - Uint64 i64 = get64(val); + Uint64 i64 = * get64(val); Uint32 hi = (i64 >> 32); Uint32 lo = (i64 & 0xFFFFFFFF); * (Uint32*)dst = htonl(key); dst += 4; @@ -596,7 +602,7 @@ ConfigValues::pack(void * _dst, Uint32 _len) const { } break; case StringType:{ - const char * str = getString(val); + const char * str = * getString(val); Uint32 len = strlen(str) + 1; * (Uint32*)dst = htonl(key); dst += 4; * (Uint32*)dst = htonl(len); dst += 4; From 1d57e419e921d85e5d880bf44ead099c7a1d9bfa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 10:19:05 +0200 Subject: [PATCH 08/22] Fix uninit variable --- ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index c763d3b4786..fe737fc584b 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -63,7 +63,7 @@ Ndbfs::Ndbfs(const Configuration & conf) : const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator(); ndbrequire(p != 0); - m_maxOpenedFiles = 40; + m_maxFiles = 40; //ndb_mgm_get_int_parameter(p, CFG_DB_MAX_OPEN_FILES, &m_maxFiles); // Create idle AsyncFiles From 46f90a6a3e1d5ac7695e7481cfae99ee9e6407aa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 13:43:15 +0500 Subject: [PATCH 09/22] rpl_charset.result, rpl_charset.test: An addition to 1.2036 04/07/02: armscii8_bin was referenced to as armscii_bin in a mistake. mysql-test/t/rpl_charset.test: An addition to 1.2036 04/07/02: armscii8_bin was referenced to as armscii_bin in a mistake. mysql-test/r/rpl_charset.result: An addition to 1.2036 04/07/02: armscii8_bin was referenced to as armscii_bin in a mistake. --- mysql-test/r/rpl_charset.result | 10 +++++----- mysql-test/t/rpl_charset.test | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_charset.result b/mysql-test/r/rpl_charset.result index 8d42957c9d3..d5f8ac4f293 100644 --- a/mysql-test/r/rpl_charset.result +++ b/mysql-test/r/rpl_charset.result @@ -25,19 +25,19 @@ test2 CREATE DATABASE `test2` /*!40100 DEFAULT CHARACTER SET latin2 */ show create database test3; Database Create Database test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET latin5 */ -set @@collation_server=armscii_bin; +set @@collation_server=armscii8_bin; drop database test3; create database test3; --- --master-- show create database test3; Database Create Database -test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii_bin */ +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii8_bin */ --- --slave-- show create database test3; Database Create Database -test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii_bin */ +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii8_bin */ use test2; create table t1 (a int auto_increment primary key, b varchar(100)); set character_set_client=cp850, collation_connection=latin2_croatian_ci; @@ -51,7 +51,7 @@ insert into t1 (b) values(@@collation_connection); select * from t1 order by a; a b 1 armscii8 -2 armscii_bin +2 armscii8_bin 3 cp850 4 latin2 5 latin2_croatian_ci @@ -60,7 +60,7 @@ a b select * from test2.t1 order by a; a b 1 armscii8 -2 armscii_bin +2 armscii8_bin 3 cp850 4 latin2 5 latin2_croatian_ci diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test index c13b57a3108..02bcdf1f5f1 100644 --- a/mysql-test/t/rpl_charset.test +++ b/mysql-test/t/rpl_charset.test @@ -26,7 +26,7 @@ show create database test2; show create database test3; connection master; -set @@collation_server=armscii_bin; +set @@collation_server=armscii8_bin; drop database test3; create database test3; --disable_query_log From 6ecb255734ac080b4a45e56187e8822d3ac9474b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 13:56:50 +0200 Subject: [PATCH 10/22] re-enable spatial features for windows grr --- include/config-win.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index 0298c9012ce..b93c5897adf 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -348,6 +348,8 @@ inline double ulonglong2double(ulonglong value) #define MYSQL_DEFAULT_CHARSET_NAME "latin1" #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" +#define HAVE_SPATIAL 1 + /* Define charsets you want */ /* #undef HAVE_CHARSET_armscii8 */ /* #undef HAVE_CHARSET_ascii */ From dce5cc109d1e4717a4c024c939a044454c433a5b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 17:15:43 +0500 Subject: [PATCH 11/22] Bug#4417 binary character set breaks multi-byte table/field name. --- mysql-test/r/ctype_recoding.result | 25 +++++++++++++++++++++++++ mysql-test/t/ctype_recoding.test | 19 +++++++++++++++++++ sql/sql_class.cc | 14 ++++++++------ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index ed59de87395..d40360b9337 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -111,3 +111,28 @@ SET character_set_connection=cp1251; SELECT hex(''); hex('') F2E5F1F2 +USE test; +SET NAMES binary; +CREATE TABLE `тест` (`тест` int); +SHOW CREATE TABLE `тест`; +Table Create Table +тест CREATE TABLE `тест` ( + `тест` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SET NAMES utf8; +SHOW CREATE TABLE `тест`; +Table Create Table +тест CREATE TABLE `тест` ( + `тест` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE `тест`; +SET NAMES binary; +SET character_set_connection=utf8; +SELECT 'тест' as s; +s +тест +SET NAMES utf8; +SET character_set_connection=binary; +SELECT 'тест' as s; +s +тест diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 8ac22e89c2d..45cc0cebfb3 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -78,3 +78,22 @@ SET NAMES koi8r; SELECT hex(''); SET character_set_connection=cp1251; SELECT hex(''); + +USE test; + +# Bug#4417 +# Check that identifiers and strings are not converted +# when the client character set is binary. + +SET NAMES binary; +CREATE TABLE `тест` (`тест` int); +SHOW CREATE TABLE `тест`; +SET NAMES utf8; +SHOW CREATE TABLE `тест`; +DROP TABLE `тест`; +SET NAMES binary; +SET character_set_connection=utf8; +SELECT 'тест' as s; +SET NAMES utf8; +SET character_set_connection=binary; +SELECT 'тест' as s; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7aa3bbbdd7b..ad4eb9f6801 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -533,21 +533,23 @@ bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs) return FALSE; } + /* Update some cache variables when character set changes */ void THD::update_charset() { - charset_is_system_charset= my_charset_same(charset(),system_charset_info); - charset_is_collation_connection= my_charset_same(charset(), - variables. - collation_connection); + uint32 not_used; + charset_is_system_charset= !String::needs_conversion(0,charset(), + system_charset_info, + ¬_used); + charset_is_collation_connection= + !String::needs_conversion(0,charset(),variables.collation_connection, + ¬_used); } - - /* routings to adding tables to list of changed in transaction tables */ inline static void list_include(CHANGED_TABLE_LIST** prev, From b5f66b02a43f45d1478f01d5e172578785c88fea Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 17:18:04 +0500 Subject: [PATCH 12/22] mysqltest.c: Bug #4338 mysql-test-run fails if compiled with non-latin1 character set. client/mysqltest.c: Bug #4338 mysql-test-run fails if compiled with non-latin1 character set. --- client/mysqltest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 5ba4ad7336c..f0d2eb0aded 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1628,6 +1628,7 @@ int do_connect(struct st_query* q) if (opt_compress) mysql_options(&next_con->mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&next_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); + mysql_options(&next_con->mysql, MYSQL_SET_CHARSET_NAME, "latin1"); #ifdef HAVE_OPENSSL if (opt_use_ssl) @@ -2692,6 +2693,8 @@ int main(int argc, char **argv) if (opt_compress) mysql_options(&cur_con->mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&cur_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); + mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_NAME, "latin1"); + #ifdef HAVE_OPENSSL if (opt_use_ssl) mysql_ssl_set(&cur_con->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca, From 692f440b42a685da5414c8612d0e022f501d77f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 14:24:44 +0200 Subject: [PATCH 13/22] HAVE_RTREE_KEYS are enabled on windows too --- include/config-win.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/config-win.h b/include/config-win.h index b93c5897adf..91697c985d1 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -349,6 +349,7 @@ inline double ulonglong2double(ulonglong value) #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" #define HAVE_SPATIAL 1 +#define HAVE_RTREE_KEYS 1 /* Define charsets you want */ /* #undef HAVE_CHARSET_armscii8 */ From 68aec1e48d58dd8251324ca4f6fc886d627d89af Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 16:29:26 +0200 Subject: [PATCH 14/22] mysql_fix_privilege_tables.sh: various fixes (for mysql-test-run at least): * accept --no-defaults * 4.0 compatible password handling (only it no other argumensts, only if doesn't start with --) ps_3innodb.test: only run ps_3innodb.test if innodb is present mysql-test-run.sh: it's --verbose, not --verbose=1 mysql-test/mysql-test-run.sh: it's --verbose, not --verbose=1 mysql-test/t/ps_3innodb.test: only run ps_3innodb.test if innodb is present scripts/mysql_fix_privilege_tables.sh: various fixes (for mysql-test-run at least): * accept --no-defaults * 4.0 compatible password handling (only it no other argumensts, only if doesn't start with --) --- mysql-test/mysql-test-run.sh | 2 +- mysql-test/t/ps_3innodb.test | 2 ++ scripts/mysql_fix_privilege_tables.sh | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 52938c8a2ee..55f9d3b00a9 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -525,7 +525,7 @@ fi MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" -MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose=1" +MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES CLIENT_BINDIR diff --git a/mysql-test/t/ps_3innodb.test b/mysql-test/t/ps_3innodb.test index e6d3e239ff9..055e1e127e5 100644 --- a/mysql-test/t/ps_3innodb.test +++ b/mysql-test/t/ps_3innodb.test @@ -10,6 +10,8 @@ use test; +-- source include/have_innodb.inc + let $type= 'InnoDB' ; -- source include/ps_create.inc -- source include/ps_renew.inc diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index f3c5c009f1c..79b4bc627b7 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -17,8 +17,24 @@ bindir="" file=mysql_fix_privilege_tables.sql +# The following test is to make this script compatible with the 4.0 where +# the single argument could be a password +if test "$#" = 1 +then + case "$1" in + --*) ;; + *) old_style_password="$1" ; shift ;; + esac +fi + # The following code is almost identical to the code in mysql_install_db.sh +case "$1" in + --no-defaults|--defaults-file=*|--defaults-extra-file=*) + defaults="$1"; shift + ;; +esac + parse_arguments() { # We only need to pass arguments through to the server if we don't # handle them here. So, we collect unrecognized options (passed on @@ -36,7 +52,7 @@ parse_arguments() { --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --sql|--sql-only) sql_only=1;; + --sql|--sql-only) sql_only=1 ;; --verbose) verbose=1 ;; --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;; --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;; @@ -47,7 +63,7 @@ parse_arguments() { then # This sed command makes sure that any special chars are quoted, # so the arg gets passed exactly to the server. - args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.-]\),\\\\\1,g'` + args="$args "`echo "$arg" | sed -e 's,\([^=a-zA-Z0-9_.-]\),\\\\\1,g'` fi ;; esac @@ -94,11 +110,9 @@ else fi fi -# The following test is to make this script compatible with the 4.0 where -# the first argument was the password if test -z "$password" then - password=`echo $args | sed -e 's/ *//g'` + password=$old_style_password fi cmd="$bindir/mysql -f --user=$user --host=$host" From 8da691f38c14ca5dd6dd78701fca9c51ed40b18f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 16:30:50 +0100 Subject: [PATCH 15/22] Bug#4407 - assertion in ha_myisam.cc Fix assertion failure where ha_myisam::index_next() is called without first calling ha_myisam::ha_index_init() BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + sql/sql_acl.cc | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 99ee1c5182b..398a9295579 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -11,6 +11,7 @@ administrador@light.hegel.local ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com antony@ltantony.dsl-verizon.net +antony@ltantony.rdg.cyberkinetica.com antony@ltantony.rdg.cyberkinetica.homeunix.net arjen@bitbike.com arjen@co3064164-a.bitbike.com diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index a03e371dd63..fa8065a5fc3 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1790,11 +1790,13 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) col_privs->field[3]->pack_length()); key_copy(key,col_privs,0,key_len); col_privs->field[4]->store("",0, &my_charset_latin1); - if (col_privs->file->index_read_idx(col_privs->record[0],0, + col_privs->file->ha_index_init(0); + if (col_privs->file->index_read(col_privs->record[0], (byte*) col_privs->field[0]->ptr, key_len, HA_READ_KEY_EXACT)) { cols = 0; /* purecov: deadcode */ + col_privs->file->ha_index_end(); return; } do @@ -1814,6 +1816,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) my_hash_insert(&hash_columns, (byte *) mem_check); } while (!col_privs->file->index_next(col_privs->record[0]) && !key_cmp_if_same(col_privs,key,0,key_len)); + col_privs->file->ha_index_end(); } } From f5652ffa1538d132919a1ff198d0a955039e7159 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jul 2004 17:45:37 +0200 Subject: [PATCH 16/22] Fixed typo --- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 9589639a332..348f6db36e4 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1417,7 +1417,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, s = SimpleProperties::pack(w, &tmpAttr, DictTabInfo::AttributeMapping, - DictTabInfo::TableMappingSize, true); + DictTabInfo::AttributeMappingSize, true); w.add(DictTabInfo::AttributeEnd, 1); } From 4e95ea7b6e917769d0da6e8eea054aba8d224a52 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jul 2004 13:47:29 +0500 Subject: [PATCH 17/22] ha_archive.cc: Memory was used after it has been alreay freed. This led to server crash on FreeBSD. sql/examples/ha_archive.cc: Memory was used after it has been alreay freed. This led to server crash on FreeBSD. --- sql/examples/ha_archive.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index e052a819ef8..a4fe2aaa8cc 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -188,9 +188,9 @@ static int free_share(ARCHIVE_SHARE *share) hash_delete(&archive_open_tables, (byte*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); if (gzclose(share->archive_write) == Z_ERRNO) rc= -1; + my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); From 288b8d957b64d9d061bc9c868965ffa8a01fd0ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jul 2004 15:20:23 +0500 Subject: [PATCH 18/22] Adding Roman (classical Latin) collation. --- mysql-test/r/ctype_uca.result | 106 ++++++++++++++++++++++++++++++++++ mysql-test/t/ctype_uca.test | 1 + mysys/charset-def.c | 4 ++ strings/ctype-uca.c | 58 +++++++++++++++++++ 4 files changed, 169 insertions(+) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index cb6fbecb6e8..51da05f9fee 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -1655,3 +1655,109 @@ Z,z,Ź,ź,Ż,ż,Ž,ž ǁ ǂ ǃ +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; +group_concat(c1 order by c1) +÷ +× +A,a,À,Á,Â,Ã,Ä,Å,à,á,â,ã,ä,å,Ā,ā,Ă,ă,Ą,ą,Ǎ,ǎ,Ǟ,ǟ,Ǡ,ǡ,Ǻ,ǻ +AA,Aa,aA,aa +Æ,æ,Ǣ,ǣ,Ǽ,ǽ +B,b +ƀ +Ɓ +Ƃ,ƃ +C,c,Ç,ç,Ć,ć,Ĉ,ĉ,Ċ,ċ,Č,č +CH,Ch,cH,ch +Ƈ,ƈ +D,d,Ď,ď +DZ,Dz,dZ,dz,DŽ,Dž,dž,DZ,Dz,dz +Đ,đ +Ɖ +Ɗ +Ƌ,ƌ +Ð,ð +E,e,È,É,Ê,Ë,è,é,ê,ë,Ē,ē,Ĕ,ĕ,Ė,ė,Ę,ę,Ě,ě +Ǝ,ǝ +Ə +Ɛ +F,f +Ƒ,ƒ +G,g,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ģ,ģ,Ǧ,ǧ,Ǵ,ǵ +Ǥ,ǥ +Ɠ +Ɣ +Ƣ,ƣ +H,h,Ĥ,ĥ +ƕ,Ƕ +Ħ,ħ +I,J,i,j,Ì,Í,Î,Ï,ì,í,î,ï,Ĩ,ĩ,Ī,ī,Ĭ,ĭ,Į,į,İ,Ǐ,ǐ +IJ,Ij,iJ,ij +IJ,ij +ı +Ɨ +Ɩ +Ĵ,ĵ,ǰ +K,k,Ķ,ķ,Ǩ,ǩ +Ƙ,ƙ +L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ +Ŀ,ŀ +LJ,Lj,lJ,lj +LJ,Lj,lj +LL,Ll,lL,ll +Ł,ł +ƚ +ƛ +M,m +N,n,Ñ,ñ,Ń,ń,Ņ,ņ,Ň,ň,Ǹ,ǹ +NJ,Nj,nJ,nj +NJ,Nj,nj +Ɲ +ƞ +Ŋ,ŋ +O,o,Ò,Ó,Ô,Õ,Ö,ò,ó,ô,õ,ö,Ō,ō,Ŏ,ŏ,Ő,ő,Ơ,ơ,Ǒ,ǒ,Ǫ,ǫ,Ǭ,ǭ +OE,Oe,oE,oe,Œ,œ +Ø,ø,Ǿ,ǿ +Ɔ +Ɵ +P,p +Ƥ,ƥ +Q,q +ĸ +R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř +RR,Rr,rR,rr +Ʀ +S,s,Ś,ś,Ŝ,ŝ,Ş,ş,Š,š,ſ +SS,Ss,sS,ss,ß +Ʃ +ƪ +T,t,Ţ,ţ,Ť,ť +ƾ +Ŧ,ŧ +ƫ +Ƭ,ƭ +Ʈ +U,V,u,v,Ù,Ú,Û,Ü,ù,ú,û,ü,Ũ,ũ,Ū,ū,Ŭ,ŭ,Ů,ů,Ű,ű,Ų,ų,Ư,ư,Ǔ,ǔ,Ǖ,ǖ,Ǘ,ǘ,Ǚ,ǚ,Ǜ,ǜ +Ɯ +Ʊ +Ʋ +W,w,Ŵ,ŵ +X,x +Y,y,Ý,ý,ÿ,Ŷ,ŷ,Ÿ +Ƴ,ƴ +Z,z,Ź,ź,Ż,ż,Ž,ž +ƍ +Ƶ,ƶ +Ʒ,Ǯ,ǯ +Ƹ,ƹ +ƺ +Þ,þ +ƿ,Ƿ +ƻ +Ƨ,ƨ +Ƽ,ƽ +Ƅ,ƅ +ʼn +ǀ +ǁ +ǂ +ǃ diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 6ff1407247f..0ab46a5a637 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -178,4 +178,5 @@ select group_concat(c1 order by c1) from t1 group by c1 collate utf8_danish_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_lithuanian_ci; --select group_concat(c1 order by c1) from t1 group by c1 collate utf8_slovak_ci; select group_concat(c1 order by c1) from t1 group by c1 collate utf8_spanish2_ci; +select group_concat(c1 order by c1) from t1 group by c1 collate utf8_roman_ci; diff --git a/mysys/charset-def.c b/mysys/charset-def.c index 73e36688594..420a13a592d 100644 --- a/mysys/charset-def.c +++ b/mysys/charset-def.c @@ -38,6 +38,7 @@ extern CHARSET_INFO my_charset_ucs2_danish_uca_ci; extern CHARSET_INFO my_charset_ucs2_lithuanian_uca_ci; extern CHARSET_INFO my_charset_ucs2_slovak_uca_ci; extern CHARSET_INFO my_charset_ucs2_spanish2_uca_ci; +extern CHARSET_INFO my_charset_ucs2_roman_uca_ci; #endif #ifdef HAVE_CHARSET_utf8 @@ -56,6 +57,7 @@ extern CHARSET_INFO my_charset_utf8_danish_uca_ci; extern CHARSET_INFO my_charset_utf8_lithuanian_uca_ci; extern CHARSET_INFO my_charset_utf8_slovak_uca_ci; extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci; +extern CHARSET_INFO my_charset_utf8_roman_uca_ci; #endif my_bool init_compiled_charsets(myf flags __attribute__((unused))) @@ -124,6 +126,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) add_compiled_collation(&my_charset_ucs2_lithuanian_uca_ci); add_compiled_collation(&my_charset_ucs2_slovak_uca_ci); add_compiled_collation(&my_charset_ucs2_spanish2_uca_ci); + add_compiled_collation(&my_charset_ucs2_roman_uca_ci); #endif #ifdef HAVE_CHARSET_ujis @@ -149,6 +152,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) add_compiled_collation(&my_charset_utf8_lithuanian_uca_ci); add_compiled_collation(&my_charset_utf8_slovak_uca_ci); add_compiled_collation(&my_charset_utf8_spanish2_uca_ci); + add_compiled_collation(&my_charset_utf8_roman_uca_ci); #endif /* Copy compiled charsets */ diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 5bb710946b1..9590b98e664 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6653,6 +6653,9 @@ static const char spanish2[]= /* Also good for Asturian and Galician */ "&N < \\u00F1 <<< \\u00D1" "&R << rr <<< Rr <<< RR"; +static const char roman[]= /* i.e. Classical Latin */ + "& I << j <<< J " + "& U << v <<< V "; /* Unicode Collation Algorithm: @@ -8328,6 +8331,34 @@ CHARSET_INFO my_charset_ucs2_spanish2_uca_ci= &my_collation_ucs2_uca_handler }; + +CHARSET_INFO my_charset_ucs2_roman_uca_ci= +{ + 143,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE, + "ucs2", /* cs name */ + "ucs2_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 2, /* mbminlen */ + 2, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + &my_charset_ucs2_handler, + &my_collation_ucs2_uca_handler +}; + #endif @@ -8779,4 +8810,31 @@ CHARSET_INFO my_charset_utf8_spanish2_uca_ci= &my_charset_utf8_handler, &my_collation_any_uca_handler }; + +CHARSET_INFO my_charset_utf8_roman_uca_ci= +{ + 207,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE, + "utf8", /* cs name */ + "utf8_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* mbminlen */ + 2, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + &my_charset_utf8_handler, + &my_collation_any_uca_handler +}; #endif From 5ef15478cdbaa65c7d037ce5662117b8ed425dba Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jul 2004 16:39:43 +0500 Subject: [PATCH 19/22] Don't allow badly formed UTF8 identitiers --- include/mysqld_error.h | 3 ++- mysql-test/r/ctype_recoding.result | 6 ++++++ mysql-test/t/ctype_recoding.test | 10 ++++++++++ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_yacc.yy | 12 ++++++++++++ 27 files changed, 53 insertions(+), 1 deletion(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 0dcc09a173f..0d752b0daf1 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -316,4 +316,5 @@ #define ER_GET_TEMPORARY_ERRMSG 1297 #define ER_UNKNOWN_TIME_ZONE 1298 #define ER_WARN_INVALID_TIMESTAMP 1299 -#define ER_ERROR_MESSAGES 300 +#define ER_INVALID_CHARACTER_STRING 1300 +#define ER_ERROR_MESSAGES 301 diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index d40360b9337..805f731f0ec 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -136,3 +136,9 @@ SET character_set_connection=binary; SELECT 'тест' as s; s тест +SET NAMES binary; +CREATE TABLE `good` (a int); +ERROR HY000: Invalid utf8 character string: '' +SET NAMES utf8; +CREATE TABLE `good` (a int); +ERROR HY000: Invalid utf8 character string: '` (a int)' diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 45cc0cebfb3..de6332f272c 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -97,3 +97,13 @@ SELECT 'тест' as s; SET NAMES utf8; SET character_set_connection=binary; SELECT 'тест' as s; + +# +# Test that we allow only well-formed UTF8 identitiers +# +SET NAMES binary; +--error 1300 +CREATE TABLE `good` (a int); +SET NAMES utf8; +--error 1300 +CREATE TABLE `good` (a int); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 2d377929229..3cc665f0597 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -312,3 +312,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index af7b8263e6b..7b42d47f008 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -306,3 +306,4 @@ character-set=latin1 "Modtog temporary fejl %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index aa20996680e..ce1d06d4356 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -314,3 +314,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index b5a7f7962cf..b8b4cd1127d 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 0cc6e06ab26..a2f4c848217 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -308,3 +308,4 @@ character-set=latin7 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 2e23db62ddb..7b3497ead2b 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index c63162c84f6..75732b3f732 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -315,3 +315,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index fa94b0f5107..3825240927a 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -303,3 +303,4 @@ character-set=greek "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 56fae82c438..eb968dd3a27 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 31768f172b4..7112bcce5f2 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 4385f25c991..005f85c6ad7 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -305,3 +305,4 @@ character-set=ujis "Got temporary NDB error %d '%-.100s'", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index a6e84fad01e..a1b6a6c2654 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -303,3 +303,4 @@ character-set=euckr "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index eaf7b3482ee..52f1a4ec12c 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Mottok temporary feil %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 692c10db58f..fadcc203c37 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Mottok temporary feil %d '%-.100s' fra %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 19f2c1c6983..bac2e0678a8 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index c77d10d83de..9e5988490b3 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -304,3 +304,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 5ee4efd0063..29dd9eb022a 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -307,3 +307,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 20188723f6d..7cbbd6e36b8 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -305,3 +305,4 @@ character-set=koi8r "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index cc822431464..c45df8bfbe9 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -309,3 +309,4 @@ character-set=cp1250 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index ee6aac5081b..f94bb70d9e8 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -311,3 +311,4 @@ character-set=latin2 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 483ec7068a2..68488528309 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -305,3 +305,4 @@ character-set=latin1 "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index d9f3adf92d4..6bb2ede2cb1 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -303,3 +303,4 @@ character-set=latin1 "Fick tilfllig felkod %d '%-.100s' frn %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index acf6f5121e8..e16b4ef64d6 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -308,3 +308,4 @@ character-set=koi8u "Got temporary error %d '%-.100s' from %s", "Unknown or incorrect time zone: '%-.64s'", "Invalid TIMESTAMP value in column '%s' at row %ld", +"Invalid %s character string: '%.64s'", diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d284bff8c7c..2860077b6a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4884,7 +4884,19 @@ IDENT_sys: { THD *thd= YYTHD; if (thd->charset_is_system_charset) + { + CHARSET_INFO *cs= system_charset_info; + uint wlen= cs->cset->well_formed_len(cs, $1.str, + $1.str+$1.length, + $1.length); + if (wlen < $1.length) + { + net_printf(YYTHD, ER_INVALID_CHARACTER_STRING, cs->csname, + $1.str + wlen); + YYABORT; + } $$= $1; + } else thd->convert_string(&$$, system_charset_info, $1.str, $1.length, thd->charset()); From 11300725dfaf9603b34dc01e05c8e316112a42a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jul 2004 23:49:03 +0200 Subject: [PATCH 20/22] bug#4441 - crash in UNHEX(NULL) --- mysql-test/r/func_str.result | 6 +++--- mysql-test/t/func_str.test | 2 +- sql/item_strfunc.cc | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index f91691853b9..1baf9d8e01c 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -192,9 +192,9 @@ length(quote(concat(char(0),"test"))) select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))); hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))) 27E0E3E6E7E8EAEB27 -select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"); -unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") -foobar 1234567890ABCDEF 4Vx +select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL); +unhex(hex("foobar")) hex(unhex("1234567890ABCDEF")) unhex("345678") unhex(NULL) +foobar 1234567890ABCDEF 4Vx NULL select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex("12345")) hex(unhex("123456")) 01 12 0123 1234 012345 123456 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index cc8d8a88437..61d0326f7dd 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -78,7 +78,7 @@ select quote(concat('abc\'', '\\cba')); select quote(1/0), quote('\0\Z'); select length(quote(concat(char(0),"test"))); select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235)))); -select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"); +select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL); select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); select length(unhex(md5("abrakadabra"))); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b0c685c1c46..b5b08a04f88 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2298,15 +2298,18 @@ String *Item_func_unhex::val_str(String *str) { DBUG_ASSERT(fixed == 1); /* Convert given hex string to a binary string */ + String *res= args[0]->val_str(str); - const char *from=res->ptr(), *end; - char *to; - int r; if (!res || tmp_value.alloc((1+res->length())/2)) { null_value=1; return 0; } + + const char *from=res->ptr(), *end; + char *to; + int r; + null_value=0; tmp_value.length((1+res->length())/2); to= (char*) tmp_value.ptr(); From 002a555e5b8cc377ff575086178e608f94352415 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jul 2004 10:11:30 +0200 Subject: [PATCH 21/22] results fixed --- mysql-test/r/bdb.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 25118702d09..4080ba227a0 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -785,7 +785,7 @@ Table Op Msg_type Msg_text test.t1 optimize status OK show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A 2 NULL NULL BTREE +t1 0 PRIMARY 1 a NULL 2 NULL NULL BTREE drop table t1; create table t1 (i int, j int )ENGINE=BDB; insert into t1 values (1,2); From f96b20c95e2bf63911c4704abadf1ba0c82ae9ff Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jul 2004 15:03:01 +0500 Subject: [PATCH 22/22] WL#807 Optimize loading database options in load_db_opt also known as BUG#2326 Charset of table is determined by charset of db only if "USE db;" --- mysql-test/r/ctype_create.result | 42 ++++-- mysql-test/t/ctype_create.test | 41 ++++-- sql/mysql_priv.h | 4 +- sql/mysqld.cc | 6 +- sql/sql_db.cc | 213 ++++++++++++++++++++++++++++++- sql/sql_parse.cc | 1 + sql/sql_table.cc | 17 +++ sql/sql_yacc.yy | 4 +- 8 files changed, 299 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/ctype_create.result b/mysql-test/r/ctype_create.result index e2dc8c1be66..0da76c556e2 100644 --- a/mysql-test/r/ctype_create.result +++ b/mysql-test/r/ctype_create.result @@ -1,15 +1,37 @@ SET @@character_set_server=latin5; -CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; -USE db1; -CREATE DATABASE db2; -SHOW CREATE DATABASE db1; +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET cp1251; +USE mysqltest1; +CREATE DATABASE mysqltest2; +SHOW CREATE DATABASE mysqltest1; Database Create Database -db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET cp1251 */ -SHOW CREATE DATABASE db2; +mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp1251 */ +SHOW CREATE DATABASE mysqltest2; Database Create Database -db2 CREATE DATABASE `db2` /*!40100 DEFAULT CHARACTER SET latin5 */ -DROP DATABASE db2; -USE db1; +mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET latin5 */ +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 +DROP TABLE mysqltest2.t1; +ALTER DATABASE mysqltest2 DEFAULT CHARACTER SET latin7; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin7 +DROP DATABASE mysqltest2; +CREATE DATABASE mysqltest2 CHARACTER SET latin2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin2 +DROP DATABASE mysqltest2; +USE mysqltest1; CREATE TABLE t1 (a char(10)); SHOW CREATE TABLE t1; Table Create Table @@ -32,4 +54,4 @@ t1 CREATE TABLE `t1` ( `a` char(10) collate latin1_german1_ci default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci DROP TABLE t1; -DROP DATABASE db1; +DROP DATABASE mysqltest1; diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test index bd8c22bb4f6..6d7ed6fc205 100644 --- a/mysql-test/t/ctype_create.test +++ b/mysql-test/t/ctype_create.test @@ -13,25 +13,48 @@ SET @@character_set_server=latin5; -CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; -USE db1; -CREATE DATABASE db2; +CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET cp1251; +USE mysqltest1; +CREATE DATABASE mysqltest2; # # This should be cp1251 # -SHOW CREATE DATABASE db1; +SHOW CREATE DATABASE mysqltest1; # -# This should take the default latin5 value from server level. +# Database "mysqltest2" should take the default latin5 value from +# the server level. +# Afterwards, table "d2.t1" should inherit the default latin5 value from +# the database "mysqltest2", using database option hash. # -SHOW CREATE DATABASE db2; -DROP DATABASE db2; +SHOW CREATE DATABASE mysqltest2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP TABLE mysqltest2.t1; + +# +# Now we check if the database charset is updated in +# the database options hash when we ALTER DATABASE. +# +ALTER DATABASE mysqltest2 DEFAULT CHARACTER SET latin7; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP DATABASE mysqltest2; + +# +# Now we check if the database charset is removed from +# the database option hash when we DROP DATABASE. +# +CREATE DATABASE mysqltest2 CHARACTER SET latin2; +CREATE TABLE mysqltest2.t1 (a char(10)); +SHOW CREATE TABLE mysqltest2.t1; +DROP DATABASE mysqltest2; # # Check that table value uses database level by default # -USE db1; +USE mysqltest1; CREATE TABLE t1 (a char(10)); SHOW CREATE TABLE t1; DROP TABLE t1; @@ -50,4 +73,4 @@ DROP TABLE t1; # # # -DROP DATABASE db1; +DROP DATABASE mysqltest1; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 72ac3af70ff..9553af13431 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -801,6 +801,7 @@ bool is_keyword(const char *name, uint len); #define MY_DB_OPT_FILE "db.opt" bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create); +void my_dbopt_free(void); /* External variables @@ -894,7 +895,8 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_system_variables, LOCK_user_conn; -extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; +extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, + LOCK_dboptions; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_attr_t connection_attrib; extern I_List threads; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 436f693d734..75f1aaeb775 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -382,7 +382,8 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count, LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received, LOCK_global_system_variables, LOCK_user_conn, LOCK_slave_list, LOCK_active_mi; -rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; +rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave, + LOCK_dboptions; pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, COND_slave_start; pthread_cond_t COND_thread_cache,COND_flush_thread_cache; @@ -901,6 +902,7 @@ void clean_up(bool print_message) bitmap_free(&slave_error_mask); #endif my_tz_free(); + my_dbopt_free(); #ifndef NO_EMBEDDED_ACCESS_CHECKS acl_free(1); grant_free(); @@ -986,6 +988,7 @@ static void clean_up_mutexes() (void) pthread_mutex_destroy(&LOCK_mysql_create_db); (void) pthread_mutex_destroy(&LOCK_Acl); (void) rwlock_destroy(&LOCK_grant); + (void) rwlock_destroy(&LOCK_dboptions); (void) pthread_mutex_destroy(&LOCK_open); (void) pthread_mutex_destroy(&LOCK_thread_count); (void) pthread_mutex_destroy(&LOCK_mapped_file); @@ -2408,6 +2411,7 @@ static int init_thread_environment() (void) my_rwlock_init(&LOCK_sys_init_connect, NULL); (void) my_rwlock_init(&LOCK_sys_init_slave, NULL); (void) my_rwlock_init(&LOCK_grant, NULL); + (void) my_rwlock_init(&LOCK_dboptions, NULL); (void) pthread_cond_init(&COND_thread_count,NULL); (void) pthread_cond_init(&COND_refresh,NULL); (void) pthread_cond_init(&COND_thread_cache,NULL); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 9db2198268a..47c50be33fa 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -39,6 +39,184 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, const char *path, uint level); +/* Database options hash */ +static HASH dboptions; +static my_bool dboptions_init= 0; + +/* Structure for database options */ +typedef struct my_dbopt_st +{ + char *name; /* Database name */ + uint name_length; /* Database length name */ + CHARSET_INFO *charset; /* Database default character set */ +} my_dbopt_t; + +/* + Function we use in the creation of our hash to get key. +*/ +static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, + my_bool not_used __attribute__((unused))) +{ + *length= opt->name_length; + return (byte*) opt->name; +} + + +/* + Function to free dboptions hash element +*/ + +static void free_dbopt(void *dbopt) +{ + my_free((gptr) dbopt, MYF(0)); +} + + +/* + Initialize database option hash. +*/ + +static my_bool my_dbopt_init(void) +{ + my_bool rc; + rw_wrlock(&LOCK_dboptions); + if (!dboptions_init) + { + dboptions_init= 1; + rc= hash_init(&dboptions, lower_case_table_names ? + &my_charset_bin : system_charset_info, + 32, 0, 0, (hash_get_key) dboptions_get_key, + free_dbopt,0); + } + else + rc= 0; + rw_unlock(&LOCK_dboptions); + return rc; +} + + +/* + Free database option hash. +*/ +void my_dbopt_free(void) +{ + rw_wrlock(&LOCK_dboptions); + if (dboptions_init) + { + hash_free(&dboptions); + dboptions_init= 0; + } + rw_unlock(&LOCK_dboptions); +} + + +/* + Find database options in the hash. + + DESCRIPTION + Search a database options in the hash, usings its path. + Fills "create" on success. + + RETURN VALUES + 0 on success. + 1 on error. +*/ + +static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create) +{ + my_dbopt_t *opt; + uint length; + my_bool rc; + + if (my_dbopt_init()) + return 1; + + length= (uint) strlen(dbname); + + rw_rdlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + { + create->default_table_charset= opt->charset; + rc= 0; + } + else + rc= 1; + rw_unlock(&LOCK_dboptions); + + return rc; +} + + +/* + Writes database options into the hash. + + DESCRIPTION + Inserts database options into the hash, or updates + options if they are already in the hash. + + RETURN VALUES + 0 on success. + 1 on error. +*/ + +static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create) +{ + my_dbopt_t *opt; + uint length; + my_bool rc; + + if (my_dbopt_init()) + return 1; + + length= (uint) strlen(dbname); + + rw_wrlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + { + /* Options are already in hash, update them */ + opt->charset= create->default_table_charset; + rc= 0; + } + else + { + /* Options are not in the hash, insert them */ + char *tmp_name; + if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + &opt, sizeof(*opt), &tmp_name, length+1, NullS)) + { + rc= 1; + goto ret; + } + + opt->name= tmp_name; + opt->name_length= length; + opt->charset= create->default_table_charset; + strmov(opt->name, dbname); + + if ((rc= my_hash_insert(&dboptions, (byte*) opt))) + my_free((gptr) opt, MYF(0)); + } + +ret: + rw_unlock(&LOCK_dboptions); + return rc; +} + + +/* + Deletes database options from the hash. +*/ + +void del_dbopt(const char *path) +{ + my_dbopt_t *opt; + rw_wrlock(&LOCK_dboptions); + if ((opt= (my_dbopt_t *)hash_search(&dboptions, path, strlen(path)))) + hash_delete(&dboptions, (byte*) opt); + rw_unlock(&LOCK_dboptions); +} + + /* Create database options file: @@ -56,15 +234,19 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) char buf[256]; // Should be enough for one option bool error=1; + if (!create->default_table_charset) + create->default_table_charset= thd->variables.collation_server; + + if (put_dbopt(path, create)) + return 1; + if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { ulong length; - CHARSET_INFO *cs= ((create && create->default_table_charset) ? - create->default_table_charset : - thd->variables.collation_server); length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", - cs->csname,cs->name)); + create->default_table_charset->csname, + create->default_table_charset->name)); /* Error is written by my_write */ if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) @@ -101,6 +283,12 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) bzero((char*) create,sizeof(*create)); create->default_table_charset= thd->variables.collation_server; + + /* Check if options for this database are already in the hash */ + if (!get_dbopt(path, create)) + DBUG_RETURN(0); + + /* Otherwise, load options from the .opt file */ if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) { IO_CACHE cache; @@ -137,9 +325,16 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) } } } - error=0; end_io_cache(&cache); my_close(file,MYF(0)); + /* + Put the loaded value into the hash. + Note that another thread could've added the same + entry to the hash after we called get_dbopt(), + but it's not an error, as put_dbopt() takes this + possibility into account. + */ + error= put_dbopt(path, create); } DBUG_RETURN(error); } @@ -338,6 +533,8 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) int error = 0; char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; + uint length; + my_dbopt_t *dbopt; DBUG_ENTER("mysql_rm_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); @@ -350,7 +547,11 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } (void) sprintf(path,"%s/%s",mysql_data_home,db); - unpack_dirname(path,path); // Convert if not unix + length= unpack_dirname(path,path); // Convert if not unix + strmov(path+length, MY_DB_OPT_FILE); // Append db option file name + del_dbopt(path); // Remove dboption hash entry + path[length]= '\0'; // Remove file name + /* See if the directory exists */ if (!(dirp = my_dir(path,MYF(MY_DONT_SORT)))) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0cc25c4fe6e..3ce1c334f96 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4805,6 +4805,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, if (lock_global_read_lock(thd)) return 1; } + my_dbopt_free(); result=close_cached_tables(thd,(options & REFRESH_FAST) ? 0 : 1, tables); } if (options & REFRESH_HOSTS) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a560bd40028..c0be95c0453 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1158,6 +1158,23 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } #endif + /* + If the table character set was not given explicitely, + let's fetch the database default character set and + apply it to the table. + */ + if (!create_info->default_table_charset) + { + HA_CREATE_INFO db_info; + uint length; + char path[FN_REFLEN]; + (void) sprintf(path,"%s/%s", mysql_data_home, db); + length= unpack_dirname(path,path); // Convert if not unix + strmov(path+length, MY_DB_OPT_FILE); + load_db_opt(thd, path, &db_info); + create_info->default_table_charset= db_info.default_table_charset; + } + if (mysql_prepare_table(thd, create_info, fields, keys, tmp_table, db_options, file, key_info_buffer, &key_count, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2860077b6a0..ccbaf7c0112 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1023,7 +1023,7 @@ create: bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.options=$2 | $4; lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; - lex->create_info.default_table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= NULL; lex->name=0; } create2 @@ -1815,7 +1815,7 @@ alter: lex->select_lex.db=lex->name=0; bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.db_type= DB_TYPE_DEFAULT; - lex->create_info.default_table_charset= thd->variables.collation_database; + lex->create_info.default_table_charset= NULL; lex->create_info.row_type= ROW_TYPE_NOT_USED; lex->alter_info.reset(); lex->alter_info.is_simple= 1;