Commit graph

473 commits

Author SHA1 Message Date
Andrei Elkin
162eca37dd fixing compilation warning and adding flush logs to test of bug#37313 2009-02-24 16:17:34 +02:00
Andrei Elkin
c02752a005 Bug #37313 BINLOG Contains Incorrect server id
Signed integer format specifier forced to print the binlog header with server_id
negative if the unsigned value sets the sign-bit ON.
  
Fixed with correcting the specifier to correspond to typeof(server_id) == ulong.
2009-02-20 13:55:43 +02:00
Mats Kindahl
b9d6d4c0d8 Bug #37150 Risk for crash in User_var_log_event::exec_event()
On certain kinds of errors (e.g., out of stack), a call to Item_func_
set_user_var::fix_fields() might fail.  Since the return value of this
call was not checked inside User_var_log_event::exec_event(), continuing
execution after this will cause a crash inside Item_func_set_user_var::
update_hash().

The bug is fixed by aborting execution of the event with an error if
fix_fields() fails, since it is not possible to continue execution anyway.
2008-07-07 09:58:27 +02:00
svoj@mysql.com/april.(none)
70ca2ae287 Make gcov happy. 2008-03-18 16:38:12 +04:00
svoj@mysql.com/june.mysql.com
fe3b1c8e25 BUG#13861 - START SLAVE UNTIL may stop 1 evnt too late if
log-slave-updates and circul repl

Slave SQL thread may execute one extra event when there are events
skipped by slave I/O thread (e.g. originated by the same server).
Whereas it was requested not to do so by the UNTIL condition.

This happens because we compare with the end position of previously
executed event. This is fine when there are no skipped by slave I/O
thread events, as end position of previous event equals to start
position of to be executed event. Otherwise this position equals to
start position of skipped event.

This is fixed by:
- reading the event to be executed before checking if the until condition
  is satisfied.
- comparing the start position of the event to be executed. Since we do
  not have the start position available, we compute it by subtracting
  event length from end position (which is available).
- if there are no events on the event queue at the slave sql starting
  time, that meet until condition, we stop immediately, as in this
  case we do not want to wait for next event.
2008-02-22 19:07:07 +04:00
sven@riska.(none)
25d53f907c BUG#26395: if crash during autocommit update to transactional table on master, slave fails
Now, every transaction (including autocommit transactions) start with
a BEGIN and end with a COMMIT/ROLLBACK in the binlog.
Added a test case, and updated lots of test case result files.
2007-12-21 20:30:23 +01:00
hezx@hezx.(none)
c2f00cc3f9 BUG#32205 Replaying statements from mysqlbinlog fails with a syntax error, replicates fine
The reason of this bug is that when mysqlbinlog dumps a query, the query is written to
output with a delimeter appended right after it, if the query string ends with a '--'
comment, then the delimeter would be considered as part of the comment, if there are any
statements after this query, then it will cause a syntax error.

Start a newline before appending delimiter after a query string
2007-12-15 19:50:23 +08:00
mats@kindahl-laptop.dnsalias.net
6e1f5f6eed Elimination of warning for unused function code_name() in non-debug mode. 2007-11-13 09:43:29 +01:00
mats@kindahl-laptop.dnsalias.net
0cf6e38cb5 Fixes to eliminate warnings. 2007-11-13 09:01:42 +01:00
mats@kindahl-laptop.dnsalias.net
0f42488cb4 BUG#31793 (log event corruption causes crash):
Corrections to get_str_len_and_pointer().
2007-11-12 22:02:12 +01:00
mats@capulet.net
a88babcb05 Merge capulet.net:/home/bk/mysql-5.0-rpl
into  capulet.net:/home/mats/devel/b31793-mysql-5.0-rpl
2007-11-09 13:45:10 +01:00
mats@capulet.net
a432d3dec4 BUG#31793 (log event corruption causes crash):
When running mysqlbinlog on a 64-bit machine with a corrupt relay log,
it causes mysqlbinlog to crash. In this case, the crash is caused
because a request for 18446744073709534806U bytes is issued, which
apparantly can be served on a 64-bit machine (speculatively, I assume)
but this causes the memcpy() issued later to copy the data to segfault.

