Commit 20b09855 authored by unknown's avatar unknown
Browse files

Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1

into  a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.1


BitKeeper/etc/config:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_berkeley.cc:
  Auto merged
sql/ha_berkeley.h:
  Auto merged
sql/ha_heap.cc:
  Auto merged
sql/ha_heap.h:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/ha_innodb.h:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_myisam.h:
  Auto merged
sql/ha_myisammrg.cc:
  Auto merged
sql/ha_myisammrg.h:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/handler.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/set_var.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Merge.
sql/field.h:
  Auto merged
parents 96c05032 f1e25513
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -73,3 +73,8 @@ hours:
[nick:]checkout:get
checkout:edit
eoln:unix

license: BKL5433d4e6925a06a150001200fff9b
licsign1: YgAAAo0AAAADgAAAAEYUtZil1XCmH6z+LTlQMDJ+1ZeBLIgtHo1azUxQ8/8G1JuW
licsign2: fxW3y9raSlpYVAleJSaBDKYiVtEuSdaUN2ILLo6Wc8TJmLl0aprUy7Lh/m/Sq/YC
licsign3: 0H7qah3bdItuw7NGNSLfBzigbKOF6kPbU84VlAUhOqLR2e5Zf32SBZhtCYGA
+54 −0
Original line number Diff line number Diff line
@@ -537,3 +537,57 @@ create table t1 ( a timestamp );
alter table t1 add unique ( a(1) );
ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
drop table t1;
create table t1 (v varchar(32));
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
v
def
abc
hij
3r4f
alter table t1 change v v2 varchar(32);
select * from t1;
v2
def
abc
hij
3r4f
alter table t1 change v2 v varchar(64);
select * from t1;
v
def
abc
hij
3r4f
update t1 set v = 'lmn' where v = 'hij';
select * from t1;
v
def
abc
lmn
3r4f
alter table t1 add i int auto_increment not null primary key first;
select * from t1;
i	v
1	def
2	abc
3	lmn
4	3r4f
update t1 set i=5 where i=3;
select * from t1;
i	v
1	def
2	abc
5	lmn
4	3r4f
alter table t1 change i i bigint;
select * from t1;
i	v
1	def
2	abc
5	lmn
4	3r4f
alter table t1 add unique key (i, v);
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
i	v
4	3r4f
+27 −0
Original line number Diff line number Diff line
@@ -360,3 +360,30 @@ create table t1 ( a timestamp );
--error 1089
alter table t1 add unique ( a(1) );
drop table t1;

#
# Some additional tests for new, faster alter table.
# Note that most of the whole alter table code is being
# tested all around the test suite already.
#

create table t1 (v varchar(32));
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
# Fast alter, no copy performed
alter table t1 change v v2 varchar(32);
select * from t1;
# Fast alter, no copy performed
alter table t1 change v2 v varchar(64);
select * from t1;
update t1 set v = 'lmn' where v = 'hij';
select * from t1;
# Regular alter table
alter table t1 add i int auto_increment not null primary key first;
select * from t1;
update t1 set i=5 where i=3;
select * from t1;
alter table t1 change i i bigint;
select * from t1;
alter table t1 add unique key (i, v);
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
+48 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ inline int field_type2index (enum_field_types field_type)
          ((int)FIELDTYPE_TEAR_FROM) + (field_type - FIELDTYPE_TEAR_TO) - 1);
}


static enum_field_types field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM]=
{
  /* MYSQL_TYPE_DECIMAL -> */
@@ -5906,6 +5907,26 @@ int Field_str::store(double nr)
}


uint Field::is_equal(create_field *new_field)
{
  return (new_field->sql_type == type());
}


uint Field_str::is_equal(create_field *new_field)
{
  if (((new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
       !(flags & (BINCMP_FLAG | BINARY_FLAG))) ||
      (!(new_field->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
	(flags & (BINCMP_FLAG | BINARY_FLAG))))
    return 0; /* One of the fields is binary and the other one isn't */

  return ((new_field->sql_type == type()) &&
	  new_field->charset == field_charset &&
	  new_field->length == max_length());
}


int Field_string::store(longlong nr)
{
  char buff[64];
@@ -6665,6 +6686,22 @@ Field *Field_varstring::new_key_field(MEM_ROOT *root,
}


uint Field_varstring::is_equal(create_field *new_field)
{
  if (new_field->sql_type == type() &&
      new_field->charset == field_charset)
  {
    if (new_field->length == max_length())
      return IS_EQUAL_YES;
    if (new_field->length > max_length() &&
	((new_field->length <= 255 && max_length() <= 255) ||
	 (new_field->length > 255 && max_length() > 255)))
      return IS_EQUAL_PACK_LENGTH; // VARCHAR, longer variable length
  }
  return IS_EQUAL_NO;
}


/****************************************************************************
** blob type
** A blob is saved as a length and a pointer. The length is stored in the
@@ -7774,6 +7811,17 @@ bool Field_num::eq_def(Field *field)
}


uint Field_num::is_equal(create_field *new_field)
{
  return ((new_field->sql_type == type()) &&
	  ((new_field->flags & UNSIGNED_FLAG) == (uint) (flags &
							 UNSIGNED_FLAG)) &&
	  ((new_field->flags & AUTO_INCREMENT_FLAG) ==
	   (uint) (flags & AUTO_INCREMENT_FLAG)) &&
	  (new_field->length >= max_length()));
}


/*
  Bit field.

+6 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

class Send_field;
class Protocol;
class create_field;
struct st_cache_field;
void field_conv(Field *to,Field *from);

@@ -315,6 +316,8 @@ class Field
  int warn_if_overflow(int op_result);
  /* maximum possible display length */
  virtual uint32 max_length()= 0;

  virtual uint is_equal(create_field *new_field);
  /* convert decimal to longlong with overflow check */
  longlong convert_decimal2longlong(const my_decimal *val, bool unsigned_flag,
                                    int *err);
@@ -355,6 +358,7 @@ class Field_num :public Field {
  bool eq_def(Field *field);
  int store_decimal(const my_decimal *);
  my_decimal *val_decimal(my_decimal *);
  uint is_equal(create_field *new_field);
};


@@ -379,6 +383,7 @@ class Field_str :public Field {
  uint32 max_length() { return field_length; }
  friend class create_field;
  my_decimal *val_decimal(my_decimal *);
  uint is_equal(create_field *new_field);
};


@@ -1097,6 +1102,7 @@ class Field_varstring :public Field_longstr {
  Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
                       char *new_ptr, uchar *new_null_ptr,
                       uint new_null_bit);
  uint is_equal(create_field *new_field);
};


Loading