Commit 5fecbb44 authored by unknown's avatar unknown
Browse files

Merge c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/clean-mysql-5.1-new

into  c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/bug19122


sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
mysql-test/r/partition.result:
  manual merge
mysql-test/t/partition.test:
  manual merge
parents e05d55de a29e59e0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -890,6 +890,16 @@ s1
2
3
drop table t1;
create table t1 (a int)
partition by key (a)
(partition p1 engine = innodb);
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
create table t1 (a int) engine=memory
partition by key(a);
insert into t1 values (1);
+15 −0
Original line number Diff line number Diff line
@@ -1023,6 +1023,21 @@ insert into t1 values (1);
create index inx1 on t1(a);
drop table t1;

#
# BUG 19122 Crash after ALTER TABLE t1 REBUILD PARTITION p1
#
create table t1 (a int)
partition by key (a)
(partition p1 engine = innodb);

alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;

#
# BUG 19304 Partitions: MERGE handler not allowed in partitioned tables
#
+29 −16
Original line number Diff line number Diff line
@@ -828,7 +828,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
  if (wait_if_global_read_lock(thd, 0, 1))
    DBUG_RETURN(1);
  VOID(pthread_mutex_lock(&LOCK_open));
  if ((lock_retcode = lock_table_name(thd, table_list)) < 0)
  if ((lock_retcode = lock_table_name(thd, table_list, TRUE)) < 0)
    goto end;
  if (lock_retcode && wait_for_locked_table_names(thd, table_list))
  {
@@ -851,6 +851,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
    lock_table_name()
    thd			Thread handler
    table_list		Lock first table in this list
    check_in_use        Do we need to check if table already in use by us

  WARNING
    If you are going to update the table, you should use
@@ -870,7 +871,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
    > 0  table locked, but someone is using it
*/

int lock_table_name(THD *thd, TABLE_LIST *table_list)
int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
{
  TABLE *table;
  char  key[MAX_DBKEY_LENGTH];
@@ -882,10 +883,14 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)

  key_length= create_table_def_key(thd, key, table_list, 0);

  if (check_in_use)
  {
    /* Only insert the table if we haven't insert it already */
  for (table=(TABLE*) hash_first(&open_cache, (byte*)key, key_length, &state);
    for (table=(TABLE*) hash_first(&open_cache, (byte*)key,
                                   key_length, &state);
         table ;
       table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length, &state))
         table = (TABLE*) hash_next(&open_cache,(byte*) key,
                                    key_length, &state))
    {
      if (table->in_use == thd)
      {
@@ -895,6 +900,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
        DBUG_RETURN(0);
      }
    }
  }
  /*
    Create a table entry with the right key and with an old refresh version
    Note that we must use my_malloc() here as this is freed by the table
@@ -918,10 +924,17 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
    DBUG_RETURN(-1);
  }

  if (!check_in_use)
  {
    DBUG_RETURN(0);
  }
  else
  {
    /* Return 1 if table is in use */
    DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
                                             RTFC_NO_FLAG)));
  }
}


void unlock_table_name(THD *thd, TABLE_LIST *table_list)
@@ -1003,7 +1016,7 @@ bool lock_table_names(THD *thd, TABLE_LIST *table_list)
  for (lock_table= table_list; lock_table; lock_table= lock_table->next_local)
  {
    int got_lock;
    if ((got_lock=lock_table_name(thd,lock_table)) < 0)
    if ((got_lock=lock_table_name(thd,lock_table, TRUE)) < 0)
      goto end;					// Fatal error
    if (got_lock)
      got_all_locks=0;				// Someone is using table
+4 −3
Original line number Diff line number Diff line
@@ -1165,7 +1165,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
                                HA_CREATE_INFO *create_info,
                                TABLE_LIST *table_list,
                                List<create_field> *create_list,
                                List<Key> *key_list, const char *db,
                                List<Key> *key_list, char *db,
                                const char *table_name,
                                uint fast_alter_partition);
uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info,
@@ -1195,6 +1195,7 @@ void create_subpartition_name(char *out, const char *in1,

typedef struct st_lock_param_type
{
  TABLE_LIST table_list;
  ulonglong copied;
  ulonglong deleted;
  THD *thd;
@@ -1205,7 +1206,7 @@ typedef struct st_lock_param_type
  List<Key> new_key_list;
  TABLE *table;
  KEY *key_info_buffer;
  const char *db;
  char *db;
  const char *table_name;
  const void *pack_frm_data;
  enum thr_lock_type old_lock_type;
@@ -1677,7 +1678,7 @@ void unset_protect_against_global_read_lock(void);

/* Lock based on name */
int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);
int lock_table_name(THD *thd, TABLE_LIST *table_list);
int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use);
void unlock_table_name(THD *thd, TABLE_LIST *table_list);
bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
bool lock_table_names(THD *thd, TABLE_LIST *table_list);
+1 −1
Original line number Diff line number Diff line
@@ -2684,7 +2684,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
      goto err;

     // Code below is for repairing a crashed file
     if ((error= lock_table_name(thd, table_list)))
     if ((error= lock_table_name(thd, table_list, TRUE)))
     {
       if (error < 0)
 	goto err;
Loading