Commit 7152382e authored by unknown's avatar unknown
Browse files

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into ice.snake.net:/Volumes/ice2/MySQL/bk/mysql-4.1


sql/set_var.cc:
  Auto merged
parents 3d23bb83 a7a508e1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1473,7 +1473,7 @@ AC_DEFUN([MYSQL_CHECK_CSVDB], [

  case "$csvdb" in
    yes )
      AC_DEFINE(HAVE_CSV_DB)
      AC_DEFINE([HAVE_CSV_DB], [1], [Builds the CSV Storage Engine])
      AC_MSG_RESULT([yes])
      [csvdb=yes]
      ;;
+91 −10
Original line number Diff line number Diff line
@@ -245,7 +245,15 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
    }
    if (seg->type == HA_KEYTYPE_TEXT)
    {
       seg->charset->coll->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,&nr2);
       CHARSET_INFO *cs= seg->charset;
       uint length= ((uchar*)key) - pos;
       uint char_length= length / cs->mbmaxlen;
       if (length > char_length)
       {
         char_length= my_charpos(cs, pos, pos + length, char_length);
         set_if_smaller(char_length, length);
       }
       cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2);
    }
    else
    {
@@ -280,7 +288,14 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
    }
    if (seg->type == HA_KEYTYPE_TEXT)
    {
      seg->charset->coll->hash_sort(seg->charset,pos,end-pos,&nr,&nr2);
      CHARSET_INFO *cs= seg->charset;
      uint char_length= seg->length / cs->mbmaxlen;
      if (seg->length > char_length)
      {
        char_length= my_charpos(cs, pos, pos + seg->length, char_length);
        set_if_smaller(char_length, seg->length);
      }
      cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2);
    }
    else
    {
@@ -401,9 +416,26 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2)
    }
    if (seg->type == HA_KEYTYPE_TEXT)
    {
      CHARSET_INFO *cs= seg->charset;
      uint char_length= seg->length / cs->mbmaxlen;
      uint char_length1;
      uint char_length2;
      uchar *pos1= (uchar*)rec1 + seg->start;
      uchar *pos2= (uchar*)rec2 + seg->start;
      if (seg->length > char_length)
      {
        char_length1= my_charpos(cs, pos1, pos1 + seg->length, char_length);
        set_if_smaller(char_length1, seg->length);
        char_length2= my_charpos(cs, pos2, pos2 + seg->length, char_length);
        set_if_smaller(char_length2, seg->length);
      }
      else
      {
        char_length1= char_length2= seg->length;
      }
      if (seg->charset->coll->strnncollsp(seg->charset,
      					  (uchar*) rec1+seg->start,seg->length,
					  (uchar*) rec2+seg->start,seg->length))
      					  pos1,char_length1,
					  pos2,char_length2))
	return 1;
    }
    else
@@ -435,9 +467,27 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key)
    }
    if (seg->type == HA_KEYTYPE_TEXT)
    {
      CHARSET_INFO *cs= seg->charset;
      uint char_length= seg->length / cs->mbmaxlen;
      uint char_length_key;
      uint char_length_rec;
      uchar *pos= (uchar*) rec + seg->start;
      if (seg->length > char_length)
      {
        char_length_key= my_charpos(cs, key, key + seg->length, char_length);
        set_if_smaller(char_length_key, seg->length);
        char_length_rec= my_charpos(cs, pos, pos + seg->length, char_length);
        set_if_smaller(char_length_rec, seg->length);
      }
      else
      {
        char_length_key= seg->length;
        char_length_rec= seg->length;
      }
      
      if (seg->charset->coll->strnncollsp(seg->charset,
					  (uchar*) rec+seg->start, seg->length,
					  (uchar*) key, seg->length))
					  (uchar*) pos, char_length_rec,
					  (uchar*) key, char_length_key))
	return 1;
    }
    else
