diff options
author | unknown <serg@serg.mylan> | 2004-11-22 21:33:15 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-11-22 21:33:15 +0100 |
commit | 6627dc7d1bd399e6b2bdac02c6878435f1a96a5d (patch) | |
tree | 9fd3b9eb87ff64ffe7e7374609beb327e419a87d | |
parent | 443143f334b7ea452ff60cccd046e4242849e31a (diff) | |
parent | f57d5412e47aa85941ea03ec3e63b017dac8c1ba (diff) | |
download | mariadb-git-6627dc7d1bd399e6b2bdac02c6878435f1a96a5d.tar.gz |
merged
BitKeeper/etc/ignore:
auto-union
BitKeeper/etc/logging_ok:
auto-union
Docs/Support/texi2html:
Auto merged
client/mysqltest.c:
Auto merged
innobase/lock/lock0lock.c:
Auto merged
innobase/row/row0sel.c:
Auto merged
mysql-test/r/fulltext.result:
Auto merged
mysql-test/r/heap.result:
Auto merged
mysql-test/r/key.result:
Auto merged
mysql-test/r/myisam.result:
Auto merged
mysql-test/r/rpl000015.result:
Auto merged
mysql-test/r/rpl_log_pos.result:
Auto merged
mysql-test/r/rpl_rotate_logs.result:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/r/type_blob.result:
Auto merged
mysql-test/t/key.test:
Auto merged
mysql-test/t/myisam.test:
Auto merged
mysql-test/t/rpl000015.test:
Auto merged
mysql-test/t/rpl_log_pos.test:
Auto merged
mysql-test/t/rpl_rotate_logs.test:
Auto merged
mysql-test/t/subselect.test:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/ha_ndbcluster.h:
Auto merged
sql/handler.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_do.cc:
Auto merged
sql/sql_table.cc:
Auto merged
49 files changed, 658 insertions, 151 deletions
diff --git a/VC++Files/client/mysqladmin.dsp b/VC++Files/client/mysqladmin.dsp index a7e4404e253..7a0b3bec1a7 100644 --- a/VC++Files/client/mysqladmin.dsp +++ b/VC++Files/client/mysqladmin.dsp @@ -115,7 +115,7 @@ LINK32=xilink6.exe # Name "mysqladmin - Win32 classic" # Begin Source File -SOURCE=.\mysqladmin.c +SOURCE=.\mysqladmin.cpp # End Source File # End Target # End Project diff --git a/extra/perror.c b/extra/perror.c index a28626fd873..1bd4b203120 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -69,7 +69,7 @@ static HA_ERRORS ha_errlist[]= { { 120,"Didn't find key on read or update" }, { 121,"Duplicate key on write or update" }, - { 123,"Someone has changed the row since it was read; Update with is recoverable" }, + { 123,"Someone has changed the row since it was read (while the table was locked to prevent it)" }, { 124,"Wrong index given to function" }, { 126,"Index file is crashed" }, { 127,"Record-file is crashed" }, diff --git a/heap/hp_rfirst.c b/heap/hp_rfirst.c index 1668376ed1c..85548fea212 100644 --- a/heap/hp_rfirst.c +++ b/heap/hp_rfirst.c @@ -52,6 +52,7 @@ int heap_rfirst(HP_INFO *info, byte *record, int inx) my_errno=HA_ERR_END_OF_FILE; DBUG_RETURN(my_errno); } + DBUG_ASSERT(0); /* TODO fix it */ info->current_record=0; info->current_hash_ptr=0; info->update=HA_STATE_PREV_FOUND; diff --git a/include/m_ctype.h b/include/m_ctype.h index ddc21070547..26e285b9683 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -63,7 +63,7 @@ typedef struct unicase_info_st #define MY_CS_UNICODE 128 /* is a charset is full unicode */ #define MY_CS_READY 256 /* if a charset is initialized */ #define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ - +#define MY_CS_CSSORT 1024 /* if case sensitive sort order */ #define MY_CHARSET_UNDEFINED 0 diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 98def88fa31..479952235f0 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -4090,6 +4090,9 @@ lock_print_info( (ulong) ut_dulint_get_low(purge_sys->purge_undo_no)); fprintf(file, + "History list length %lu\n", (ulong) trx_sys->rseg_history_len); + + fprintf(file, "Total number of lock structs in row lock hash table %lu\n", (ulong) lock_get_n_rec_locks()); diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 71163bc35b6..26d26ca323c 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -638,23 +638,24 @@ row_sel_get_clust_rec( if (!node->read_view) { /* Try to place a lock on the index record */ - /* If innodb_locks_unsafe_for_binlog option is used, - we lock only the record, i.e. next-key locking is - not used. - */ - if ( srv_locks_unsafe_for_binlog ) - { - err = lock_clust_rec_read_check_and_lock(0, clust_rec, - index,node->row_lock_mode, LOCK_REC_NOT_GAP, thr); - } - else - { - err = lock_clust_rec_read_check_and_lock(0, clust_rec, index, - node->row_lock_mode, LOCK_ORDINARY, thr); - - } - - if (err != DB_SUCCESS) { + /* If innodb_locks_unsafe_for_binlog option is used, + we lock only the record, i.e. next-key locking is + not used. + */ + + if (srv_locks_unsafe_for_binlog) { + err = lock_clust_rec_read_check_and_lock(0, + clust_rec, + index, node->row_lock_mode, + LOCK_REC_NOT_GAP, thr); + } else { + err = lock_clust_rec_read_check_and_lock(0, + clust_rec, + index, node->row_lock_mode, + LOCK_ORDINARY, thr); + } + + if (err != DB_SUCCESS) { return(err); } @@ -1205,22 +1206,24 @@ rec_loop: if (!consistent_read) { - /* If innodb_locks_unsafe_for_binlog option is used, - we lock only the record, i.e. next-key locking is - not used. - */ - - if ( srv_locks_unsafe_for_binlog ) - { - err = sel_set_rec_lock(page_rec_get_next(rec), index, - node->row_lock_mode, LOCK_REC_NOT_GAP, thr); - } - else - { - err = sel_set_rec_lock(page_rec_get_next(rec), index, - node->row_lock_mode, LOCK_ORDINARY, thr); - } - if (err != DB_SUCCESS) { + /* If innodb_locks_unsafe_for_binlog option is used, + we lock only the record, i.e. next-key locking is + not used. + */ + + if (srv_locks_unsafe_for_binlog) { + err = sel_set_rec_lock(page_rec_get_next(rec), + index, + node->row_lock_mode, + LOCK_REC_NOT_GAP, thr); + } else { + err = sel_set_rec_lock(page_rec_get_next(rec), + index, + node->row_lock_mode, + LOCK_ORDINARY, thr); + } + + if (err != DB_SUCCESS) { /* Note that in this case we will store in pcur the PREDECESSOR of the record we are waiting the lock for */ @@ -1245,21 +1248,18 @@ rec_loop: if (!consistent_read) { /* Try to place a lock on the index record */ - /* If innodb_locks_unsafe_for_binlog option is used, - we lock only the record, i.e. next-key locking is - not used. - */ + /* If innodb_locks_unsafe_for_binlog option is used, + we lock only the record, i.e. next-key locking is + not used. + */ - if ( srv_locks_unsafe_for_binlog ) - { - err = sel_set_rec_lock(rec, index, node->row_lock_mode, + if (srv_locks_unsafe_for_binlog) { + err = sel_set_rec_lock(rec, index, node->row_lock_mode, LOCK_REC_NOT_GAP, thr); - } - else - { - err = sel_set_rec_lock(rec, index, node->row_lock_mode, + } else { + err = sel_set_rec_lock(rec, index, node->row_lock_mode, LOCK_ORDINARY, thr); - } + } if (err != DB_SUCCESS) { @@ -3234,8 +3234,7 @@ rec_loop: we do not lock gaps. Supremum record is really a gap and therefore we do not set locks there. */ - if ( srv_locks_unsafe_for_binlog == FALSE ) - { + if (srv_locks_unsafe_for_binlog == FALSE) { err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type, LOCK_ORDINARY, thr); @@ -3337,11 +3336,18 @@ rec_loop: if (prebuilt->select_lock_type != LOCK_NONE && set_also_gap_locks) { - /* Try to place a lock on the index record */ - err = sel_set_rec_lock(rec, index, + /* Try to place a gap lock on the index + record only if innodb_locks_unsafe_for_binlog + option is not set */ + + if (srv_locks_unsafe_for_binlog == FALSE) { + + err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type, LOCK_GAP, thr); + } + if (err != DB_SUCCESS) { goto lock_wait_or_error; @@ -3363,11 +3369,18 @@ rec_loop: if (prebuilt->select_lock_type != LOCK_NONE && set_also_gap_locks) { - /* Try to place a lock on the index record */ - err = sel_set_rec_lock(rec, index, + /* Try to place a gap lock on the index + record only if innodb_locks_unsafe_for_binlog + option is not set */ + + if (srv_locks_unsafe_for_binlog == FALSE) { + + err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type, LOCK_GAP, thr); + } + if (err != DB_SUCCESS) { goto lock_wait_or_error; @@ -3401,19 +3414,16 @@ rec_loop: prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr); } else { - /* If innodb_locks_unsafe_for_binlog option is used, - we lock only the record, i.e. next-key locking is - not used. - */ - if ( srv_locks_unsafe_for_binlog ) - { - err = sel_set_rec_lock(rec, index, + /* If innodb_locks_unsafe_for_binlog option is used, + we lock only the record, i.e. next-key locking is + not used. */ + + if (srv_locks_unsafe_for_binlog) { + err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type, LOCK_REC_NOT_GAP, thr); - } - else - { - err = sel_set_rec_lock(rec, index, + } else { + err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type, LOCK_ORDINARY, thr); } diff --git a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c index 5c62640e011..3df34111281 100644 --- a/innobase/trx/trx0purge.c +++ b/innobase/trx/trx0purge.c @@ -289,7 +289,7 @@ trx_purge_add_update_undo_to_history( flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr)); mlog_write_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE, - hist_size + undo->size, MLOG_4BYTES, mtr); + hist_size + undo->size, MLOG_4BYTES, mtr); } /* Add the log as the first in the history list */ @@ -646,6 +646,27 @@ trx_purge_rseg_get_next_history_log( mutex_exit(&(rseg->mutex)); mtr_commit(&mtr); + mutex_enter(&kernel_mutex); + + /* Add debug code to track history list corruption reported + on the MySQL mailing list on Nov 9, 2004. The fut0lst.c + file-based list was corrupt. The prev node pointer was + FIL_NULL, even though the list length was over 8 million nodes! + We assume that purge truncates the history list in moderate + size pieces, and if we here reach the head of the list, the + list cannot be longer than 20 000 undo logs now. */ + + if (trx_sys->rseg_history_len > 20000) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: Warning: purge reached the head of the history list,\n" +"InnoDB: but its length is still reported as %lu! Make a detailed bug\n" +"InnoDB: report, and post it to bugs.mysql.com\n", + (ulong)trx_sys->rseg_history_len); + } + + mutex_exit(&kernel_mutex); + return; } diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c index c1edc223cbc..8d1518753dd 100644 --- a/innobase/trx/trx0undo.c +++ b/innobase/trx/trx0undo.c @@ -1241,7 +1241,7 @@ trx_undo_lists_init( if (page_no != FIL_NULL && srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN) { - + undo = trx_undo_mem_create_at_db_start(rseg, i, page_no, &mtr); size += undo->size; diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 9a51eff88e1..c432ac5a16c 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -348,7 +348,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) FTB_EXPR *top_ftbe=ftbe->up->up; ftbw->docid[0]=HA_OFFSET_ERROR; for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) - if (ftbe->flags & FTB_FLAG_YES) + if (!(ftbe->flags & FTB_FLAG_NO)) ftbe->yweaks++; ftbe=0; break; @@ -356,7 +356,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) } if (!ftbe) continue; - /* 3 */ + /* 4 */ if (!is_tree_inited(& ftb->no_dupes)) init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), _ftb_no_dupes_cmp,0,0,0); diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index a8182438ac4..355f53b63a5 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -296,3 +296,12 @@ FD C3BD FD 1 FE C3BE FE 1 FF C3BF FF 1 DROP TABLE t1; +select 'a' regexp 'A' collate latin1_general_ci; +'a' regexp 'A' collate latin1_general_ci +1 +select 'a' regexp 'A' collate latin1_general_cs; +'a' regexp 'A' collate latin1_general_cs +0 +select 'a' regexp 'A' collate latin1_bin; +'a' regexp 'A' collate latin1_bin +0 diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 5575ee1bf98..f1fba87c70b 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -16,12 +16,34 @@ SET AUTOCOMMIT=0; DELETE from t1; SET AUTOCOMMIT=1; drop table t1; -create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); -insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); delete from t1 where a=26; drop table t1; -create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); -insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); +create table t1 ( +a bigint not null, +b bigint not null default 0, +c bigint not null default 0, +d bigint not null default 0, +e bigint not null default 0, +f bigint not null default 0, +g bigint not null default 0, +h bigint not null default 0, +i bigint not null default 0, +j bigint not null default 0, +primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; CREATE TABLE `t1` ( diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 5f0b228e23d..1951f68e822 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -190,6 +190,14 @@ a select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); a aaa10 bbb20 +select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 drop table t1; CREATE TABLE t1 ( id int(11), diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 3f468a5751e..e741a6859c7 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -233,3 +233,10 @@ SELECT * FROM t1 WHERE B is not null; a B 1 1 DROP TABLE t1; +CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP; +INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496); +DELETE FROM t1 WHERE date<1101106546; +SELECT * FROM t1; +pseudo date +ZoomZip 1101106546 +DROP TABLE t1; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 6097dadb1fa..b36084de58c 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1630,6 +1630,24 @@ show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 drop table t1; +create table t1 (c char(10), index (c,c)) engine=innodb; +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; create table t1 (x bigint unsigned not null primary key) engine=innodb; insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); select * from t1; diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index b11969ab6d7..98e8851bb7e 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -311,3 +311,21 @@ test.t1 check status OK drop table t1; create table t1 (c char(10), index (c(0))); ERROR HY000: Key part 'c' length cannot be 0 +create table t1 (c char(10), index (c,c)); +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)); +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)); +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)); +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)); +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index af9b84022ed..31b258c0a6f 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -44,6 +44,51 @@ a b c 7 8 3 8 2 3 drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned, +c int unsigned, +UNIQUE bc(b,c) +) engine = ndb; +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc)order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (bc) order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (PRIMARY) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +a b c +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +a b c +select * from t1 use index (bc) where b < 4 order by a; +a b c +1 1 1 +select * from t1 use index (bc) where b IS NOT NULL order by a; +a b c +1 1 1 +4 4 NULL +insert into t1 values(5,1,1); +ERROR 23000: Duplicate entry '5' for key 1 +drop table t1; CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, @@ -87,6 +132,13 @@ a b c 7 8 3 8 2 3 drop table t2; +CREATE TABLE t2 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned, +UNIQUE USING HASH (b, c) +) engine=ndbcluster; +ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL CREATE TABLE t3 ( a int unsigned NOT NULL, b int unsigned not null, diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index e0f230fa579..a4c16206b11 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -450,6 +450,27 @@ PREPARE stmt FROM 'UPDATE t1 AS P1 INNER JOIN (SELECT N FROM t1 GROUP BY N HAVIN EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +prepare stmt from "select ? is null, ? is not null, ?"; +select @no_such_var is null, @no_such_var is not null, @no_such_var; +@no_such_var is null @no_such_var is not null @no_such_var +1 0 NULL +execute stmt using @no_such_var, @no_such_var, @no_such_var; +? is null ? is not null ? +1 0 NULL +set @var='abc'; +select @var is null, @var is not null, @var; +@var is null @var is not null @var +0 1 abc +execute stmt using @var, @var, @var; +? is null ? is not null ? +0 1 abc +set @var=null; +select @var is null, @var is not null, @var; +@var is null @var is not null @var +1 0 NULL +execute stmt using @var, @var, @var; +? is null ? is not null ? +1 0 NULL create table t1 (a varchar(20)); insert into t1 values ('foo'); prepare stmt FROM 'SELECT char_length (a) FROM t1'; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 1374a8fd0ed..17e1ee5ea1a 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -220,7 +220,8 @@ insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); update t1 set y=x; explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE t1 ref y y 5 const 1 Using where +1 SIMPLE t2 range x x 5 NULL 4 Range checked for each record (index map: 0x1) explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index ceb8919b26a..20ab3ac8f80 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1998,3 +1998,18 @@ ac 700 NULL drop tables t1,t2; +create table t1 (a int not null, b int not null, c int, primary key (a,b)); +insert into t1 values (1,1,1), (2,2,2), (3,3,3); +set @b:= 0; +explain select sum(a) from t1 where b > @b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using where; Using index +set @a:= (select sum(a) from t1 where b > @b); +explain select a from t1 where c=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +do @a:= (select sum(a) from t1 where b > @b); +explain select a from t1 where c=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +drop table t1; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 2f564112e40..c9c15b4c293 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -682,8 +682,8 @@ id txt 3 NULL 1 Chevy drop table t1; -CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); -INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i), KEY (c(1),d)); +INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,''); select max(i) from t1 where c = ''; max(i) 4 diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 14062437428..677acd9faa9 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -53,3 +53,10 @@ SELECT hex(@l:=convert(@u using latin1)), a=@l FROM t1; DROP TABLE t1; + +# +# Bug #6737: REGEXP gives wrong result with case sensitive collation +# +select 'a' regexp 'A' collate latin1_general_ci; +select 'a' regexp 'A' collate latin1_general_cs; +select 'a' regexp 'A' collate latin1_bin; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 5f60445d765..0bf7187865d 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -29,12 +29,34 @@ drop table t1; # (This assumes a block size of 1024) # -create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); -insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); +create table t1 ( + a bigint not null, + b bigint not null default 0, + c bigint not null default 0, + d bigint not null default 0, + e bigint not null default 0, + f bigint not null default 0, + g bigint not null default 0, + h bigint not null default 0, + i bigint not null default 0, + j bigint not null default 0, + primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23); delete from t1 where a=26; drop table t1; -create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); -insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); +create table t1 ( + a bigint not null, + b bigint not null default 0, + c bigint not null default 0, + d bigint not null default 0, + e bigint not null default 0, + f bigint not null default 0, + g bigint not null default 0, + h bigint not null default 0, + i bigint not null default 0, + j bigint not null default 0, + primary key (a,b,c,d,e,f,g,h,i,j)); +insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index afbe8f8117c..41fbf3f27ac 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -98,6 +98,8 @@ select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode); +select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode); drop table t1; # diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index e1776245d9e..2eff36f3317 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -174,3 +174,14 @@ CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP; INSERT INTO t1 VALUES(1,1), (1,NULL); SELECT * FROM t1 WHERE B is not null; DROP TABLE t1; + +# +# Bug #6748 +# heap_rfirst() doesn't work (and never did!) +# +CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP; +INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496); +DELETE FROM t1 WHERE date<1101106546; +SELECT * FROM t1; +DROP TABLE t1; + diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 5ea6817bfba..47324f1b828 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1180,6 +1180,28 @@ select count(*) from t1 where x = 18446744073709551601; drop table t1; +# +# Bug #6126: Duplicate columns in keys gives misleading error message +# +--error 1060 +create table t1 (c char(10), index (c,c)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +--error 1060 +alter table t1 add key (c1,c1); +--error 1060 +alter table t1 add key (c2,c1,c1); +--error 1060 +alter table t1 add key (c1,c2,c1); +--error 1060 +alter table t1 add key (c1,c1,c2); +drop table t1; + # Test for testable InnoDB status variables. This test # uses previous ones(pages_created, rows_deleted, ...). show status like "Innodb_buffer_pool_pages_total"; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 0a86c1cd145..af3509c8454 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -301,3 +301,26 @@ drop table t1; --error 1391 create table t1 (c char(10), index (c(0))); + +# +# Bug #6126: Duplicate columns in keys should fail +# Bug #6252: (dup) +# +--error 1060 +create table t1 (c char(10), index (c,c)); +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)); +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)); +--error 1060 +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)); +create table t1 (c1 char(10), c2 char(10)); +--error 1060 +alter table t1 add key (c1,c1); +--error 1060 +alter table t1 add key (c2,c1,c1); +--error 1060 +alter table t1 add key (c1,c2,c1); +--error 1060 +alter table t1 add key (c1,c1,c2); +drop table t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index fd7fe0e60d8..6551732adba 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -199,7 +199,7 @@ insert into t4 values (1, "Automatic"); select * from t4; # Remove the table from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t4 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 > /dev/null ; # # Test that correct error is returned @@ -230,7 +230,7 @@ select * from t4; flush tables; # Remove the table from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t4 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 > /dev/null ; SHOW TABLES; @@ -264,8 +264,8 @@ insert into t8 values (8, "myisam table 8"); insert into t9 values (9); # Remove t3, t5 from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t3 > /dev/null ; -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t5 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; # Remove t6, t7 from disk system rm var/master-data/test/t6.frm > /dev/null ; system rm var/master-data/test/t7.frm > /dev/null ; @@ -306,8 +306,8 @@ insert into t8 values (8, "myisam table 8"); insert into t9 values (9); # Remove t3, t5 from NDB -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t3 > /dev/null ; -system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t5 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; # Remove t6, t7 from disk system rm var/master-data/test/t6.frm > /dev/null ; system rm var/master-data/test/t7.frm > /dev/null ; @@ -479,4 +479,4 @@ create table t10 ( insert into t10 values (1, 'kalle'); ---exec $NDB_TOOLS_DIR/ndb_drop_table -d test `$NDB_TOOLS_DIR/ndb_show_tables | grep BLOB` > /dev/null 2>&1 || true +--exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB` > /dev/null 2>&1 || true diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index bdb23949763..397a2c45a9f 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -30,6 +30,32 @@ select * from t1 order by a; drop table t1; +# +# Indexing NULL values +# + +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned, + c int unsigned, + UNIQUE bc(b,c) +) engine = ndb; + +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; + +select * from t1 use index (bc)order by a; +select * from t1 use index (bc) order by a; +select * from t1 use index (PRIMARY) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +select * from t1 use index (bc) where b < 4 order by a; +select * from t1 use index (bc) where b IS NOT NULL order by a; +-- error 1062 +insert into t1 values(5,1,1); +drop table t1; + # # Show use of UNIQUE USING HASH indexes @@ -58,6 +84,14 @@ select * from t2 order by a; drop table t2; +-- error 1121 +CREATE TABLE t2 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned, + UNIQUE USING HASH (b, c) +) engine=ndbcluster; + # # Show use of PRIMARY KEY USING HASH indexes # diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 1d23a09a71e..157b125a13d 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -458,6 +458,20 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1; +# +# Bug#6297 "prepared statement, wrong handling of <parameter> IS NULL" +# Test that placeholders work with IS NULL/IS NOT NULL clauses. +# +prepare stmt from "select ? is null, ? is not null, ?"; +select @no_such_var is null, @no_such_var is not null, @no_such_var; +execute stmt using @no_such_var, @no_such_var, @no_such_var; +set @var='abc'; +select @var is null, @var is not null, @var; +execute stmt using @var, @var, @var; +set @var=null; +select @var is null, @var is not null, @var; +execute stmt using @var, @var, @var; + # # Bug#6102 "Server crash with prepared statement and blank after # function name" @@ -469,3 +483,4 @@ insert into t1 values ('foo'); --error 1305 prepare stmt FROM 'SELECT char_length (a) FROM t1'; drop table t1; + diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test index 2e0ba2fff25..835af92186f 100644 --- a/mysql-test/t/rpl000001.test +++ b/mysql-test/t/rpl000001.test @@ -98,7 +98,7 @@ wait_for_slave_to_stop; # The following test can't be done because the result of Pos will differ # on different computers -# --replace_result 9306 9999 3334 9999 3335 9999 +# --replace_result $MASTER_MYPORT MASTER_PORT # show slave status; set global sql_slave_skip_counter=1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 16556c4864c..9cf9f13cfea 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1287,3 +1287,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,' SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b; SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b; drop tables t1,t2; + +# +# Test for bug #6462. "Same request on same data returns different +# results." a.k.a. "Proper cleanup of subqueries is missing for +# SET and DO statements". +# +create table t1 (a int not null, b int not null, c int, primary key (a,b)); +insert into t1 values (1,1,1), (2,2,2), (3,3,3); +set @b:= 0; +# Let us check that subquery will use covering index +explain select sum(a) from t1 where b > @b; +# This should not crash -debug server due to failing assertion +set @a:= (select sum(a) from t1 where b > @b); +# And this should not falsely report index usage +explain select a from t1 where c=2; +# Same for DO statement +do @a:= (select sum(a) from t1 where b > @b); +explain select a from t1 where c=2; +drop table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index b67fa7a552d..f70193ddbe0 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -369,8 +369,8 @@ explain select * from t1 where txt='Chevy' or txt is NULL order by txt; select * from t1 where txt='Chevy' or txt is NULL order by txt; drop table t1; -CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); -INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i), KEY (c(1),d)); +INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,''); select max(i) from t1 where c = ''; drop table t1; diff --git a/mysys/charset.c b/mysys/charset.c index 1388fc40c6d..cb2379f8723 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -228,6 +228,7 @@ static int add_collation(CHARSET_INFO *cs) } else { + uchar *sort_order= all_charsets[cs->number]->sort_order; simple_cs_init_functions(all_charsets[cs->number]); new->mbminlen= 1; new->mbmaxlen= 1; @@ -236,6 +237,16 @@ static int add_collation(CHARSET_INFO *cs) all_charsets[cs->number]->state |= MY_CS_LOADED; } all_charsets[cs->number]->state|= MY_CS_AVAILABLE; + + /* + Check if case sensitive sort order: A < a < B. + We need MY_CS_FLAG for regex library, and for + case sensitivity flag for 5.0 client protocol, + to support isCaseSensitive() method in JDBC driver + */ + if (sort_order && sort_order['A'] < sort_order['a'] && + sort_order['a'] < sort_order['B']) + all_charsets[cs->number]->state|= MY_CS_CSSORT; } } else diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index 7ff03684cff..5193d3eae9d 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -1,7 +1,7 @@ Next QMGR 1 Next NDBCNTR 1000 Next NDBFS 2000 -Next DBACC 3001 +Next DBACC 3002 Next DBTUP 4013 Next DBLQH 5042 Next DBDICT 6006 @@ -393,6 +393,7 @@ Failed Create Table: -------------------- 7173: Create table failed due to not sufficient number of fragment or replica records. +3001: Fail create 1st fragment 4007 12001: Fail create 1st fragment 4008 12002: Fail create 2nd fragment 4009 12003: Fail create 1st attribute in 1st fragment diff --git a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index c275e5382f7..5c7cc597672 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -1062,7 +1062,21 @@ void Dbacc::execACCFRAGREQ(Signal* signal) { const AccFragReq * const req = (AccFragReq*)&signal->theData[0]; jamEntry(); + if (ERROR_INSERTED(3001)) { + jam(); + addFragRefuse(signal, 1); + CLEAR_ERROR_INSERT_VALUE; + return; + } tabptr.i = req->tableId; +#ifndef VM_TRACE + // config mismatch - do not crash if release compiled + if (tabptr.i >= ctablesize) { + jam(); + addFragRefuse(signal, 800); + return; + } +#endif ptrCheckGuard(tabptr, ctablesize, tabrec); ndbrequire((req->reqInfo & 0xF) == ZADDFRAG); ndbrequire(!getrootfragmentrec(signal, rootfragrecptr, req->fragId)); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp index 914dba00674..405f790954e 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp @@ -69,6 +69,17 @@ void Dbtup::execTUPFRAGREQ(Signal* signal) Uint32 noOfAttributeGroups = signal->theData[12]; Uint32 globalCheckpointIdIndicator = signal->theData[13]; +#ifndef VM_TRACE + // config mismatch - do not crash if release compiled + if (regTabPtr.i >= cnoOfTablerec) { + ljam(); + signal->theData[0] = userptr; + signal->theData[1] = 800; + sendSignal(userblockref, GSN_TUPFRAGREF, signal, 2, JBB); + return; + } +#endif + ptrCheckGuard(regTabPtr, cnoOfTablerec, tablerec); if (cfirstfreeFragopr == RNIL) { ljam(); diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index 712ab2e4d25..0a43bb02fff 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1480,8 +1480,10 @@ runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ } int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ + static int acclst[] = { 3001 }; static int tuplst[] = { 4007, 4008, 4009, 4010, 4011, 4012 }; static int tuxlst[] = { 12001, 12002, 12003, 12004, 12005, 12006 }; + static unsigned acccnt = sizeof(acclst)/sizeof(acclst[0]); static unsigned tupcnt = sizeof(tuplst)/sizeof(tuplst[0]); static unsigned tuxcnt = sizeof(tuxlst)/sizeof(tuxlst[0]); @@ -1509,6 +1511,19 @@ int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ (void)pDic->dropTable(tab.getName()); for (int l = 0; l < loops; l++) { + for (unsigned i0 = 0; i0 < acccnt; i0++) { + unsigned j = (l == 0 ? i0 : myRandom48(acccnt)); + int errval = acclst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } for (unsigned i1 = 0; i1 < tupcnt; i1++) { unsigned j = (l == 0 ? i1 : myRandom48(tupcnt)); int errval = tuplst[j]; @@ -1638,7 +1653,7 @@ TESTCASE("DictionaryPerf", INITIALIZER(runTestDictionaryPerf); } TESTCASE("FailAddFragment", - "Fail add fragment or attribute in TUP or TUX\n"){ + "Fail add fragment or attribute in ACC or TUP or TUX\n"){ INITIALIZER(runFailAddFragment); } NDBT_TESTSUITE_END(testDict); @@ -1650,5 +1665,3 @@ int main(int argc, const char** argv){ myRandom48Init(NdbTick_CurrentMillisecond()); return testDict.execute(argc, argv); } - - diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a9537db39c7..0dc1399db24 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -796,7 +796,8 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase) error= create_unique_index(unique_index_name, key_info); break; case UNIQUE_INDEX: - error= create_unique_index(unique_index_name, key_info); + if (!(error= check_index_fields_not_null(i))) + error= create_unique_index(unique_index_name, key_info); break; case ORDERED_INDEX: error= create_ordered_index(index_name, key_info); @@ -848,6 +849,26 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const ORDERED_INDEX); } +int ha_ndbcluster::check_index_fields_not_null(uint inx) +{ + KEY* key_info= table->key_info + inx; + KEY_PART_INFO* key_part= key_info->key_part; + KEY_PART_INFO* end= key_part+key_info->key_parts; + DBUG_ENTER("check_index_fields_not_null"); + + for (; key_part != end; key_part++) + { + Field* field= key_part->field; + if (field->maybe_null()) + { + my_printf_error(ER_NULL_COLUMN_IN_INDEX,ER(ER_NULL_COLUMN_IN_INDEX), + MYF(0),field->field_name); + DBUG_RETURN(ER_NULL_COLUMN_IN_INDEX); + } + } + + DBUG_RETURN(0); +} void ha_ndbcluster::release_metadata() { diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 02d7b96db20..354a98e698c 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -160,7 +160,8 @@ class ha_ndbcluster: public handler void release_metadata(); NDB_INDEX_TYPE get_index_type(uint idx_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; - + int check_index_fields_not_null(uint index_no); + int pk_read(const byte *key, uint key_len, byte *buf); int complemented_pk_read(const byte *old_data, byte *new_data); int peek_row(); diff --git a/sql/handler.cc b/sql/handler.cc index 3c5244927d4..b474e6290f2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -970,8 +970,10 @@ int handler::read_first_row(byte * buf, uint primary_key) /* If there is very few deleted rows in the table, find the first row by scanning the table. + TODO remove the test for HA_READ_ORDER */ - if (deleted < 10 || primary_key >= MAX_KEY) + if (deleted < 10 || primary_key >= MAX_KEY || + !(index_flags(primary_key, 0, 0) & HA_READ_ORDER)) { (void) ha_rnd_init(1); while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ; diff --git a/sql/item.h b/sql/item.h index 9c036c28408..23515abc7a8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -266,6 +266,14 @@ public: virtual bool get_time(TIME *ltime); virtual bool get_date_result(TIME *ltime,uint fuzzydate) { return get_date(ltime,fuzzydate); } + /* + This function is used only in Item_func_isnull/Item_func_isnotnull + (implementations of IS NULL/IS NOT NULL clauses). Item_func_is{not}null + calls this method instead of one of val/result*() methods, which + normally will set null_value. This allows to determine nullness of + a complex expression without fully evaluating it. + Any new item which can be NULL must implement this call. + */ virtual bool is_null() { return 0; } /* it is "top level" item of WHERE clause and we do not need correct NULL @@ -710,6 +718,8 @@ public: void print(String *str); /* parameter never equal to other parameter of other item */ bool eq(const Item *item, bool binary_cmp) const { return 0; } + bool is_null() + { DBUG_ASSERT(state != NO_VALUE); return state == NULL_VALUE; } }; class Item_int :public Item_num diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4a4485ba2da..23bd1b503f7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2429,11 +2429,12 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) return FALSE; } int error; - if ((error=regcomp(&preg,res->c_ptr(), - (cmp_collation.collation->state & MY_CS_BINSORT) ? - REG_EXTENDED | REG_NOSUB : - REG_EXTENDED | REG_NOSUB | REG_ICASE, - cmp_collation.collation))) + if ((error= regcomp(&preg,res->c_ptr(), + ((cmp_collation.collation->state & MY_CS_BINSORT) || + (cmp_collation.collation->state & MY_CS_CSSORT)) ? + REG_EXTENDED | REG_NOSUB : + REG_EXTENDED | REG_NOSUB | REG_ICASE, + cmp_collation.collation))) { (void) regerror(error,&preg,buff,sizeof(buff)); my_error(ER_REGEXP_ERROR, MYF(0), buff); @@ -2481,10 +2482,11 @@ longlong Item_func_regex::val_int() regex_compiled=0; } if (regcomp(&preg,res2->c_ptr(), - (cmp_collation.collation->state & MY_CS_BINSORT) ? - REG_EXTENDED | REG_NOSUB : - REG_EXTENDED | REG_NOSUB | REG_ICASE, - cmp_collation.collation)) + ((cmp_collation.collation->state & MY_CS_BINSORT) || + (cmp_collation.collation->state & MY_CS_CSSORT)) ? + REG_EXTENDED | REG_NOSUB : + REG_EXTENDED | REG_NOSUB | REG_ICASE, + cmp_collation.collation)) { null_value=1; return 0; diff --git a/sql/set_var.cc b/sql/set_var.cc index 79d886fb84f..46865de9314 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2781,13 +2781,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list) while ((var=it++)) { if ((error=var->check(thd))) - DBUG_RETURN(error); + goto err; } - if (thd->net.report_error) - DBUG_RETURN(1); - it.rewind(); - while ((var=it++)) - error|= var->update(thd); // Returns 0, -1 or 1 + if (!thd->net.report_error) + { + it.rewind(); + while ((var= it++)) + error|= var->update(thd); // Returns 0, -1 or 1 + } + else + error= 1; +err: + free_underlaid_joins(thd, &thd->lex->select_lex); DBUG_RETURN(error); } diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 3ca3bea743a..3f34835c2c9 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -29,6 +29,7 @@ bool mysql_do(THD *thd, List<Item> &values) DBUG_RETURN(TRUE); while ((value = li++)) value->val_int(); + free_underlaid_joins(thd, &thd->lex->select_lex); thd->clear_error(); // DO always is OK send_ok(thd); DBUG_RETURN(FALSE); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 58c19422b24..bff599ce64a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2626,7 +2626,7 @@ add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond, bool is_const=1; for (uint i=0; i<num_values; i++) - is_const&= (value[i])->const_item(); + is_const&= value[i]->const_item(); if (is_const) stat[0].const_keys.merge(possible_keys); /* diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8ff2fa5faa8..8600a58f792 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -835,7 +835,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, #endif } - List_iterator<key_part_spec> cols(key->columns); + List_iterator<key_part_spec> cols(key->columns), cols2(key->columns); CHARSET_INFO *ft_key_charset=0; // for FULLTEXT for (uint column_nr=0 ; (column=cols++) ; column_nr++) { @@ -851,6 +851,19 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name); DBUG_RETURN(-1); } + for (uint dup_nr= 0; dup_nr < column_nr; dup_nr++) + { + key_part_spec *dup_column= cols2++; + if (!my_strcasecmp(system_charset_info, + column->field_name, dup_column->field_name)) + { + my_printf_error(ER_DUP_FIELDNAME, + ER(ER_DUP_FIELDNAME),MYF(0), + column->field_name); + DBUG_RETURN(-1); + } + } + cols2.rewind(); /* for fulltext keys keyseg length is 1 for blobs (it's ignored in ft code anyway, and 0 (set to column width later) for char's. it has to be correct col width for char's, as char data are not diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 6f9e9f74d35..2177a18504e 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -589,12 +589,12 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = CHARSET_INFO my_charset_latin2_czech_ci = { - 2,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ - "latin2", /* cs name */ - "latin2_czech_cs", /* name */ - "", /* comment */ - NULL, /* tailoring */ + 2,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state */ + "latin2", /* cs name */ + "latin2_czech_cs", /* name */ + "", /* comment */ + NULL, /* tailoring */ ctype_czech, to_lower_czech, to_upper_czech, diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index b4dbda3e8ed..4ada3d47bf5 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -624,12 +624,12 @@ static MY_COLLATION_HANDLER my_collation_czech_ci_handler = CHARSET_INFO my_charset_cp1250_czech_ci = { - 34,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ - "cp1250", /* cs name */ - "cp1250_czech_cs", /* name */ - "", /* comment */ - NULL, /* tailoring */ + 34,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_CSSORT, /* state */ + "cp1250", /* cs name */ + "cp1250_czech_cs", /* name */ + "", /* comment */ + NULL, /* tailoring */ ctype_win1250ch, to_lower_win1250ch, to_upper_win1250ch, diff --git a/strings/uca-dump.c b/strings/uca-dump.c index 6836c321526..db5cb7e999a 100644 --- a/strings/uca-dump.c +++ b/strings/uca-dump.c @@ -23,13 +23,14 @@ struct uca_item_st #define MY_UCA_PSHIFT 8 #endif +static char *pname[]= {"", "2", "3"}; + int main(int ac, char **av) { char str[256]; char *weights[64]; struct uca_item_st uca[64*1024]; - size_t code, page, w; - int pagemaxlen[MY_UCA_NPAGES]; + size_t code, w; int pageloaded[MY_UCA_NPAGES]; bzero(uca, sizeof(uca)); @@ -155,14 +156,20 @@ int main(int ac, char **av) printf("#define MY_UCA_CMASK %d\n",MY_UCA_CMASK); printf("#define MY_UCA_PSHIFT %d\n",MY_UCA_PSHIFT); - for (w=0; w<1; w++) + for (w=0; w<3; w++) { + size_t page; + int pagemaxlen[MY_UCA_NPAGES]; + for (page=0; page < MY_UCA_NPAGES; page++) { size_t offs; size_t maxnum= 0; size_t nchars= 0; size_t mchars; + size_t ndefs= 0; + + pagemaxlen[page]= 0; /* Skip this page if no weights were loaded @@ -183,15 +190,36 @@ int main(int ac, char **av) code= page*MY_UCA_NCHARS+offs; /* Calculate only non-zero weights */ - num=0; - for (i=0; i < uca[code].num; i++) + for (num=0, i=0; i < uca[code].num; i++) if (uca[code].weight[w][i]) num++; maxnum= maxnum < num ? num : maxnum; + + /* Check if default weight */ + if (w == 1 && num == 1) + { + /* 0020 0000 ... */ + if (uca[code].weight[w][0] == 0x0020) + ndefs++; + } + else if (w == 2 && num == 1) + { + /* 0002 0000 ... */ + if (uca[code].weight[w][0] == 0x0002) + ndefs++; + } } maxnum++; + /* + If the page have only default weights + then no needs to dump it, skip. + */ + if (ndefs == MY_UCA_NCHARS) + { + continue; + } switch (maxnum) { case 0: mchars= 8; break; @@ -210,8 +238,8 @@ int main(int ac, char **av) */ - printf("uint16 page%03Xdata[]= { /* %04X (%d weights per char) */\n", - page, page*MY_UCA_NCHARS, maxnum); + printf("uint16 page%03Xdata%s[]= { /* %04X (%d weights per char) */\n", + page, pname[w], page*MY_UCA_NCHARS, maxnum); for (offs=0; offs < MY_UCA_NCHARS; offs++) { @@ -234,7 +262,17 @@ int main(int ac, char **av) for (i=0; i < maxnum; i++) { - printf("0x%04X",(int)weight[i]); + /* + Invert weights for secondary level to + sort upper case letters before their + lower case counter part. + */ + int tmp= weight[i]; + if (w == 2 && tmp) + tmp= (int)(0x100 - weight[i]); + + + printf("0x%04X", tmp); if ((offs+1 != MY_UCA_NCHARS) || (i+1!=maxnum)) printf(","); nchars++; @@ -251,25 +289,28 @@ int main(int ac, char **av) } printf("};\n\n"); } - } - printf("uchar ucal[%d]={\n",MY_UCA_NPAGES); - for (page=0; page < MY_UCA_NPAGES; page++) - { - printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n"); - } - printf("};\n"); - - - printf("uint16 *ucaw[%d]={\n",MY_UCA_NPAGES); - for (page=0; page < MY_UCA_NPAGES; page++) - { - if (!pageloaded[page]) - printf("NULL %s%s",page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n"); - else - printf("page%03Xdata%s%s",page,page<MY_UCA_NPAGES-1?",":"", (page+1) % 4 ? "":"\n"); + printf("uchar uca_length%s[%d]={\n", pname[w], MY_UCA_NPAGES); + for (page=0; page < MY_UCA_NPAGES; page++) + { + printf("%d%s%s",pagemaxlen[page],page<MY_UCA_NPAGES-1?",":"",(page+1) % 16 ? "":"\n"); + } + printf("};\n"); + + + printf("uint16 *uca_weight%s[%d]={\n", pname[w], MY_UCA_NPAGES); + for (page=0; page < MY_UCA_NPAGES; page++) + { + const char *comma= page < MY_UCA_NPAGES-1 ? "," : ""; + const char *nline= (page+1) % 4 ? "" : "\n"; + if (!pagemaxlen[page]) + printf("NULL %s%s", comma , nline); + else + printf("page%03Xdata%s%s%s", page, pname[w], comma, nline); + } + printf("};\n"); } - printf("};\n"); + printf("int main(void){ return 0;};\n"); return 0; |