From c1fd20bb5ed75b4d6df24703e0b26a488eac4a3b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Aug 2004 23:48:30 -0700 Subject: null.test, null.result: Added test case for bug #4256. join_outer.result: Fixed bug #4256. item_cmpfunc.h: Fixed inconsistency of values of used_tables_cache and const_item_cache for Item_func_isnull objects. This inconsistency caused bug #4256. sql/item_cmpfunc.h: Fixed inconsistency of values of used_tables_cache and const_item_cache for Item_func_isnull objects. This inconsistency caused bug #4256. mysql-test/r/join_outer.result: Fixed bug #4256. mysql-test/r/null.result: Added test case for bug #4256. mysql-test/t/null.test: Added test case for bug #4256. --- mysql-test/r/join_outer.result | 2 +- mysql-test/r/null.result | 19 +++++++++++++++++++ mysql-test/t/null.test | 23 +++++++++++++++++++++++ sql/item_cmpfunc.h | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index ae4d99e6241..5778b2f9b72 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -91,7 +91,7 @@ grp a c id a c d NULL NULL NULL NULL NULL NULL explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1; Comment -Impossible WHERE noticed after reading const tables +Impossible WHERE explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 7 diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index ba2161d3147..41a1a06aebe 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -109,3 +109,22 @@ a b c d 0 0000-00-00 00:00:00 0 0 0000-00-00 00:00:00 0 drop table t1; +CREATE TABLE t1(i int, KEY(i)); +INSERT INTO t1 VALUES(1); +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +EXPLAIN SELECT * FROM t1 WHERE i=2 OR i IS NULL; +table type possible_keys key key_len ref rows Extra +t1 range i i 5 NULL 10 Using where; Using index +ALTER TABLE t1 CHANGE i i int NOT NULL; +EXPLAIN SELECT * FROM t1 WHERE i=2 OR i IS NULL; +table type possible_keys key key_len ref rows Extra +t1 range i i 4 NULL 7 Using where; Using index +DROP TABLE t1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 6fea7f0d10d..fc9b0a8aff2 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -79,3 +79,26 @@ INSERT INTO t1 (d) values (null),(null); select * from t1; drop table t1; +# Test case for bug #4256 + +CREATE TABLE t1(i int, KEY(i)); + +INSERT INTO t1 VALUES(1); + +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; +INSERT INTO t1 SELECT i*2 FROM t1; + +EXPLAIN SELECT * FROM t1 WHERE i=2 OR i IS NULL; + +ALTER TABLE t1 CHANGE i i int NOT NULL; + +EXPLAIN SELECT * FROM t1 WHERE i=2 OR i IS NULL; + +DROP TABLE t1; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index a0bcd864d4b..236ebb8d28b 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -469,6 +469,7 @@ public: if (!args[0]->maybe_null) { used_tables_cache= 0; /* is always false */ + const_item_cache= 1; cached_value= (longlong) 0; } else -- cgit v1.2.1 From 35d5744e8a868477416eaa232b647250a69668a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 22 Aug 2004 09:36:17 +0200 Subject: bug#2408 - Multiple threads altering MERGE table UNIONs hang/crash. Abandoned improper use of MyISAM data. Thanks Ingo! --- myisammrg/myrg_open.c | 101 ++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 52 deletions(-) diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index df94fb680cb..ad89d109b85 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -35,86 +35,86 @@ const char *name, int mode, int handle_locking) { - int save_errno,i,errpos; + int save_errno,errpos; uint files,dir_length,length; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; - MYRG_INFO info,*m_info; + MYRG_INFO *m_info; File fd; IO_CACHE file; - MI_INFO *isam,*last_isam; + MI_INFO *isam; DBUG_ENTER("myrg_open"); - LINT_INIT(last_isam); LINT_INIT(m_info); isam=0; errpos=files=0; - bzero((gptr) &info,sizeof(info)); bzero((char*) &file,sizeof(file)); if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), - O_RDONLY | O_SHARE,MYF(0))) < 0 || - init_io_cache(&file, fd, IO_SIZE, READ_CACHE, 0, 0, - MYF(MY_WME | MY_NABP))) + O_RDONLY | O_SHARE,MYF(0))) < 0) goto err; errpos=1; + if (init_io_cache(&file, fd, 4*IO_SIZE, READ_CACHE, 0, 0, + MYF(MY_WME | MY_NABP))) + goto err; + errpos=2; dir_length=dirname_part(name_buff,name); - info.reclength=0; while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ { - if (!test_if_hard_path(buff)) - { - VOID(strmake(name_buff+dir_length,buff, - sizeof(name_buff)-1-dir_length)); - VOID(cleanup_dirname(buff,name_buff)); - } - if (!(isam=mi_open(buff,mode,test(handle_locking)))) - goto err; files++; - last_isam=isam; - if (info.reclength && info.reclength != isam->s->base.reclength) - { - my_errno=HA_ERR_WRONG_IN_RECORD; - goto err; - } - info.reclength=isam->s->base.reclength; } } + if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+ files*sizeof(MYRG_TABLE), - MYF(MY_WME)))) + MYF(MY_WME|MY_ZEROFILL)))) goto err; - *m_info=info; + errpos=3; m_info->open_tables=(files) ? (MYRG_TABLE *) (m_info+1) : 0; m_info->tables=files; - errpos=2; - - for (i=files ; i-- > 0 ; ) - { - m_info->open_tables[i].table=isam; - m_info->options|=isam->s->options; - m_info->records+=isam->state->records; - m_info->del+=isam->state->del; - m_info->data_file_length+=isam->state->data_file_length; - if (i) - isam=(MI_INFO*) (isam->open_list.next->data); - } - /* Fix fileinfo for easyer debugging (actually set by rrnd) */ + files=0; file_offset=0; - for (i=0 ; (uint) i < files ; i++) + + my_b_seek(&file, 0); + while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - m_info->open_tables[i].file_offset=(my_off_t) file_offset; - file_offset+=m_info->open_tables[i].table->state->data_file_length; + if ((end=buff+length)[-1] == '\n') + end[-1]='\0'; + if (buff[0] && buff[0] == '#') /* Skipp empty lines and comments */ + continue; + if (!test_if_hard_path(buff)) + { + VOID(strmake(name_buff+dir_length,buff, + sizeof(name_buff)-1-dir_length)); + VOID(cleanup_dirname(buff,name_buff)); + } + if (!(isam=mi_open(buff,mode,test(handle_locking)))) + goto err; + m_info->open_tables[files].table= isam; + m_info->open_tables[files].file_offset=(my_off_t) file_offset; + file_offset+=isam->state->data_file_length; + files++; + if (m_info->reclength && (m_info->reclength != isam->s->base.reclength)) + { + my_errno=HA_ERR_WRONG_IN_RECORD; + goto err; + } + m_info->reclength=isam->s->base.reclength; + m_info->options|= isam->s->options; + m_info->records+= isam->state->records; + m_info->del+= isam->state->del; + m_info->data_file_length+= isam->state->data_file_length; } + if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) { my_errno=HA_ERR_RECORD_FILE_FULL; goto err; } - m_info->keys=(files) ? m_info->open_tables->table->s->base.keys : 0; + m_info->keys=(files) ? isam->s->base.keys : 0; bzero((char*) &m_info->by_key,sizeof(m_info->by_key)); /* this works ok if the table list is empty */ @@ -132,19 +132,16 @@ int handle_locking) err: save_errno=my_errno; switch (errpos) { - case 2: + case 3: + while (files) + mi_close(m_info->open_tables[--files].table); my_free((char*) m_info,MYF(0)); /* Fall through */ + case 2: + end_io_cache(&file); + /* Fall through */ case 1: VOID(my_close(fd,MYF(0))); - end_io_cache(&file); - for (i=files ; i-- > 0 ; ) - { - isam=last_isam; - if (i) - last_isam=(MI_INFO*) (isam->open_list.next->data); - mi_close(isam); - } } my_errno=save_errno; DBUG_RETURN (NULL); -- cgit v1.2.1 From cb6dc5738cc41445725bbcb19ed33d45d1f5a48a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 22 Aug 2004 12:43:26 +0200 Subject: after merge fixes --- myisammrg/myrg_open.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 35b5adc8770..2d6b6dcf167 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -43,6 +43,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) DBUG_ENTER("myrg_open"); LINT_INIT(m_info); + m_info=0; isam=0; errpos=files=0; bzero((char*) &file,sizeof(file)); @@ -75,7 +76,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if( !strncmp(buff+1,"INSERT_METHOD=",14)) { /* Lookup insert method */ int tmp=find_type(buff+15,&merge_insert_method,2); - m_info.merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); + m_info->merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } continue; /* Skip comments */ } @@ -115,7 +116,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) m_info->open_tables[files].file_offset=(my_off_t) file_offset; file_offset+=isam->state->data_file_length; files++; - if (m_info.reclength != isam->s->base.reclength) + if (m_info->reclength != isam->s->base.reclength) { my_errno=HA_ERR_WRONG_MRG_TABLE_DEF; goto err; @@ -128,6 +129,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) m_info->rec_per_key_part[i]+=isam->s->state.rec_per_key_part[i] / m_info->tables; } + if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), + MYF(MY_WME|MY_ZEROFILL)))) + goto err; /* Don't mark table readonly, for ALTER TABLE ... UNION=(...) to work */ m_info->options&= ~(HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA); @@ -136,7 +140,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) my_errno=HA_ERR_RECORD_FILE_FULL; goto err; } - m_info->keys=(files) ? m_info->open_tables->table->s->base.keys : 0; + m_info->keys= files ? isam->s->base.keys : 0; bzero((char*) &m_info->by_key,sizeof(m_info->by_key)); /* this works ok if the table list is empty */ -- cgit v1.2.1