Commit 2e0e77d5 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-mysqladmin
parents c60412e7 c47ae401
......@@ -2899,3 +2899,41 @@ hex(a) STRCMP(a,'a') STRCMP(a,'a ')
6109 -1 -1
61 0 0
DROP TABLE t1;
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`url` varchar(200) NOT NULL default '',
`name` varchar(250) NOT NULL default '',
`type` int(11) NOT NULL default '0',
`website` varchar(250) NOT NULL default '',
`adddate` date NOT NULL default '0000-00-00',
`size` varchar(20) NOT NULL default '',
`movieid` int(11) NOT NULL default '0',
`musicid` int(11) NOT NULL default '0',
`star` varchar(20) NOT NULL default '',
`download` int(11) NOT NULL default '0',
`lastweek` int(11) NOT NULL default '0',
`thisweek` int(11) NOT NULL default '0',
`page` varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`)
) CHARACTER SET tis620;
INSERT INTO t1 VALUES
(1,'http://www.siamzone.com/download/download/000001-frodo_1024.jpg','The Lord
of the Rings
Wallpapers',1,'http://www.lordoftherings.net','2002-01-22','',448,0,'',3805,0,0,
'');
INSERT INTO t1 VALUES (2,'http://www.othemovie.com/OScreenSaver1.EXE','O
Screensaver',2,'','2002-01-22','',491,0,'',519,0,0,'');
INSERT INTO t1 VALUES
(3,'http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg','Jaso
n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,'');
select * from t1 order by id;
id url name type website adddate size movieid musicid star download lastweek thisweek page
1 http://www.siamzone.com/download/download/000001-frodo_1024.jpg The Lord
of the Rings
Wallpapers 1 http://www.lordoftherings.net 2002-01-22 448 0 3805 0 0
2 http://www.othemovie.com/OScreenSaver1.EXE O
Screensaver 2 2002-01-22 491 0 519 0 0
3 http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg Jaso
n X Wallpapers 1 2002-05-31 579 0 1091 0 0
DROP TABLE t1;
......@@ -20,3 +20,73 @@ a
9
drop table t1;
drop database mysqltest1;
drop database if exists rewrite;
create database rewrite;
use test;
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
Warning 1265 Data truncated for column 'a' at row 2
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
select * from rewrite.t1;
a b c d
0000-00-00 NULL 0000-00-00 0000-00-00
0000-00-00 0000-00-00 0000-00-00 0000-00-00
2003-03-03 2003-03-03 2003-03-03 NULL
2003-03-03 2003-03-03 2003-03-03 NULL
truncate table t1;
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'd' at row 1
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 2
select * from rewrite.t1;
a b c d
NULL NULL 0000-00-00 0000-00-00
NULL 0000-00-00 0000-00-00 0000-00-00
NULL 2003-03-03 2003-03-03 NULL
drop table t1;
create table t1 (a text, b text);
load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
Warnings:
Warning 1261 Row 3 doesn't contain data for all columns
select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1;
concat('|',a,'|') concat('|',b,'|')
|Field A| |Field B|
|Field 1| |Field 2'
Field 3,'Field 4|
|Field 5' ,'Field 6| NULL
|Field 6| | 'Field 7'|
drop table t1;
create table t1 (a int, b char(10));
load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
Warnings:
Warning 1265 Data truncated for column 'a' at row 3
Warning 1262 Row 3 was truncated; it contained more data than there were input columns
Warning 1265 Data truncated for column 'a' at row 5
Warning 1262 Row 5 was truncated; it contained more data than there were input columns
select * from rewrite.t1;
a b
1 row 1
2 row 2
0 1234567890
3 row 3
0 1234567890
truncate table t1;
load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
Warnings:
Warning 1265 Data truncated for column 'a' at row 4
Warning 1261 Row 4 doesn't contain data for all columns
select * from rewrite.t1;
a b
1 row 1
2 row 2
3 row 3
0
drop table t1;
......@@ -116,3 +116,38 @@ CREATE TABLE t1 (a char(10) not null) CHARACTER SET tis620;
INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
DROP TABLE t1;
#
# Bug#6608
#
CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment,
`url` varchar(200) NOT NULL default '',
`name` varchar(250) NOT NULL default '',
`type` int(11) NOT NULL default '0',
`website` varchar(250) NOT NULL default '',
`adddate` date NOT NULL default '0000-00-00',
`size` varchar(20) NOT NULL default '',
`movieid` int(11) NOT NULL default '0',
`musicid` int(11) NOT NULL default '0',
`star` varchar(20) NOT NULL default '',
`download` int(11) NOT NULL default '0',
`lastweek` int(11) NOT NULL default '0',
`thisweek` int(11) NOT NULL default '0',
`page` varchar(250) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`)
) CHARACTER SET tis620;
INSERT INTO t1 VALUES
(1,'http://www.siamzone.com/download/download/000001-frodo_1024.jpg','The Lord
of the Rings
Wallpapers',1,'http://www.lordoftherings.net','2002-01-22','',448,0,'',3805,0,0,
'');
INSERT INTO t1 VALUES (2,'http://www.othemovie.com/OScreenSaver1.EXE','O
Screensaver',2,'','2002-01-22','',491,0,'',519,0,0,'');
INSERT INTO t1 VALUES
(3,'http://www.siamzone.com/download/download/000003-jasonx2(800x600).jpg','Jaso
n X Wallpapers',1,'','2002-05-31','',579,0,'',1091,0,0,'');
select * from t1 order by id;
DROP TABLE t1;
"--replicate-rewrite-db=mysqltest1->test"
"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test"
......@@ -17,3 +17,61 @@ drop table t1;
drop database mysqltest1;
sync_slave_with_master;
#
# BUG#6353:
# Option --replicate-rewrite-db should work together with LOAD DATA INFILE
#
connection slave;
--disable_warnings
drop database if exists rewrite;
--enable_warnings
create database rewrite;
connection master;
use test;
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
sync_slave_with_master;
connection slave;
select * from rewrite.t1;
connection master;
truncate table t1;
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
sync_slave_with_master;
connection slave;
select * from rewrite.t1;
connection master;
drop table t1;
create table t1 (a text, b text);
load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
sync_slave_with_master;
connection slave;
select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1;
connection master;
drop table t1;
create table t1 (a int, b char(10));
load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
sync_slave_with_master;
connection slave;
select * from rewrite.t1;
connection master;
truncate table t1;
load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
sync_slave_with_master;
connection slave;
# The empty line last comes from the end line field in the file
select * from rewrite.t1;
connection master;
drop table t1;
......@@ -1655,16 +1655,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db,
/*
Load_log_event::set_fields()
Note that this function can not use the member variable
for the database, since LOAD DATA INFILE on the slave
can be for a different database than the current one.
This is the reason for the affected_db argument to this method.
*/
#ifndef MYSQL_CLIENT
void Load_log_event::set_fields(List<Item> &field_list)
void Load_log_event::set_fields(const char* affected_db,
List<Item> &field_list)
{
uint i;
const char* field = fields;
for (i= 0; i < num_fields; i++)
{
field_list.push_back(new Item_field(db, table_name, field));
field_list.push_back(new Item_field(affected_db, table_name, field));
field+= field_lens[i] + 1;
}
}
......@@ -1820,7 +1826,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
ex.skip_lines = skip_lines;
List<Item> field_list;
set_fields(field_list);
set_fields(thd->db,field_list);
thd->variables.pseudo_thread_id= thread_id;
if (net)
{
......@@ -1837,13 +1843,13 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
if (thd->cuted_fields)
{
/* log_pos is the position of the LOAD event in the master log */
sql_print_error("\
Slave: load data infile on table '%s' at log position %s in log \
'%s' produced %ld warning(s). Default database: '%s'",
(char*) table_name,
llstr(log_pos,llbuff), RPL_LOG_NAME,
(ulong) thd->cuted_fields,
print_slave_db_safe(thd->db));
sql_print_warning("Slave: load data infile on table '%s' at "
"log position %s in log '%s' produced %ld "
"warning(s). Default database: '%s'",
(char*) table_name,
llstr(log_pos,llbuff), RPL_LOG_NAME,
(ulong) thd->cuted_fields,
print_slave_db_safe(thd->db));
}
if (net)
net->pkt_nr= thd->net.pkt_nr;
......
......@@ -587,7 +587,7 @@ class Load_log_event: public Log_event
const char* table_name_arg,
List<Item>& fields_arg, enum enum_duplicates handle_dup,
bool using_trans);
void set_fields(List<Item> &fields_arg);
void set_fields(const char* db, List<Item> &fields_arg);
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
......
......@@ -562,17 +562,13 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
const uchar *b0, uint b_length)
{
uchar buf[80] ;
uchar *end, *a, *b;
uchar *end, *a, *b, *alloced= NULL;
uint length;
int res= 0;
int alloced= 0;
a= buf;
if ((a_length + b_length +2) > (int) sizeof(buf))
{
a= (uchar*) malloc(a_length+b_length);
alloced= 1;
}
alloced= a= (uchar*) malloc(a_length+b_length);
b= a + a_length+1;
memcpy((char*) a, (char*) a0, a_length);
......@@ -618,7 +614,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
ret:
if (alloced)
free(a);
free(alloced);
return res;
}
......
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