Commit graph

35 commits

Author SHA1 Message Date
Kristian Nielsen
16aa4b5f59 Merge from 10.4 to 10.5
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-04-15 17:46:49 +02:00
Oleksandr Byelkin
f291c3df2c Merge branch '10.4' into 10.5 2023-07-27 15:43:21 +02:00
Lena Startseva
9854fb6fa7 MDEV-31003: Second execution for ps-protocol
This patch adds for "--ps-protocol" second execution
of queries "SELECT".
Also in this patch it is added ability to disable/enable
(--disable_ps2_protocol/--enable_ps2_protocol) second
execution for "--ps-prototocol" in testcases.
2023-07-26 17:15:00 +07:00
Marko Mäkelä
cc2651b74c Merge 10.4 into 10.5 2021-05-18 09:21:59 +03:00
Sujatha
410e3c1a9a MDEV-17515: GTID Replication in optimistic mode deadlock
Problem:
=======
In slave_parallel_mode=optimistic configuration, when admin commands and
DML operation on the same table are scheduled simultaneously for execution,
it results in lock conflict and slave server either hangs due to
deadlock or goes down with an assert.

Analysis:
========
Admin commands OPTIMIZE, REPAIR and ANALYZE are written to binary log as
ordinary transactions. When 'slave_parallel_mode' is 'optimistic' DMLs are
allowed to run in parallel. But these locks are not detected by parallel
replication deadlock detection-and-handling mechanism. At times they result
in deadlock or assertion.

Fix:
===
Flag admin commands as DDL in Gtid_log_event at the time of writing to
binary log. Add a new bit EXECUTED_TABLE_ADMIN_CMD to
'm_unsafe_rollback_flags'. During 'mysql_admin_table' command execution it
accepts a list of tables to be processed and executes them in a loop. Upon
successful execution enable 'EXECUTED_TABLE_ADMIN_CMD' bit in
thd->transaction.stmt_unsafe_rollback_flags. Gtid_log_event constructor
will notice this flag and mark the current transaction with 'FL_DDL' flag.
Gtid_log_events marked as FL_DDL will not be scheduled parallel execution,
on the slave. They will execute in isolation to prevent deadlocks.

Note: Removed the call to 'trans_commit_implicit' from 'mysql_admin_table'
function as 'mysql_execute_command' will take care of invoking
'trans_commit_implicit'.
2021-05-17 16:38:58 +05:30
Monty
4102f1589c Aria will now register it's transactions
MDEV-22531 Remove maria::implicit_commit()
MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in
           MYSQL_BIN_LOG::unlog_xa_prepare

From the handler point of view, Aria now looks like a transactional
engine. One effect of this is that we don't need to call
maria::implicit_commit() anymore.

This change also forces the server to call trans_commit_stmt() after doing
any read or writes to system tables.  This work will also make it easier
to later allow users to have system tables in other engines than Aria.

To handle the case that Aria doesn't support rollback, a new
handlerton flag, HTON_NO_ROLLBACK, was added to engines that has
transactions without rollback (for the moment only binlog and Aria).

Other things
- Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE
  can be still part of a transaction even if the table has closed.
- Changed Aria checkpoint to use the new MARIA_SHARE free function. This
  fixes a possible memory leak when using S3 tables
- Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK
- Removed checking of has_transaction_manager() in handler.cc as we can
  assume that as the transaction was started by the engine, it does
  support transactions.
- Added new class 'start_new_trans' that can be used to start indepdendent
  sub transactions, for example while reading mysql.proc, using help or
  status tables etc.
- open_system_tables...() and open_proc_table_for_Read() doesn't anymore
  take a Open_tables_backup list. This is now handled by 'start_new_trans'.
- Split thd::has_transactions() to thd::has_transactions() and
  thd::has_transactions_and_rollback()
- Added handlerton code to free cached transactions objects.
  Needed by InnoDB.

squash! 2ed35999f2a2d84f1c786a21ade5db716b6f1bbc
2020-05-23 12:29:10 +03:00
Nirbhay Choubey
8b2e642aa2 MDEV-7635: Update tests to adapt to the new default sql_mode 2017-02-10 06:30:42 -05:00
Sergei Golubchik
b38ff28ade bugfix: mark_columns_needed_for_update
cannot use TABLE:merge_keys for that, because Field::part_of_key
was designed to mark fields for KEY_READ, so a field is not a
"part of key", if only prefix of the field is.
2016-12-12 20:27:36 +01:00
Michael Widenius
7ffc9da093 Implementation of MDEV-5491: CREATE OR REPLACE TABLE
Using CREATE OR REPLACE TABLE is be identical to

DROP TABLE IF EXISTS table_name;
CREATE TABLE ...;

Except that:

* CREATE OR REPLACE is be atomic (now one can create the same table between drop and create).
* Temporary tables will not shadow the table name for the DROP as the CREATE TABLE tells us already if we are using a temporary table or not.
* If the table was locked with LOCK TABLES, the new table will be locked with the same lock after it's created.

Implementation details:
- We don't anymore open the to-be-created table during CREATE TABLE, which the original code did.
  - There is no need to open a table we are planning to create. It's enough to check if the table exists or not.
