summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <Sinisa@sinisa.nasamreza.org>2004-01-20 17:49:10 +0200
committerunknown <Sinisa@sinisa.nasamreza.org>2004-01-20 17:49:10 +0200
commit862b0622758c7ddca64cbfbfd74c468d960ed921 (patch)
treed51b1b9abd48f73c199cfa141cb625e499c2162f
parent3991a1d0d1e7cb3a8afca85a7c83fc07be419e94 (diff)
parent4e6744a45fd95a5ca86b183277fe0684b0c9d795 (diff)
downloadmariadb-git-862b0622758c7ddca64cbfbfd74c468d960ed921.tar.gz
Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.1
into sinisa.nasamreza.org:/mnt/work/mysql-4.1
-rw-r--r--include/m_ctype.h3
-rw-r--r--innobase/row/row0sel.c2
-rw-r--r--mysql-test/r/ctype_ucs.result48
-rw-r--r--mysql-test/r/ctype_utf8.result11
-rw-r--r--mysql-test/r/func_misc.result11
-rw-r--r--mysql-test/r/func_str.result3
-rw-r--r--mysql-test/r/subselect.result9
-rw-r--r--mysql-test/t/ctype_ucs.test21
-rw-r--r--mysql-test/t/ctype_utf8.test12
-rw-r--r--mysql-test/t/func_misc.test4
-rw-r--r--mysql-test/t/func_str.test6
-rw-r--r--mysql-test/t/subselect.test12
-rw-r--r--mysys/charset.c4
-rw-r--r--sql/field.cc6
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item.h20
-rw-r--r--sql/item_func.cc9
-rw-r--r--sql/item_strfunc.cc5
-rw-r--r--sql/item_subselect.cc15
-rw-r--r--sql/sql_class.h13
-rw-r--r--sql/sql_string.cc46
-rw-r--r--sql/sql_string.h1
-rw-r--r--strings/ctype-big5.c2
-rw-r--r--strings/ctype-bin.c1
-rw-r--r--strings/ctype-czech.c1
-rw-r--r--strings/ctype-euc_kr.c2
-rw-r--r--strings/ctype-extra.c1
-rw-r--r--strings/ctype-gb2312.c2
-rw-r--r--strings/ctype-gbk.c2
-rw-r--r--strings/ctype-latin1.c3
-rw-r--r--strings/ctype-sjis.c2
-rw-r--r--strings/ctype-tis620.c2
-rw-r--r--strings/ctype-ucs2.c2
-rw-r--r--strings/ctype-ujis.c2
-rw-r--r--strings/ctype-utf8.c2
-rw-r--r--strings/ctype-win1250ch.c1
36 files changed, 257 insertions, 32 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 0228b359111..4a9415f43f9 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -206,8 +206,9 @@ typedef struct charset_info_st
uchar state_map[256];
uchar ident_map[256];
uint strxfrm_multiply;
+ uint mbminlen;
uint mbmaxlen;
- char max_sort_char; /* For LIKE optimization */
+ char max_sort_char; /* For LIKE optimization */
MY_CHARSET_HANDLER *cset;
MY_COLLATION_HANDLER *coll;
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index 5a5da3ba59a..57de309c090 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -2903,8 +2903,6 @@ row_search_for_mysql(
mtr_start(&mtr);
- mtr_start(&mtr);
-
/*-------------------------------------------------------------*/
/* PHASE 2: Try fast adaptive hash index search if possible */
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 58761526150..d6e9cc690a2 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -276,3 +276,51 @@ aardvara
aardvark
aardvarz
DROP TABLE t1;
+SELECT HEX(_ucs2 0x0);
+HEX(_ucs2 0x0)
+0000
+SELECT HEX(_ucs2 0x01);
+HEX(_ucs2 0x01)
+0001
+SELECT HEX(_ucs2 0x012);
+HEX(_ucs2 0x012)
+0012
+SELECT HEX(_ucs2 0x0123);
+HEX(_ucs2 0x0123)
+0123
+SELECT HEX(_ucs2 0x01234);
+HEX(_ucs2 0x01234)
+00001234
+SELECT HEX(_ucs2 0x012345);
+HEX(_ucs2 0x012345)
+00012345
+SELECT HEX(_ucs2 0x0123456);
+HEX(_ucs2 0x0123456)
+00123456
+SELECT HEX(_ucs2 0x01234567);
+HEX(_ucs2 0x01234567)
+01234567
+SELECT HEX(_ucs2 0x012345678);
+HEX(_ucs2 0x012345678)
+000012345678
+SELECT HEX(_ucs2 0x0123456789);
+HEX(_ucs2 0x0123456789)
+000123456789
+SELECT HEX(_ucs2 0x0123456789A);
+HEX(_ucs2 0x0123456789A)
+00123456789A
+SELECT HEX(_ucs2 0x0123456789AB);
+HEX(_ucs2 0x0123456789AB)
+0123456789AB
+SELECT HEX(_ucs2 0x0123456789ABC);
+HEX(_ucs2 0x0123456789ABC)
+0000123456789ABC
+SELECT HEX(_ucs2 0x0123456789ABCD);
+HEX(_ucs2 0x0123456789ABCD)
+000123456789ABCD
+SELECT HEX(_ucs2 0x0123456789ABCDE);
+HEX(_ucs2 0x0123456789ABCDE)
+00123456789ABCDE
+SELECT HEX(_ucs2 0x0123456789ABCDEF);
+HEX(_ucs2 0x0123456789ABCDEF)
+0123456789ABCDEF
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 16c65619878..7c05b1ea446 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -1,3 +1,4 @@
+drop table if exists t1;
set names utf8;
select left(_utf8 0xD0B0D0B1D0B2,1);
left(_utf8 0xD0B0D0B1D0B2,1)
@@ -68,3 +69,13 @@ this is a test
select insert("aa",100,1,"b"),insert("aa",1,3,"b");
insert("aa",100,1,"b") insert("aa",1,3,"b")
aa b
+create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` char(4) character set utf8 default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+date_format("2004-01-19 10:10:10", "%Y-%m-%d")
+2004-01-19
+drop table t1;
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index d51bea020ed..ec5f76409e7 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -6,10 +6,19 @@ inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
NULL
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
-1099511627775 4294902271 511
+1099511627775 4294902271 65791
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
NULL 255.255.1.255 0.0.1.255
+select hex(inet_aton('127'));
+hex(inet_aton('127'))
+7F
+select hex(inet_aton('127.1'));
+hex(inet_aton('127.1'))
+7F000001
+select hex(inet_aton('127.1.1'));
+hex(inet_aton('127.1.1'))
+7F010001
select length(format('nan', 2)) > 0;
length(format('nan', 2)) > 0
1
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index c74feccfb7f..f08ae1b1efd 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -605,3 +605,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")`
+SELECT lpad(12345, 5, "#");
+lpad(12345, 5, "#")
+12345
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 672a39299dd..ded98265a1c 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1569,3 +1569,12 @@ INSERT INTO t2 VALUES (100, 200, 'C');
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
COLC
DROP TABLE t1, t2;
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1;
+delete from t1;
+load data infile "subselect.out.file.1" into table t1;
+select * from t1;
+a b
+1 0.123
+drop table t1;
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 7eec58563b3..fd2a1b1cd7d 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -197,3 +197,24 @@ DROP TABLE t1;
# END OF Bug 1264 test
#
########################################################
+
+
+# Bug #2390
+# Check alignment
+#
+SELECT HEX(_ucs2 0x0);
+SELECT HEX(_ucs2 0x01);
+SELECT HEX(_ucs2 0x012);
+SELECT HEX(_ucs2 0x0123);
+SELECT HEX(_ucs2 0x01234);
+SELECT HEX(_ucs2 0x012345);
+SELECT HEX(_ucs2 0x0123456);
+SELECT HEX(_ucs2 0x01234567);
+SELECT HEX(_ucs2 0x012345678);
+SELECT HEX(_ucs2 0x0123456789);
+SELECT HEX(_ucs2 0x0123456789A);
+SELECT HEX(_ucs2 0x0123456789AB);
+SELECT HEX(_ucs2 0x0123456789ABC);
+SELECT HEX(_ucs2 0x0123456789ABCD);
+SELECT HEX(_ucs2 0x0123456789ABCDE);
+SELECT HEX(_ucs2 0x0123456789ABCDEF);
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 5c924e82729..5e9324dd68f 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -2,6 +2,9 @@
# Tests with the utf8 character set
#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
set names utf8;
select left(_utf8 0xD0B0D0B1D0B2,1);
@@ -41,3 +44,12 @@ select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
#
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+
+#
+# CREATE ... SELECT
+#
+create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
+show create table t1;
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index d15c26279ec..9759127b222 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -8,6 +8,10 @@ select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
+select hex(inet_aton('127'));
+select hex(inet_aton('127.1'));
+select hex(inet_aton('127.1.1'));
+
#
# Test for core dump with nan
#
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index ad7b9b21b51..155ed459d1f 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -346,3 +346,9 @@ DROP TABLE t1;
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty");
+
+#
+# Bug #2182
+#
+
+SELECT lpad(12345, 5, "#");
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 95e4f022f2d..37dbc8f24d9 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1009,3 +1009,15 @@ INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
INSERT INTO t2 VALUES (100, 200, 'C');
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
DROP TABLE t1, t2;
+
+#
+# Bug 2198
+#
+
+create table t1 (a int, b decimal(13, 3));
+insert into t1 values (1, 0.123);
+select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1;
+delete from t1;
+load data infile "subselect.out.file.1" into table t1;
+select * from t1;
+drop table t1;
diff --git a/mysys/charset.c b/mysys/charset.c
index 5e9e3c3fcaa..40a026f161f 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -131,7 +131,8 @@ static void simple_cs_init_functions(CHARSET_INFO *cs)
cs->coll= &my_collation_8bit_simple_ci_handler;
cs->cset= &my_charset_8bit_handler;
- cs->mbmaxlen = 1;
+ cs->mbminlen= 1;
+ cs->mbmaxlen= 1;
}
@@ -273,6 +274,7 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from)
if (create_fromuni(to))
goto err;
}
+ to->mbminlen= 1;
to->mbmaxlen= 1;
return 0;
diff --git a/sql/field.cc b/sql/field.cc
index 5602231dd9b..1a0716326fe 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5611,16 +5611,16 @@ create_field::create_field(Field *old_field,Field *orig_field)
case 3: sql_type= FIELD_TYPE_MEDIUM_BLOB; break;
default: sql_type= FIELD_TYPE_LONG_BLOB; break;
}
- length /= charset->mbmaxlen; // QQ: Probably not needed
+ length=(length+charset->mbmaxlen-1)/charset->mbmaxlen; // QQ: Probably not needed
break;
case FIELD_TYPE_STRING:
case FIELD_TYPE_VAR_STRING:
- length /= charset->mbmaxlen;
+ length=(length+charset->mbmaxlen-1)/charset->mbmaxlen;
break;
default:
break;
}
-
+
decimals= old_field->decimals();
if (sql_type == FIELD_TYPE_STRING)
{
diff --git a/sql/item.cc b/sql/item.cc
index 417f05680cf..37240700c68 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1867,7 +1867,6 @@ void Item_cache_int::store(Item *item)
{
value= item->val_int_result();
null_value= item->null_value;
- collation.set(item->collation);
}
@@ -1875,7 +1874,6 @@ void Item_cache_real::store(Item *item)
{
value= item->val_result();
null_value= item->null_value;
- collation.set(item->collation);
}
@@ -1898,7 +1896,6 @@ void Item_cache_str::store(Item *item)
value_buff.copy(*value);
value= &value_buff;
}
- collation.set(item->collation);
}
diff --git a/sql/item.h b/sql/item.h
index 5def1e2b710..e7ccdb7ea12 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -477,7 +477,7 @@ public:
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
collation.set(cs, dv);
- str_value.set(str,length,cs);
+ str_value.set_or_copy_aligned(str,length,cs);
/*
We have to have a different max_length than 'length' here to
ensure that we get the right length if we do use the item
@@ -493,7 +493,7 @@ public:
CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
{
collation.set(cs, dv);
- str_value.set(str,length,cs);
+ str_value.set_or_copy_aligned(str,length,cs);
max_length= str_value.numchars()*cs->mbmaxlen;
set_name(name_par,0,cs);
decimals=NOT_FIXED_DEC;
@@ -878,13 +878,15 @@ public:
void set_used_tables(table_map map) { used_table_map= map; }
virtual bool allocate(uint i) { return 0; };
- virtual bool setup(Item *item) { example= item; return 0; };
- virtual void store(Item *)= 0;
- void set_len_n_dec(uint32 max_len, uint8 dec)
+ virtual bool setup(Item *item)
{
- max_length= max_len;
- decimals= dec;
- }
+ example= item;
+ max_length= item->max_length;
+ decimals= item->decimals;
+ collation.set(item->collation);
+ return 0;
+ };
+ virtual void store(Item *)= 0;
enum Type type() const { return CACHE_ITEM; }
static Item_cache* get_cache(Item_result type);
table_map used_tables() const { return used_table_map; }
@@ -909,7 +911,7 @@ class Item_cache_real: public Item_cache
double value;
public:
Item_cache_real(): Item_cache() {}
-
+
void store(Item *item);
double val() { return value; }
longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 5af64ca0be4..802b6dbb8d6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2618,6 +2618,7 @@ longlong Item_func_inet_aton::val_int()
const char *p,* end;
char c = '.'; // we mark c to indicate invalid IP in case length is 0
char buff[36];
+ int dot_count= 0;
String *s,tmp(buff,sizeof(buff),&my_charset_bin);
if (!(s = args[0]->val_str(&tmp))) // If null value
@@ -2636,6 +2637,7 @@ longlong Item_func_inet_aton::val_int()
}
else if (c == '.')
{
+ dot_count++;
result= (result << 8) + (ulonglong) byte_result;
byte_result = 0;
}
@@ -2643,7 +2645,14 @@ longlong Item_func_inet_aton::val_int()
goto err; // Invalid character
}
if (c != '.') // IP number can't end on '.'
+ {
+ switch (dot_count)
+ {
+ case 1: result<<= 8;
+ case 2: result<<= 8;
+ }
return (result << 8) + (ulonglong) byte_result;
+ }
err:
null_value=1;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 3b67fd371a4..4507b2598a3 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2023,9 +2023,8 @@ String *Item_func_lpad::val_str(String *str)
{
uint32 res_char_length,pad_char_length;
ulong count= (long) args[1]->val_int(), byte_count;
- String a1,a3;
- String *res= args[0]->val_str(&a1);
- String *pad= args[2]->val_str(&a3);
+ String *res= args[0]->val_str(&tmp_value);
+ String *pad= args[2]->val_str(&lpad_str);
if (!res || args[1]->null_value || !pad)
goto err;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 0380cd2c6cc..ee034e4c559 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -301,8 +301,6 @@ void Item_singlerow_subselect::fix_length_and_dec()
if ((max_columns= engine->cols()) == 1)
{
engine->fix_length_and_dec(row= &value);
- if (!(value= Item_cache::get_cache(engine->type())))
- return;
}
else
{
@@ -956,13 +954,9 @@ static Item_result set_row(List<Item> &item_list, Item *item,
res_type= sel_item->result_type();
item->decimals= sel_item->decimals;
*maybe_null= sel_item->maybe_null;
- if (row)
- {
- if (!(row[i]= Item_cache::get_cache(res_type)))
- return STRING_RESULT; // we should return something
- row[i]->set_len_n_dec(sel_item->max_length, sel_item->decimals);
- row[i]->collation.set(sel_item->collation);
- }
+ if (!(row[i]= Item_cache::get_cache(res_type)))
+ return STRING_RESULT; // we should return something
+ row[i]->setup(sel_item);
}
if (item_list.elements > 1)
res_type= ROW_RESULT;
@@ -983,7 +977,10 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
DBUG_ASSERT(row || unit->first_select()->item_list.elements==1);
if (unit->first_select()->item_list.elements == 1)
+ {
res_type= set_row(unit->types, item, row, &maybe_null);
+ item->collation.set(row[0]->collation);
+ }
else
{
bool fake= 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5390e8a4ac4..7971137d848 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -624,6 +624,19 @@ public:
and are still in use by this thread
*/
TABLE *open_tables,*temporary_tables, *handler_tables, *derived_tables;
+ /*
+ During a MySQL session, one can lock tables in two modes: automatic
+ or manual. In automatic mode all necessary tables are locked just before
+ statement execution, and all acquired locks are stored in 'lock'
+ member. Unlocking takes place automatically as well, when the
+ statement ends.
+ Manual mode comes into play when a user issues a 'LOCK TABLES'
+ statement. In this mode the user can only use the locked tables.
+ Trying to use any other tables will give an error. The locked tables are
+ stored in 'locked_tables' member. Manual locking is described in
+ the 'LOCK_TABLES' chapter of the MySQL manual.
+ See also lock_tables() for details.
+ */
MYSQL_LOCK *lock; /* Current locks */
MYSQL_LOCK *locked_tables; /* Tables locked with LOCK */
/*
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 89f48607969..9534c5605fe 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -228,6 +228,52 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
return FALSE;
}
+/*
+** For real multi-byte, ascii incompatible charactser sets,
+** like UCS-2, add leading zeros if we have an incomplete character.
+** Thus,
+** SELECT _ucs2 0xAA
+** will automatically be converted into
+** SELECT _ucs2 0x00AA
+*/
+
+bool String::set_or_copy_aligned(const char *str,uint32 arg_length,
+ CHARSET_INFO *cs)
+{
+ /* How many bytes are in incomplete character */
+ uint32 offs= (arg_length % cs->mbminlen);
+
+ if (!offs) /* All characters are complete, just copy */
+ {
+ set(str, arg_length, cs);
+ return FALSE;
+ }
+
+ offs= cs->mbmaxlen - offs; /* How many zeros we should prepend */
+ uint32 aligned_length= arg_length + offs;
+ if (alloc(aligned_length))
+ return TRUE;
+
+ /*
+ Probably this condition is not really necessary
+ because if aligned_length is 0 then offs is 0 too
+ and we'll return after calling set().
+ */
+ if ((str_length= aligned_length))
+ {
+ /*
+ Note, this is only safe for little-endian UCS-2.
+ If we add big-endian UCS-2 sometimes, this code
+ will be more complicated. But it's OK for now.
+ */
+ bzero((char*)Ptr, offs);
+ memcpy(Ptr + offs, str, arg_length);
+ }
+ Ptr[aligned_length]=0;
+ str_charset=cs;
+ return FALSE;
+}
+
/* Copy with charset convertion */
bool String::copy(const char *str, uint32 arg_length,
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 325611737ca..8817aa8eab8 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -183,6 +183,7 @@ public:
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
+ bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs);
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
CHARSET_INFO *csto);
bool append(const String &s);
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index c5ddc167d0d..8d4081fb2aa 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6281,6 +6281,7 @@ CHARSET_INFO my_charset_big5_chinese_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_big5_handler,
@@ -6304,6 +6305,7 @@ CHARSET_INFO my_charset_big5_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_big5_handler,
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index 6f28c43b2c6..67435b7df6c 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -381,6 +381,7 @@ CHARSET_INFO my_charset_bin =
NULL, /* tab_from_uni */
"","",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
(char) 255, /* max_sort_char */
&my_charset_handler,
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index b2e4f1886ed..1a07a5eba7e 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -631,6 +631,7 @@ CHARSET_INFO my_charset_latin2_czech_ci =
idx_uni_8859_2, /* tab_from_uni */
"","",
4, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_8bit_handler,
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index addd7803680..366a5d500ed 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -8689,6 +8689,7 @@ CHARSET_INFO my_charset_euckr_korean_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
@@ -8712,6 +8713,7 @@ CHARSET_INFO my_charset_euckr_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index 55bfa09ea5f..0085d264416 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -34,6 +34,7 @@ CHARSET_INFO compiled_charsets[] = {
0,
0,
0,
+ 0,
NULL,
NULL
}
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index b84ddc9081b..44a58b2b906 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -5740,6 +5740,7 @@ CHARSET_INFO my_charset_gb2312_chinese_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
@@ -5762,6 +5763,7 @@ CHARSET_INFO my_charset_gb2312_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 585dc66be4c..5475c3bd363 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -9936,6 +9936,7 @@ CHARSET_INFO my_charset_gbk_chinese_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
@@ -9958,6 +9959,7 @@ CHARSET_INFO my_charset_gbk_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index 15798abb85b..c00ded21575 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -215,6 +215,7 @@ CHARSET_INFO my_charset_latin1=
NULL, /* tab_from_uni */
"","",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_handler,
@@ -410,6 +411,7 @@ CHARSET_INFO my_charset_latin1_german2_ci=
NULL, /* tab_from_uni */
"","",
2, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_handler,
@@ -433,6 +435,7 @@ CHARSET_INFO my_charset_latin1_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index a84fbd16e5d..42f32fe739b 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4525,6 +4525,7 @@ CHARSET_INFO my_charset_sjis_japanese_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
@@ -4547,6 +4548,7 @@ CHARSET_INFO my_charset_sjis_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 92b2eeb25e0..09552a0dc23 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -956,6 +956,7 @@ CHARSET_INFO my_charset_tis620_thai_ci=
"",
"",
4, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_handler,
@@ -978,6 +979,7 @@ CHARSET_INFO my_charset_tis620_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index beb803a69f2..a7a59fc50f7 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1322,6 +1322,7 @@ CHARSET_INFO my_charset_ucs2_general_ci=
"",
"",
1, /* strxfrm_multiply */
+ 2, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_ucs2_handler,
@@ -1345,6 +1346,7 @@ CHARSET_INFO my_charset_ucs2_bin=
"",
"",
1, /* strxfrm_multiply */
+ 2, /* mbminlen */
2, /* mbmaxlen */
0,
&my_charset_ucs2_handler,
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index 2815b70351b..f6928e9426e 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -8480,6 +8480,7 @@ CHARSET_INFO my_charset_ujis_japanese_ci=
NULL, /* tab_from_uni */
"","",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
3, /* mbmaxlen */
0,
&my_charset_handler,
@@ -8502,6 +8503,7 @@ CHARSET_INFO my_charset_ujis_bin=
NULL, /* tab_from_uni */
"","",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
3, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index b5716c53ea2..8004fba75b7 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2006,6 +2006,7 @@ CHARSET_INFO my_charset_utf8_general_ci=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
3, /* mbmaxlen */
0,
&my_charset_handler,
@@ -2029,6 +2030,7 @@ CHARSET_INFO my_charset_utf8_bin=
"",
"",
1, /* strxfrm_multiply */
+ 1, /* mbminlen */
3, /* mbmaxlen */
0,
&my_charset_handler,
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index 60a5737009f..d3b5c9d1796 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -671,6 +671,7 @@ CHARSET_INFO my_charset_cp1250_czech_ci =
idx_uni_cp1250, /* tab_from_uni */
"","",
2, /* strxfrm_multiply */
+ 1, /* mbminlen */
1, /* mbmaxlen */
0,
&my_charset_8bit_handler,