diff --git a/.bzrignore b/.bzrignore index 460ea002bff..8a947d63b75 100644 --- a/.bzrignore +++ b/.bzrignore @@ -382,8 +382,11 @@ libmysqld/examples/link_sources libmysqld/examples/my_readline.h libmysqld/examples/mysql libmysqld/examples/mysql.cc +libmysqld/examples/mysql_client_test.c +libmysqld/examples/mysql_client_test_embedded libmysqld/examples/mysqltest libmysqld/examples/mysqltest.c +libmysqld/examples/mysqltest_embedded libmysqld/examples/readline.cc libmysqld/examples/sql_string.cc libmysqld/examples/sql_string.h diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug new file mode 100755 index 00000000000..1bbca36d851 --- /dev/null +++ b/BUILD/compile-pentium64-debug @@ -0,0 +1,13 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium64_cflags $debug_cflags" +c_warnings="$c_warnings $debug_extra_warnings" +cxx_warnings="$cxx_warnings $debug_extra_warnings" +extra_configs="$pentium_configs $debug_configs $static_link" + +extra_configs="$extra_configs " + +. "$path/FINISH.sh" diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 99912228445..019589289cd 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -228,10 +228,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/VC++Files/mysqldemb/mysqldemb.dsp b/VC++Files/mysqldemb/mysqldemb.dsp index a8207d436a0..61a745ff7e8 100644 --- a/VC++Files/mysqldemb/mysqldemb.dsp +++ b/VC++Files/mysqldemb/mysqldemb.dsp @@ -169,10 +169,6 @@ SOURCE=..\sql\ha_innodb.cpp # End Source File # Begin Source File -SOURCE=..\sql\ha_isammrg.cpp -# End Source File -# Begin Source File - SOURCE=..\sql\ha_myisam.cpp # End Source File # Begin Source File diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 45daa64705a..caf126f2830 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -744,7 +744,7 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { - MYSQL *local_mysql = mysql_init(NULL); + MYSQL *local_mysql= mysql_init(NULL); if (!local_mysql) die("Failed on mysql_init"); @@ -752,9 +752,13 @@ static MYSQL* safe_connect() if (opt_protocol) mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) - die("failed on connect: %s", mysql_error(local_mysql)); + { + char errmsg[256]; + strmake(errmsg, mysql_error(local_mysql), sizeof(errmsg)-1); + mysql_close(local_mysql); + die("failed on connect: %s", errmsg); + } local_mysql->reconnect= 1; - return local_mysql; } @@ -781,9 +785,8 @@ static int check_master_version(MYSQL* mysql, if (mysql_query(mysql, "SELECT VERSION()") || !(res = mysql_store_result(mysql))) { - char errmsg[FN_REFLEN]; - - strmake(errmsg, mysql_error(mysql), sizeof(errmsg) - 1); + char errmsg[256]; + strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1); mysql_close(mysql); die("Error checking master version: %s", errmsg); } diff --git a/extra/comp_err.c b/extra/comp_err.c index baed28a0350..a554fc2437e 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -41,7 +41,7 @@ static char *HEADERFILE= (char*) "mysqld_error.h"; static char *NAMEFILE= (char*) "mysqld_ername.h"; static char *STATEFILE= (char*) "sql_state.h"; static char *TXTFILE= (char*) "../sql/share/errmsg.txt"; -static char *DATADIR= (char*) "../sql/share/"; +static char *DATADIRECTORY= (char*) "../sql/share/"; static char *default_dbug_option= (char*) "d:t:O,/tmp/comp_err.trace"; /* Header for errmsg.sys files */ @@ -112,8 +112,8 @@ static struct my_option my_long_options[]= 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"in_file", 'F', "Input file", (gptr *) & TXTFILE, (gptr *) & TXTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"out_dir", 'D', "Output base directory", (gptr *) & DATADIR, - (gptr *) & DATADIR, + {"out_dir", 'D', "Output base directory", (gptr *) & DATADIRECTORY, + (gptr *) & DATADIRECTORY, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"out_file", 'O', "Output filename (errmsg.sys)", (gptr *) & OUTFILE, (gptr *) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -281,7 +281,7 @@ static int create_sys_files(struct languages *lang_head, DBUG_RETURN(1); } - outfile_end= strxmov(outfile, DATADIR, + outfile_end= strxmov(outfile, DATADIRECTORY, tmp_lang->lang_long_name, NullS); if (!my_stat(outfile, &stat_info,MYF(0))) { diff --git a/include/m_ctype.h b/include/m_ctype.h index c2354c7feff..c41c7385b3d 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -110,6 +110,7 @@ typedef struct my_collation_handler_st my_bool diff_if_only_endspace_difference); int (*strnxfrm)(struct charset_info_st *, uchar *, uint, const uchar *, uint); + uint (*strnxfrmlen)(struct charset_info_st *, uint); my_bool (*like_range)(struct charset_info_st *, const char *s, uint s_length, pchar w_prefix, pchar w_one, pchar w_many, @@ -259,7 +260,8 @@ extern CHARSET_INFO my_charset_cp1250_czech_ci; /* declarations for simple charsets */ extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, - uint); + uint); +uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, const uchar *, uint, my_bool); diff --git a/innobase/include/eval0eval.ic b/innobase/include/eval0eval.ic index 2530c869206..069cbfe5f37 100644 --- a/innobase/include/eval0eval.ic +++ b/innobase/include/eval0eval.ic @@ -205,8 +205,6 @@ eval_node_copy_and_alloc_val( { byte* data; - ut_ad(UNIV_SQL_NULL > ULINT_MAX); - if (len == UNIV_SQL_NULL) { dfield_set_len(que_node_get_val(node), len); diff --git a/innobase/include/univ.i b/innobase/include/univ.i index c413c3bc67e..8158c198e21 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,10 +80,8 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ -#ifdef DBUG_ON -# define UNIV_DEBUG -#endif /* DBUG_ON */ /* +#define UNIV_DEBUG #define UNIV_MEM_DEBUG #define UNIV_IBUF_DEBUG #define UNIV_SYNC_DEBUG @@ -122,7 +120,7 @@ by one. */ /* Definition for inline version */ #ifdef __WIN__ -#define UNIV_INLINE __inline +#define UNIV_INLINE __inline #else /* config.h contains the right def for 'inline' for the current compiler */ #if (__GNUC__ == 2) diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index f35b4dea5e0..6f2aa0957d8 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -82,10 +82,17 @@ ut_usectime( ulint* sec, /* out: seconds since the Epoch */ ulint* ms) /* out: microseconds since the Epoch+*sec */ { +#ifdef __WIN__ + SYSTEMTIME st; + GetLocalTime(&st); + *sec = (ulint) st.wSecond; + *ms = (ulint) st.wMilliseconds; +#else struct timeval tv; gettimeofday(&tv,NULL); *sec = (ulint) tv.tv_sec; *ms = (ulint) tv.tv_usec; +#endif } /************************************************************** diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c6815d2a5ce..258391ac899 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1740,7 +1740,7 @@ static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row); STMT_ATTR_UPDATE_MAX_LENGTH attribute is set. */ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); -static bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); +static my_bool setup_one_fetch_function(MYSQL_BIND *bind, MYSQL_FIELD *field); /* Maximum sizes of MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME @@ -3718,7 +3718,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlongstore(buffer, data); } *param->error= value != (param->is_unsigned ? - (double) (*(ulonglong*) buffer) : + ulonglong2double(*(ulonglong*) buffer) : (double) (*(longlong*) buffer)); break; case MYSQL_TYPE_FLOAT: diff --git a/mysql-test/include/ndb_default_cluster.inc b/mysql-test/include/ndb_default_cluster.inc new file mode 100644 index 00000000000..2f900b6a0b4 --- /dev/null +++ b/mysql-test/include/ndb_default_cluster.inc @@ -0,0 +1,4 @@ +-- require r/ndb_default_cluster.require +disable_query_log; +show status like "Ndb_connected_host"; +enable_query_log; diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index 2857a4b5cc7..2aab46014a9 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 0 0 0 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 0 0 # # 0 # 1 # # # latin1_swedish_ci NULL # SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 96 131072 0 0 0 101 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 96 # # 0 # 101 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col1 col2 col3 col4 col5 col6 to_be_deleted 0 4 3 5 PENDING 1 7 @@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 152 131072 0 0 0 102 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 9 152 # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 @@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8 insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 10 152 131072 0 0 0 103 NULL NULL NULL latin1_swedish_ci NULL number_of_replicas: 2 +t1 ndbcluster 10 Dynamic 10 152 # # 0 # 103 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col6 col1 col3 fourth col4 col4_5 col5 col7 col8 1 0 3 4 5 PENDING 0000-00-00 00:00:00 diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index b89b4ce1f21..ba21483a9b0 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -144,8 +144,8 @@ Handler_discover 1 flush tables; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL -t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL number_of_replicas: 2 +t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL # +t7 ndbcluster 9 Fixed 1 276 # # # 0 NULL # # NULL # NULL # show status like 'handler_discover%'; Variable_name Value Handler_discover 2 diff --git a/mysql-test/r/ndb_default_cluster.require b/mysql-test/r/ndb_default_cluster.require new file mode 100644 index 00000000000..aa4988cdca3 --- /dev/null +++ b/mysql-test/r/ndb_default_cluster.require @@ -0,0 +1,2 @@ +Variable_name Value +Ndb_connected_host localhost diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9cc89ee4cc..598b9dcccf7 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -612,3 +612,17 @@ a b c 3 NULL NULL 4 4 NULL drop table t1, t8; +create table t1( +id integer not null auto_increment, +month integer not null, +year integer not null, +code varchar( 2) not null, +primary key ( id), +unique idx_t1( month, code, year) +) engine=ndb; +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); +select * from t1 where code = '12' and month = 4 and year = 2004 ; +id month year code +1 4 2004 12 +drop table t1; diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 892443a1407..3544a50c3e1 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -47,10 +47,12 @@ col3 varchar (20) not null, col4 varchar(4) not null, col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, col6 int not null, to_be_deleted int) ENGINE=ndbcluster; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; alter table t1 @@ -59,9 +61,11 @@ add column col7 varchar(30) not null after col5, add column col8 datetime not null, drop column to_be_deleted, change column col2 fourth varchar(30) not null after col3, modify column col6 int not null first; +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +--replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 # show table status; select * from t1 order by col1; delete from t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 2159e6b6e62..713aa326e4d 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -176,7 +176,7 @@ show status like 'handler_discover%'; flush tables; system rm var/master-data/test/t7.frm ; ---replace_column 7 # 8 # 9 # 12 # 13 # 15 # +--replace_column 7 # 8 # 9 # 12 # 13 # 15 # 18 # show table status; show status like 'handler_discover%'; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index f235d1ffc30..9bbea75028b 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -286,3 +286,24 @@ select * from t8 order by a; select * from t1 order by a; drop table t1, t8; +############################### +# Bug 8101 +# +# Unique index not specified in the same order as in table +# + +create table t1( + id integer not null auto_increment, + month integer not null, + year integer not null, + code varchar( 2) not null, + primary key ( id), + unique idx_t1( month, code, year) +) engine=ndb; + +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); + +select * from t1 where code = '12' and month = 4 and year = 2004 ; + +drop table t1; diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 09939ec119d..3a77289a8fb 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc --disable_warnings use test; diff --git a/sql/field.h b/sql/field.h index fd1ef09d14f..84d71afcd6f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1228,7 +1228,7 @@ public: int cmp(const char *a, const char *b) { return cmp_binary(a, b); } int key_cmp(const byte *a, const byte *b) - { return cmp_binary(a, b); } + { return cmp_binary((char *) a, (char *) b); } int key_cmp(const byte *str, uint length); int cmp_offset(uint row_offset); void get_key_image(char *buff, uint length, imagetype type); diff --git a/sql/filesort.cc b/sql/filesort.cc index 0e9fa8c79ed..1665358dbf0 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1187,7 +1187,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) { sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); } } if (sortorder->field->maybe_null()) @@ -1200,7 +1200,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) sortorder->length=sortorder->item->max_length; if (use_strnxfrm((cs=sortorder->item->collation.collation))) { - sortorder->length= sortorder->length*cs->strxfrm_multiply; + sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length); sortorder->need_strxnfrm= 1; *multi_byte_charset= 1; } diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5cca81b1200..cfd1698ae2d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -852,6 +852,42 @@ int ha_ndbcluster::get_metadata(const char *path) DBUG_RETURN(build_index_list(table, ILBP_OPEN)); } +static int fix_unique_index_attr_order(NDB_INDEX_DATA &data, + const NDBINDEX *index, + KEY *key_info) +{ + DBUG_ENTER("fix_unique_index_attr_order"); + unsigned sz= index->getNoOfIndexColumns(); + + if (data.unique_index_attrid_map) + my_free((char*)data.unique_index_attrid_map, MYF(0)); + data.unique_index_attrid_map= (unsigned char*)my_malloc(sz,MYF(MY_WME)); + + KEY_PART_INFO* key_part= key_info->key_part; + KEY_PART_INFO* end= key_part+key_info->key_parts; + DBUG_ASSERT(key_info->key_parts == sz); + for (unsigned i= 0; key_part != end; key_part++, i++) + { + const char *field_name= key_part->field->field_name; + unsigned name_sz= strlen(field_name); + if (name_sz >= NDB_MAX_ATTR_NAME_SIZE) + name_sz= NDB_MAX_ATTR_NAME_SIZE-1; +#ifndef DBUG_OFF + data.unique_index_attrid_map[i]= 255; +#endif + for (unsigned j= 0; j < sz; j++) + { + const NdbDictionary::Column *c= index->getColumn(j); + if (strncmp(field_name, c->getName(), name_sz) == 0) + { + data.unique_index_attrid_map[i]= j; + break; + } + } + DBUG_ASSERT(data.unique_index_attrid_map[i] != 255); + } + DBUG_RETURN(0); +} int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) { @@ -926,7 +962,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) const NDBINDEX *index= dict->getIndex(unique_index_name, m_tabname); if (!index) DBUG_RETURN(1); m_index[i].unique_index= (void *) index; - } + error= fix_unique_index_attr_order(m_index[i], index, key_info); + } } DBUG_RETURN(error); @@ -984,6 +1021,11 @@ void ha_ndbcluster::release_metadata() { m_index[i].unique_index= NULL; m_index[i].index= NULL; + if (m_index[i].unique_index_attrid_map) + { + my_free((char *)m_index[i].unique_index_attrid_map, MYF(0)); + m_index[i].unique_index_attrid_map= NULL; + } } DBUG_VOID_RETURN; @@ -1152,7 +1194,7 @@ ha_ndbcluster::set_index_key(NdbOperation *op, const byte* ptr= key_part->null_bit ? key_ptr + 1 : key_ptr; char buf[256]; shrink_varchar(field, ptr, buf); - if (set_ndb_key(op, field, i, ptr)) + if (set_ndb_key(op, field, m_index[active_index].unique_index_attrid_map[i], ptr)) ERR_RETURN(m_active_trans->getNdbError()); key_ptr+= key_part->store_length; } @@ -1655,13 +1697,10 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, // Set bound if not cancelled via type -1 if (p.bound_type != -1) { - char truncated_field_name[NDB_MAX_ATTR_NAME_SIZE]; - strnmov(truncated_field_name,field->field_name,sizeof(truncated_field_name)); - truncated_field_name[sizeof(truncated_field_name)-1]= '\0'; const char* ptr= p.bound_ptr; char buf[256]; shrink_varchar(field, ptr, buf); - if (op->setBound(truncated_field_name, p.bound_type, ptr)) + if (op->setBound(i, p.bound_type, ptr)) ERR_RETURN(op->getNdbError()); } } @@ -3990,9 +4029,10 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): for (i= 0; i < MAX_KEY; i++) { - m_index[i].type= UNDEFINED_INDEX; - m_index[i].unique_index= NULL; - m_index[i].index= NULL; + m_index[i].type= UNDEFINED_INDEX; + m_index[i].unique_index= NULL; + m_index[i].index= NULL; + m_index[i].unique_index_attrid_map= NULL; } DBUG_VOID_RETURN; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 05bb5233664..942a4988252 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -51,6 +51,7 @@ typedef struct ndb_index_data { NDB_INDEX_TYPE type; void *index; void *unique_index; + unsigned char *unique_index_attrid_map; } NDB_INDEX_DATA; typedef struct st_ndbcluster_share { diff --git a/sql/item_create.cc b/sql/item_create.cc index 8a5aeb6c9b7..9fb44658dd5 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -370,13 +370,14 @@ Item *create_func_space(Item *a) { uint dummy_errors; sp= new Item_string("",0,cs); - sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); + if (sp) + sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); } else { sp= new Item_string(" ",1,cs); } - return new Item_func_repeat(sp, a); + return sp ? new Item_func_repeat(sp, a) : 0; } Item *create_func_soundex(Item* a) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index be89aa3f86d..29837c3afbd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1234,7 +1234,7 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2) { Field* f = *field; int len = *lengths++; - int res = f->cmp(key1, key2); + int res = f->cmp((char *) key1, (char *) key2); if (res) return res; key1 += len; @@ -1688,7 +1688,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return res; } } @@ -1722,7 +1722,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) { int res; uint offset= (uint) (field->ptr - record); - if ((res= field->cmp(key1 + offset, key2 + offset))) + if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) return (*order_item)->asc ? res : -res; } } diff --git a/sql/key.cc b/sql/key.cc index aec294e370a..c5ed60b129c 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -135,7 +135,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->get_key_image(to_key, length, Field::itRAW); + key_part->field->get_key_image((char *) to_key, length, Field::itRAW); to_key+= HA_KEY_BLOB_LENGTH; } else @@ -217,7 +217,7 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->set_key_image(from_key, length); + key_part->field->set_key_image((char *) from_key, length); from_key+= HA_KEY_BLOB_LENGTH; } else diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3195b442de3..94eb34954ba 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3036,12 +3036,11 @@ You should consider changing lower_case_table_names to 1 or 2", (test_if_case_insensitive(mysql_real_data_home) == 1))) { if (global_system_variables.log_warnings) - sql_print_warning("\ -You have forced lower_case_table_names to 2 through a command-line \ -option, even though your file system '%s' is case sensitive. This means \ -that you can create a table that you can then no longer access. \ -You should consider changing lower_case_table_names to 0.", + sql_print_warning("lower_case_table_names was set to 2, even though your " + "the file system '%s' is case sensitive. Now setting " + "lower_case_table_names to 0 to avoid future problems.", mysql_real_data_home); + lower_case_table_names= 0; } select_thread=pthread_self(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c3b84564504..e5799bfd509 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1891,7 +1891,7 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records) else { double n_blocks= - ceil((double)param->table->file->data_file_length / IO_SIZE); + ceil(ulonglong2double(param->table->file->data_file_length) / IO_SIZE); double busy_blocks= n_blocks * (1.0 - pow(1.0 - 1.0/n_blocks, rows2double(records))); if (busy_blocks < 1.0) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f9d95b2cde5..71d042eda02 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1494,12 +1494,12 @@ static bool update_user_table(THD *thd, const char *host, const char *user, DBUG_RETURN(1); /* purecov: deadcode */ table->field[0]->store(host,(uint) strlen(host), system_charset_info); table->field[1]->store(user,(uint) strlen(user), system_charset_info); - key_copy(user_key, table->record[0], table->key_info, + key_copy((byte *) user_key, table->record[0], table->key_info, table->key_info->key_length); table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); if (table->file->index_read_idx(table->record[0], 0, - user_key, table->key_info->key_length, + (byte *) user_key, table->key_info->key_length, HA_READ_KEY_EXACT)) { my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 7bf28a439b6..759b535da53 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -558,8 +558,13 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, TABLE_LIST *tables, { if (!cond->fixed) cond->fix_fields(thd, tables, &cond); // can never fail + + /* Assume that no indexes cover all required fields */ + table->used_keys.clear_all(); + SQL_SELECT *res= make_select(table,0,0,cond,error); - if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR))) + if (*error || (res && res->check_quick(thd, 0, HA_POS_ERROR)) || + (res->quick && res->quick->reset())) { delete res; res=0; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f097bbd740d..69b5c667f6b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4474,16 +4474,9 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, x = used key parts (1 <= x <= c) */ double rec_per_key; -#if 0 - if (!(rec_per_key=(double) - keyinfo->rec_per_key[keyinfo->key_parts-1])) - rec_per_key=(double) s->records/rec+1; -#else rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : (double) s->records/rec+1; -#endif - if (!s->records) tmp=0; else if (rec_per_key/(double) s->records >= 0.01) diff --git a/sql/table.cc b/sql/table.cc index 82ad32341c0..69a132329c0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -305,7 +305,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, if (!(record= (char *) alloc_root(&outparam->mem_root, rec_buff_length * records))) goto err; /* purecov: inspected */ - share->default_values= record; + share->default_values= (byte *) record; if (my_pread(file,(byte*) record, (uint) share->reclength, (ulong) (uint2korr(head+6)+ ((uint2korr(head+14) == 0xffff ? @@ -320,9 +320,9 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, } else { - outparam->record[0]= record+ rec_buff_length; + outparam->record[0]= (byte *) record+ rec_buff_length; if (records > 2) - outparam->record[1]= record+ rec_buff_length*2; + outparam->record[1]= (byte *) record+ rec_buff_length*2; else outparam->record[1]= outparam->record[0]; // Safety } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index a2db7de244e..70c5ec633be 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6293,6 +6293,7 @@ static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = my_strnncoll_big5, my_strnncollsp_big5, my_strnxfrm_big5, + my_strnxfrmlen_simple, my_like_range_big5, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 401605a462f..50c66a63e97 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -447,6 +447,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler = my_strnncoll_8bit_bin, my_strnncollsp_8bit_bin, my_strnxfrm_8bit_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, @@ -461,6 +462,7 @@ static MY_COLLATION_HANDLER my_collation_binary_handler = my_strnncoll_binary, my_strnncollsp_binary, my_strnxfrm_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 804f87b2a5b..c47f2c2d8ce 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5454,6 +5454,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_cp932, my_strnncollsp_cp932, my_strnxfrm_cp932, + my_strnxfrmlen_simple, my_like_range_cp932, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 2834dbb28ff..f5a410afc50 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -593,6 +593,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = my_strnncoll_czech, my_strnncollsp_czech, my_strnxfrm_czech, + my_strnxfrmlen_simple, my_like_range_czech, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index ee792d9c3e4..289b7309ea0 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8641,6 +8641,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 5b108d24f4b..8c8d237cf48 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8636,6 +8636,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index f17cc94723f..73e4132dd7f 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5692,6 +5692,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple, /* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple, /* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, /* instr */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index dc4aea60096..6b47b537fb9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9939,6 +9939,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_gbk, my_strnncollsp_gbk, my_strnxfrm_gbk, + my_strnxfrmlen_simple, my_like_range_gbk, my_wildcmp_mb, my_strcasecmp_mb, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index b5da99a7452..043645684cf 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -693,6 +693,7 @@ static MY_COLLATION_HANDLER my_collation_german2_ci_handler= my_strnncoll_latin1_de, my_strnncollsp_latin1_de, my_strnxfrm_latin1_de, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 4be21599fef..e902730d65a 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -912,6 +912,7 @@ MY_COLLATION_HANDLER my_collation_mb_bin_handler = my_strnncoll_mb_bin, my_strnncollsp_mb_bin, my_strnxfrm_mb_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index bb623ef66f1..e436d5f8702 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -21,6 +21,15 @@ #include "stdarg.h" +/* + Returns the number of bytes required for strnxfrm(). +*/ +uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) +{ + return len * (cs->strxfrm_multiply ? cs->strxfrm_multiply : 1); +} + + /* Converts a string into its sort key. @@ -1365,6 +1374,7 @@ MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler = my_strnncoll_simple, my_strnncollsp_simple, my_strnxfrm_simple, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_8bit, my_strcasecmp_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index c1e41dc2d94..22cc8d9818d 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4627,6 +4627,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_sjis, my_strnncollsp_sjis, my_strnxfrm_sjis, + my_strnxfrmlen_simple, my_like_range_sjis, my_wildcmp_mb, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index c6bdd106ad4..9ba35e1c8ec 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -927,6 +927,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_tis620, my_strnncollsp_tis620, my_strnxfrm_tis620, + my_strnxfrmlen_simple, my_like_range_tis620, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 2353c9397a2..8345d0474f2 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -8024,6 +8024,7 @@ MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = my_strnncoll_ucs2_uca, my_strnncollsp_ucs2_uca, my_strnxfrm_ucs2_uca, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_uca, NULL, @@ -8504,6 +8505,7 @@ MY_COLLATION_HANDLER my_collation_any_uca_handler = my_strnncoll_any_uca, my_strnncollsp_any_uca, my_strnxfrm_any_uca, + my_strnxfrmlen_simple, my_like_range_mb, my_wildcmp_uca, NULL, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index adfd4794e36..0d45cceb64d 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1499,6 +1499,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = my_strnncoll_ucs2, my_strnncollsp_ucs2, my_strnxfrm_ucs2, + my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_ucs2_ci, my_strcasecmp_ucs2, @@ -1513,6 +1514,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_strnncoll_ucs2_bin, my_strnncollsp_ucs2_bin, my_strnxfrm_ucs2_bin, + my_strnxfrmlen_simple, my_like_range_simple, my_wildcmp_ucs2_bin, my_strcasecmp_ucs2_bin, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index fc1496df280..deaddcc76f6 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8501,6 +8501,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_simple,/* strnncoll */ my_strnncollsp_simple, my_strnxfrm_simple, /* strnxfrm */ + my_strnxfrmlen_simple, my_like_range_simple,/* like_range */ my_wildcmp_mb, /* wildcmp */ my_strcasecmp_mb, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 1f9f158a73d..e17e7587e85 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2238,6 +2238,12 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, } +static +uint my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), uint len) +{ + return (len * 2 + 2) / 3; +} + static int my_strnxfrm_utf8(CHARSET_INFO *cs, uchar *dst, uint dstlen, const uchar *src, uint srclen) @@ -2245,29 +2251,33 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, my_wc_t wc; int res; int plane; - uchar *de = dst + dstlen; + uchar *de= dst + dstlen; + uchar *de_beg= de - 1; const uchar *se = src + srclen; - while( src < se && dst < de ) + while (dst < de_beg) { - if ((res=my_utf8_uni(cs,&wc, src, se))<0) - { + if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0) break; - } src+=res; - srclen-=res; plane=(wc>>8) & 0xFF; wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - if ((res=my_uni_utf8(cs,wc,dst,de)) <0) - { - break; - } - dst+=res; + *dst++= wc >> 8; + *dst++= wc & 0xFF; + } - if (dst < de) - bfill(dst, de - dst, ' '); + + while (dst < de_beg) /* Fill the tail with keys for space character */ + { + *dst++= 0x00; + *dst++= 0x20; + } + + if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ + *de= 0x00; + return dstlen; } @@ -2306,6 +2316,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_utf8, + my_strnxfrmlen_utf8, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index b58a8f0f1e5..37611a5bd20 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -626,6 +626,7 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler = my_strnncoll_win1250ch, my_strnncollsp_win1250ch, my_strnxfrm_win1250ch, + my_strnxfrmlen_simple, my_like_range_win1250ch, my_wildcmp_8bit, my_strcasecmp_8bit,