From: Date: November 19 2005 2:02am Subject: bk commit into 5.1 tree (patg:1.1960) BUG#14524 List-Archive: http://lists.mysql.com/internals/32422 X-Bug: 14524 Message-Id: <20051119010244.A971AD44B3@krsna.patg.net> Below is the list of changes that have just been committed into a local 5.1 repository of patg. When patg does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1960 05/11/18 17:02:27 patg@stripped +6 -0 BUG #14524 Patch that fixes crashing when partition uses blackole for underlying tables. sql/sql_partition.cc 1.12 05/11/18 17:01:29 patg@stripped +1 -1 BUG #14524 Changed umlaut o to allow fixing bug 14524 using DDD (file would not display in DDD) sql/lock.cc 1.78 05/11/18 17:01:29 patg@stripped +11 -4 BUG #14524 DBUG PRINTs and ENTERs to make tracking the bug easier. I think these are useful regardless of this bug. sql/ha_partition.h 1.4 05/11/18 17:01:29 patg@stripped +1 -0 BUG #14524 Added new class var m_no_locks to keep track of lock count sql/ha_partition.cc 1.9 05/11/18 17:01:29 patg@stripped +10 -2 BUG# 14524 Added new class var m_no_locks to keep track of the absense of locks. If '0', then lock_count returns 0, which keeps thr_multi_lock from crashing in the case of the underlying table being ha_blackhole. mysql-test/t/partition.test 1.6 05/11/18 17:01:29 patg@stripped +10 -0 BUG #14524 New test mysql-test/r/partition.result 1.6 05/11/18 17:01:29 patg@stripped +8 -0 BUG #14524 New test result # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: patg # Host: krsna.patg.net # Root: /home/patg/mysql-build/mysql-5.1-new --- 1.77/sql/lock.cc 2005-09-14 22:31:40 -07:00 +++ 1.78/sql/lock.cc 2005-11-18 17:01:29 -08:00 @@ -146,6 +146,7 @@ } thd->proc_info="System lock"; + DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); if (lock_external(thd, tables, count)) { my_free((gptr) sql_lock,MYF(0)); @@ -153,6 +154,7 @@ break; } thd->proc_info="Table lock"; + DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info)); thd->locked=1; rc= thr_lock_errno_to_mysql[(int) thr_multi_lock(sql_lock->locks, sql_lock->lock_count, @@ -218,6 +220,7 @@ int lock_type,error; DBUG_ENTER("lock_external"); + DBUG_PRINT("info", ("count %d", count)); for (i=1 ; i <= count ; i++, tables++) { DBUG_ASSERT((*tables)->reginfo.lock_type >= TL_READ); @@ -460,6 +463,8 @@ THR_LOCK_DATA **locks; TABLE **to; + DBUG_ENTER("get_lock_data"); + DBUG_PRINT("info", ("count %d", count)); *write_lock_used=0; for (i=tables=lock_count=0 ; i < count ; i++) { @@ -479,7 +484,7 @@ { my_error(ER_WRONG_LOCK_OF_SYSTEM_TABLE, MYF(0), table_ptr[i]->s->db, table_ptr[i]->s->table_name); - return 0; + DBUG_RETURN(0); } } @@ -487,11 +492,13 @@ my_malloc(sizeof(*sql_lock)+ sizeof(THR_LOCK_DATA*)*tables+sizeof(table_ptr)*lock_count, MYF(0)))) - return 0; + DBUG_RETURN(0); locks=sql_lock->locks=(THR_LOCK_DATA**) (sql_lock+1); to=sql_lock->table=(TABLE**) (locks+tables); sql_lock->table_count=lock_count; sql_lock->lock_count=tables; + DBUG_PRINT("info", ("sql_lock->table_count %d sql_lock->lock_count %d", + sql_lock->table_count, sql_lock->lock_count)); for (i=0 ; i < count ; i++) { @@ -507,7 +514,7 @@ { my_error(ER_OPEN_AS_READONLY, MYF(0), table->alias); my_free((gptr) sql_lock,MYF(0)); - return 0; + DBUG_RETURN(0); } } THR_LOCK_DATA **org_locks = locks; @@ -517,7 +524,7 @@ for ( ; org_locks != locks ; org_locks++) (*org_locks)->debug_print_param= (void *) table; } - return sql_lock; + DBUG_RETURN(sql_lock); } --- 1.5/mysql-test/r/partition.result 2005-09-20 07:29:52 -07:00 +++ 1.6/mysql-test/r/partition.result 2005-11-18 17:01:29 -08:00 @@ -108,3 +108,11 @@ insert into t1 values (4); UNLOCK TABLES; drop table t1; +DROP TABLE IF EXISTS `t1`; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE `t1` ( +`id` int(11) default NULL +) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ; +SELECT * FROM t1; +id --- 1.5/mysql-test/t/partition.test 2005-09-20 07:29:52 -07:00 +++ 1.6/mysql-test/t/partition.test 2005-11-18 17:01:29 -08:00 @@ -162,3 +162,13 @@ drop table t1; +# +# BUG 14524 +# +--disable-warnings +DROP TABLE IF EXISTS `t1`; +--enable-warnings +CREATE TABLE `t1` ( + `id` int(11) default NULL +) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ; +SELECT * FROM t1; --- 1.8/sql/ha_partition.cc 2005-11-07 08:14:55 -08:00 +++ 1.9/sql/ha_partition.cc 2005-11-18 17:01:29 -08:00 @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - This handler was developed by Mikael Ronström for version 5.1 of MySQL. + This handler was developed by Mikael Ronstrom for version 5.1 of MySQL. It is an abstraction layer on top of other handlers such as MyISAM, InnoDB, Federated, Berkeley DB and so forth. Partitioned tables can also be handled by a storage engine. The current example of this is NDB @@ -167,6 +167,10 @@ m_last_part= 0; m_rec0= 0; m_curr_key_info= 0; + /* + this allows blackhole to work properly + */ + m_no_locks= 0; #ifdef DONT_HAVE_TO_BE_INITALIZED m_start_key.flag= 0; @@ -912,6 +916,7 @@ if ((error= (*file)->ha_open((const char*) name_buff, mode, test_if_locked))) goto err_handler; + m_no_locks+= (*file)->lock_count(); name_buffer_ptr+= strlen(name_buffer_ptr) + 1; set_if_bigger(ref_length, ((*file)->ref_length)); } while (*(++file)); @@ -1098,6 +1103,9 @@ uint ha_partition::lock_count() const { DBUG_ENTER("ha_partition::lock_count"); + if (m_no_locks == 0) + DBUG_RETURN(0); + DBUG_RETURN(m_tot_parts); } @@ -1143,7 +1151,7 @@ ADDITIONAL INFO: Most handlers set timestamp when calling write row if any such fields - exists. Since we are calling an underlying handler we assume the´ + exists. Since we are calling an underlying handler we assume the underlying handler will assume this responsibility. Underlying handlers will also call update_auto_increment to calculate --- 1.3/sql/ha_partition.h 2005-10-06 03:45:16 -07:00 +++ 1.4/sql/ha_partition.h 2005-11-18 17:01:29 -08:00 @@ -67,6 +67,7 @@ u_long m_low_byte_first; uint m_tot_parts; // Total number of partitions; + uint m_no_locks; // For engines like ha_blackhole, which needs no locks uint m_last_part; // Last file that we update,write int m_lock_type; // Remembers type of last // external_lock --- 1.11/sql/sql_partition.cc 2005-11-07 08:14:56 -08:00 +++ 1.12/sql/sql_partition.cc 2005-11-18 17:01:29 -08:00 @@ -20,7 +20,7 @@ used by all handlers that support partitioning, which in the first version is the partitioning handler itself and the NDB handler. - The first version was written by Mikael Ronström. + The first version was written by Mikael Ronstrom. This version supports RANGE partitioning, LIST partitioning, HASH partitioning and composite partitioning (hereafter called subpartitioning)