- Removed some of duplicated code for CREATE IF NOT EXISTS.
- Give an error when using CREATE OR REPLACE with IF NOT EXISTS (conflicting options).
- As a side effect of the code changes, we don't anymore have to internally re-prepare prepared statements with CREATE TABLE if the table exists.
- Made one code path for all testing if log table are in use.
- Better error message if one tries to create/drop/alter a log table in use
- Added back disabled rpl_row_create_table test as it now seams to work and includes a lot of interesting tests.
- Added HA_LEX_CREATE_REPLACE to mark if we are using CREATE OR REPLACE
- Aligned CREATE OR REPLACE parsing code in sql_yacc.yy for TABLE and VIEW
- Changed interface for drop_temporary_table() to make it more reusable
- Changed Locked_tables_list::init_locked_tables() to work on the table object instead of the table list object. Before this it used a mix of both, which was not good.
- Locked_tables_list::unlock_locked_tables(THD *thd) now requires a valid thd argument. Old usage of calling this with 0 i changed to instead call Locked_tables_list::reset()
- Added functions Locked_tables_list:restore_lock() and Locked_tables_list::add_back_last_deleted_lock() to be able to easily add back a locked table to the lock list.
- Added restart_trans_for_tables() to be able to restart a transaction.
- DROP_ACL is required if one uses CREATE TABLE OR REPLACE.
- Added drop of normal and temporary tables in create_table_imp() if CREATE OR REPLACE was used.
- Added reacquiring of table locks in mysql_create_table() and mysql_create_like_table()




mysql-test/include/commit.inc:
  With new code we get fewer status increments
mysql-test/r/commit_1innodb.result:
  With new code we get fewer status increments
mysql-test/r/create.result:
  Added testing of create or replace with timeout
mysql-test/r/create_or_replace.result:
  Basic testing of CREATE OR REPLACE TABLE
mysql-test/r/partition_exchange.result:
  New error message
mysql-test/r/ps_ddl.result:
  Fewer reprepares with new code
mysql-test/suite/archive/discover.result:
  Don't rediscover archive tables if the .frm file exists
  (Sergei will look at this if there is a better way...)
mysql-test/suite/archive/discover.test:
  Don't rediscover archive tables if the .frm file exists
  (Sergei will look at this if there is a better way...)
mysql-test/suite/funcs_1/r/innodb_views.result:
  New error message
mysql-test/suite/funcs_1/r/memory_views.result:
  New error message
mysql-test/suite/rpl/disabled.def:
  rpl_row_create_table should now be safe to use
mysql-test/suite/rpl/r/rpl_row_create_table.result:
  Updated results after adding back disabled test
mysql-test/suite/rpl/t/rpl_create_if_not_exists.test:
  Added comment
mysql-test/suite/rpl/t/rpl_row_create_table.test:
  Added CREATE OR REPLACE TABLE test
mysql-test/t/create.test:
  Added CREATE OR REPLACE TABLE test
mysql-test/t/create_or_replace-master.opt:
  Create logs
mysql-test/t/create_or_replace.test:
  Basic testing of CREATE OR REPLACE TABLE
mysql-test/t/partition_exchange.test:
  Error number changed as we are now using same code for all log table change issues
mysql-test/t/ps_ddl.test:
  Fewer reprepares with new code
sql/handler.h:
  Moved things around a bit in a structure to get better alignment.
  Added HA_LEX_CREATE_REPLACE to mark if we are using CREATE OR REPLACE
  Added 3 elements to end of HA_CREATE_INFO to be able to store state to add backs locks in case of LOCK TABLES.
sql/log.cc:
  Reimplemented check_if_log_table():
  - Simpler and faster usage
  - Can give error messages
  
  This gives us one code path for allmost all error messages if log tables are in use
sql/log.h:
  New interface for check_if_log_table()
sql/slave.cc:
  More logging
sql/sql_alter.cc:
  New interface for check_if_log_table()
sql/sql_base.cc:
  More documentation
  Changed interface for drop_temporary_table() to make it more reusable
  Changed Locked_tables_list::init_locked_tables() to work on the table object instead of the table list object. Before this it used a mix of both, which was not good.
  Locked_tables_list::unlock_locked_tables(THD *thd) now requires a valid thd argument.  Old usage of calling this with 0 i changed to instead call Locked_tables_list::reset()
  Added functions Locked_tables_list:restore_lock() and Locked_tables_list::add_back_last_deleted_lock() to be able to easily add back a locked table to the lock list.
  Check for command number instead of open_strategy of CREATE TABLE was used.
  Added restart_trans_for_tables() to be able to restart a transaction.  This was needed in "create or replace ... select" between the drop table and the select.
sql/sql_base.h:
  Added and updated function prototypes
sql/sql_class.h:
  Added new prototypes to Locked_tables_list class
  Added extra argument to select_create to avoid double call to eof() or send_error()
  - I needed this in some edge case where the table was not created against expections.
sql/sql_db.cc:
  New interface for check_if_log_table()
sql/sql_insert.cc:
  Remember position to lock information so that we can reaquire table lock for LOCK TABLES + CREATE OR REPLACE TABLE SELECT. Later add back the lock by calling restore_lock().
  Removed one not needed indentation level in create_table_from_items()
  Ensure we don't call send_eof() or abort_result_set() twice.
sql/sql_lex.h:
  Removed variable that I temporarly added in an earlier changeset
sql/sql_parse.cc:
  Removed old test code (marked with QQ)
  Ensure that we have open_strategy set as TABLE_LIST::OPEN_STUB in CREATE TABLE
  Removed some IF NOT EXISTS code as this is now handled in create_table_table_impl().
  Set OPTION_KEEP_LOGS later. This code had to be moved as the test for IF EXISTS has changed place.
  DROP_ACL is required if one uses CREATE TABLE OR REPLACE.
sql/sql_partition_admin.cc:
  New interface for check_if_log_table()
sql/sql_rename.cc:
  New interface for check_if_log_table()
sql/sql_table.cc:
  New interface for check_if_log_table()
  Moved some code in mysql_rm_table() under a common test.
  - Safe as temporary tables doesn't have statistics.
  - !is_temporary_table(table) test was moved out from drop_temporary_table() and merged with upper level code.
  - Added drop of normal and temporary tables in create_table_imp() if CREATE OR REPLACE was used.
  - Added reacquiring of table locks in mysql_create_table() and mysql_create_like_table()
  - In mysql_create_like_table(), restore table->open_strategy() if it was changed.
  - Re-test if table was a view after opening it.
sql/sql_table.h:
  New prototype for mysql_create_table_no_lock()
sql/sql_yacc.yy:
  Added syntax for CREATE OR REPLACE TABLE
  Reuse new code for CREATE OR REPLACE VIEW
sql/table.h:
  Added name for enum type
sql/table_cache.cc:
  More DBUG
2014-01-29 15:37:17 +02:00
Sergei Golubchik
f171d3ff79 commit_1innodb.test: update results from 5.6 2013-07-09 18:43:12 +02:00
Rohit Kalhans
0122a138e4 BUG#11758262 BUG#13043055:
Fix for commit_1innodb failure on pb2.

Background: as status increment differs for an unsafe statement 
when logged in stmt and row format,  mtr throws a content mismatch
error.

Fix:  call p_verify_status_increment with different arguments
for loging format as stmt and row/mixed and disable query log.
2011-10-03 16:05:52 +05:30
Rohit Kalhans
0e6afc7f6b BUG#11758262 BUG#13043055
Problem: commit_1innodb fails on pb2 after the patch for BUG#11758262
Background: Certain statements threw warnings only in statement mode causing
the result cintent mismatch.

Fix: disabled warnings from the statements.
2011-09-30 15:16:35 +05:30
Alfranio Correia
318bdb6c66 merge mysql-5.1 --> mysql-5.5
Conflicts:
  
  . mysql-test/extra/rpl_tests/rpl_insert_ignore.test
  . mysql-test/suite/rpl/t/disabled.def
  . mysql-test/suite/rpl/t/rpl_insert_ignore.test
  . sql/sql_insert.cc
  . sql/sql_repl.cc
2011-01-31 13:11:05 +00:00
Alfranio Correia
8ce9b99246 BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR
In SBR, if a statement does not fail, it is always written to the binary
log, regardless if rows are changed or not. If there is a failure, a
statement is only written to the binary log if a non-transactional (.e.g.
MyIsam) engine is updated.

INSERT ON DUPLICATE KEY UPDATE and INSERT IGNORE were not following the
rule above and were not written to the binary log, if then engine was
Innodb.

mysql-test/extra/rpl_tests/rpl_insert_duplicate.test:
  Added test case.
mysql-test/extra/rpl_tests/rpl_insert_ignore.test:
  Updated test case.
mysql-test/include/commit.inc:
  Updated test case as the calls to the binary log have changed
  for INSERT ON DUPLICATE and INSERT IGNORE.
mysql-test/r/commit_1innodb.result:
  Updated result file.
mysql-test/suite/rpl/r/rpl_insert_duplicate.result:
  Added test case.
mysql-test/suite/rpl/r/rpl_insert_ignore.result:
  Updated result file.
mysql-test/suite/rpl/t/rpl_insert_duplicate.test:
  Added test case.
mysql-test/suite/rpl/t/rpl_insert_ignore.test:
  Improved test case.
2011-01-28 12:09:15 +00:00
unknown
d0d8bbed5e WL#5370 Keep forward-compatibility when changing
'CREATE TABLE IF NOT EXISTS ... SELECT' behaviour
BUG#47132, BUG#47442, BUG49494, BUG#23992 and BUG#48814 will disappear
automatically after the this patch.
BUG#55617 is fixed by this patch too.
            
This is the 5.5 part.
It implements:
- 'CREATE TABLE IF NOT EXISTS ... SELECT' statement will not insert
  anything and binlog anything if the table already exists.
  It only generate a warning that table already exists.
- A couple of test cases for the behavior changing.
2010-08-18 17:35:41 +08:00
Davi Arnaut
b0035c76d4 Bug#54453: Failing assertion: trx->active_trans when renaming a
table with active trx

Essentially, the problem is that InnoDB does a implicit commit
when a cursor (table handler) is unlocked/closed, creating
a dissonance between the transaction state within the server
layer and the storage engine layer. Theoretically, a statement
transaction can encompass several table instances in a similar
manner to a multiple statement transaction, hence it does not
make sense to limit a statement transaction to the lifetime of
the table instances (cursors) used within it.

Since this particular instance of the problem is only triggerable
on 5.1 and is masked on 5.5 due 2PC being skipped (assertion is in
the prepare phase of a 2PC), the solution (which is less risky) is
to explicitly end the transaction before the cached table is unlock
on rename table.

The patch is to be null merged into trunk.

mysql-test/include/commit.inc:
  Fix counters, the binlog engine does not get involved anymore.
mysql-test/suite/innodb_plugin/r/innodb_bug54453.result:
  Add test case result for Bug#54453
mysql-test/suite/innodb_plugin/t/innodb_bug54453.test:
  Add test case for Bug#54453
sql/sql_table.cc:
  End transaction as otherwise InnoDB will end it behind our backs.
2010-07-20 14:36:15 -03:00
Alfranio Correia
dbf7c215ce BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a
transaction
BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW

Post-merge fixes.


mysql-test/include/commit.inc:
  Changed the test case as drop temporary is now written to the binary log in row mode.
mysql-test/r/commit_1innodb.result:
  Changed the test case as drop temporary is now written to the binary log in row mode.
mysql-test/r/ctype_cp932_binlog_stm.result:
  Disabled warning messages because the test runs in both statement and mixed modes.
mysql-test/t/ctype_cp932_binlog_stm.test:
  Disabled warning messages because the test runs in both statement and mixed modes.
mysql-test/t/mysqlbinlog.test:
  Removed the --short-form due to BUG#18337 what was suppressing the
  select * from t5 /* must be (1),(1) */ in row format.
2010-04-21 14:28:00 +01:00
Konstantin Osipov
e7b332ba83 Merge next-mr -> next-4284. 2010-02-05 01:08:08 +03:00
Konstantin Osipov
3543d2556d Backport of:
------------------------------------------------------------
revno: 2630.13.16
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: WL#4284
timestamp: Sat 2008-07-26 13:38:20 -0300
message:
WL#4284: Transactional DDL locking

SQL statements' effect on transactions.

Currently the MySQL server and its storage engines are not
capable of rolling back operations that define or modify data
structures (also known as DDL statements) or operations that
alter any of the system tables (the mysql database). Allowing
these group of statements to participate in transactions
is unfeasible at this time (since rollback has no effect
whatsoever on them) and goes against the design of our metadata
locking subsystem.

The solution is to issue implicit commits before and after
those statements execution. This effectively confines each of
those statements to its own special transaction and ensures
that metadata locks taken during this special transaction
are not leaked into posterior statements/transactions.


mysql-test/include/commit.inc:
  Alter table rename was not committing the normal transaction at the
  end of its execution, and as a consequence, the commit was being
  issued in the next DDL command (rename table) that happened to end
  the active transaction. Other changes are to take into account the
  implicit commits issued before and after the DDL command execution.
mysql-test/include/implicit_commit_helper.inc:
  Add auxiliary test that shows if a statement issued a 
  implicit commit.
mysql-test/r/commit_1innodb.result:
  
  Update test case result.
mysql-test/r/implicit_commit.result:
  Test implicit commit behavior of some SQL commands.
mysql-test/t/implicit_commit.test:
  Test implicit commit behavior of some SQL commands.
sql/events.cc:
  Transaction is now ended before the command execution.
sql/mysql_priv.h:
  Add flags array for server commands and remove historical 
  left over.
sql/sql_class.h:
  Add flags to control when to issue implicit commits before and
  after a command execution.
sql/sql_delete.cc:
  A implicit commit is issued at the end of truncate
  statements.
sql/sql_parse.cc:
  Mark commands that need implicit commits before and
  after their executions. The implicit commits of the
  statement and the normal transaction are now issued
  regardless of the user access privileges.
sql/sql_table.cc:
  A implicit commit is now issued before admin commands.
tests/mysql_client_test.c:
  Test that COM_REFRESH issues a implicit commit.
2009-12-03 18:47:20 +03:00
Alfranio Correia
19c380aaff WL#2687 WL#5072 BUG#40278 BUG#47175
Non-transactional updates that take place inside a transaction present problems
for logging because they are visible to other clients before the transaction
is committed, and they are not rolled back even if the transaction is rolled
back. It is not always possible to log correctly in statement format when both
transactional and non-transactional tables are used in the same transaction.

In the current patch, we ensure that such scenario is completely safe under the
ROW and MIXED modes.
2009-11-03 19:02:56 +00:00
Alfranio Correia
6c2b32515e BUG#28976 Mixing trans and non-trans tables in one transaction results in incorrect
binlog

Mixing transactional (T) and non-transactional (N) tables on behalf of a
transaction may lead to inconsistencies among masters and slaves in STATEMENT
mode. The problem stems from the fact that although modifications done to
non-transactional tables on behalf of a transaction become immediately visible
to other connections they do not immediately get to the binary log and therefore
consistency is broken. Although there may be issues in mixing T and M tables in
STATEMENT mode, there are safe combinations that clients find useful.

In this bug, we fix the following issue. Mixing N and T tables in multi-level
(e.g. a statement that fires a trigger) or multi-table table statements (e.g.
update t1, t2...) were not handled correctly. In such cases, it was not possible
to distinguish when a T table was updated if the sequence of changes was N and T.
In a nutshell, just the flag "modified_non_trans_table" was not enough to reflect
that both a N and T tables were changed. To circumvent this issue, we check if an
engine is registered in the handler's list and changed something which means that
a T table was modified.

Check WL 2687 for a full-fledged patch that will make the use of either the MIXED or
ROW modes completely safe.

mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
2009-08-27 00:13:03 +01:00
Alfranio Correia
18bd3cd5f3 Post-fix for BUG#43929. 2009-06-19 12:27:24 +01:00
Alfranio Correia
3cf052b76c BUG#43929 binlog corruption when max_binlog_cache_size is exceeded
Large transactions and statements may corrupt the binary log if the size of the
cache, which is set by the max_binlog_cache_size, is not enough to store the
the changes.

In a nutshell, to fix the bug, we save the position of the next character in the
cache before starting processing a statement. If there is a problem, we simply
restore the position thus removing any effect of the statement from the cache.
Unfortunately, to avoid corrupting the binary log, we may end up loosing changes
on non-transactional tables if they do not fit in the cache. In such cases, we
store an Incident_log_event in order to stop the slave and alert users that some
changes were not logged.

Precisely, for every non-transactional changes that do not fit into the cache,
we do the following:
  a) the statement is *not* logged
  b) an incident event is logged after committing/rolling back the transaction,
  if any. Note that if a failure happens before writing the incident event to
  the binary log, the slave will not stop and the master will not have reported
  any error.
  c) its respective statement gives an error

For transactional changes that do not fit into the cache, we do the following:
  a) the statement is *not* logged
  b) its respective statement gives an error

To work properly, this patch requires two additional things. Firstly, callers to
MYSQL_BIN_LOG::write and THD::binlog_query must handle any error returned and
take the appropriate actions such as undoing the effects of a statement. We
already changed some calls in the sql_insert.cc, sql_update.cc and sql_insert.cc
modules but the remaining calls spread all over the code should be handled in
BUG#37148. Secondly, statements must be either classified as DDL or DML because
DDLs that do not get into the cache must generate an incident event since they
cannot be rolled back.
2009-06-18 14:52:46 +01:00
Luis Soares
df8543868d merge: 5.1 -> 5.1-rpl
conflicts:
  Text conflict in client/mysqltest.cc
  Text conflict in mysql-test/include/wait_until_connected_again.inc
  Text conflict in mysql-test/lib/mtr_report.pm
  Text conflict in mysql-test/mysql-test-run.pl
  Text conflict in mysql-test/r/events_bugs.result
  Text conflict in mysql-test/r/log_state.result
  Text conflict in mysql-test/r/myisam_data_pointer_size_func.result
  Text conflict in mysql-test/r/mysqlcheck.result
  Text conflict in mysql-test/r/query_cache.result
  Text conflict in mysql-test/r/status.result
  Text conflict in mysql-test/suite/binlog/r/binlog_index.result
  Text conflict in mysql-test/suite/binlog/r/binlog_innodb.result
  Text conflict in mysql-test/suite/rpl/r/rpl_packet.result
  Text conflict in mysql-test/suite/rpl/t/rpl_packet.test
  Text conflict in mysql-test/t/disabled.def
  Text conflict in mysql-test/t/events_bugs.test
  Text conflict in mysql-test/t/log_state.test
  Text conflict in mysql-test/t/myisam_data_pointer_size_func.test
  Text conflict in mysql-test/t/mysqlcheck.test
  Text conflict in mysql-test/t/query_cache.test
  Text conflict in mysql-test/t/rpl_init_slave_func.test
  Text conflict in mysql-test/t/status.test
2009-01-23 13:22:05 +01:00
Davi Arnaut
d1323f433d Post-merge fix for bug 37016: Update test case for row-based logging.
mysql-test/r/commit_1innodb.result:
  Increase commit count for row-based logging.
2009-01-12 10:48:33 -02:00
Davi Arnaut
8dbb9c885d Bug#37016: TRUNCATE TABLE removes some rows but not all
The special TRUNCATE TABLE (DDL) transaction wasn't being properly
rolled back if a error occurred during row by row deletion. The
error can be caused by a foreign key restriction imposed by InnoDB
SE and would cause the server to erroneously issue a implicit
commit.

The solution is to rollback the transaction if a truncation via row
by row deletion fails, otherwise commit. All effects of a TRUNCATE 
ABLE operation are rolled back if a row by row deletion fails.

mysql-test/include/commit.inc:
  Truncate always starts a transaction and commits at the end.
  The commit at the end increases the count by two, one is the
  storage engine commit and the other is the binary log.
mysql-test/r/commit_1innodb.result:
  Update test case results.
mysql-test/r/innodb_mysql.result:
  Update test case results.
mysql-test/t/innodb_mysql.test:
  Add test case for Bug#37016
sql/sql_delete.cc:
  Move truncation using row by row deletion to its own function.
  If row by row deletion fails, rollback the transaction.
  
  Remove the meddling with disabling and enabling of autocommit
  as TRUNCATE transaction is now explicitly ended (committed
  or rolled back).
2009-01-09 08:20:32 -02:00
Andrei Elkin
5753307aef Bug #41383 Test commit1_innodb fails with binlog-format=row
The test explicitly warned on existence of a bug in its 27th part.
The expected values of prepare and commit counters changed, corrected, by
fixes to bug#40221.
Notice, that binlog does not have to register for a statement with
the statement binlog-format because the statement rollback does not need
to do anything in that mode. It's not so with the ROW format which was
bug#40221 concern.

Fixed with correcting the expected values of the mentioned counters and
explained that with comments in the test.

mysql-test/include/commit.inc:
  Removing `Sic' that warned on a bug (The one is bug#40221).
  Correcting the expected values of prepare and commit counters due to fixes to bug#40221.
mysql-test/r/commit_1innodb.result:
  results changed.
2008-12-12 14:52:20 +02:00
unknown
3ad402570d Merge pilot.mysql.com:/data/msvensson/mysql/mysql-5.1-rpl
into  pilot.mysql.com:/data/msvensson/mysql/mysql-5.1-mtr


BitKeeper/etc/ignore:
  auto-union
BitKeeper/deleted/.del-rpl_row_charset.test:
  Auto merged
CMakeLists.txt:
  Auto merged
configure.in:
  Auto merged
client/mysqltest.c:
  Auto merged
mysql-test/extra/binlog_tests/blackhole.test:
  Auto merged
mysql-test/include/commit.inc:
  Auto merged
mysql-test/include/mix1.inc:
  Auto merged
mysql-test/lib/mtr_report.pm:
  Auto merged
mysql-test/r/commit_1innodb.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/ctype_big5.result:
  Auto merged
mysql-test/r/drop.result:
  Auto merged
mysql-test/r/group_by.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/r/loaddata.result:
  Auto merged
mysql-test/r/mysqlbinlog.result:
  Auto merged
mysql-test/r/partition_error.result:
  Auto merged
mysql-test/r/query_cache.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/r/warnings.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_stm_blackhole.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Auto merged
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Auto merged
mysql-test/suite/federated/federated.result:
  Auto merged
mysql-test/suite/federated/federated.test:
  Auto merged
mysql-test/suite/parts/r/partition_alter1_myisam.result:
  Auto merged
mysql-test/suite/parts/r/partition_alter2_myisam.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_row_log.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_row_log_innodb.result:
  Auto merged
mysql-test/suite/rpl/t/disabled.def:
  Auto merged
mysql-test/suite/rpl/t/rpl_flushlog_loop.test:
  Auto merged
mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result:
  Auto merged
mysql-test/suite/rpl_ndb/t/rpl_ndb_transaction.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/csv.test:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/distinct.test:
  Auto merged
mysql-test/t/drop.test:
  Auto merged
mysql-test/t/group_by.test:
  Auto merged
mysql-test/t/innodb.test:
  Auto merged
mysql-test/t/loaddata.test:
  Auto merged
mysql-test/t/partition_error.test:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
mysql-test/t/warnings.test:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
BitKeeper/deleted/.del-combinations:
  Delete: mysql-test/suite/binlog/combinations
mysql-test/r/partition_not_windows.result:
  Use remote
mysql-test/r/partition_symlink.result:
  Use remote
mysql-test/r/symlink.result:
  SCCS merged
mysql-test/suite/parts/inc/partition_basic.inc:
  SCCS merged
mysql-test/suite/parts/inc/partition_check_drop.inc:
  Use remote
mysql-test/suite/parts/inc/partition_layout_check1.inc:
  Use remote
mysql-test/suite/parts/inc/partition_layout_check2.inc:
  Use remote
mysql-test/suite/parts/r/partition_basic_innodb.result:
  Use remote
mysql-test/suite/parts/r/partition_basic_myisam.result:
  Use remote
mysql-test/suite/parts/r/partition_engine_myisam.result:
  Use remote
mysql-test/suite/parts/t/partition_sessions.test:
  SCCS merged
mysql-test/t/partition.test:
  SCCS merged
mysql-test/t/partition_not_windows.test:
  Use remote
mysql-test/t/partition_symlink.test:
  Use remote
mysql-test/t/symlink.test:
  Use remote
mysql-test/suite/binlog/r/binlog_multi_engine.result:
  Manual merge, name of binlog file changed
mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test:
  Manual merge
mysys/my_init.c:
  Manual merge
2008-04-03 11:50:43 +02:00
unknown
600a664a5a Updating commit.inc since the number of commits done for non-transactional
tables is not zero any more. For row-based logging, there is an extra commit
for sending rows changed by the statement to the binary log.


mysql-test/include/commit.inc:
  For row-based logging, an extra commit is done for each statement to commit
  non-transactional changes to the binary log.
mysql-test/r/commit_1innodb.result:
  Result change.
2008-03-31 11:29:03 +02:00
unknown
bd02573610 After merge fixes
mysql-test/include/commit.inc:
  Adjust path
  Add missing drop tables
mysql-test/mysql-test-run.pl:
  Remove duplicate printout
mysql-test/lib/mtr_report.pm:
  Only print each test that has failed once
mysql-test/r/commit_1innodb.result:
  Adjust path
  Add missing drop table
mysql-test/suite/binlog/r/binlog_multi_engine.result:
  Remove merge error - extra s
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Remove drop of non existing view
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Remove drop of non existing view
2008-03-26 07:22:42 +01:00
unknown
774d21cf3b Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.1
into  dl145h.mysql.com:/data0/mkindahl/mysql-5.1-rpl


mysql-test/include/commit.inc:
  Auto merged
mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/r/commit_1innodb.result:
  Auto merged
mysql-test/r/variables.result:
  Auto merged
mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/log.cc:
  Auto merged
sql/rpl_rli.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2008-03-14 18:32:01 +01:00
unknown
3155a88d6c Fixed test failures caused by insufficient cleanups in the tests for
bug12713.
2008-03-12 16:52:29 +03:00
unknown
875ad6d8b8 BUG#31168: @@hostname does not replicate
Problem: in mixed and statement mode, a query that refers to a
system variable will use the slave's value when replayed on
slave. So if the value of a system variable is inserted into a
table, the slave will differ from the master.
Fix: mark statements that refer to a system variable as "unsafe",
meaning they will be replicated by row in mixed mode and produce a warning
in statement mode. There are some exceptions: some variables are actually
replicated. Those should *not* be marked as unsafe.
BUG#34732: mysqlbinlog does not print default values for auto_increment variables
Problem: mysqlbinlog does not print default values for some variables,
including auto_increment_increment and others. So if a client executing
the output of mysqlbinlog has different default values, replication will
be wrong.
Fix: Always print default values for all variables that are replicated.
I need to fix the two bugs at the same time, because the test cases would
fail if I only fixed one of them.


include/m_ctype.h:
  Added definition of ILLEGAL_CHARSET_INFO_NUMBER. We just need a symbol
  for a number that will never be used by any charset. ~0U should be safe
  since charset numbers are sequential, starting from 0.
mysql-test/include/commit.inc:
  Upated test to avoid making statements unsafe.
mysql-test/r/commit_1innodb.result:
  Updated test needs updated result file.
mysql-test/r/mysqlbinlog.result:
  Updated result file.
mysql-test/r/mysqlbinlog2.result:
  Updated result file.
mysql-test/r/user_var-binlog.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_base64_flag.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result:
  Updated result file.
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Modified test file needs modified result file.
mysql-test/suite/binlog/t/binlog_base64_flag.test:
  Need to filter out pseudo_thread_id from result since it is
  nondeterministic.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Add tests that using variables is unsafe. The 'CREATE VIEW' tests didn't
  make sense, so I removed them. SHOW WARNINGS is not necessary either,
  because we get warnings for each statement in the result file.
mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result:
  Updated result file.
mysql-test/suite/rpl/r/rpl_skip_error.result:
  Updated result file.
mysql-test/suite/rpl/t/rpl_skip_error.test:
  The test used @@server_id, which is not safe to replicate, so it would
  have given a warning. The way it used @@server_id was hackish (issue a
  query on master that removes rows only on master), so I replaced it by a
  more robust way to do the same thing (connect to slave and insert the
  rows only there).
  Also clarified what the test case does.
mysql-test/t/mysqlbinlog2.test:
  Use --short-form instead of manually filtering out nondeterministic stuff
  from mysqlbinlog (because we added the nondeterministic @@pseudo_thread_id
  to the output).
sql/item_func.cc:
  Added method of Item_func_get_system_var that indicates whether the given
  system variable will be written to the binlog or not.
sql/item_func.h:
  Added method of Item_func_get_system_var that indicates whether the given
  system variable will be written to the binlog or not.
sql/log_event.cc:
   - auto_increment_offset was not written to the binlog if
  auto_increment_increment=1
   - mysqlbinlog did not output default values for some variables
  (BUG#34732). In st_print_event_info, we remember for each variable whether
  it has been printed or not. This is achieved in different ways for
  different variables:
      - For auto_increment_*, lc_time_names, charset_database_number,
        we set the default values in st_print_event_info to something
        illegal, so that it will look like they have changed the first time
        they are seen.
      - For charset, sql_mode, pseudo_thread_id, we add a flag to
        st_print_event_info which indicates whether the variable has been
        printed.
      - Since pseudo_thread_id is now printed more often, and its value is
        not guaranteed to be constant across different runs of the same
        test script, I replaced it by a constant if --short-form is used.
   - Moved st_print_event_info constructor from log_event.h to log_event.cc,
  since it now depends on ILLEGAL_CHARSET_NUMBER, which is defined in
  m_ctype.h, which is better to include from a .cc file than from a header
  file.
sql/log_event.h:
  Added fields to st_print_event_info that indicate whether some of the
  variables have been written or not. Since the initialization of
  charset_database_number now depends on ILLEGAL_CHARSET_INFO_NUMBER, which
  is defined in a header file, which we'd better not include from this
  header file -- I moved the constructor from here to log_event.cc.
sql/set_var.cc:
  System variables now have a flag binlog_status, which indicates if they
  are written to the binlog. If nothing is specified, all variables are
  marked as not written to the binlog (NOT_IN_BINLOG) when created. In this
  file, the variables that are written to the binlog are marked with
  SESSION_VARIABLE_IN_BINLOG.
sql/set_var.h:
  Added flag binlog_status to class sys_var. Added a getter and a
  constructor parameter that sets it.
  Since I had to change sys_var_thd_enum constructor anyways, I simplified
  it to use default values of arguments instead of three copies of the
  constructor.
sql/sql_yacc.yy:
  Mark statements that refer to a system variable as "unsafe",
  meaning they will be replicated by row in mixed mode. Added comment to
  explain strange piece of code just above.
mysql-test/include/diff_tables.inc:
  New auxiliary test file that tests whether two tables (possibly one on
  master and one on slave) differ.
mysql-test/suite/rpl/r/rpl_variables.result:
  New test case needs new result file.
mysql-test/suite/rpl/r/rpl_variables_stm.result:
  New test file needs new result file.
mysql-test/suite/rpl/t/rpl_variables.test:
  Test that INSERT of @@variables is replicated correctly (by switching to
  row-based mode).
mysql-test/suite/rpl/t/rpl_variables_stm.test:
  Test that replication of @@variables which are replicated explicitly works
  as expected in statement mode (without giving warnings).
2008-03-07 13:59:36 +01:00
unknown
6dd9666d0f Update Bug#12713 test results to take into account fixed bugs (29157, 33846) 2008-02-27 18:38:17 +03:00
unknown
526798dbb5 A fix and a test case for Bug#12713 "Error in a stored function called from
a SELECT doesn't cause ROLLBACK of statem".

The idea of the fix is to ensure that we always commit the current
statement at the end of dispatch_command(). In order to not issue
redundant disc syncs, an optimization of the two-phase commit
protocol is implemented to bypass the two phase commit if
the transaction is read-only.


mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Update test results.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Update test results.
mysql-test/suite/rpl_ndb/t/disabled.def:
  Disable the tests, for which this changeset reveals a bug:
  the injector thread does not always add 'statement commit' to the
  rows injected in circular replication set up.
  To be investigated separately.
sql/ha_ndbcluster_binlog.cc:
  Add close_thread_tables() to run_query: this ensures
  that all tables are closed and there is no pending statement transaction.
sql/handler.cc:
  Implement optimisation of read-only transactions.
  If a transaction consists only of DML statements that do not change
  data, we do not perform a two-phase commit for it 
  (run one phase commit only).
sql/handler.h:
  Implement optimisation of read-only transactions.
  If a transaction consists only of DML statements that do not change
  data, we do not perform a two-phase commit for it 
  (run one phase commit only).
sql/log.cc:
  Mark the binlog transaction read-write whenever it's started.
  We never read from binlog, so it's safe and least intrusive to add
  this mark up here.
sql/log_event.cc:
  Update to the new layout of thd->transaction.
sql/rpl_injector.cc:
  Always commit statement transaction before committing the global one.
sql/sp.cc:
  Ad comments.
sql/sp_head.cc:
  Add comments.
sql/sql_base.cc:
  Commit transaction at the end of the statement. Always.
sql/sql_class.cc:
  Update thd_ha_data to return the right pointer in the new layout.
  
  Fix select_dumpvar::send_data to properly return operation status.
  A test case from commit.inc would lead to an assertion failure in the 
  diagnostics area (double assignment). Not test otherwise by the test suite.
sql/sql_class.h:
  Implement a new layout of storage engine transaction info in which 
  it is easy to access all members related to the handlerton only
  based on ht->slot.
sql/sql_cursor.cc:
  Update to the new layout of thd->transaction.
sql/sql_delete.cc:
  Remove wrong and now redundant calls to ha_autocommit_or_rollback.
  The transaction is committed in one place, at the end of the statement.
  Remove calls to mysql_unlock_tables, since some engines count locks
  and commit statement transaction in unlock_tables(), which essentially
  equates mysql_unlock_tables to ha_autocommit_or_rollback.
  Previously it was necessary to unlock tables soon because we wanted
  to avoid sending of 'ok' packet to the client under locked tables.
  This is no longer necessary, since OK packet is also sent from one place
  at the end of transaction.
sql/sql_do.cc:
  Add DO always clears the error, we must rollback the current
  statement before this happens. Otherwise the statement will be committed,
  and not rolled back in the end.
sql/sql_insert.cc:
  Remove wrong and now redundant calls to ha_autocommit_or_rollback.
  The transaction is committed in one place, at the end of the statement.
  Remove calls to mysql_unlock_tables, since some engines count locks
  and commit statement transaction in unlock_tables(), which essentially
  equates mysql_unlock_tables to ha_autocommit_or_rollback.
  Previously it was necessary to unlock tables soon because we wanted
  to avoid sending of 'ok' packet to the client under locked tables.
  This is no longer necessary, since OK packet is also sent from one place
  at the end of transaction.
sql/sql_load.cc:
  Remove wrong and now redundant calls to ha_autocommit_or_rollback.
  The transaction is committed in one place, at the end of the statement.
  Remove calls to mysql_unlock_tables, since some engines count locks
  and commit statement transaction in unlock_tables(), which essentially
  equates mysql_unlock_tables to ha_autocommit_or_rollback.
  Previously it was necessary to unlock tables soon because we wanted
  to avoid sending of 'ok' packet to the client under locked tables.
  This is no longer necessary, since OK packet is also sent from one place
  at the end of transaction.
sql/sql_parse.cc:
  Implement optimisation of read-only transactions: bypass 2-phase
  commit for them.
  Always commit statement transaction before commiting the global one.
  Fix an unrelated crash in check_table_access, when called from 
  information_schema.
sql/sql_partition.cc:
  Partitions commit at the end of a DDL operation.
  Make sure that send_ok() is done only if the commit has succeeded.
sql/sql_table.cc:
  Use ha_autocommit_or_rollback and end_active_trans everywhere.
  Add end_trans to mysql_admin_table, so that it leaves no pending
  transaction.
sql/sql_udf.cc:
  Remvove a redundant call to close_thread_tables()
sql/sql_update.cc:
  Remove wrong and now redundant calls to ha_autocommit_or_rollback.
  The transaction is committed in one place, at the end of the statement.
  Remove calls to mysql_unlock_tables, since some engines count locks
  and commit statement transaction in unlock_tables(), which essentially
  equates mysql_unlock_tables to ha_autocommit_or_rollback.
  Previously it was necessary to unlock tables soon because we wanted
  to avoid sending of 'ok' packet to the client under locked tables.
  This is no longer necessary, since OK packet is also sent from one place
  at the end of transaction.
mysql-test/include/commit.inc:
  New BitKeeper file ``mysql-test/include/commit.inc''
mysql-test/r/commit_1innodb.result:
  New BitKeeper file ``mysql-test/r/commit_1innodb.result''
mysql-test/t/commit_1innodb.test:
  New BitKeeper file ``mysql-test/t/commit_1innodb.test''
2008-02-19 14:43:01 +03:00