diff options
author | unknown <monty@mysql.com> | 2004-02-17 01:35:17 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-02-17 01:35:17 +0200 |
commit | f9976eb1cd69b66bd1ac16a90f96fb222207c8c8 (patch) | |
tree | 7e3324032ecc97c6af3771a6904e8ae32dbf7a48 | |
parent | cad7f2a155c26fe2477a104284a4db59470ae694 (diff) | |
download | mariadb-git-f9976eb1cd69b66bd1ac16a90f96fb222207c8c8.tar.gz |
Changed wellformedlen to well_formed_len
Fixed that blobs >16M can be inserted/updated
Fixed bug when doing CREATE TEMPORARY TABLE ... LIKE
include/m_ctype.h:
Changed wellformedlen to well_formed_len
include/mysql.h:
Fixed comment
libmysql/libmysql.c:
Fixed indentation
libmysqld/lib_sql.cc:
Fixed indentation
mysql-test/r/ctype_utf8.result:
updated warning numbers
mysql-test/r/innodb.result:
Moved test to right place
mysql-test/r/myisam-blob.result:
More test for blobs
mysql-test/r/rpl000002.result:
Move test to better place
mysql-test/r/rpl_log.result:
Move test to better place
mysql-test/r/union.result:
Move test to better place
mysql-test/t/innodb.test:
Moved test to right place
mysql-test/t/myisam-blob.test:
More test of blobs
mysql-test/t/rpl000002.test:
Move test to better place
mysql-test/t/rpl_log.test:
Move test to better place
mysql-test/t/union.test:
Move test to better place
sql/field.cc:
Changed wellformedlen to well_formed_len.
Fixed that blobs >16M can be inserted/updated (new bug)
sql/field.h:
Code optimization
sql/sql_lex.cc:
Changed short variable names
sql/sql_show.cc:
Optimized quote handling
sql/sql_table.cc:
Fixed bug when doing CREATE TEMPORARY TABLE ... LIKE
sql/sql_union.cc:
Added comment
strings/ctype-big5.c:
Changed wellformedlen to well_formed_len
strings/ctype-bin.c:
Changed wellformedlen to well_formed_len
strings/ctype-euc_kr.c:
Changed wellformedlen to well_formed_len
strings/ctype-gb2312.c:
Changed wellformedlen to well_formed_len
strings/ctype-gbk.c:
Changed wellformedlen to well_formed_len
strings/ctype-latin1.c:
Changed wellformedlen to well_formed_len
strings/ctype-mb.c:
Changed wellformedlen to well_formed_len
strings/ctype-simple.c:
Changed wellformedlen to well_formed_len
strings/ctype-sjis.c:
Changed wellformedlen to well_formed_len
strings/ctype-tis620.c:
Changed wellformedlen to well_formed_len
strings/ctype-ucs2.c:
Changed wellformedlen to well_formed_len
Indentation changes
strings/ctype-ujis.c:
Changed wellformedlen to well_formed_len
strings/ctype-utf8.c:
Changed wellformedlen to well_formed_len
34 files changed, 266 insertions, 211 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h index 5870458af56..a97d25862bd 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -144,7 +144,7 @@ typedef struct my_charset_handler_st int (*mbcharlen)(struct charset_info_st *, uint); uint (*numchars)(struct charset_info_st *, const char *b, const char *e); uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); - uint (*wellformedlen)(struct charset_info_st *, + uint (*well_formed_len)(struct charset_info_st *, const char *b,const char *e, uint nchars); uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); @@ -313,7 +313,7 @@ int my_wildcmp_8bit(CHARSET_INFO *, uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_wellformedlen_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); int my_mbcharlen_8bit(CHARSET_INFO *, uint c); @@ -330,7 +330,7 @@ int my_wildcmp_mb(CHARSET_INFO *, int escape, int w_one, int w_many); uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_wellformedlen_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); uint my_instr_mb(struct charset_info_st *, const char *b, uint b_length, const char *s, uint s_length, diff --git a/include/mysql.h b/include/mysql.h index 35d9aa62040..5b3037d9261 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -534,8 +534,8 @@ typedef struct st_mysql_stmt char *query; /* query buffer */ MEM_ROOT mem_root; /* root allocations */ my_ulonglong last_fetched_column; /* last fetched column */ - my_ulonglong affected_rows; /* copy of mysql->affected_rows - after statement execution */ + /* copy of mysql->affected_rows after statement execution */ + my_ulonglong affected_rows; unsigned long stmt_id; /* Id for prepared statement */ unsigned int last_errno; /* error code */ unsigned int param_count; /* parameters count */ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 0eea5ee7007..8da695c5a9d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2997,7 +2997,7 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt) DBUG_RETURN(1); } - if((*mysql->methods->unbuffered_fetch)(mysql, ( char **)&row)) + if ((*mysql->methods->unbuffered_fetch)(mysql, (char**) &row)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index ee6451f4a17..f44b14b0030 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -189,8 +189,9 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) thd->data= 0; } if (emb_advanced_command(stmt->mysql, COM_EXECUTE,0,0, - (const char*)&stmt->stmt_id,sizeof(stmt->stmt_id),1) - || emb_mysql_read_query_result(stmt->mysql)) + (const char*)&stmt->stmt_id,sizeof(stmt->stmt_id), + 1) || + emb_mysql_read_query_result(stmt->mysql)) { NET *net= &stmt->mysql->net; set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); @@ -251,8 +252,8 @@ int emb_next_result(MYSQL *mysql) DBUG_ENTER("emb_next_result"); if (emb_advanced_command(mysql, COM_QUERY,0,0, - thd->query_rest.ptr(),thd->query_rest.length(),1) - || emb_mysql_read_query_result(mysql)) + thd->query_rest.ptr(),thd->query_rest.length(),1) || + emb_mysql_read_query_result(mysql)) DBUG_RETURN(1); DBUG_RETURN(0); /* No more results */ diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index c2c2f548de7..b7498ab2bc7 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -91,19 +91,19 @@ drop table t1; create table t1 (s1 tinytext character set utf8); insert into t1 select repeat('a',300); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('Ñ',300); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('aÑ',300); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('Ña',300); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('ÑÑ',300); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select hex(s1) from t1; hex(s1) 616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 @@ -122,19 +122,19 @@ drop table t1; create table t1 (s1 text character set utf8); insert into t1 select repeat('a',66000); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('Ñ',66000); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('aÑ',66000); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('Ña',66000); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 insert into t1 select repeat('ÑÑ',66000); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select length(s1),char_length(s1) from t1; length(s1) char_length(s1) 65535 65535 @@ -146,7 +146,7 @@ drop table t1; create table t1 (s1 char(10) character set utf8); insert into t1 values (0x41FF); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select hex(s1) from t1; hex(s1) 41 @@ -154,7 +154,7 @@ drop table t1; create table t1 (s1 varchar(10) character set utf8); insert into t1 values (0x41FF); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select hex(s1) from t1; hex(s1) 41 @@ -162,7 +162,7 @@ drop table t1; create table t1 (s1 text character set utf8); insert into t1 values (0x41FF); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select hex(s1) from t1; hex(s1) 41 diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 95dc2ca3a2a..57ad5ef79a2 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1413,3 +1413,17 @@ test.t2 968604391 test.t3 968604391 test.t4 NULL drop table t1,t2,t3; +create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; +insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); +select name2 from t1 union all select name from t1 union all select id from t1; +name2 +fff +sss +ttt +first +second +third +1 +2 +3 +drop table t1; diff --git a/mysql-test/r/myisam-blob.result b/mysql-test/r/myisam-blob.result index 743d4dac254..43db7c8badd 100644 --- a/mysql-test/r/myisam-blob.result +++ b/mysql-test/r/myisam-blob.result @@ -24,4 +24,21 @@ delete from t1 where left(data,1)='c'; check table t1; Table Op Msg_type Msg_text test.t1 check status OK +INSERT INTO t1 set data=repeat('a',18*1024*1024); +select length(data) from t1; +length(data) +18874368 +alter table t1 modify data blob; +select length(data) from t1; +length(data) +0 +drop table t1; +CREATE TABLE t1 (data BLOB) ENGINE=myisam; +INSERT INTO t1 (data) VALUES (NULL); +UPDATE t1 set data=repeat('a',18*1024*1024); +Warnings: +Warning 1265 Data truncated for column 'data' at row 1 +select length(data) from t1; +length(data) +65535 drop table t1; diff --git a/mysql-test/r/rpl000002.result b/mysql-test/r/rpl000002.result index 56e34b4874f..e5e661795fe 100644 --- a/mysql-test/r/rpl000002.result +++ b/mysql-test/r/rpl000002.result @@ -23,8 +23,24 @@ insert into t2 set created=now(); select * from t2; id created 1 1970-01-01 06:25:45 +create table t3 like t2; +create temporary table t4 like t2; +create table t5 select * from t4; start slave; select * from t2; id created 1 1970-01-01 06:25:45 -drop table t2; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL auto_increment, + `created` datetime default NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `id` int(11) NOT NULL default '0', + `created` datetime default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2,t3,t5; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 34d41c5dfac..2f8a54369c9 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -16,7 +16,6 @@ load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; select count(*) from t1; count(*) 69 -create table t2 like t1; drop table t1; show binlog events; Log_name Pos Event_type Server_id Orig_log_pos Info @@ -28,8 +27,7 @@ master-bin.000001 263 Query 1 263 use `test`; drop table t1 master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 master-bin.000001 1056 Exec_load 1 1056 ;file_id=1 -master-bin.000001 1079 Query 1 1079 use `test`; create table t2 like t1 -master-bin.000001 1137 Query 1 1137 use `test`; drop table t1 +master-bin.000001 1079 Query 1 1079 use `test`; drop table t1 show binlog events from 79 limit 1; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key) @@ -40,10 +38,6 @@ master-bin.000001 172 Intvar 1 172 INSERT_ID=1 show binlog events from 79 limit 2,1; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) -show binlog events from 79 limit 2,2; -Log_name Pos Event_type Server_id Orig_log_pos Info -master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL) -master-bin.000001 263 Query 1 263 use `test`; drop table t1 flush logs; create table t5 (a int); drop table t5; @@ -63,9 +57,8 @@ master-bin.000001 263 Query 1 263 use `test`; drop table t1 master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 master-bin.000001 1056 Exec_load 1 1056 ;file_id=1 -master-bin.000001 1079 Query 1 1079 use `test`; create table t2 like t1 -master-bin.000001 1137 Query 1 1137 use `test`; drop table t1 -master-bin.000001 1185 Rotate 1 1185 master-bin.000002;pos=4 +master-bin.000001 1079 Query 1 1079 use `test`; drop table t1 +master-bin.000001 1127 Rotate 1 1127 master-bin.000002;pos=4 show binlog events in 'master-bin.000002'; Log_name Pos Event_type Server_id Orig_log_pos Info master-bin.000002 4 Query 1 4 use `test`; create table t5 (a int) @@ -92,11 +85,10 @@ slave-bin.000001 263 Query 1 263 use `test`; drop table t1 slave-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null) slave-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 slave-bin.000001 1065 Exec_load 1 1065 ;file_id=1 -slave-bin.000001 1088 Query 1 1088 use `test`; create table t2 like t1 -slave-bin.000001 1146 Query 1 1146 use `test`; drop table t1 -slave-bin.000001 1194 Query 1 1194 use `test`; create table t5 (a int) -slave-bin.000001 1252 Query 1 1252 use `test`; drop table t5 -slave-bin.000001 1300 Rotate 2 1300 slave-bin.000002;pos=4 +slave-bin.000001 1088 Query 1 1088 use `test`; drop table t1 +slave-bin.000001 1136 Query 1 1136 use `test`; create table t5 (a int) +slave-bin.000001 1194 Query 1 1194 use `test`; drop table t5 +slave-bin.000001 1242 Rotate 2 1242 slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; Log_name Pos Event_type Server_id Orig_log_pos Info slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 23ed06dee6a..512517991e6 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -879,17 +879,3 @@ d 444 d 454 NULL NULL f 666 NULL NULL g 777 drop table t1; -create table t1 ( id int, name char(10) not null, name2 char(10) not null ) engine=innodb; -insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); -select name2 from t1 union all select name from t1 union all select id from t1; -name2 -fff -sss -ttt -first -second -third -1 -2 -3 -drop table t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index ada2771fdc2..f931b4bb798 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1011,3 +1011,11 @@ checksum table t1, t2, t3, t4 extended; #show table status; drop table t1,t2,t3; +# +# Test problem with refering to different fields in same table in UNION +# (Bug #2552) +# +create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; +insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); +select name2 from t1 union all select name from t1 union all select id from t1; +drop table t1; diff --git a/mysql-test/t/myisam-blob.test b/mysql-test/t/myisam-blob.test index d58222ec8bf..7af8c661c02 100644 --- a/mysql-test/t/myisam-blob.test +++ b/mysql-test/t/myisam-blob.test @@ -27,4 +27,15 @@ UPDATE t1 set data=repeat('c',17*1024*1024); check table t1; delete from t1 where left(data,1)='c'; check table t1; + +INSERT INTO t1 set data=repeat('a',18*1024*1024); +select length(data) from t1; +alter table t1 modify data blob; +select length(data) from t1; +drop table t1; + +CREATE TABLE t1 (data BLOB) ENGINE=myisam; +INSERT INTO t1 (data) VALUES (NULL); +UPDATE t1 set data=repeat('a',18*1024*1024); +select length(data) from t1; drop table t1; diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test index 803eb069b66..4fbb6a595a4 100644 --- a/mysql-test/t/rpl000002.test +++ b/mysql-test/t/rpl000002.test @@ -1,5 +1,7 @@ source include/master-slave.inc; +# Test replication of auto_increment + create table t1 (n int auto_increment primary key); set insert_id = 2000; insert into t1 values (NULL),(NULL),(NULL); @@ -12,15 +14,26 @@ drop table t1; sync_slave_with_master; stop slave; connection master; + +# Test replication of timestamp + create table t2(id int auto_increment primary key, created datetime); set timestamp=12345; insert into t2 set created=now(); select * from t2; + +# Test replication of CREATE .. LIKE (Bug #2557) + +create table t3 like t2; +create temporary table t4 like t2; +create table t5 select * from t4; save_master_pos; connection slave; start slave; sync_with_master; select * from t2; +show create table t3; +show create table t5; connection master; -drop table t2; +drop table t2,t3,t5; sync_slave_with_master; diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test index 5f59b1034dc..7ae0a4dc3c2 100644 --- a/mysql-test/t/rpl_log.test +++ b/mysql-test/t/rpl_log.test @@ -35,14 +35,12 @@ drop table t1; create table t1 (word char(20) not null); load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; select count(*) from t1; -create table t2 like t1; drop table t1; --replace_result $VERSION VERSION show binlog events; show binlog events from 79 limit 1; show binlog events from 79 limit 2; show binlog events from 79 limit 2,1; -show binlog events from 79 limit 2,2; flush logs; # We need an extra update before doing save_master_pos. diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index c88ac4e70d8..60963548eed 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -473,14 +473,3 @@ create table t1 ( RID int(11) not null default '0', IID int(11) not null def insert into t1 ( RID,IID,nada,NAME,PHONE) values (1, 1, 'main', 'a', '111'), (2, 1, 'main', 'b', '222'), (3, 1, 'main', 'c', '333'), (4, 1, 'main', 'd', '444'), (5, 1, 'main', 'e', '555'), (6, 2, 'main', 'c', '333'), (7, 2, 'main', 'd', '454'), (8, 2, 'main', 'e', '555'), (9, 2, 'main', 'f', '666'), (10, 2, 'main', 'g', '777'); select A.NAME, A.PHONE, B.NAME, B.PHONE from t1 A left join t1 B on A.NAME = B.NAME and B.IID = 2 where A.IID = 1 and (A.PHONE <> B.PHONE or B.NAME is null) union select A.NAME, A.PHONE, B.NAME, B.PHONE from t1 B left join t1 A on B.NAME = A.NAME and A.IID = 1 where B.IID = 2 and (A.PHONE <> B.PHONE or A.NAME is null); drop table t1; - -# -# bug #2552 -# ---disable_warnings -create table t1 ( id int, name char(10) not null, name2 char(10) not null ) engine=innodb; ---enable_warnings -insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); -select name2 from t1 union all select name from t1 union all select id from t1; -drop table t1; - diff --git a/sql/field.cc b/sql/field.cc index 1e926c0926e..4632fbc5c69 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4075,10 +4075,10 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) Make sure we don't break a multibyte sequence as well as don't copy a malformed data. */ - copy_length= field_charset->cset->wellformedlen(field_charset, - from,from+length, - field_length/ - field_charset->mbmaxlen); + copy_length= field_charset->cset->well_formed_len(field_charset, + from,from+length, + field_length/ + field_charset->mbmaxlen); memcpy(ptr,from,copy_length); if (copy_length < field_length) // Append spaces if shorter field_charset->cset->fill(field_charset,ptr+copy_length, @@ -4571,11 +4571,15 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) } copy_length= max_data_length(); - if (copy_length > length) - copy_length= length; - copy_length= field_charset->cset->wellformedlen(field_charset, - from,from+copy_length, - field_length); + /* + copy_length is ok as last argument to well_formed_len as this is never + used to limit the length of the data. The cut of long data is done with + the 'min()' call below. + */ + copy_length= field_charset->cset->well_formed_len(field_charset, + from,from + + min(length, copy_length), + copy_length); if (copy_length < length) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED); diff --git a/sql/field.h b/sql/field.h index 90e78c5421a..f815324c698 100644 --- a/sql/field.h +++ b/sql/field.h @@ -953,14 +953,9 @@ public: void sort_string(char *buff,uint length); uint32 pack_length() const { return (uint32) (packlength+table->blob_ptr_size); } - uint32 max_data_length() const + inline uint32 max_data_length() const { - switch (packlength) { - case 1: return 255; - case 2: return (uint32) 0xFFFFL; - case 3: return (uint32) 0xFFFFFF; - default: return (uint32) 0xFFFFFFFF; - } + return (uint32) (((ulonglong) 1 << (packlength*8)) -1); } void reset(void) { bzero(ptr, packlength+sizeof(char*)); } void reset_fields() { bzero((char*) &value,sizeof(value)); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5ffe8c1c365..7982bd35f30 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -688,15 +688,15 @@ int yylex(void *arg, void *yythd) yylval->lex_str= get_token(lex,yyLength()); return(result_state); - case MY_LEX_USER_VARIABLE_DELIMITER: + case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char { uint double_quotes= 0; char quote_char= c; // Used char lex->tok_start=lex->ptr; // Skip first ` while ((c=yyGet())) { - int l; - if ((l= my_mbcharlen(cs, c)) == 1) + int length; + if ((length= my_mbcharlen(cs, c)) == 1) { if (c == (uchar) NAMES_SEP_CHAR) break; /* Old .frm format can't handle this char */ @@ -710,12 +710,9 @@ int yylex(void *arg, void *yythd) } } #ifdef USE_MB - else if (l > 1) - { - lex->ptr += l-1; - } - else - break; + else if (length < 1) + break; // Error + lex->ptr+= length-1; #endif } if (double_quotes) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8ed44d618fb..c169ea8952f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1089,100 +1089,86 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) DBUG_RETURN(0); } -static inline const char *require_quotes(const char *name, uint length) -{ - uint i, d, c; - for (i=0; i<length; i+=d) - { - c=((uchar *)name)[i]; - d=my_mbcharlen(system_charset_info, c); - if (d==1 && !system_charset_info->ident_map[c]) - return name+i; - } - return 0; -} - /* - Looking for char in multibyte string + Go through all character combinations and ensure that sql_lex.cc can + parse it as an identifer. SYNOPSIS - look_for_char() - name string for looking at - length length of name - q '\'' or '\"' for looking for - - RETURN VALUES - # pointer to found char in string - 0 string doesn't contain required char + require_quotes() + name attribute name + name_length length of name + + RETURN + # Pointer to conflicting character + 0 No conflicting character */ -static inline const char *look_for_char(const char *name, - uint length, char q) +static const char *require_quotes(const char *name, uint name_length) { - const char *cur= name; - const char *end= cur+length; - uint symbol_length; - for (; cur<end; cur+= symbol_length) + uint length; + const char *end= name + name_length; + + for ( ; name < end ; name++) { - char c= *cur; - symbol_length= my_mbcharlen(system_charset_info, c); - if (symbol_length==1 && c==q) - return cur; + uchar chr= (uchar) *name; + length= my_mbcharlen(system_charset_info, chr); + if (length == 1 && !system_charset_info->ident_map[chr]) + return name; } return 0; } + +static void append_quoted_simple_identifier(String *packet, char quote_char, + const char *name, uint length) +{ + packet->append("e_char, 1, system_charset_info); + packet->append(name, length, system_charset_info); + packet->append("e_char, 1, system_charset_info); +} + + void append_identifier(THD *thd, String *packet, const char *name, uint length) { - char qtype; + const char *name_end; + char quote_char; uint part_len; - const char *qplace; + if (thd->variables.sql_mode & MODE_ANSI_QUOTES) - qtype= '\"'; + quote_char= '\"'; else - qtype= '`'; + quote_char= '`'; if (is_keyword(name,length)) { - packet->append(&qtype, 1, system_charset_info); - packet->append(name, length, system_charset_info); - packet->append(&qtype, 1, system_charset_info); + append_quoted_simple_identifier(packet, quote_char, name, length); + return; } - else + + if (!require_quotes(name, length)) { - if (!(qplace= require_quotes(name, length))) - { - if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) - packet->append(name, length, system_charset_info); - else - { - packet->append(&qtype, 1, system_charset_info); - packet->append(name, length, system_charset_info); - packet->append(&qtype, 1, system_charset_info); - } - } - else - { - packet->shrink(packet->length()+length+2); - packet->append(&qtype, 1, system_charset_info); - if (*qplace != qtype) - qplace= look_for_char(qplace+1,length-(qplace-name)-1,qtype); - while (qplace) - { - if ((part_len= qplace-name)) - { - packet->append(name, part_len, system_charset_info); - length-= part_len; - } - packet->append(qplace, 1, system_charset_info); - name= qplace; - qplace= look_for_char(name+1,length-1,qtype); - } + if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) packet->append(name, length, system_charset_info); - packet->append(&qtype, 1, system_charset_info); - } + else + append_quoted_simple_identifier(packet, quote_char, name, length); + return; + } + + /* The identifier must be quoted as it includes a quote character */ + + packet->reserve(length*2 + 2); + packet->append("e_char, 1, system_charset_info); + + for (name_end= name+length ; name < name_end ; name+= length) + { + char chr= *name; + length= my_mbcharlen(system_charset_info, chr); + if (length == 1 && chr == quote_char) + packet->append("e_char, 1, system_charset_info); + packet->append(name, length, packet->charset()); } + packet->append("e_char, 1, system_charset_info); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index fb86e446fb7..8d1d64e9491 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1868,20 +1868,17 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, table_name); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */ } - else + + // Must be written before unlock + mysql_update_log.write(thd,thd->query, thd->query_length); + if (mysql_bin_log.is_open()) { - // Must be written before unlock - mysql_update_log.write(thd,thd->query, thd->query_length); - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - Query_log_event qinfo(thd, thd->query, thd->query_length, - test(create_info->options & - HA_LEX_CREATE_TMP_TABLE)); - mysql_bin_log.write(&qinfo); - } + thd->clear_error(); + Query_log_event qinfo(thd, thd->query, thd->query_length, + test(create_info->options & + HA_LEX_CREATE_TMP_TABLE)); + mysql_bin_log.write(&qinfo); } - DBUG_RETURN(0); table_exists: diff --git a/sql/sql_union.cc b/sql/sql_union.cc index f2e9016aec3..dc372bcd0b5 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -331,6 +331,14 @@ int st_select_lex_unit::exec() */ setup_table_map(table_list->table, table_list, tablenr); } + /* + Mark that we are using all fields in the table. This is needed + for InnoDB when using the same table but different fields in + an UNION + QQ: Replace query_id with a bit map of used fields and + change this for each union part. After this change, + this code can be removed. + */ for (unsigned int i=0; i < table_list->table->fields; i++) table_list->table->field[i]->query_id= query_id; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 1b0a235ed57..712f909ae47 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6245,7 +6245,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler= mbcharlen_big5, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_big5, /* mb_wc */ my_wc_mb_big5, /* wc_mb */ diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 35382b05c88..ea7777aabc0 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -350,7 +350,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, - my_wellformedlen_8bit, + my_well_formed_len_8bit, my_lengthsp_8bit, my_mb_wc_bin, my_wc_mb_bin, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 278e8529e83..ce6f695059f 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8653,7 +8653,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_euc_kr, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_euc_kr, /* mb_wc */ my_wc_mb_euc_kr, /* wc_mb */ diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 722f00f0f7a..9f663f0b1ce 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5704,7 +5704,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_gb2312, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_gb2312, /* mb_wc */ my_wc_mb_gb2312, /* wc_mb */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 2ebf145f840..f49bc5d360b 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9900,7 +9900,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_gbk, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_gbk, my_wc_mb_gbk, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 00d49f40ee4..eaef5441a65 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -180,7 +180,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, my_numchars_8bit, my_charpos_8bit, - my_wellformedlen_8bit, + my_well_formed_len_8bit, my_lengthsp_8bit, my_mb_wc_latin1, my_wc_mb_latin1, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index b35162c8fb6..2f7cf698664 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -274,12 +274,12 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), return pos ? e+2-b0 : b-b0; } -uint my_wellformedlen_mb(CHARSET_INFO *cs, - const char *b, const char *e, uint pos) +uint my_well_formed_len_mb(CHARSET_INFO *cs, + const char *b, const char *e, uint pos) { my_wc_t wc; int mblen; - const char *b0= b; + const char *b_start= b; while (pos) { @@ -288,7 +288,7 @@ uint my_wellformedlen_mb(CHARSET_INFO *cs, b+= mblen; pos--; } - return b - b0; + return b - b_start; } diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index baefe17c32f..719ae14f653 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1001,18 +1001,21 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) } } + void my_fill_8bit(CHARSET_INFO *cs __attribute__((unused)), char *s, uint l, int fill) { bfill(s,l,fill); } + uint my_numchars_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) { return e-b; } + uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *b __attribute__((unused)), const char *e __attribute__((unused)), @@ -1021,15 +1024,17 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), return pos; } -uint my_wellformedlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *start, - const char *end, - uint nchars) + +uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *start, + const char *end, + uint nchars) { uint nbytes= (uint) (end-start); - return nbytes < nchars ? nbytes : nchars; + return min(nbytes, nchars); } + uint my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *ptr, uint length) { @@ -1106,7 +1111,7 @@ MY_CHARSET_HANDLER my_charset_8bit_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, - my_wellformedlen_8bit, + my_well_formed_len_8bit, my_lengthsp_8bit, my_mb_wc_8bit, my_wc_mb_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 09bd12dcdeb..a4a8b3d4b2c 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4489,7 +4489,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_sjis, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_sjis, /* mb_wc */ my_wc_mb_sjis, /* wc_mb */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index b9856799add..abe9972cfd6 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -873,7 +873,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, - my_wellformedlen_8bit, + my_well_formed_len_8bit, my_lengthsp_8bit, my_mb_wc_tis620, /* mb_wc */ my_wc_mb_tis620, /* wc_mb */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index ec306d9af35..908d27859ff 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -985,6 +985,7 @@ cnv: return (int) (dst-db); } + static uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) @@ -992,6 +993,7 @@ uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), return (e-b)/2; } + static uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b __attribute__((unused)), @@ -1001,17 +1003,19 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), return pos*2; } + static -uint my_wellformedlen_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, - const char *e, - uint nchars) +uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, + const char *e, + uint nchars) { uint nbytes= (e-b) & ~ (uint)1; nchars*= 2; - return nbytes < nchars ? nbytes : nchars; + return min(nbytes, nchars); } + static void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), char *s, uint l, int fill) @@ -1019,6 +1023,7 @@ void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), for ( ; l >= 2; s[0]= 0, s[1]= fill, s+=2, l-=2); } + static uint my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *ptr, uint length) @@ -1029,6 +1034,7 @@ uint my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), return (uint) (end-ptr); } + /* ** Compare string against string with wildcard ** 0 if matched @@ -1043,7 +1049,7 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, int escape, int w_one, int w_many, MY_UNICASE_INFO **weights) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan, plane; @@ -1052,21 +1058,23 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, while (1) { - scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); + scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, + (const uchar*)wildend); if (scan <= 0) return 1; if (w_wc == (my_wc_t)escape) { wildstr+= scan; - scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); + scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, + (const uchar*)wildend); if (scan <= 0) return 1; } if (w_wc == (my_wc_t)w_many) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ break; } @@ -1078,7 +1086,7 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, if (w_wc == (my_wc_t)w_one) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ } else { @@ -1103,7 +1111,8 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, /* Remove any '%' and '_' from the wild search string */ for ( ; wildstr != wildend ; ) { - scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); + scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, + (const uchar*)wildend); if (scan <= 0) return 1; @@ -1116,7 +1125,8 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, if (w_wc == (my_wc_t)w_one) { wildstr+= scan; - scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, (const uchar*)str_end); + scan= my_ucs2_uni(cs, &s_wc, (const uchar*)str, + (const uchar*)str_end); if (scan <=0) return 1; str+= scan; @@ -1131,14 +1141,16 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, if (str == str_end) return -1; - scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); + scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, + (const uchar*)wildend); if (scan <= 0) return 1; if (w_wc == (my_wc_t)escape) { wildstr+= scan; - scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, (const uchar*)wildend); + scan= my_ucs2_uni(cs,&w_wc, (const uchar*)wildstr, + (const uchar*)wildend); if (scan <= 0) return 1; } @@ -1148,7 +1160,8 @@ int my_wildcmp_ucs2(CHARSET_INFO *cs, /* Skip until the first character from wildstr is found */ while (str != str_end) { - scan= my_ucs2_uni(cs,&s_wc, (const uchar*)str, (const uchar*)str_end); + scan= my_ucs2_uni(cs,&s_wc, (const uchar*)str, + (const uchar*)str_end); if (scan <= 0) return 1; if (weights) @@ -1190,6 +1203,7 @@ int my_wildcmp_ucs2_ci(CHARSET_INFO *cs, escape,w_one,w_many,uni_plane); } + static int my_wildcmp_ucs2_bin(CHARSET_INFO *cs, const char *str,const char *str_end, @@ -1232,6 +1246,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, return ( (se-s) - (te-t) ); } + static int my_strcasecmp_ucs2_bin(CHARSET_INFO *cs, const char *s, const char *t) { @@ -1241,6 +1256,7 @@ int my_strcasecmp_ucs2_bin(CHARSET_INFO *cs, const char *s, const char *t) return my_strncasecmp_ucs2(cs, s, t, len); } + static int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), uchar *dst, uint dstlen, @@ -1251,6 +1267,7 @@ int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), return srclen; } + static void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *key, uint len,ulong *nr1, ulong *nr2) @@ -1280,6 +1297,7 @@ static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = my_hash_sort_ucs2 }; + static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = { my_strnncoll_ucs2_bin, @@ -1292,13 +1310,14 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = my_hash_sort_ucs2_bin }; + static MY_CHARSET_HANDLER my_charset_ucs2_handler= { my_ismbchar_ucs2, /* ismbchar */ my_mbcharlen_ucs2, /* mbcharlen */ my_numchars_ucs2, my_charpos_ucs2, - my_wellformedlen_ucs2, + my_well_formed_len_ucs2, my_lengthsp_ucs2, my_ucs2_uni, /* mb_wc */ my_uni_ucs2, /* wc_mb */ @@ -1319,7 +1338,6 @@ static MY_CHARSET_HANDLER my_charset_ucs2_handler= }; - CHARSET_INFO my_charset_ucs2_general_ci= { 35,0,0, /* number */ diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index f27ddcf3e30..acb1d049a03 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8444,7 +8444,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_ujis, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_mb_wc_euc_jp, /* mb_wc */ my_wc_mb_euc_jp, /* wc_mb */ diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 64956c872aa..cafc43f3f70 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1969,7 +1969,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_utf8, my_numchars_mb, my_charpos_mb, - my_wellformedlen_mb, + my_well_formed_len_mb, my_lengthsp_8bit, my_utf8_uni, my_uni_utf8, |