The request for the number of bytes is caused by a computation
of data_len - server_vars_len where server_vars_len is corrupt in such
a sense that it is > data_len. This causes a wrap-around, with the
the data_len given above.

This patch adds a check that if server_vars_len is greater than
data_len before the substraction, and aborts reading the event in
that case marking the event as invalid. It also adds checks to see
that reading the server variables does not go outside the bounds
of the available space, giving a limited amount of integrity check.
2007-11-09 13:43:09 +01:00
aelkin/elkin@koti.dsl.inet.fi
27436f0ba3 Bug #27571 asynchronousity in setting mysql_query::error and
Query_log_event::error_code

A query can perform completely having the local var error of mysql_$query
zero, where $query in insert, update, delete, load,
and be  binlogged with error_code e.g KILLED_QUERY while there is no
reason do to so.
That can happen because Query_log_event consults thd->killed flag to
evaluate error_code.

Fixed with implementing a scheme suggested and partly implemented at
time of bug@22725 work-on. error_status is cached immediatly after the
control leaves the main rows-loop and that instance always corresponds
to `error' the local of mysql_$query functions. The cached value
is passed to Query_log_event constructor, not the default thd->killed
which can be changed in between of the caching and the constructing.
2007-10-29 15:20:59 +02:00
aelkin/elkin@koti.dsl.inet.fi
501cce2b33 Bug #29309 Incorrect "Seconds_Behind_Master" value in SHOW SLAVE STATUS after FLUSH LOGS
Report claims that Seconds_behind_master behaves unexpectedly. 

Code analysis shows that there is an evident flaw in that treating of FormatDescription event is wrong
so  that after FLUSH LOGS on slave the Seconds_behind_master's calculation slips and incorrect
value can be reported to SHOW SLAVE STATUS. 
Even worse is that the gap between the correct and incorrect deltas grows with time.

Fixed with prohibiting changes to rpl->last_master_timestamp by artifical events (any kind of).
suggestion as comments is added how to fight with lack of info on the slave side by means of
new heartbeat feature coming.

The test can not be done ealily fully determistic.
2007-10-04 18:46:31 +03:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
7fb417d0ba Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect
restores from mysqlbinlog out

Problem: using "mysqlbinlog | mysql" for recoveries the connection_id() 
result may differ from what was used when issuing the statement.

Fix: if there is a connection_id() in a statement, write to binlog
SET pseudo_thread_id= XXX; before it and use the value later on.
2007-08-01 15:27:03 +05:00
gshchepa/uchum@gleb.loc
684d0ced77 Merge gleb.loc:/home/uchum/work/bk/5.0
into  gleb.loc:/home/uchum/work/bk/5.0-opt
2007-06-24 12:58:45 +05:00
holyfoot/hf@hfmain.(none)
8a6b7f7cca Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/28839/my50-28839
2007-06-21 12:04:13 +05:00
gshchepa/uchum@gleb.loc
1b5d893122 Fixed bug #28293.
Occasionally mysqlbinlog --hexdump failed with error:
  ERROR 1064 (42000) at line ...: You have an error in your
  SQL syntax; check the manual that corresponds to your MySQL
  server version for the right syntax to use near
  'Query thread_id=... exec_time=... error_code=...

When the length of hexadecimal dump of binlog header was
divisible by 16, commentary sign '#' after header was lost.
The Log_event::print_header function has been modified to always
finish hexadecimal binlog header with "\n# ".
2007-06-21 02:11:28 +05:00
aelkin/elkin@dsl-hkibras1-ff5dc300-70.dhcp.inet.fi
9391d42165 Bug #27583 slave sql fails to read from iocache when slave got stopped at pos==4
forgotten merge with 5.0. There can be some bugs waiting for this fix in 5.0 like Bug@29232
2007-06-20 13:21:16 +03:00
holyfoot/hf@mysql.com/hfmain.(none)
3b08919f6a Bug #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists.
slave_sql thread calls thd->clear_error() to force error to be ignored,
though this method didn't clear thd->killed state, what causes
slave_sql thread to stop.

clear thd->killed state if we ignore an error
2007-06-20 14:05:49 +05:00
aelkin/elkin@dsl-hkibras1-ff5dc300-70.dhcp.inet.fi
b8a5a770f0 Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events
The reason for the bug was that replaying of a query on slave could not be possible since its event
was recorded with the killed error. Due to the specific of handling INSERT, which per-row-while-loop is 
unbreakable to killing, the query on transactional table should have not appeared in binlog unless
there was  a call to a stored routine that got interrupted with killing (and then there must be an error
returned out of the loop).
   
The offered solution added the following rule for binlogging of INSERT that accounts the above
specifics:
For INSERT on transactional-table if the error was not set the only raised flag
is harmless and is ignored via masking out on time of creation of binlog event.
   
For both table types the combination of raised error and KILLED flag indicates that there
was potentially partial execution on master and consistency is under the question.
In that case the code continues to binlog an event with an appropriate killed error.
 
The fix relies on the specified behaviour of stored routine that must propagate the error 
to the top level query handling if the thd->killed flag was raised in the routine execution.
   
The patch adds an arg with the default killed-status-unset value to Query_log_event::Query_log_event.
2007-05-28 22:20:22 +03:00
malff/marcsql@weblab.(none)
fc809c70cc Bug#25411 (trigger code truncated), PART I
The issue found with bug 25411 is due to the function skip_rear_comments()
which damages the source code while implementing a work around.
The root cause of the problem is in the lexical analyser, which does not
process special comments properly.
For special comments like :
[1] aaa /*!50000 bbb */ ccc
since 5.0 is a version older that the current code, the parser is in lining
the content of the special comment, so that the query to process is
[2] aaa bbb ccc
However, the text of the query captured when processing a stored procedure,
stored function or trigger (or event in 5.1), can be after rebuilding it:
[3] aaa bbb */ ccc
which is wrong.

To fix bug 25411 properly, the lexical analyser needs to return [2] when
in lining special comments.
In order to implement this, some preliminary cleanup is required in the code,
which is implemented by this patch.

Before this change, the structure named LEX (or st_lex) contains attributes
that belong to lexical analysis, as well as attributes that represents the
abstract syntax tree (AST) of a statement.
Creating a new LEX structure for each statements (which makes sense for the
AST part) also re-initialized the lexical analysis phase each time, which
is conceptually wrong.

With this patch, the previous st_lex structure has been split in two:
- st_lex represents the Abstract Syntax Tree for a statement. The name "lex"
has not been changed to avoid a bigger impact in the code base.
- class lex_input_stream represents the internal state of the lexical
  analyser, which by definition should *not* be reinitialized when parsing
  multiple statements from the same input stream.

This change is a pre-requisite for bug 25411, since the implementation of
lex_input_stream will later improve to deal properly with special comments,
and this processing can not be done with the current implementation of
sp_head::reset_lex and sp_head::restore_lex, which interfere with the lexer.

This change set alone does not fix bug 25411.
2007-04-24 09:24:21 -06:00
msvensson@pilot.blaudden
696102a8c6 Bug#26837 Return value ignored for packet->append() call within Log_event::read_log_event
- Improve error handling for "out of memory" problems when master is
   sending logs to slave. If memory allocation fails the log should
   now  report error "memory allocation failed reading log event"
2007-03-23 19:00:34 +01:00
anozdrin/alik@booka.opbmk
c666e2f276 Polishing: use constants instead of magic numbers. 2007-03-09 08:05:08 +03:00
kostja@bodhi.local
86f02cd378 A fix for Bug#26750 "valgrind leak in sp_head" (and post-review
fixes).

The legend: on a replication slave, in case a trigger creation
was filtered out because of application of replicate-do-table/
replicate-ignore-table rule, the parsed definition of a trigger was not 
cleaned up properly. LEX::sphead member was left around and leaked 
memory. Until the actual implementation of support of 
replicate-ignore-table rules for triggers by the patch for Bug 24478 it 
was never the case that "case SQLCOM_CREATE_TRIGGER"
was not executed once a trigger was parsed,
so the deletion of lex->sphead there worked and the memory did not leak.

The fix: 

The real cause of the bug is that there is no 1 or 2 places where
we can clean up the main LEX after parse. And the reason we 
can not have just one or two places where we clean up the LEX is
asymmetric behaviour of MYSQLparse in case of success or error. 

One of the root causes of this behaviour is the code in Item::Item()
constructor. There, a newly created item adds itself to THD::free_list
- a single-linked list of Items used in a statement. Yuck. This code
is unaware that we may have more than one statement active at a time,
and always assumes that the free_list of the current statement is
located in THD::free_list. One day we need to be able to explicitly
allocate an item in a given Query_arena.
Thus, when parsing a definition of a stored procedure, like
CREATE PROCEDURE p1() BEGIN SELECT a FROM t1; SELECT b FROM t1; END;
we actually need to reset THD::mem_root, THD::free_list and THD::lex
to parse the nested procedure statement (SELECT *).
The actual reset and restore is implemented in semantic actions
attached to sp_proc_stmt grammar rule.
The problem is that in case of a parsing error inside a nested statement
Bison generated parser would abort immediately, without executing the
restore part of the semantic action. This would leave THD in an 
in-the-middle-of-parsing state.
This is why we couldn't have had a single place where we clean up the LEX
after MYSQLparse - in case of an error we needed to do a clean up
immediately, in case of success a clean up could have been delayed.
This left the door open for a memory leak.

One of the following possibilities were considered when working on a fix:
- patch the replication logic to do the clean up. Rejected
as breaks module borders, replication code should not need to know the
gory details of clean up procedure after CREATE TRIGGER.
- wrap MYSQLparse with a function that would do a clean up.
Rejected as ideally we should fix the problem when it happens, not
adjust for it outside of the problematic code.
- make sure MYSQLparse cleans up after itself by invoking the clean up
functionality in the appropriate places before return. Implemented in 
this patch.
- use %destructor rule for sp_proc_stmt to restore THD - cleaner
than the prevoius approach, but rejected
because needs a careful analysis of the side effects, and this patch is 
for 5.0, and long term we need to use the next alternative anyway
- make sure that sp_proc_stmt doesn't juggle with THD - this is a 
large work that will affect many modules.

Cleanup: move main_lex and main_mem_root from Statement to its
only two descendants Prepared_statement and THD. This ensures that
when a Statement instance was created for purposes of statement backup,
we do not involve LEX constructor/destructor, which is fairly expensive.
In order to track that the transformation produces equivalent 
functionality please check the respective constructors and destructors
of Statement, Prepared_statement and THD - these members were
used only there.
This cleanup is unrelated to the patch.
2007-03-07 12:24:46 +03:00
bar@mysql.com
7e38927a38 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  mysql.com:/home/bar/mysql-5.0.b15126
2007-02-28 17:17:06 +04:00
bar@mysql.com
dd0c43d5fa Bug#15126 character_set_database is not replicated (LOAD DATA INFILE need it)
This patch fixes problem that LOAD DATA could use different
character sets when loading files on master and on slave sides:
- Adding replication of thd->variables.collation_database
- Adding optional character set clause into LOAD DATA

Note, the second way, with explicit CHARACTER SET clause
should be the recommended way to load data using an alternative
character set.
The old way, using "SET @@character_set_database=xxx" should be
gradually depricated.
2007-02-28 17:06:57 +04:00
lars/lthalmann@mysql.com/dl145j.mysql.com
1a09fb81fc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-02-25 00:10:51 +01:00
guilhem@gbichot3.local
b3a03dada9 Fix for BUG#24432
"INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values".
When in an INSERT ON DUPLICATE KEY UPDATE, using
an autoincrement column, we inserted some autogenerated values and
also updated some rows, some autogenerated values were not used
(for example, even if 10 was the largest autoinc value in the table
at the start of the statement, 12 could be the first autogenerated
value inserted by the statement, instead of 11). One autogenerated
value was lost per updated row. Led to exhausting the range of the
autoincrement column faster.
Bug introduced by fix of BUG#20188; present since 5.0.24 and 5.1.12.
This bug breaks replication from a pre-5.0.24 master.
But the present bugfix, as it makes INSERT ON DUP KEY UPDATE
behave like pre-5.0.24, breaks replication from a [5.0.24,5.0.34]
master to a fixed (5.0.36) slave! To warn users against this when
they upgrade their slave, as agreed with the support team, we add
code for a fixed slave to detect that it is connected to a buggy
master in a situation (INSERT ON DUP KEY UPDATE into autoinc column)
likely to break replication, in which case it cannot replicate so
stops and prints a message to the slave's error log and to SHOW SLAVE
STATUS.
For 5.0.36->[5.0.24,5.0.34] replication we cannot warn as master
does not know the slave's version (but we always recommended to users
to have slave at least as new as master).
As agreed with support, I'll also ask for an alert to be put into
the MySQL Network Monitoring and Advisory Service.
2007-02-08 15:53:14 +01:00
monty@mysql.com/narttu.mysql.fi
a04157fbb3 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2007-01-22 14:04:40 +02:00
lars/lthalmann@mysql.com/dl145j.mysql.com
c380de50ef Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-01-12 12:22:54 +01:00
cbell/Chuck@suse.vabb.com
183c675980 BUG#22645 - LC_TIME_NAMES: Statement not replicated
This patch is an additional code change to the get_str_len_and_pointer
method in log_events.cc. This change is necessary to correct a problem
encountered on 64-bit SUSE where the auto_increment_* variables were
being overwritten. The change corrects a cast mismatch which caused
the problem.
2007-01-10 13:45:41 -05:00
bar@mysql.com
2c039cccb6 log_event.cc:
After merge fix
2006-12-29 16:42:16 +04:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
monty@mysql.com/narttu.mysql.fi
88dd873de0 Fixed compiler warnings detected by option -Wshadow and -Wunused:
- Removed not used variables and functions
- Added #ifdef around code that is not used
- Renamed variables and functions to avoid conflicts
- Removed some not used arguments

Fixed some class/struct warnings in ndb
Added define IS_LONGDATA() to simplify code in libmysql.c

I did run gcov on the changes and added 'purecov' comments on almost all lines that was not just variable name changes
2006-12-15 00:51:37 +02:00
bar@mysql.com/bar.intranet.mysql.r18.ru
cfdec2ca1e After merge fix for bug N22645 2006-12-14 16:31:23 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
cedafa8dec Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  mysql.com:/usr/home/bar/mysql-5.0.b22645
2006-12-14 14:19:30 +04:00
rafal@quant.(none)
fe2d5c59c2 Merge quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
into  quant.(none):/ext/mysql/bk/mysql-5.0-bug24507
2006-12-08 11:47:48 +01:00
bar@mysql.com/bar.intranet.mysql.r18.ru
b66f34bd19 Bug#22645 LC_TIME_NAMES: Statement not replicated
Implementing event based replication of LC_TIME_NAMES for 5.0
(as a replacement of previously made ONE_SHOT replication)
2006-12-07 09:31:53 +04:00
bar@mysql.com/bar.intranet.mysql.r18.ru
a70028a855 Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
Problem: when loading mysqlbinlog dumps, CREATE PROCEDURE having semicolons
in their bodies failed.
Fix: Using safe delimiter "/*!*/;" to dump log entries.
2006-11-28 16:26:15 +04:00
monty@mysql.com/nosik.monty.fi
306b871d52 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2006-11-20 22:46:52 +02:00
monty@mysql.com/nosik.monty.fi
e825879800 Remove compiler warnings
(Mostly in DBUG_PRINT() and unused arguments)
Fixed bug in query cache when used with traceing (--with-debug)
Fixed memory leak in mysqldump
Removed warnings from mysqltest scripts (replaced -- with #)
2006-11-20 22:42:06 +02:00
bar@mysql.com/bar.intranet.mysql.r18.ru
d3603eb152 Merge mysql.com:/usr/home/bar/mysql-5.0-rpl
into  mysql.com:/usr/home/bar/mysql-5.0.b23619
2006-11-16 12:28:09 +04:00
aelkin/elkin@dsl-hkibras-fe30f900-107.dhcp.inet.fi
650a245568 bug#19402 SQL close to the size of the max_allowed_packet fails on the slave
ver 5.0 and 5.1 refinement.
adding to the MAX_SIZE_LOG_EVENT_STATUS estimation status vars and 
EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN
2006-11-14 12:48:17 +02:00
bar@mysql.com/bar.intranet.mysql.r18.ru
a5de478d51 Bug#23619 Incorrectly escaped multibyte characters in binary log break replication
Problem: when embedding a character string with introducer with charset X
into a SQL query which is generally in character set Y, the string constants
were escaped according to their own character set (i.e.X), then after reading
such a "mixed" query from binlog, the string constants were unescaped
using character set of the query (i.e. Y), instead of X, which gave wrong
results or even syntax errors with tricky charsets (e.g. sjis)
Fix: when embedding a string constant of charset X into a query of charset Y,
the string constant is now escaped according to character Y, instead of
its own character set X.
2006-11-09 14:27:34 +04:00
kroki/tomash@moonlight.intranet
5ea8adfae7 BUG#21726: Incorrect result with multiple invocations of LAST_INSERT_ID
Non-upper-level INSERTs (the ones in the body of stored procedure,
stored function, or trigger) into a table that have AUTO_INCREMENT
column didn't affected the result of LAST_INSERT_ID() on this level.

The problem was introduced with the fix of bug 6880, which in turn was
introduced with the fix of bug 3117, where current insert_id value was
remembered on the first call to LAST_INSERT_ID() (bug 3117) and was
returned from that function until it was reset before the next
_upper-level_ statement (bug 6880).

The fix for bug#21726 brings back the behaviour of version 4.0, and
implements the following: remember insert_id value at the beginning
of the statement or expression (which at that point equals to
the first insert_id value generated by the previous statement), and
return that remembered value from LAST_INSERT_ID() or @@LAST_INSERT_ID.

Thus, the value returned by LAST_INSERT_ID() is not affected by values
generated by current statement, nor by LAST_INSERT_ID(expr) calls in
this statement.

Version 5.1 does not have this bug (it was fixed by WL 3146).
2006-10-02 14:28:23 +04:00
kaa@polly.local
b9811a6df1 Fixed the faulty merge 2006-09-13 19:32:21 +04:00
kaa@polly.local
e812ae873d Merge polly.local:/tmp/20924/bug20294/my41-bug20294
into  polly.local:/tmp/20924/bug20294/my50-bug20294
2006-09-13 15:18:14 +04:00
kaa@polly.local
397f0df9ad Cset exclude: kaa@polly.local|ChangeSet|20060912122540|09861
Cset exclude: kaa@polly.local|ChangeSet|20060908100829|09983
2006-09-13 14:41:28 +04:00
kaa@polly.local
e03faff3e4 Merge polly.local:/tmp/20924/bug20294/my41-bug20294
into  polly.local:/tmp/20924/bug20294/my50-bug20294
2006-09-12 17:57:15 +04:00