@@ -458,10 +508,19 @@ void hp_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec)

  for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
  {
    CHARSET_INFO *cs= seg->charset;
    uint char_length= (cs && cs->mbmaxlen > 1) ? seg->length / cs->mbmaxlen :
                                                 seg->length;
    uchar *pos= (uchar*) rec + seg->start;
    if (seg->null_bit)
      *key++= test(rec[seg->null_pos] & seg->null_bit);
    memcpy(key,rec+seg->start,(size_t) seg->length);
    key+=seg->length;
    if (seg->length > char_length)
    {
      char_length= my_charpos(cs, pos, pos + seg->length, char_length);
      set_if_smaller(char_length, seg->length);
    }
    memcpy(key,rec+seg->start,(size_t) char_length);
    key+= char_length;
  }
}

@@ -473,6 +532,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,

  for (seg= keydef->seg, endseg= seg + keydef->keysegs; seg < endseg; seg++)
  {
    uint char_length;
    if (seg->null_bit)
    {
      if (!(*key++= 1 - test(rec[seg->null_pos] & seg->null_bit)))
@@ -515,7 +575,18 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,
      }
      continue;
    }
    memcpy(key, rec + seg->start, (size_t) seg->length);
    char_length= seg->length / (seg->charset ? seg->charset->mbmaxlen : 1);
    if (seg->length > char_length)
    {
      char_length= my_charpos(seg->charset, 
                              rec + seg->start, rec + seg->start + seg->length,
                              char_length);
      set_if_smaller(char_length, seg->length);
      if (char_length < seg->length)
        seg->charset->cset->fill(seg->charset, key + char_length, 
                                 seg->length - char_length, ' ');
    }
    memcpy(key, rec + seg->start, (size_t) char_length);
    key+= seg->length;
  }
  memcpy(key, &recpos, sizeof(byte*));
@@ -530,6 +601,7 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len)
  for (seg= keydef->seg, endseg= seg + keydef->keysegs;
       seg < endseg && (int) k_len > 0; old+= seg->length, seg++)
  {
    uint char_length;
    if (seg->null_bit)
    {
      k_len--;
@@ -551,7 +623,16 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len)
      }
      continue;
    }
    memcpy((byte*) key, old, seg->length);
    char_length= seg->length / (seg->charset ? seg->charset->mbmaxlen : 1);
    if (seg->length > char_length)
    {
      char_length= my_charpos(seg->charset, old, old+seg->length, char_length);
      set_if_smaller(char_length, seg->length);
      if (char_length < seg->length)
        seg->charset->cset->fill(seg->charset, key + char_length, 
                                 seg->length - char_length, ' ');
    }
    memcpy(key, old, (size_t) char_length);
    key+= seg->length;
    k_len-= seg->length;
  }
