Commit 23313449 authored by unknown's avatar unknown
Browse files

ndb - wl-1442 new varchar


mysql-test/r/ndb_alter_table.result:
  wl-1442 new varchar
mysql-test/r/ndb_bitfield.result:
  wl-1442 new varchar
mysql-test/r/ndb_charset.result:
  wl-1442 new varchar
mysql-test/t/ndb_charset.test:
  wl-1442 new varchar
ndb/include/kernel/signaldata/DictTabInfo.hpp:
  wl-1442 new varchar
ndb/include/ndb_constants.h:
  wl-1442 new varchar
ndb/include/ndbapi/NdbDictionary.hpp:
  wl-1442 new varchar
ndb/include/util/NdbSqlUtil.hpp:
  wl-1442 new varchar
ndb/src/common/util/NdbSqlUtil.cpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbtc/Dbtc.hpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbtc/DbtcMain.cpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp:
  wl-1442 new varchar
ndb/src/kernel/blocks/dbtux/DbtuxScan.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbDictionary.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbOperationDefine.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbOperationSearch.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbRecAttr.cpp:
  wl-1442 new varchar
ndb/src/ndbapi/NdbTransaction.cpp:
  wl-1442 new varchar
ndb/test/ndbapi/testOIBasic.cpp:
  wl-1442 new varchar
sql/ha_ndbcluster.cc:
  wl-1442 new varchar
parent bec9de67
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int)  ENGINE=ndbcluster;
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	0	0	0	0	0	0	1	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	10	Dynamic	0	0	0	0	0	0	1	NULL	NULL	NULL	latin1_swedish_ci	NULL		
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
insert into t1 values
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	9	0	0	0	0	0	101	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	10	Dynamic	9	0	0	0	0	0	101	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col1	col2	col3	col4	col5	col6	to_be_deleted
0	4	3	5	PENDING	1	7
@@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	9	0	0	0	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	10	Dynamic	9	0	0	0	0	0	102	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col6	col1	col3	fourth	col4	col4_5	col5	col7	col8
1	0	3	4	5		PENDING		0000-00-00 00:00:00
@@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
show table status;
Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
t1	ndbcluster	9	Dynamic	10	0	0	0	0	0	103	NULL	NULL	NULL	latin1_swedish_ci	NULL		
t1	ndbcluster	10	Dynamic	10	0	0	0	0	0	103	NULL	NULL	NULL	latin1_swedish_ci	NULL		
select * from t1 order by col1;
col6	col1	col3	fourth	col4	col4_5	col5	col7	col8
1	0	3	4	5		PENDING		0000-00-00 00:00:00
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ create table t1 (
pk1 bit(9) not null primary key,
b int
) engine=ndbcluster;
ERROR HY000: Can't create table './test/t1.frm' (errno: 743)
ERROR HY000: Can't create table './test/t1.frm' (errno: 739)
create table t1 (
pk1 int not null primary key,
b bit(9),
+141 −1
Original line number Diff line number Diff line
@@ -47,6 +47,40 @@ a
aAa
drop table t1;
create table t1 (
a varchar(20) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
insert into t1 values ('A'),('b '),('C  '),('d      '),('E'),('f');
insert into t1 values('b');
ERROR 23000: Duplicate entry 'b' for key 1
insert into t1 values('a         ');
ERROR 23000: Duplicate entry 'a         ' for key 1
select a,length(a) from t1 order by a;
a	length(a)
A	1
b 	2
C  	3
d      	7
E	1
f	1
select a,length(a) from t1 order by a desc;
a	length(a)
f	1
E	1
d      	7
C  	3
b 	2
A	1
select * from t1 where a = 'a';
a
A
select * from t1 where a = 'a   ';
a
A
select * from t1 where a = 'd';
a
d      
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
unique key(a)
@@ -99,6 +133,42 @@ p a
drop table t1;
create table t1 (
p int primary key,
a varchar(20) character set latin1 collate latin1_swedish_ci not null,
unique key(a)
) engine=ndb;
insert into t1 values (1,'A'),(2,'b '),(3,'C  '),(4,'d      '),(5,'E'),(6,'f');
insert into t1 values(99,'b');
ERROR 23000: Duplicate entry '99' for key 1
insert into t1 values(99,'a         ');
ERROR 23000: Duplicate entry '99' for key 1
select a,length(a) from t1 order by a;
a	length(a)
A	1
b 	2
C  	3
d      	7
E	1
f	1
select a,length(a) from t1 order by a desc;
a	length(a)
f	1
E	1
d      	7
C  	3
b 	2
A	1
select * from t1 where a = 'a';
p	a
1	A
select * from t1 where a = 'a   ';
p	a
1	A
select * from t1 where a = 'd';
p	a
4	d      
drop table t1;
create table t1 (
p int primary key,
a char(3) character set latin1 collate latin1_bin not null,
index(a)
) engine=ndb;
@@ -190,7 +260,77 @@ p a
6	AAA
drop table t1;
create table t1 (
a varchar(10) primary key
p int primary key,
a varchar(20) character set latin1 collate latin1_swedish_ci not null,
index(a, p)
) engine=ndb;
insert into t1 values (1,'A'),(2,'b '),(3,'C  '),(4,'d      '),(5,'E'),(6,'f');
insert into t1 values (7,'a'),(8,'B '),(9,'c  '),(10,'D'),(11,'e'),(12,'F  ');
select p,a,length(a) from t1 order by a, p;
p	a	length(a)
1	A	1
7	a	1
2	b 	2
8	B 	2
3	C  	3
9	c  	3
4	d      	7
10	D	1
5	E	1
11	e	1
6	f	1
12	F  	3
select * from t1 where a = 'a  ' order by a desc, p desc;
p	a
7	a
1	A
select * from t1 where a >= 'D' order by a, p;
p	a
4	d      
10	D
5	E
11	e
6	f
12	F  
select * from t1 where a < 'D' order by a, p;
p	a
1	A
7	a
2	b 
8	B 
3	C  
9	c  
select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a;
count(*)
48
drop table t1;
create table t1 (
a char(5) character set ucs2,
b varchar(7) character set utf8,
primary key(a, b)
) engine=ndb;
insert into t1 values
('a','A '),('B   ','b'),('c','C    '),('D','d'),('e  ','E'),('F','f  '),
('A','b '),('b   ','C'),('C','d  '),('d','E'),('E  ','f'),
('a','C '),('B   ','d'),('c','E  '),('D','f');
insert into t1 values('d','f');
ERROR 23000: Duplicate entry '' for key 1
select a,b,length(a),length(b) from t1 order by a,b limit 3;
a	b	length(a)	length(b)
a	A 	2	2
A	b 	2	2
a	C 	2	2
select a,b,length(a),length(b) from t1 order by a desc, b desc limit 3;
a	b	length(a)	length(b)
F	f  	2	3
E	f	2	1
e	E	2	1
select a,b,length(a),length(b) from t1 where a='c' and b='c';
a	b	length(a)	length(b)
c	C    	2	5
drop table t1;
create table t1 (
a char(10) primary key
) engine=ndb;
insert into t1 values ('jonas % ');
replace into t1 values ('jonas % ');
+79 −1
Original line number Diff line number Diff line
@@ -53,6 +53,25 @@ select * from t1 where a = 'AaA';
select * from t1 where a = 'AAA';
drop table t1;

# pk - varchar

create table t1 (
  a varchar(20) character set latin1 collate latin1_swedish_ci primary key
) engine=ndb;
#
insert into t1 values ('A'),('b '),('C  '),('d      '),('E'),('f');
-- error 1062
insert into t1 values('b');
-- error 1062
insert into t1 values('a         ');
#
select a,length(a) from t1 order by a;
select a,length(a) from t1 order by a desc;
select * from t1 where a = 'a';
select * from t1 where a = 'a   ';
select * from t1 where a = 'd';
drop table t1;

# unique hash index - binary

create table t1 (
@@ -102,6 +121,27 @@ select * from t1 where a = 'AaA';
select * from t1 where a = 'AAA';
drop table t1;

# unique hash index - varchar

create table t1 (
  p int primary key,
  a varchar(20) character set latin1 collate latin1_swedish_ci not null,
  unique key(a)
) engine=ndb;
#
insert into t1 values (1,'A'),(2,'b '),(3,'C  '),(4,'d      '),(5,'E'),(6,'f');
-- error 1062
insert into t1 values(99,'b');
-- error 1062
insert into t1 values(99,'a         ');
#
select a,length(a) from t1 order by a;
select a,length(a) from t1 order by a desc;
select * from t1 where a = 'a';
select * from t1 where a = 'a   ';
select * from t1 where a = 'd';
drop table t1;

# ordered index - binary

create table t1 (
@@ -158,9 +198,47 @@ select * from t1 where a = 'AaA' order by p;
select * from t1 where a = 'AAA' order by p;
drop table t1;

# ordered index - varchar

create table t1 (
  p int primary key,
  a varchar(20) character set latin1 collate latin1_swedish_ci not null,
  index(a, p)
) engine=ndb;
#
insert into t1 values (1,'A'),(2,'b '),(3,'C  '),(4,'d      '),(5,'E'),(6,'f');
insert into t1 values (7,'a'),(8,'B '),(9,'c  '),(10,'D'),(11,'e'),(12,'F  ');
select p,a,length(a) from t1 order by a, p;
select * from t1 where a = 'a  ' order by a desc, p desc;
select * from t1 where a >= 'D' order by a, p;
select * from t1 where a < 'D' order by a, p;
#
select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a;
drop table t1;

# minimal multi-byte test

create table t1 (
  a char(5) character set ucs2,
  b varchar(7) character set utf8,
  primary key(a, b)
) engine=ndb;
#
insert into t1 values
  ('a','A '),('B   ','b'),('c','C    '),('D','d'),('e  ','E'),('F','f  '),
  ('A','b '),('b   ','C'),('C','d  '),('d','E'),('E  ','f'),
  ('a','C '),('B   ','d'),('c','E  '),('D','f');
-- error 1062
insert into t1 values('d','f');
#
select a,b,length(a),length(b) from t1 order by a,b limit 3;
select a,b,length(a),length(b) from t1 order by a desc, b desc limit 3;
select a,b,length(a),length(b) from t1 where a='c' and b='c';
drop table t1;

# bug 
create table t1 (
  a varchar(10) primary key
  a char(10) primary key
) engine=ndb;
insert into t1 values ('jonas % ');
replace into t1 values ('jonas % ');
+33 −38
Original line number Diff line number Diff line
@@ -269,7 +269,9 @@ public:
    ExtTimespec = NdbSqlUtil::Type::Timespec,
    ExtBlob = NdbSqlUtil::Type::Blob,
    ExtText = NdbSqlUtil::Type::Text,
    ExtBit = NdbSqlUtil::Type::Bit
    ExtBit = NdbSqlUtil::Type::Bit,
    ExtLongvarchar = NdbSqlUtil::Type::Longvarchar,
    ExtLongvarbinary = NdbSqlUtil::Type::Longvarbinary
  };

  // Attribute data interpretation
@@ -297,98 +299,91 @@ public:
      return ((1 << AttributeSize) * AttributeArraySize + 31) >> 5;
    }

    // translate to old kernel types and sizes
    // compute old-sty|e attribute size and array size
    inline bool
    translateExtType() {
      AttributeType = ~0; // deprecated
      switch (AttributeExtType) {
      case DictTabInfo::ExtUndefined:
        break;
        return false;
      case DictTabInfo::ExtTinyint:
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = AttributeExtLength;
	return true;
      case DictTabInfo::ExtTinyunsigned:
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = AttributeExtLength;
	return true;
	break;
      case DictTabInfo::ExtSmallint:
        AttributeSize = DictTabInfo::a16Bit;
        AttributeArraySize = AttributeExtLength;
	return true;
      case DictTabInfo::ExtSmallunsigned:
        AttributeSize = DictTabInfo::a16Bit;
        AttributeArraySize = AttributeExtLength;
	return true;
	break;
      case DictTabInfo::ExtMediumint:
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = 3 * AttributeExtLength;
	return true;
      case DictTabInfo::ExtMediumunsigned:
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = 3 * AttributeExtLength;
	return true;
	break;
      case DictTabInfo::ExtInt:	
        AttributeSize = DictTabInfo::a32Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
      case DictTabInfo::ExtUnsigned:
        AttributeSize = DictTabInfo::a32Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtBigint:
        AttributeSize = DictTabInfo::a64Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
      case DictTabInfo::ExtBigunsigned:
        AttributeSize = DictTabInfo::a64Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtFloat:
        AttributeSize = DictTabInfo::a32Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtDouble:
        AttributeSize = DictTabInfo::a64Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtDecimal:
        // not yet implemented anywhere
        break;
        return false;
      case DictTabInfo::ExtChar:
      case DictTabInfo::ExtBinary:
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtVarchar:
      case DictTabInfo::ExtVarbinary:
        // to fix
        if (AttributeExtLength > 0xff)
          return false;
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = AttributeExtLength + 2;
        return true;
        AttributeArraySize = AttributeExtLength + 1;
        break;
      case DictTabInfo::ExtDatetime:
        // to fix
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = 8 * AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtTimespec:
        // to fix
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = 12 * AttributeExtLength;
        return true;
        break;
      case DictTabInfo::ExtBlob:
      case DictTabInfo::ExtText:
        AttributeSize = DictTabInfo::an8Bit;
        // head + inline part [ attr precision lower half ]
        // head + inline part (length in precision lower half)
        AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF);
        return true;
        break;
      case DictTabInfo::ExtBit:
	AttributeSize = DictTabInfo::aBit;
	AttributeArraySize = AttributeExtLength;
	return true;
      };
      
	break;
      case DictTabInfo::ExtLongvarchar:
      case DictTabInfo::ExtLongvarbinary:
        if (AttributeExtLength > 0xffff)
          return false;
        AttributeSize = DictTabInfo::an8Bit;
        AttributeArraySize = AttributeExtLength + 2;
        break;
      default:
        return false;
      };
      return true;
    }
    
    inline void print(FILE *out) {
Loading