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.
mysql-test/r/binlog_killed.result:
results changed
mysql-test/t/binlog_killed.test:
Demonstrating that effective killing during rows-loop execution leads to the speficied actions:
binlogging with the error for a query modified a not-transactional table or
rolling back effects for transactional table;
fixing possible non-determinism with ID when query_log_enabled;
leave commented out tests for multi-update,delete due to another bug;
removing an obsolete tests template;
changing system rm to --remove_file.
sql/log_event.cc:
adding killed status arg
sql/log_event.h:
added killed status arg
sql/sql_delete.cc:
deploying the update part patch for delete, multi-delete
sql/sql_insert.cc:
deploying the update-part patch for insert..select
sql/sql_load.cc:
deploying the update-part patch for load data.
simulation added.
sql/sql_update.cc:
Impementing the fix as described in the comments left by bug@22725.
Also simulation of killing after the loop that would affect binlogging in the old code.
mysql-test/t/binlog_killed_bug27571-master.opt:
post rows-loop killing simulation's options
mysql-test/t/binlog_killed_bug27571.test:
Checking that if killing happens inbetween of the end of rows loop and
recording into binlog that will not lead to recording any error incl
the killed error.
mysql-test/t/binlog_killed_simulate-master.opt:
simulation options
mysql-test/t/binlog_killed_simulate.test:
tests for
a query (update is choosen) being killed after the row-loop;
load data killed within the loop - effective killed error in the event is gained.
similar to bug_27716, but it was stressed on in the synopsis on that there is another
side of the artifact affecting behaviour in transaction.
Fixed with deploying multi_delete::send_error() - otherwise never called - and refining its logic
to perform binlogging job if needed.
The changeset includes the following side effects:
- added tests to check bug_23333's scenarios on the mixture of tables for multi_update;
- fixes bug@30763 with two-liner patch and a test coinciding to one added for bug_23333.
mysql-test/r/innodb.result:
results changed
mysql-test/r/mix_innodb_myisam_binlog.result:
results changed
mysql-test/r/multi_update.result:
results changed
mysql-test/t/innodb.test:
trans table specific test added
mysql-test/t/mix_innodb_myisam_binlog.test:
multi-update and multi-delete of mixure of ta and not-ta tables tests added (relates to bug_23333).
mysql-test/t/multi_update.test:
testing another branch of mult-delete: send_eof() (binloggin there), send_error (early return)
sql/sql_class.h:
a new flag to designate the fact the statement's error has been handled.
The flag is checked by ::send_error() methods (multi_update and _delete classes)
sql/sql_delete.cc:
expanding multi_delete::send_error to
1. early return if error_handled == t
2. binlogging locally if there was a non-trans table modified side effect
sql/sql_parse.cc:
adding multi_update::send_error which can perform binlogging and rollback job in needed
sql/sql_update.cc:
issues relating to
1. bug_27716 with zeroing of `updated' to serve as the flag of early return from send_error().
The flag is changed to be a new member error_handled; also moved outside binlogging branch.
The reason for this change is that bug_23333 fixes were pushed after the bug_27716's and they
left this flaw (also no test coverage).
2. bug_30763 with assertion on trans_safe. I decide to make 2 liner fix for that bug here instead of to remove
those two assertions. This new bug test case is the same as for multi-update on the mixure of tables.
The rational for this fix:
presumption for mutli_update::trans_safe to be set to zero at
multi_update::multi_update or multi_update::initialize_tables() is incorrect.
trans_safe := false should happen only when a non-transactional table gets modified.
Therefore, at initialization the member must be be set to true.
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.
sql/log_event.cc:
changing timestamp is affirmed only by non-artificial events. Artifical FD won't change it anymore.
The simulation code is off unless server is started with the args from the opt-file.
The simulation code assumes that it will execute specific schedule generated by rpl_replication_delay.test.
sql/slave.cc:
Comments are changed to announce a new possibility to cope with
Seconds_behind_master jumping due to EOF special treatment (reset of the timestamp)
mysql-test/suite/manual/r/rpl_replication_delay.result:
result are not deterministic though there are comments saying the most probable expected
value for Seconds_behind_master
mysql-test/suite/manual/t/rpl_replication_delay-slave.opt:
bug emulation
mysql-test/suite/manual/t/rpl_replication_delay.test:
specic test for bug#29309. It's hard to make it reliable as it deals with timestamps.
(a way to automate the test like this is to have I_S table for show slave status' fields)
A possible way to check results is to run
grep -i 'show\|seconds' < suite/manual/r/rpl_replication_delay.reject and to get the lines like these:
show slave status /* Second_behind reports 0 */;;
Seconds_Behind_Master 0
show slave status /* bug emulated: reports slave threads starting time about 3*3 not 3 secs */;;
Seconds_Behind_Master 9
show slave status /* reports the correct diff with master query time about 3+3 secs */;;
Seconds_Behind_Master 6
Due to time discreteness of time the reported numbers may slightly vary. That's why the test is not reliable.
Problem: one thread could read uninitialized memory from (the stack of) another
thread.
Fix: swapped order of initializing the memory and making it available to the
other thread.
Fix: put lock around the statement that makes the memory available to the other
thread.
Fix: all fields of the struct are now initialized in the constructor, to avoid
future problems.
sql/sql_class.h:
Initialize all members in constructor for more safe future code.
sql/sql_repl.cc:
Swap order so that linfo is first initialized, then assigned, instead of the
other way around.
Put a lock around the assignment. We use LOCK_thread_count since log_in_use
uses it: log_in_use may be running concurrently, called from
MYSQL_LOG::purge_logs.
active_mi has been reset (shutdown) at the time of quering with
SHOW SLAVE STATUS so that
at handling of SHOW an attempt to read its members segfaults.
Fixed with checking the value of active_mi before to call show_master_info()
Merely send_ok() is invoked when active_mi does not exist.
A test can not be easiely written.
Notice, there are more analogical cases in the code which require a similar
treatment (to be reported as a bug separately).
sql/sql_parse.cc:
Ignore reporting and send only OK if master info struct has been destoyed.
As this must be at shutdown merely a warning is sent to the client.
added get_field_default_value() function which obtains default value from the field
(used in store_create_info() & get_schema_column_record() functions)
mysql-test/r/alter_table.result:
result fix
mysql-test/r/create.result:
result fix
mysql-test/r/ctype_collate.result:
result fix
mysql-test/r/ctype_recoding.result:
result fix
mysql-test/r/default.result:
result fix
mysql-test/r/gis.result:
result fix
mysql-test/r/grant.result:
result fix
mysql-test/r/information_schema.result:
result fix
mysql-test/r/key.result:
result fix
mysql-test/r/mysql.result:
result fix
mysql-test/r/ps_1general.result:
result fix
mysql-test/r/show_check.result:
result fix
mysql-test/r/sp.result:
result fix
mysql-test/r/type_enum.result:
result fix
mysql-test/r/type_ranges.result:
result fix
mysql-test/t/information_schema.test:
test case
The optimizer sets index traversal in reverse order only if there are
used key parts that are not compared to a constant.
However using the primary key as an ORDER BY suffix rendered the check
incomplete : going in reverse order must still be used even if
all the parts of the secondary key are compared to a constant.
Fixed by relaxing the check and set reverse traversal even when all
the secondary index keyparts are compared to a const.
Also account for the case when all the primary keys are compared to a
constant.
mysql-test/r/innodb_mysql.result:
Bug #31001: test case
mysql-test/t/innodb_mysql.test:
Bug #31001: test case
sql/sql_select.cc:
Bug #31001:
- account for the case when all the primary key parts are compared
to a constant
- force test_if_skip_sort_order to go backwards over the key even
when the number of keyparts used is the same as the number of
keyparts equal to a constant. (because of the primary key
suffix).
- The bug was caused by COUNT(DISTINCT ...) code using Unique object in
a way that assumed that BIT(N) column occupies a contiguous space in
temp_table->record[0] buffer.
- The fix is to make COUNT(DISTINCT ...) code instruct create_tmp_table to
create temporary table with column of type BIGINT, not BIT(N).
mysql-test/r/type_bit.result:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Testcase
mysql-test/t/type_bit.test:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Testcase
sql/item_sum.cc:
BUG#30324: Grouping queries with COUNT(DISTINCT bit column) return wrong results
- Make COUNT(DISTINCT ...) code instruct create_tmp_table to create
temporary table with BIGINT, not BIT(N) column.
Declaring an all space column name in the SELECT FROM DUAL or in a view
leads to misleading warning message:
"Leading spaces are removed from name ' '".
The Item::set_name method has been modified to raise warnings like
"Name ' ' has become ''" in case of the truncation of an all
space identifier to an empty string identifier instead of the
"Leading spaces are removed from name ' '" warning message.
sql/item.cc:
Fixed bug #27695.
The Item::set_name method has been modified to raise warnings like
"Name ' ' has become ''" in case of the truncation of an all
space identifier to an empty string identifier instead of the
"Leading spaces are removed from name ' '" warning message.
sql/share/errmsg.txt:
Fixed bug #27695.
mysql-test/t/select.test:
Added test case for bug #27695.
mysql-test/r/select.result:
Added test case for bug #27695.
in get_index_for_order(), don't walk over the end of the index key parts
when matching index description and needed ordering.
mysql-test/r/delete.result:
BUG#30385: Testcase
mysql-test/t/delete.test:
BUG#30385: Testcase
into weblab.(none):/home/marcsql/TREE/mysql-5.0-rt-merge
mysql-test/r/sp.result:
Auto merged
mysql-test/t/mysql.test:
Auto merged
mysql-test/t/sp.test:
Auto merged
DELETE FROM ... USING ... statements with the following type of
ambiguous aliasing gave unexpected results:
DELETE FROM t1 AS alias USING t1, t2 AS alias WHERE t1.a = alias.a;
This query would leave table t1 intact but delete rows from t2.
Fixed by changing DELETE FROM ... USING syntax so that only alias
references (as opposed to alias declarations) may be used in FROM.
mysql-test/r/delete.result:
Bug#30234: Test Result
mysql-test/t/delete.test:
Bug#30234: Test Case
sql/sql_yacc.yy:
Bug#30234:
- Added parser rule table_alias_ref_list that contains a list of table
aliases only.
- Added parser rule table_alias_ref that sets the TL_OPTION_ALIAS in
order to turn off semantic checking that applies only for table names.
Invaldating a subset of a sufficiently large query cache can take a long time.
During this time the server is efficiently frozen and no other operation can
be executed. This patch addresses this problem by setting a time limit on
how long time a dictionary access request can take before giving up on the
attempt. This patch does not work for query cache invalidations issued by
DROP, ALTER or RENAME TABLE operations.
sql/sql_cache.cc:
Changed mutex locking to a timed spinn lock. If access to query cache dictionary
takes "a long time" (currently more than 0.1 seconds) the system fall backs on
ordinary statement execution.
Use view db name as thread default database, in order to ensure
that the view is parsed and prepared correctly.
mysql-test/r/sp.result:
test result
mysql-test/t/sp.test:
test case
sql/sql_parse.cc:
copy thd->db_length to table_list->db_length
sql/sql_view.cc:
Use view db name as thread default database, in order to ensure
that the view is parsed and prepared correctly.
When dumping database from a 4.x server, the mysqldump client
inserted a delimiter sign inside special commentaries of the form:
/*!... CREATE DATABASE IF NOT EXISTS ... ;*/
During restoration that dump file was splitten by delimiter signs on
the client side, and the rest of some commentary strings was prepended
to following statements.
The 4x_server_emul test case option has been added for use with the
DBUG_EXECUTE_IF debugging macro. This option affects debug server
builds only to emulate particular behavior of a 4.x server for
the mysqldump client testing. Non-debugging builds are not affected.
mysql-test/r/mysqldump-compat.result:
Added test case for bug #30126.
mysql-test/t/mysqldump-compat.opt:
Added test case for bug #30126.
mysql-test/t/mysqldump-compat.test:
Added test case for bug #30126.
sql/sql_parse.cc:
Fixed bug #30126.
The mysqldump client uses the "SHOW CREATE DATABASE" query to
obtain the "CREATE DATABASE" statement from that database.
The 4.x server doesn't recognise that query, and mysqldump
forms the "CREATE DATABASE" statement from scratch.
That statement was formed incorrectly.
To enforce the mysqldump client to create that statement from
scratch, debugging code has been added to the mysql_execute_command
function: in tcase of the --loose-debug=d,4x_server_emul option,
the server returns parse error to client to emulate old behaviour.
The 4x_server_emul test case option has been added for use with the
DBUG_EXECUTE_IF debugging macro. This option affects debug server
builds only to emulate particular behavior of a 4.x server for
the mysqldump client testing. Non-debugging builds are not affected.
client/mysqldump.c:
Fixed bug #30126.
The init_dumping_tables function has been modified to output semicolon
outside of commentaries.
The problem is that a SELECT on one thread is blocked by INSERT ... ON
DUPLICATE KEY UPDATE on another thread even when low_priority_updates is
activated.
The solution is to possibly downgrade the lock type to the setting of
low_priority_updates if the INSERT cannot be concurrent.
sql/sql_insert.cc:
Possibly downgrade lock type to the the setting of low_priority_updates if
if the INSERT cannot be concurrent.
comments)
Before this fix, the server would accept queries that contained comments,
even when the comments were not properly closed with a '*' '/' marker.
For example,
select 1 /* + 2 <EOF>
would be accepted as
select 1 /* + 2 */ <EOF>
and executed as
select 1
With this fix, the server now rejects queries with unclosed comments
as syntax errors.
Both regular comments ('/' '*') and special comments ('/' '*' '!') must be
closed with '*' '/' to be parsed correctly.
mysql-test/r/comments.result:
Unbalanced comments are a syntax error.
mysql-test/t/comments.test:
Unbalanced comments are a syntax error.
sql/sql_lex.cc:
Unbalanced comments are a syntax error.