+72 −0
Original line number Diff line number Diff line
@@ -325,3 +325,75 @@ insert into t1 values ('ꪪꪪ');
insert into t1 values ('ꪪꪪꪪ');
ERROR 23000: Duplicate entry 'ꪪꪪ' for key 1
drop table t1;
create table t1 (
c char(10) character set utf8,
unique key a using hash (c(1))
) engine=heap;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) character set utf8 default NULL,
  UNIQUE KEY `a` (`c`(1))
) ENGINE=HEAP DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 1
insert into t1 values ('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values ('б');
insert into t1 values ('бб');
ERROR 23000: Duplicate entry 'б' for key 1
insert into t1 values ('ббб');
ERROR 23000: Duplicate entry 'б' for key 1
select c as c_all from t1 order by c;
c_all
a
b
c
d
e
f
б
select c as c_a from t1 where c='a';
c_a
a
select c as c_a from t1 where c='б';
c_a
б
drop table t1;
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a using btree (c(1))
) engine=heap;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c` char(10) character set utf8 collate utf8_bin default NULL,
  UNIQUE KEY `a` TYPE BTREE (`c`(1))
) ENGINE=HEAP DEFAULT CHARSET=latin1
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
insert into t1 values ('aa');
ERROR 23000: Duplicate entry 'aa' for key 1
insert into t1 values ('aaa');
ERROR 23000: Duplicate entry 'aaa' for key 1
insert into t1 values ('б');
insert into t1 values ('бб');
ERROR 23000: Duplicate entry 'б' for key 1
insert into t1 values ('ббб');
ERROR 23000: Duplicate entry 'б' for key 1
select c as c_all from t1 order by c;
c_all
a
b
c
d
e
f
б
select c as c_a from t1 where c='a';
c_a
a
select c as c_a from t1 where c='б';
c_a
б
drop table t1;
+50 −1
Original line number Diff line number Diff line
@@ -21,6 +21,28 @@ insert into t1 values(7,8,3);
select * from t1 where b = 4 order by a;
a	b	c
3	4	6
insert into t1 values(8, 2, 3);
ERROR 23000: Can't write, because of unique constraint, to table 't1'
select * from t1 order by a;
a	b	c
1	2	3
2	3	5
3	4	6
4	5	8
5	6	2
6	7	2
7	8	3
delete from t1 where a = 1;
insert into t1 values(8, 2, 3);
select * from t1 order by a;
a	b	c
2	3	5
3	4	6
4	5	8
5	6	2
6	7	2
7	8	3
8	2	3
drop table t1;
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
@@ -42,6 +64,28 @@ insert into t2 values(7,8,3);
select * from t2 where b = 4 order by a;
a	b	c
3	4	6
insert into t2 values(8, 2, 3);
ERROR 23000: Can't write, because of unique constraint, to table 't2'
select * from t2 order by a;
a	b	c
1	2	3
2	3	5
3	4	6
4	5	8
5	6	2
6	7	2
7	8	3
delete from t2 where a = 1;
insert into t2 values(8, 2, 3);
select * from t2 order by a;
a	b	c
2	3	5
3	4	6
4	5	8
5	6	2
6	7	2
7	8	3
8	2	3
drop table t2;
CREATE TABLE t3 (
a int unsigned NOT NULL,
@@ -74,8 +118,10 @@ INSERT INTO t1 VALUES (8,'dummy');
CREATE TABLE t2 (
cid bigint(20) unsigned NOT NULL auto_increment,
cap varchar(255) NOT NULL default '',
PRIMARY KEY  (cid)
PRIMARY KEY  (cid),
UNIQUE KEY (cid, cap)
) engine=ndbcluster;
INSERT INTO t2 VALUES (NULL,'another dummy');
CREATE TABLE t3 (
gid bigint(20) unsigned NOT NULL auto_increment,
gn varchar(255) NOT NULL default '',
@@ -132,6 +178,9 @@ cid cv
8	dummy
select * from t1 where cv = 'test';
cid	cv
select * from t2 where cap = 'another dummy';
cid	cap
0	another dummy
select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4;
uid	gid	rid	cid
1	1	2	4
+47 −0
Original line number Diff line number Diff line
@@ -236,3 +236,50 @@ insert into t1 values ('ꪪꪪ');
insert into t1 values ('ꪪꪪꪪ');
drop table t1;

#
# Bug 4531: unique key prefix interacts poorly with utf8
# Check HEAP+HASH, case insensitive collation
#
create table t1 (
c char(10) character set utf8,
unique key a using hash (c(1))
) engine=heap;
show create table t1;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
insert into t1 values ('aa');
--error 1062
insert into t1 values ('aaa');
insert into t1 values ('б');
--error 1062
insert into t1 values ('бб');
--error 1062
insert into t1 values ('ббб');
select c as c_all from t1 order by c;
select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;

#
# Bug 4531: unique key prefix interacts poorly with utf8
# Check HEAP+BTREE, case insensitive collation
#
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a using btree (c(1))
) engine=heap;
show create table t1;
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error 1062
insert into t1 values ('aa');
--error 1062
insert into t1 values ('aaa');
insert into t1 values ('б');
--error 1062
insert into t1 values ('бб');
--error 1062
insert into t1 values ('ббб');
select c as c_all from t1 order by c;
select c as c_a from t1 where c='a';
select c as c_a from t1 where c='б';
drop table t1;
Loading