summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-12-11 15:46:39 +0200
committerunknown <monty@mashka.mysql.fi>2002-12-11 15:46:39 +0200
commit934f5cc4662ded62609ce64be15c54d327cc554e (patch)
tree39c72cd72a11f307f9898185deca1854ccf90c57 /sql
parent3c9b877b19bd4eaa4734ea5d699add9ca70a4e53 (diff)
downloadmariadb-git-934f5cc4662ded62609ce64be15c54d327cc554e.tar.gz
Ensure that BEGIN / COMMIT is handled properly if slave dies
Added syntax support for CREATE TABLE foo (a char CHARACTER SET latin1) CHARSET=latin1; Docs/internals.texi: Update binary protocol description innobase/include/db0err.h: Merge from 3.23 mysql-test/r/insert.result: Updated test result from 3.23 sql/log.cc: Fixed bug in replication and log rotation sql/log_event.cc: Ensure that BEGIN / COMMIT is handled properly if slave dies sql/slave.cc: Fixed bug in replication and log rotation sql/slave.h: Ensure that BEGIN / COMMIT is handled properly if slave dies sql/sql_analyse.cc: Moved usage of res before res is destroyed (by bzero(&s...)) sql/sql_yacc.yy: Added syntax support for CREATE TABLE foo (a char CHARACTER SET latin1) CHARSET=latin1; To be able to read MySQL 4.1 dump files.
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc5
-rw-r--r--sql/log_event.cc23
-rw-r--r--sql/slave.cc7
-rw-r--r--sql/slave.h10
-rw-r--r--sql/sql_analyse.cc49
-rw-r--r--sql/sql_yacc.yy5
6 files changed, 67 insertions, 32 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 32dbdac1074..56019a76b22 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -654,7 +654,12 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
rli->linfo.log_file_name);
goto err;
}
+ /*
+ Reset position to current log. This involves setting both of the
+ position variables:
+ */
rli->relay_log_pos = BIN_LOG_HEADER_SIZE;
+ rli->pending = 0;
strmake(rli->relay_log_name,rli->linfo.log_file_name,
sizeof(rli->relay_log_name)-1);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 373e50b84f7..d451a5bc46c 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -208,9 +208,13 @@ int Log_event::exec_event(struct st_relay_log_info* rli)
{
if (rli) // QQ When is this not true ?
{
- rli->inc_pos(get_event_len(),log_pos);
- DBUG_ASSERT(rli->sql_thd != 0);
- flush_relay_log_info(rli);
+ if (rli->inside_transaction)
+ rli->inc_pending(get_event_len());
+ else
+ {
+ rli->inc_pos(get_event_len(),log_pos);
+ flush_relay_log_info(rli);
+ }
}
return 0;
}
@@ -1707,6 +1711,19 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
mysql_log.write(thd,COM_QUERY,"%s",thd->query);
DBUG_PRINT("query",("%s",thd->query));
mysql_parse(thd, thd->query, q_len);
+
+ /*
+ Set a flag if we are inside an transaction so that we can restart
+ the transaction from the start if we are killed
+
+ This will only be done if we are supporting transactional tables
+ in the slave.
+ */
+ if (!strcmp(thd->query,"BEGIN"))
+ rli->inside_transaction= opt_using_transactions;
+ else if (!strcmp(thd->query,"COMMIT"))
+ rli->inside_transaction=0;
+
if ((expected_error != (actual_error = thd->net.last_errno)) &&
expected_error &&
!ignored_error_code(actual_error) &&
diff --git a/sql/slave.cc b/sql/slave.cc
index eb53e488856..a4e0b029bbf 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2711,7 +2711,12 @@ static IO_CACHE *reopen_relay_log(RELAY_LOG_INFO *rli, const char **errmsg)
if ((rli->cur_log_fd=open_binlog(cur_log,rli->relay_log_name,
errmsg)) <0)
DBUG_RETURN(0);
- my_b_seek(cur_log,rli->relay_log_pos);
+ /*
+ We want to start exactly where we was before:
+ relay_log_pos Current log pos
+ pending Number of bytes already processed from the event
+ */
+ my_b_seek(cur_log,rli->relay_log_pos + rli->pending);
DBUG_RETURN(cur_log);
}
diff --git a/sql/slave.h b/sql/slave.h
index 721fd8534a0..cb368ad26b1 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -169,11 +169,13 @@ typedef struct st_relay_log_info
volatile bool abort_slave, slave_running;
bool log_pos_current;
bool skip_log_purge;
-
+ bool inside_transaction;
+
st_relay_log_info()
- :info_fd(-1),cur_log_fd(-1), cur_log_old_open_count(0), abort_pos_wait(0),
- slave_run_id(0), inited(0), abort_slave(0), slave_running(0),
- log_pos_current(0), skip_log_purge(0)
+ :info_fd(-1),cur_log_fd(-1), cur_log_old_open_count(0), abort_pos_wait(0),
+ slave_run_id(0), inited(0), abort_slave(0), slave_running(0),
+ log_pos_current(0), skip_log_purge(0),
+ inside_transaction(0) /* the default is autocommit=1 */
{
relay_log_name[0] = master_log_name[0] = 0;
bzero(&info_file,sizeof(info_file));
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 96bbd731882..cbd586b8d30 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -310,30 +310,6 @@ void field_str::add()
was_maybe_zerofill = num_info.maybe_zerofill;
}
- if (room_in_tree)
- {
- if (res != &s)
- s.copy(*res);
- if (!tree_search(&tree, (void*) &s)) // If not in tree
- {
- s.copy(); // slow, when SAFE_MALLOC is in use
- if (!tree_insert(&tree, (void*) &s, 0))
- {
- room_in_tree = 0; // Remove tree, out of RAM ?
- delete_tree(&tree);
- }
- else
- {
- bzero((char*) &s, sizeof(s)); // Let tree handle free of this
- if ((treemem += length) > pc->max_treemem)
- {
- room_in_tree = 0; // Remove tree, too big tree
- delete_tree(&tree);
- }
- }
- }
- }
-
if (!found)
{
found = 1;
@@ -364,6 +340,31 @@ void field_str::add()
max_arg.copy(*res);
}
}
+
+ if (room_in_tree)
+ {
+ if (res != &s)
+ s.copy(*res);
+ if (!tree_search(&tree, (void*) &s)) // If not in tree
+ {
+ s.copy(); // slow, when SAFE_MALLOC is in use
+ if (!tree_insert(&tree, (void*) &s, 0))
+ {
+ room_in_tree = 0; // Remove tree, out of RAM ?
+ delete_tree(&tree);
+ }
+ else
+ {
+ bzero((char*) &s, sizeof(s)); // Let tree handle free of this
+ if ((treemem += length) > pc->max_treemem)
+ {
+ room_in_tree = 0; // Remove tree, too big tree
+ delete_tree(&tree);
+ }
+ }
+ }
+ }
+
if ((num_info.zerofill && (max_length != min_length)) ||
(was_zero_fill && (max_length != min_length)))
can_be_still_num = 0; // zerofilled numbers must be of same length
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7cb05d6bd3c..2eb32d16bb7 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token CACHE_SYM
%token CASCADE
%token CAST_SYM
+%token CHARSET
%token CHECKSUM_SYM
%token CHECK_SYM
%token COMMITTED_SYM
@@ -855,6 +856,8 @@ create_table_option:
table_list->next=0;
lex->create_info.used_fields|= HA_CREATE_USED_UNION;
}
+ | CHARSET opt_equal ident {}
+ | CHAR_SYM SET opt_equal ident {}
| INSERT_METHOD EQ merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;}
| DATA_SYM DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.data_file_name= $4.str; }
| INDEX DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.index_file_name= $4.str; };
@@ -1088,6 +1091,7 @@ attribute:
opt_binary:
/* empty */ {}
| BINARY { Lex->type|=BINARY_FLAG; };
+ | CHAR_SYM SET opt_equal ident {}
references:
REFERENCES table_ident opt_on_delete {}
@@ -3192,6 +3196,7 @@ keyword:
| BOOLEAN_SYM {}
| CACHE_SYM {}
| CHANGED {}
+ | CHARSET {}
| CHECKSUM_SYM {}
| CIPHER_SYM {}
| CLIENT_SYM {}