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
This commit is contained in:
unknown 2004-02-17 01:35:17 +02:00
parent 0c259c54b0
commit 709356d473
34 changed files with 266 additions and 211 deletions

View file

@ -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,

View file

@ -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 */

View file

@ -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);

View file

@ -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 */

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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);

View file

@ -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)); }

View file

@ -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)

View file

@ -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
require_quotes()
name attribute name
name_length length of name
RETURN VALUES
# pointer to found char in string
0 string doesn't contain required char
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(&quote_char, 1, system_charset_info);
packet->append(name, length, system_charset_info);
packet->append(&quote_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(&quote_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(&quote_char, 1, system_charset_info);
packet->append(name, length, packet->charset());
}
packet->append(&quote_char, 1, system_charset_info);
}

View file

@ -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())
{
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);
}
}
// 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);
}
DBUG_RETURN(0);
table_exists:

View file

@ -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;
}

View file

@ -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 */

View file

@ -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,

View file

@ -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 */

View file

@ -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 */

View file

@ -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,

View file

@ -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,

View file

@ -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;
}

View file

@ -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,

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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,