Commit ffc6c262 authored by rafal@quant.(none)'s avatar rafal@quant.(none)

Merge rsomla@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl

into  quant.(none):/ext/mysql/bkroot/mysql-5.1-new-rpl
parents 00e6bf6e e71dbbd5
......@@ -30,17 +30,17 @@ HEX(s1) HEX(s2) d
466F6F2773206120426172 ED40ED41ED42 47.93
DROP PROCEDURE bug18293|
DROP TABLE t4|
SHOW BINLOG EVENTS FROM 397|
SHOW BINLOG EVENTS FROM 406|
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 397 Query 1 560 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
master-bin.000001 406 Query 1 572 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
s2 CHAR(50) CHARACTER SET cp932,
d DECIMAL(10,2))
master-bin.000001 560 Query 1 805 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50),
master-bin.000001 572 Query 1 820 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50),
IN ins2 CHAR(50) CHARACTER SET cp932,
IN ind DECIMAL(10,2))
BEGIN
INSERT INTO t4 VALUES (ins1, ins2, ind);
END
master-bin.000001 805 Query 1 1021 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 1021 Query 1 1107 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1107 Query 1 1183 use `test`; DROP TABLE t4
master-bin.000001 820 Query 1 1039 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 1039 Query 1 1128 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1128 Query 1 1207 use `test`; DROP TABLE t4
......@@ -274,3 +274,61 @@ call p1();
1
drop procedure p1;
flush logs;
create table t1 (a varchar(64) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
D0AA
C3BF
D0AA
drop table t1;
flush logs;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
use test/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
create table t1 (a varchar(64) character set utf8)/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/;
SET TIMESTAMP=1000000000/*!*/;
load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop table t1/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
flush logs;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a varchar(10) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
C3BF
D0AA
D0AA
select hex(a) from t1;
hex(a)
C3BF
D0AA
C3BF
C3BF
C3BF
D0AA
D0AA
drop table t1;
......@@ -41,3 +41,37 @@ select * from t1;
ts
2005-08-12 00:00:00
drop table t1;
*** master ***
create table t1 (a int, b int);
create trigger trg1 before insert on t1 for each row set new.b=2;
create table t2 (a int, b int);
create trigger trg2 before insert on t2 for each row set new.b=2;
show tables;
Tables_in_test
t1
t2
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
*** master ***
drop trigger trg1;
drop trigger trg2;
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
*** slave ***
show tables;
Tables_in_test
t1
show triggers;
Trigger Event Table Statement Timing Created sql_mode Definer
*** master ***
drop table t1;
drop table t2;
......@@ -22,7 +22,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
SELECT HEX(s1),HEX(s2),d FROM t4|
DROP PROCEDURE bug18293|
DROP TABLE t4|
SHOW BINLOG EVENTS FROM 397|
SHOW BINLOG EVENTS FROM 406|
delimiter ;|
# End of 5.0 tests
......
......@@ -193,6 +193,30 @@ drop procedure p1;
--exec $MYSQL_BINLOG --help 2>&1 > /dev/null
--enable_query_log
#
# Bug#15126 character_set_database is not replicated
# (LOAD DATA INFILE need it)
#
flush logs;
create table t1 (a varchar(64) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set character_set_database=latin1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
drop table t1;
flush logs;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000012
# End of 5.0 tests
#
......@@ -200,7 +224,7 @@ drop procedure p1;
#
flush logs;
--error 1
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000012 >/dev/null 2>/dev/null
--exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000012 >/dev/null 2>/dev/null
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000014 >/dev/null 2>/dev/null
--exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000014 >/dev/null 2>/dev/null
# End of 5.1 tests
#
# Check LOAD DATA + character sets + replication
#
source include/master-slave.inc;
#
# Bug#15126 character_set_database is not replicated
# (LOAD DATA INFILE need it)
#
connection master;
create table t1 (a varchar(10) character set utf8);
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=koi8r;
load data infile '../std_data_ln/loaddata6.dat' into table t1;
set @@character_set_database=DEFAULT;
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
select hex(a) from t1;
save_master_pos;
connection slave;
sync_with_master;
select hex(a) from t1;
connection master;
drop table t1;
sync_slave_with_master;
......@@ -58,3 +58,35 @@ drop table t1;
sync_slave_with_master;
# End of 4.1 tests
#
# Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters
#
--echo *** master ***
connection master;
create table t1 (a int, b int);
create trigger trg1 before insert on t1 for each row set new.b=2;
create table t2 (a int, b int);
create trigger trg2 before insert on t2 for each row set new.b=2;
show tables;
show triggers;
sync_slave_with_master;
--echo *** slave ***
connection slave;
show tables;
show triggers;
--echo *** master ***
connection master;
drop trigger trg1;
drop trigger trg2;
show triggers;
sync_slave_with_master;
--echo *** slave ***
connection slave;
show tables;
show triggers;
--echo *** master ***
connection master;
drop table t1;
drop table t2;
sync_slave_with_master;
......@@ -1281,7 +1281,8 @@ bool Query_log_event::write(IO_CACHE* file)
1+4+ // code of autoinc and the 2 autoinc variables
1+6+ // code of charset and charset
1+1+MAX_TIME_ZONE_NAME_LENGTH+ // code of tz and tz length and tz name
1+2 // code of lc_time_names and lc_time_names_number
1+2+ // code of lc_time_names and lc_time_names_number
1+2 // code of charset_database and charset_database_number
], *start, *start_of_status;
ulong event_length;
......@@ -1400,6 +1401,13 @@ bool Query_log_event::write(IO_CACHE* file)
int2store(start, lc_time_names_number);
start+= 2;
}
if (charset_database_number)
{
DBUG_ASSERT(charset_database_number <= 0xFFFF);
*start++= Q_CHARSET_DATABASE_CODE;
int2store(start, charset_database_number);
start+= 2;
}
/*
Here there could be code like
if (command-line-option-which-says-"log_this_variable" && inited)
......@@ -1465,7 +1473,8 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
sql_mode(thd_arg->variables.sql_mode),
auto_increment_increment(thd_arg->variables.auto_increment_increment),
auto_increment_offset(thd_arg->variables.auto_increment_offset),
lc_time_names_number(thd_arg->variables.lc_time_names->number)
lc_time_names_number(thd_arg->variables.lc_time_names->number),
charset_database_number(0)
{
time_t end_time;
time(&end_time);
......@@ -1473,6 +1482,9 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
catalog_len = (catalog) ? (uint32) strlen(catalog) : 0;
/* status_vars_len is set just before writing the event */
db_len = (db) ? (uint32) strlen(db) : 0;
if (thd_arg->variables.collation_database != thd_arg->db_charset)
charset_database_number= thd_arg->variables.collation_database->number;
/*
If we don't use flags2 for anything else than options contained in
thd->options, it would be more efficient to flags2=thd_arg->options
......@@ -1543,7 +1555,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
db(NullS), catalog_len(0), status_vars_len(0),
flags2_inited(0), sql_mode_inited(0), charset_inited(0),
auto_increment_increment(1), auto_increment_offset(1),
time_zone_len(0), lc_time_names_number(0)
time_zone_len(0), lc_time_names_number(0), charset_database_number(0)
{
ulong data_len;
uint32 tmp;
......@@ -1648,6 +1660,10 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
lc_time_names_number= uint2korr(pos);
pos+= 2;
break;
case Q_CHARSET_DATABASE_CODE:
charset_database_number= uint2korr(pos);
pos+= 2;
break;
default:
/* That's why you must write status vars in growing order of code */
DBUG_PRINT("info",("Query_log_event has unknown status vars (first has\
......@@ -1846,6 +1862,16 @@ void Query_log_event::print_query_header(IO_CACHE* file,
lc_time_names_number, print_event_info->delimiter);
print_event_info->lc_time_names_number= lc_time_names_number;
}
if (charset_database_number != print_event_info->charset_database_number)
{
if (charset_database_number)
my_b_printf(file, "SET @@session.collation_database=%d%s\n",
charset_database_number, print_event_info->delimiter);
else
my_b_printf(file, "SET @@session.collation_database=DEFAULT%s\n",
print_event_info->delimiter);
print_event_info->charset_database_number= charset_database_number;
}
}
......@@ -2001,6 +2027,20 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli,
}
else
thd->variables.lc_time_names= &my_locale_en_US;
if (charset_database_number)
{
CHARSET_INFO *cs;
if (!(cs= get_charset(charset_database_number, MYF(0))))
{
char buf[20];
int10_to_str((int) charset_database_number, buf, -10);
my_error(ER_UNKNOWN_COLLATION, MYF(0), buf);
goto compare_errors;
}
thd->variables.collation_database= cs;
}
else
thd->variables.collation_database= thd->db_charset;
/* Execute the query (note that we bypass dispatch_command()) */
mysql_parse(thd, thd->query, thd->query_length);
......
......@@ -272,6 +272,7 @@ struct sql_ex_info
#define Q_LC_TIME_NAMES_CODE 7
#define Q_CHARSET_DATABASE_CODE 8
/* Intvar event post-header */
#define I_TYPE_OFFSET 0
......@@ -533,10 +534,11 @@ typedef struct st_print_event_info
char charset[6]; // 3 variables, each of them storable in 2 bytes
char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
uint lc_time_names_number;
uint charset_database_number;
st_print_event_info()
:flags2_inited(0), sql_mode_inited(0),
auto_increment_increment(1),auto_increment_offset(1), charset_inited(0),
lc_time_names_number(0)
lc_time_names_number(0), charset_database_number(0)
{
/*
Currently we only use static PRINT_EVENT_INFO objects, so zeroed at
......@@ -849,6 +851,7 @@ class Query_log_event: public Log_event
uint time_zone_len; /* 0 means uninited */
const char *time_zone_str;
uint lc_time_names_number; /* 0 means en_US */
uint charset_database_number;
#ifndef MYSQL_CLIENT
......
......@@ -99,7 +99,7 @@ void net_set_read_timeout(NET *net, uint timeout);
#define WARN_DEPRECATED(Thd,Ver,Old,New) \
do { \
DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \
if (Thd != NULL) \
if (((gptr)Thd) != NULL) \
push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \
(Old), (Ver), (New)); \
......
......@@ -7632,7 +7632,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (!slave_warning_issued) //only show the warning once
{
slave_warning_issued = true;
WARN_DEPRECATED(0, "5.2", "for replication startup options",
WARN_DEPRECATED(NULL, "5.2", "for replication startup options",
"'CHANGE MASTER'");
}
break;
......
......@@ -53,6 +53,10 @@ ulonglong relay_log_space_limit = 0;
*/
int disconnect_slave_event_count = 0, abort_slave_event_count = 0;
int events_till_abort = -1;
#ifndef DBUG_OFF
static int events_till_disconnect = -1;
#endif
typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE;
......
......@@ -996,6 +996,7 @@ sql_exchange::sql_exchange(char *name,bool flag)
enclosed= line_start= &my_empty_string;
line_term= &default_line_term;
escaped= &default_escaped;
cs= NULL;
}
bool select_send::send_fields(List<Item> &list, uint flags)
......
......@@ -1656,6 +1656,7 @@ class sql_exchange :public Sql_alloc
bool opt_enclosed;
bool dumpfile;
ulong skip_lines;
CHARSET_INFO *cs;
sql_exchange(char *name,bool dumpfile_flag);
};
......
......@@ -362,7 +362,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
List_item *values;
Name_resolution_context *context;
Name_resolution_context_state ctx_state;
#ifndef EMBEDDED_LIBRARY
char *query= thd->query;
#endif
/*
log_on is about delayed inserts only.
By default, both logs are enabled (this won't cause problems if the server
......
......@@ -316,7 +316,8 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
info.handle_duplicates=handle_duplicates;
info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
READ_INFO read_info(file,tot_length,thd->variables.collation_database,
READ_INFO read_info(file,tot_length,
ex->cs ? ex->cs : thd->variables.collation_database,
*field_term,*ex->line_start, *ex->line_term, *enclosed,
info.escape_char, read_file_from_client, is_fifo);
if (read_info.error)
......
......@@ -27,6 +27,7 @@
#include "sp_cache.h"
#include "events.h"
#include "event_data_objects.h"
#include "sql_trigger.h"
/* Used in error handling only */
#define SP_TYPE_STRING(LP) \
......@@ -1596,6 +1597,30 @@ mysql_execute_command(THD *thd)
#ifdef HAVE_REPLICATION
if (unlikely(thd->slave_thread))
{
if (lex->sql_command == SQLCOM_DROP_TRIGGER)
{
/*
When dropping a trigger, we need to load its table name
before checking slave filter rules.
*/
add_table_for_trigger(thd, thd->lex->spname, 1, &all_tables);
if (!all_tables)
{
/*
If table name cannot be loaded,
it means the trigger does not exists possibly because
CREATE TRIGGER was previously skipped for this trigger
according to slave filtering rules.
Returning success without producing any errors in this case.
*/
DBUG_RETURN(0);
}
// force searching in slave.cc:tables_ok()
all_tables->updating= 1;
}
/*
Check if statment should be skipped because of slave filtering
rules
......
......@@ -106,10 +106,6 @@ const LEX_STRING trg_event_type_names[]=
};
static int
add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
TABLE_LIST ** table);
class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook
{
private:
......@@ -1180,7 +1176,7 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event,
1 Error
*/
static int
int
add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
TABLE_LIST **table)
{
......
......@@ -137,3 +137,7 @@ class Table_triggers_list: public Sql_alloc
extern const LEX_STRING trg_action_time_type_names[];
extern const LEX_STRING trg_event_type_names[];
int
add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
TABLE_LIST **table);
......@@ -1067,6 +1067,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
old_or_new_charset_name_or_default
collation_name
collation_name_or_default
opt_load_data_charset
%type <variable> internal_variable_name
......@@ -4662,6 +4663,10 @@ charset_name_or_default:
charset_name { $$=$1; }
| DEFAULT { $$=NULL; } ;
opt_load_data_charset:
/* Empty */ { $$= NULL; }
| charset charset_name_or_default { $$= $2; }
;
old_or_new_charset_name:
ident_or_text
......@@ -8964,6 +8969,8 @@ load_data:
lex->update_list.empty();
lex->value_list.empty();
}
opt_load_data_charset
{ Lex->exchange->cs= $12; }
opt_field_term opt_line_term opt_ignore_lines opt_field_or_var_spec
opt_load_data_set_spec
{}
......
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