Commit 1ef49b93 authored by lars/lthalmann@dl145h.mysql.com's avatar lars/lthalmann@dl145h.mysql.com

Merge mysql.com:/users/lthalmann/bkroot/mysql-5.1-new-rpl

into  mysql.com:/users/lthalmann/bk/MERGE/mysql-5.1-merge
parents 99b572b9 36de830f
......@@ -59,4 +59,17 @@ insert into t1 values(null);
select * from t1;
drop table t1;
# bug#22027
create table t1 (a int);
create table if not exists t2 select * from t1;
# bug#22762
create temporary table tt1 (a int);
create table if not exists t3 like tt1;
--replace_column 2 # 5 #
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
show binlog events from 102;
drop table t1,t2,t3,tt1;
-- source extra/binlog_tests/binlog_insert_delayed.test
......@@ -245,6 +245,24 @@ select * from t1;
id
127
drop table t1;
create table t1 (a int);
create table if not exists t2 select * from t1;
create temporary table tt1 (a int);
create table if not exists t3 like tt1;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key)
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
master-bin.000001 # Query 1 # use `test`; CREATE TABLE IF NOT EXISTS `t2` (
`a` int(11) DEFAULT NULL
)
master-bin.000001 # Query 1 # use `test`; CREATE TABLE IF NOT EXISTS `t3` (
`a` int(11) DEFAULT NULL
)
drop table t1,t2,t3,tt1;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
insert delayed into t1 values (207);
......@@ -256,6 +274,14 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_incre
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
master-bin.000001 # Query 1 # use `test`; CREATE TABLE IF NOT EXISTS `t2` (
`a` int(11) DEFAULT NULL
)
master-bin.000001 # Query 1 # use `test`; CREATE TABLE IF NOT EXISTS `t3` (
`a` int(11) DEFAULT NULL
)
master-bin.000001 # Query 1 # use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
......
......@@ -155,6 +155,21 @@ select * from t1;
id
127
drop table t1;
create table t1 (a int);
create table if not exists t2 select * from t1;
create temporary table tt1 (a int);
create table if not exists t3 like tt1;
show binlog events from 102;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key)
master-bin.000001 # Intvar 1 # INSERT_ID=127
master-bin.000001 # Query 1 # use `test`; insert into t1 values(null)
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
master-bin.000001 # Query 1 # use `test`; create table if not exists t2 select * from t1
master-bin.000001 # Query 1 # use `test`; create temporary table tt1 (a int)
master-bin.000001 # Query 1 # use `test`; create table if not exists t3 like tt1
drop table t1,t2,t3,tt1;
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
insert delayed into t1 values (207);
......@@ -166,6 +181,11 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_incre
master-bin.000001 # Intvar 1 # INSERT_ID=127
master-bin.000001 # Query 1 # use `test`; insert into t1 values(null)
master-bin.000001 # Query 1 # use `test`; drop table t1
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
master-bin.000001 # Query 1 # use `test`; create table if not exists t2 select * from t1
master-bin.000001 # Query 1 # use `test`; create temporary table tt1 (a int)
master-bin.000001 # Query 1 # use `test`; create table if not exists t3 like tt1
master-bin.000001 # Query 1 # use `test`; drop table t1,t2,t3,tt1
master-bin.000001 # Query 1 # use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
......
......@@ -723,6 +723,28 @@ lily
river
drop table t1;
deallocate prepare stmt;
create table t1 (
a char(10) unicode not null,
index a (a)
) engine=myisam;
insert into t1 values (repeat(0x201f, 10));
insert into t1 values (repeat(0x2020, 10));
insert into t1 values (repeat(0x2021, 10));
explain select hex(a) from t1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 20 NULL 3 Using index
select hex(a) from t1 order by a;
hex(a)
201F201F201F201F201F201F201F201F201F201F
2020202020202020202020202020202020202020
2021202120212021202120212021202120212021
alter table t1 drop index a;
select hex(a) from t1 order by a;
hex(a)
201F201F201F201F201F201F201F201F201F201F
2020202020202020202020202020202020202020
2021202120212021202120212021202120212021
drop table t1;
CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
SELECT id, MIN(s) FROM t1 GROUP BY id;
......
......@@ -2967,3 +2967,22 @@ ERROR HY000: CHECK OPTION failed 'test.v1'
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests.
DROP DATABASE IF EXISTS `d-1`;
CREATE DATABASE `d-1`;
USE `d-1`;
CREATE TABLE `t-1` (c1 INT);
CREATE VIEW `v-1` AS SELECT c1 FROM `t-1`;
SHOW TABLES;
Tables_in_d-1
t-1
v-1
RENAME TABLE `t-1` TO `t-2`;
RENAME TABLE `v-1` TO `v-2`;
SHOW TABLES;
Tables_in_d-1
t-2
v-2
DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
......@@ -454,6 +454,23 @@ select utext from t1 where utext like '%%';
drop table t1;
deallocate prepare stmt;
#
# Bug#22052 Trailing spaces are not removed from UNICODE fields in an index
#
create table t1 (
a char(10) unicode not null,
index a (a)
) engine=myisam;
insert into t1 values (repeat(0x201f, 10));
insert into t1 values (repeat(0x2020, 10));
insert into t1 values (repeat(0x2021, 10));
# make sure "index read" is used
explain select hex(a) from t1 order by a;
select hex(a) from t1 order by a;
alter table t1 drop index a;
select hex(a) from t1 order by a;
drop table t1;
#
# Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
# over a 'ucs2' field uses a temporary table
......
......@@ -2900,3 +2900,22 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests.
#
# Bug#21370 View renaming lacks tablename_to_filename encoding
#
--disable_warnings
DROP DATABASE IF EXISTS `d-1`;
--enable_warnings
CREATE DATABASE `d-1`;
USE `d-1`;
CREATE TABLE `t-1` (c1 INT);
CREATE VIEW `v-1` AS SELECT c1 FROM `t-1`;
SHOW TABLES;
RENAME TABLE `t-1` TO `t-2`;
RENAME TABLE `v-1` TO `v-2`;
SHOW TABLES;
DROP TABLE `t-2`;
DROP VIEW `v-2`;
DROP DATABASE `d-1`;
USE test;
......@@ -368,32 +368,33 @@ my_bool rename_in_schema_file(const char *schema, const char *old_name,
{
char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN];
strxnmov(old_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/",
old_name, reg_ext, NullS);
(void) unpack_filename(old_path, old_path);
strxnmov(new_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/",
new_name, reg_ext, NullS);
(void) unpack_filename(new_path, new_path);
build_table_filename(old_path, sizeof(old_path) - 1,
schema, old_name, reg_ext, 0);
build_table_filename(new_path, sizeof(new_path) - 1,
schema, new_name, reg_ext, 0);
if (my_rename(old_path, new_path, MYF(MY_WME)))
return 1;
/* check if arc_dir exists */
strxnmov(arc_path, FN_REFLEN-1, mysql_data_home, "/", schema, "/arc", NullS);
(void) unpack_filename(arc_path, arc_path);
build_table_filename(arc_path, sizeof(arc_path) - 1, schema, "arc", "", 0);
if (revision > 0 && !access(arc_path, F_OK))
{
char old_name_buf[FN_REFLEN], new_name_buf[FN_REFLEN];
ulonglong limit= ((revision > num_view_backups) ?
revision - num_view_backups : 0);
VOID(tablename_to_filename(old_name, old_name_buf, sizeof(old_name_buf)));
VOID(tablename_to_filename(new_name, new_name_buf, sizeof(new_name_buf)));
for (; revision > limit ; revision--)
{
my_snprintf(old_path, FN_REFLEN, "%s/%s%s-%04lu",
arc_path, old_name, reg_ext, (ulong)revision);
arc_path, old_name_buf, reg_ext, (ulong) revision);
(void) unpack_filename(old_path, old_path);
my_snprintf(new_path, FN_REFLEN, "%s/%s%s-%04lu",
arc_path, new_name, reg_ext, (ulong)revision);
arc_path, new_name_buf, reg_ext, (ulong) revision);
(void) unpack_filename(new_path, new_path);
my_rename(old_path, new_path, MYF(0));
}
......
......@@ -1058,6 +1058,9 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN("CREATE TEMPORARY TABLE "));
else
packet->append(STRING_WITH_LEN("CREATE TABLE "));
if (create_info_arg &&
(create_info_arg->options & HA_LEX_CREATE_IF_NOT_EXISTS))
packet->append(STRING_WITH_LEN("IF NOT EXISTS "));
if (table_list->schema_table)
alias= table_list->schema_table->table_name;
else
......
......@@ -1655,24 +1655,23 @@ mysql_rename_view(THD *thd,
const char *new_name,
TABLE_LIST *view)
{
LEX_STRING pathstr, file;
LEX_STRING pathstr;
File_parser *parser;
char view_path[FN_REFLEN];
char path_buff[FN_REFLEN];
bool error= TRUE;
DBUG_ENTER("mysql_rename_view");
strxnmov(view_path, FN_REFLEN-1, mysql_data_home, "/", view->db, "/",
view->table_name, reg_ext, NullS);
(void) unpack_filename(view_path, view_path);
pathstr.str= (char *)view_path;
pathstr.length= strlen(view_path);
pathstr.str= (char *) path_buff;
pathstr.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
view->db, view->table_name,
reg_ext, 0);
if ((parser= sql_parse_prepare(&pathstr, thd->mem_root, 1)) &&
is_equal(&view_type, parser->type()))
{
TABLE_LIST view_def;
char dir_buff[FN_REFLEN], file_buff[FN_REFLEN];
char dir_buff[FN_REFLEN];
LEX_STRING dir, file;
/*
To be PS-friendly we should either to restore state of
......@@ -1695,18 +1694,18 @@ mysql_rename_view(THD *thd,
view_def.revision - 1, num_view_backups))
goto err;
strxnmov(dir_buff, FN_REFLEN-1, mysql_data_home, "/", view->db, "/",
NullS);
(void) unpack_filename(dir_buff, dir_buff);
dir.str= dir_buff;
dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
view->db, "", "", 0);
pathstr.str= (char*)dir_buff;
pathstr.length= strlen(dir_buff);
pathstr.str= path_buff;
pathstr.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
view->db, new_name, reg_ext, 0);
file.str= file_buff;
file.length= (strxnmov(file_buff, FN_REFLEN, new_name, reg_ext, NullS)
- file_buff);
file.str= pathstr.str + dir.length;
file.length= pathstr.length - dir.length;
if (sql_create_definition_file(&pathstr, &file, view_file_type,
if (sql_create_definition_file(&dir, &file, view_file_type,
(gptr)&view_def, view_parameters,
num_view_backups))
{
......
......@@ -52,7 +52,7 @@ static int _mi_put_key_in_record(MI_INFO *info,uint keynr,byte *record);
uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
const byte *record, my_off_t filepos)
{
byte *pos,*end;
byte *pos;
uchar *start;
reg1 HA_KEYSEG *keyseg;
my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT;
......@@ -107,18 +107,17 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
}
if (keyseg->flag & HA_SPACE_PACK)
{
end= pos + length;
if (type != HA_KEYTYPE_NUM)
{
while (end > pos && end[-1] == ' ')
end--;
length= cs->cset->lengthsp(cs, pos, length);
}
else
{
byte *end= pos + length;
while (pos < end && pos[0] == ' ')
pos++;
}
length=(uint) (end-pos);
}
FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length);
memcpy((byte*) key,(byte*) pos,(size_t) char_length);
......@@ -404,7 +403,9 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
if (keyseg->type != (int) HA_KEYTYPE_NUM)
{
memcpy(pos,key,(size_t) length);
bfill(pos+length,keyseg->length-length,' ');
keyseg->charset->cset->fill(keyseg->charset,
pos + length, keyseg->length - length,
' ');
}
else
{
......
......@@ -348,6 +348,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
goto err;
}
}
else if (pos->type == HA_KEYTYPE_BINARY)
pos->charset= &my_charset_bin;
}
if (share->keyinfo[i].flag & HA_SPATIAL)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment