mariadb/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
Michael Widenius 6659ad49fe Fixes after last merge of MySQL 5.1
- INSERT with RAND() doesn't require row based logging again
- Some bugs fixed in opt_range() where we table->key_read was wrongly used



.bzrignore:
  Ignore new xtstat binary
mysql-test/r/index_merge_myisam.result:
  Update results (old result was wrong)
mysql-test/suite/binlog/r/binlog_stm_binlog.result:
  Added drop table first
mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
  Added test for when RAND() requires row based logging
mysql-test/suite/binlog/t/binlog_stm_binlog.test:
  Added drop table first
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Added test for when RAND() requires row based logging
scripts/make_binary_distribution.sh:
  Removed type from last commit
sql/item_create.cc:
  Don't require row based logging when using RAND() with INSERT
sql/opt_range.cc:
  Revert wrong patch from Oracle:
  - As QUICK_RANGE_SELECT uses it's own 'file' handler to the tables, one can't use 'table->key_read' as a flag to detect if index only read (keyread) is used or not
  - Don't set keyread if keyread is already enabled
  - Don't disable key read, if we didn't enable it ourselves
  - Simplify code (and ensure that we do proper cleanup of index only read)
sql/opt_range.h:
  Added flags to detect if the range optimizer enabled index only read (key read) or not
sql/opt_sum.cc:
  Use our more optimized macros
sql/sql_lex.h:
  Added 'readable' function to check if we are in a sub query function or not (not normal query or sub query in FROM clause)
sql/sql_select.cc:
  Use our more optimized keyread macros
  Added ASSERTS early
  Simplify code on eliminate_item_equal()
  Fixed that substitute_for_best_equal_field() doesn't core dump in case of out of memory conditions.
  Removed not needed test for 'field->maybe_null()'
  Replaced master_unit()->item with is_subquery_function() (More readable)
sql/sql_update.cc:
  Use our more optimized keyread macros
sql/table.cc:
  Use our more optimized keyread macros
sql/table.h:
  Use separate functions to enable/disable Index only reads
  - Safer, more readable, better logging and faster.
2010-05-13 14:00:53 +03:00

133 lines
3.5 KiB
Text

# BUG#42851: Spurious "Statement is not safe to log in statement
# format." warnings
#
# WHY
# ===
#
# This test aims at checking that the fix that removes spurious
# entries in the error log when the statement is filtered out from
# binlog, is working.
#
# HOW
# ===
#
# The test case is split into three assertions when issuing statements
# containing LIMIT and ORDER BY:
#
# i) issue statements in database that is not filtered => check
# that warnings ARE shown;
#
# ii) issue statements in database that is not filtered, but with
# binlog disabled => check that warnings ARE NOT shown;
#
# iii) issue statements in database that is filtered => check that
# warnings ARE NOT shown.
-- source include/have_log_bin.inc
-- source include/have_binlog_format_statement.inc
-- echo ### NOT filtered database => assertion: warnings ARE shown
-- disable_warnings
DROP TABLE IF EXISTS t1;
-- enable_warnings
CREATE TABLE t1 (a int, b int, primary key (a));
INSERT INTO t1 VALUES (1,2), (2,3);
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
DROP TABLE t1;
-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
SET SQL_LOG_BIN= 0;
-- disable_warnings
DROP TABLE IF EXISTS t1;
-- enable_warnings
CREATE TABLE t1 (a int, b int, primary key (a));
INSERT INTO t1 VALUES (1,2), (2,3);
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
DROP TABLE t1;
SET SQL_LOG_BIN= 1;
-- echo ### FILTERED database => assertion: warnings ARE NOT shown
let $old_db= `SELECT DATABASE()`;
CREATE DATABASE b42851;
USE b42851;
-- disable_warnings
DROP TABLE IF EXISTS t1;
-- enable_warnings
CREATE TABLE t1 (a int, b int, primary key (a));
INSERT INTO t1 VALUES (1,2), (2,3);
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
DROP TABLE t1;
# clean up
DROP DATABASE b42851;
eval USE $old_db;
--echo #
--echo # Bug#46265: Can not disable warning about unsafe statements for binary logging
--echo #
SET @old_log_warnings = @@log_warnings;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10));
SET GLOBAL LOG_WARNINGS = 0;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
SET GLOBAL LOG_WARNINGS = 1;
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
DROP TABLE t1;
SET GLOBAL log_warnings = @old_log_warnings;
let $log_error_= `SELECT @@GLOBAL.log_error`;
if(!`select LENGTH('$log_error_')`)
{
# MySQL Server on windows is started with --console and thus
# does not know the location of its .err log, use default location
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
}
# Assign env variable LOG_ERROR
let LOG_ERROR=$log_error_;
--echo # Count the number of times the "Unsafe" message was printed
--echo # to the error log.
perl;
use strict;
my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
my $count = () = grep(/Bug#46265/g,<FILE>);
print "Occurrences: $count\n";
close(FILE);
EOF
#
# Check how RAND() can be used with replication
#
create table t1 (n1 int, n2 int, n3 int,
key (n1, n2, n3),
key (n2, n3, n1),
key (n3, n1, n2));
insert into t1 values (1,1,1);
# This should work fine
insert into t1 values (RAND()*1000+10, RAND()*1000+10, RAND()*1000+10);
# This should need row based logging.
update t1 set n1=rand() where n1=1;
delete from t1 where n2=1 + rand()*0;
drop table t1;