Commit 6d5ccfa1 authored by Tatiana A. Nurnberg's avatar Tatiana A. Nurnberg

manual merge

parents 38a9c269 71c12404
......@@ -1295,6 +1295,8 @@ mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc
mysql-test/mtr
mysql-test/mysql-test-run
mysql-test/mysql-test-gcov.err
mysql-test/mysql-test-gcov.msg
mysql-test/mysql-test-run-shell
mysql-test/mysql-test-run.log
mysql-test/mysql_test_run_new
......
......@@ -22,40 +22,46 @@ use strict;
sub gcov_prepare ($) {
my ($dir)= @_;
print "Purging gcov information from '$dir'...\n";
`find $dir -name \*.gcov \
-or -name \*.da | xargs rm`;
system("find $dir -name \*.gcov -o -name \*.da"
. " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
}
my @mysqld_src_dirs=
(
"strings",
"mysys",
"include",
"extra",
"regex",
"isam",
"merge",
"myisam",
"myisammrg",
"heap",
"sql",
);
#
# Collect gcov statistics.
# Arguments:
# $dir basedir, normally source directory
# $gcov gcov utility program [path] name
# $gcov_msg message file name
# $gcov_err error file name
#
sub gcov_collect ($$$) {
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
# Get current directory to return to later.
my $start_dir= cwd();
print "Collecting source coverage info...\n";
-f $gcov_msg and unlink($gcov_msg);
-f $gcov_err and unlink($gcov_err);
foreach my $d ( @mysqld_src_dirs )
{
chdir("$dir/$d");
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
{
`$gcov $f 2>>$gcov_err >>$gcov_msg`;
print "Collecting source coverage info using '$gcov'...\n";
-f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
-f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
my @dirs= `find "$dir" -type d -print | sort`;
#print "List of directories:\n@dirs\n";
foreach my $d ( @dirs ) {
my $dir_reported= 0;
chomp($d);
chdir($d) or next;
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) {
$f =~ /(.*)\.[ch]c?/;
-f "$1.gcno" or next;
if (!$dir_reported) {
print "Collecting in '$d'...\n";
$dir_reported= 1;
}
system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg");
}
chdir($start_dir);
}
......
......@@ -163,8 +163,9 @@ our $opt_force;
our $opt_mem= $ENV{'MTR_MEM'};
our $opt_gcov;
our $opt_gcov_err;
our $opt_gcov_msg;
our $opt_gcov_exe= "gcov";
our $opt_gcov_err= "mysql-test-gcov.msg";
our $opt_gcov_msg= "mysql-test-gcov.err";
our $glob_debugger= 0;
our $opt_gdb;
......@@ -396,7 +397,7 @@ sub main {
mtr_print_line();
if ( $opt_gcov ) {
gcov_collect($basedir, $opt_gcov,
gcov_collect($basedir, $opt_gcov_exe,
$opt_gcov_msg, $opt_gcov_err);
}
......@@ -5057,6 +5058,8 @@ Misc options
to turn off.
sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time
gcov Collect coverage information after the test.
The result is a gcov file per source and header file.
HERE
exit(1);
......
......@@ -1691,3 +1691,15 @@ FROM t1;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode='ONLY_FULL_GROUP_BY';
CREATE TABLE t1(i INT);
INSERT INTO t1 VALUES (1), (10);
SELECT COUNT(i) FROM t1;
COUNT(i)
2
SELECT COUNT(i) FROM t1 WHERE i > 1;
COUNT(i)
1
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
......@@ -2448,3 +2448,18 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a`
drop table t1;
CREATE TABLE t1 (a int, b int, c int, d int,
KEY foo (c,d,a,b), KEY bar (c,a,b,d));
INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL foo 10 NULL 9 Using where; Using index for group-by
SELECT DISTINCT c FROM t1 WHERE d=4;
c
1
2
DROP TABLE t1;
End of 5.0 tests
......@@ -166,4 +166,31 @@ ERROR HY000: View's SELECT refers to a temporary table 't2'
Cleanup.
drop table t2, t3;
#
# Bug#39843 DELETE requires write access to table in subquery in where clause
#
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
table1_rowid SMALLINT NOT NULL
);
CREATE TABLE t2 (
table2_rowid SMALLINT NOT NULL
);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
LOCK TABLES t1 WRITE, t2 READ;
# Sub-select should not try to aquire a write lock.
DELETE FROM t1
WHERE EXISTS
(
SELECT 'x'
FROM t2
WHERE t1.table1_rowid = t2.table2_rowid
) ;
# While implementing the patch we didn't break old behavior;
# The following sub-select should still requires a write lock:
SELECT * FROM t1 WHERE 1 IN (SELECT * FROM t2 FOR UPDATE);
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UNLOCK TABLES;
DROP TABLE t1,t2;
End of 5.1 tests.
......@@ -149,7 +149,7 @@ SET NAMES DEFAULT;
mysqlcheck --default-character-set="latin1" --databases test
test.?
Error : Table doesn't exist
error : Corrupt
status : Operation failed
mysqlcheck --default-character-set="utf8" --databases test
test.я OK
SET NAMES utf8;
......
......@@ -144,7 +144,7 @@ Key_reads 0
load index into cache t3, t2 key (primary,b) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t3 preload_keys error Corrupt
test.t3 preload_keys status Operation failed
test.t2 preload_keys status OK
show status like "key_read%";
Variable_name Value
......@@ -159,7 +159,7 @@ Key_reads 0
load index into cache t3 key (b), t2 key (c) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t3 preload_keys error Corrupt
test.t3 preload_keys status Operation failed
test.t2 preload_keys Error Key 'c' doesn't exist in table 't2'
test.t2 preload_keys status Operation failed
show status like "key_read%";
......
......@@ -1396,13 +1396,13 @@ execute stmt;
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t4 repair Error Table 'test.t4' doesn't exist
test.t4 repair error Corrupt
test.t4 repair status Operation failed
test.t3 repair status OK
execute stmt;
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t4 repair Error Table 'test.t4' doesn't exist
test.t4 repair error Corrupt
test.t4 repair status Operation failed
test.t3 repair status OK
prepare stmt from "optimize table t1, t3, t4";
execute stmt;
......@@ -1410,23 +1410,23 @@ Table Op Msg_type Msg_text
test.t1 optimize status OK
test.t3 optimize status OK
test.t4 optimize Error Table 'test.t4' doesn't exist
test.t4 optimize error Corrupt
test.t4 optimize status Operation failed
execute stmt;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
test.t3 optimize status Table is already up to date
test.t4 optimize Error Table 'test.t4' doesn't exist
test.t4 optimize error Corrupt
test.t4 optimize status Operation failed
prepare stmt from "analyze table t4, t1";
execute stmt;
Table Op Msg_type Msg_text
test.t4 analyze Error Table 'test.t4' doesn't exist
test.t4 analyze error Corrupt
test.t4 analyze status Operation failed
test.t1 analyze status Table is already up to date
execute stmt;
Table Op Msg_type Msg_text
test.t4 analyze Error Table 'test.t4' doesn't exist
test.t4 analyze error Corrupt
test.t4 analyze status Operation failed
test.t1 analyze status Table is already up to date
deallocate prepare stmt;
drop table t1, t2, t3;
......
......@@ -27,7 +27,7 @@ drop table t1;
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair Error Table 'test.t1' doesn't exist
test.t1 repair error Corrupt
test.t1 repair status Operation failed
create table t1 engine=myisam SELECT 1,"table 1";
flush tables;
repair table t1;
......
......@@ -1198,7 +1198,7 @@ CREATE DATABASE mysqltest1;
use mysqltest1;
CREATE TABLE t1(1 INT);
---> Dumping mysqltest1 to show_check.mysqltest1.sql
---> Dumping mysqltest1 to outfile1
DROP DATABASE mysqltest1;
......
......@@ -9,6 +9,3 @@ select user();
user()
#
show processlist;
Id User Host db Command Time State Info
<id> root <host> test <command> <time> <state> <info>
<id> root <host> test <command> <time> <state> <info>
......@@ -1305,7 +1305,7 @@ set @@sql_mode='traditional';
create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*123456789*';
ERROR HY000: Too long comment for table 't1'
ERROR HY000: Comment for table 't1' is too long (max = 60)
create table t1 (
i int comment
'123456789*123456789*123456789*123456789*
......@@ -1315,7 +1315,7 @@ i int comment
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
ERROR HY000: Too long comment for field 'i'
ERROR HY000: Comment for field 'i' is too long (max = 255)
set @@sql_mode= @org_mode;
create table t1
(i int comment
......@@ -1327,7 +1327,7 @@ create table t1
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
Warnings:
Warning 1105 Unknown error
Warning 1629 Comment for field 'i' is too long (max = 255)
select column_name, column_comment from information_schema.columns where
table_schema = 'test' and table_name = 't1';
column_name column_comment
......
......@@ -299,59 +299,107 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000;
select ROUND(RAND(),5);
ROUND(RAND(),5)
0.02887
show variables like '%alloc%';
==+ Testing %alloc% system variables +==
==+ NOTE: These values *must* be a multiple of 1024 +==
==+ Other values will be rounded down to nearest multiple +==
==+ Show initial values +==
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 8192
QUERY_PREALLOC_SIZE 8192
RANGE_ALLOC_BLOCK_SIZE 4096
TRANSACTION_ALLOC_BLOCK_SIZE 8192
TRANSACTION_PREALLOC_SIZE 4096
set @@range_alloc_block_size=1024*16;
Testing values that are multiples of 1024
set @@range_alloc_block_size=1024*15+1024;
set @@query_alloc_block_size=1024*15+1024*2;
set @@query_prealloc_size=1024*18-1024;
set @@transaction_alloc_block_size=1024*21-1024*1;
set @@transaction_prealloc_size=1024*21-2048;
==+ Check manipulated values ==+
select @@query_alloc_block_size;
@@query_alloc_block_size
17408
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 17408
query_prealloc_size 17408
range_alloc_block_size 16384
transaction_alloc_block_size 20480
transaction_prealloc_size 19456
==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 17408
QUERY_PREALLOC_SIZE 17408
RANGE_ALLOC_BLOCK_SIZE 16384
TRANSACTION_ALLOC_BLOCK_SIZE 20480
TRANSACTION_PREALLOC_SIZE 19456
==+ Manipulate variable values +==
Testing values that are not 1024 multiples
set @@range_alloc_block_size=1024*16+1023;
set @@query_alloc_block_size=1024*17+2;
set @@query_prealloc_size=1024*18;
set @@query_prealloc_size=1024*18-1023;
set @@transaction_alloc_block_size=1024*20-1;
set @@transaction_prealloc_size=1024*21-1;
select @@query_alloc_block_size;
@@query_alloc_block_size
17408
show variables like '%alloc%';
==+ Check manipulated values ==+
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 17408
query_prealloc_size 18432
query_prealloc_size 17408
range_alloc_block_size 16384
transaction_alloc_block_size 19456
transaction_prealloc_size 20480
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 17408
QUERY_PREALLOC_SIZE 18432
QUERY_PREALLOC_SIZE 17408
RANGE_ALLOC_BLOCK_SIZE 16384
TRANSACTION_ALLOC_BLOCK_SIZE 19456
TRANSACTION_PREALLOC_SIZE 20480
==+ Set values back to the default values +==
set @@range_alloc_block_size=default;
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
show variables like '%alloc%';
==+ Check the values now that they are reset +==
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 8192
QUERY_PREALLOC_SIZE 8192
RANGE_ALLOC_BLOCK_SIZE 4096
TRANSACTION_ALLOC_BLOCK_SIZE 8192
TRANSACTION_PREALLOC_SIZE 4096
SELECT @@version LIKE 'non-existent';
@@version LIKE 'non-existent'
0
......@@ -1373,4 +1421,9 @@ SELECT @@global.expire_logs_days;
@@global.expire_logs_days
99
SET GLOBAL expire_logs_days = @old_eld;
select @@storage_engine;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @@storage_engine 253 6 6 N 1 31 8
@@storage_engine
MyISAM
End of 5.1 tests
......@@ -921,6 +921,32 @@ c4
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1(f1 INT, f2 INT);
CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
GRANT SELECT (f1) ON t1 TO foo;
GRANT SELECT (f1) ON v1 TO foo;
USE db1;
SELECT f1 FROM t1;
f1
SELECT f2 FROM t1;
ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 't1'
SELECT * FROM t1;
ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't1'
SELECT f1 FROM v1;
f1
SELECT f2 FROM v1;
ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 'v1'
SELECT * FROM v1;
ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'v1'
USE test;
REVOKE SELECT (f1) ON db1.t1 FROM foo;
REVOKE SELECT (f1) ON db1.v1 FROM foo;
DROP USER foo;
DROP VIEW db1.v1;
DROP TABLE db1.t1;
DROP DATABASE db1;
End of 5.0 tests.
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
SET @old_sql_mode= @@global.sql_mode;
SET @old_binlog_format=@@session.binlog_format;
SET SESSION sql_mode=8;
Initialization
RESET MASTER;
CREATE TABLE t1 (id INT);
CREATE PROCEDURE testProc() SELECT * FROM t1;
CREATE VIEW testView as SELECT * from t1;
CREATE FUNCTION testFunc()
RETURNS INT
BEGIN
return 1;
END;|
CREATE TRIGGER testTrig BEFORE INSERT ON t1
FOR EACH ROW BEGIN
UPDATE t1 SET id = id +1;
END;|
CREATE EVENT testEvent ON SCHEDULE
EVERY 1 DAY
DO
BEGIN
UPDATE t1 SET id = id +1;
END;|
Chceck Result
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
is not null
1
*** String sql_mode=0 is found: 0 ***
Clean Up
DROP PROCEDURE testProc;
DROP FUNCTION testFunc;
DROP TRIGGER testTrig;
DROP EVENT testEvent;
DROP VIEW testView;
DROP TABLE t1;
SET @@global.sql_mode= @old_sql_mode;
SET @@session.binlog_format=@old_binlog_format;
......@@ -227,3 +227,86 @@ UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
Warnings:
Warning 1592 Statement is not safe to log in statement format.
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1(i INT PRIMARY KEY);
CREATE TABLE t2(i INT PRIMARY KEY);
CREATE TABLE t3(i INT, ch CHAR(50));
"Should issue message Statement is not safe to log in statement format."
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
Warnings:
Warning 1592 Statement is not safe to log in statement format.
CREATE FUNCTION func6()
RETURNS INT
BEGIN
INSERT INTO t1 VALUES (10);
INSERT INTO t1 VALUES (11);
INSERT INTO t1 VALUES (12);
RETURN 0;
END|
"Should issue message Statement is not safe to log in statement format only once"
INSERT INTO t3 VALUES(func6(), UUID());
Warnings:
Warning 1592 Statement is not safe to log in statement format.
"Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements"
CREATE FUNCTION fun_check_log_bin() RETURNS INT
BEGIN
SET @@SQL_LOG_BIN = 0;
INSERT INTO t1 VALUES(@@global.sync_binlog);
RETURN 100;
END|
"One unsafe warning should be issued in the following statement"
SELECT fun_check_log_bin();
fun_check_log_bin()
100
Warnings:
Warning 1592 Statement is not safe to log in statement format.
"SQL_LOG_BIN should be ON still"
SHOW VARIABLES LIKE "SQL_LOG_BIN";
Variable_name Value
sql_log_bin ON
set @save_log_bin = @@SESSION.SQL_LOG_BIN;
set @@SESSION.SQL_LOG_BIN = 0;
"Should NOT have any warning message issued in the following statements"
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
DROP TABLE t1,t2;
"Should NOT have any warning message issued in the following func7() and trig"
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a CHAR(40));
CREATE TABLE trigger_table (a CHAR(7));
CREATE FUNCTION func7()
RETURNS INT
BEGIN
INSERT INTO t1 VALUES (@@global.sync_binlog);
INSERT INTO t1 VALUES (@@session.insert_id);
INSERT INTO t2 SELECT UUID();
INSERT INTO t2 VALUES (@@session.sql_mode);
INSERT INTO t2 VALUES (@@global.init_slave);
RETURN 0;
END|
SHOW VARIABLES LIKE "SQL_LOG_BIN";
Variable_name Value
sql_log_bin OFF
SELECT func7();
func7()
0
---- Insert from trigger ----
CREATE TRIGGER trig
BEFORE INSERT ON trigger_table
FOR EACH ROW
BEGIN
INSERT INTO t1 VALUES (@@global.sync_binlog);
INSERT INTO t1 VALUES (@@session.insert_id);
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
INSERT INTO t2 SELECT UUID();
INSERT INTO t2 VALUES (@@session.sql_mode);
INSERT INTO t2 VALUES (@@global.init_slave);
INSERT INTO t2 VALUES (@@hostname);
END|
INSERT INTO trigger_table VALUES ('bye.');
DROP FUNCTION fun_check_log_bin;
DROP FUNCTION func6;
DROP FUNCTION func7;
DROP TRIGGER trig;
DROP TABLE t1, t2, t3, trigger_table;
set @@SESSION.SQL_LOG_BIN = @save_log_bin;
"End of tests"
# ==== Purpose ====
#
# Test that sql_mode can correct restore before generating the binlog event
# when creating CREATEable objects.
#
# ==== Method ====
#
# Scan binlog file to check if the sql_mode is still set to 0 before generating binlog event
#
-- source include/master-slave.inc
-- source include/have_log_bin.inc
# BUG#39526 sql_mode not retained in binary log for CREATE PROCEDURE
SET @old_sql_mode= @@global.sql_mode;
SET @old_binlog_format=@@session.binlog_format;
let $MYSQLD_DATADIR= `select @@datadir`;
SET SESSION sql_mode=8;
--echo Initialization
RESET MASTER;
CREATE TABLE t1 (id INT);
CREATE PROCEDURE testProc() SELECT * FROM t1;
CREATE VIEW testView as SELECT * from t1;
DELIMITER |;
CREATE FUNCTION testFunc()
RETURNS INT
BEGIN
return 1;
END;|
DELIMITER ;|
DELIMITER |;
CREATE TRIGGER testTrig BEFORE INSERT ON t1
FOR EACH ROW BEGIN
UPDATE t1 SET id = id +1;
END;|
DELIMITER ;|
DELIMITER |;
CREATE EVENT testEvent ON SCHEDULE
EVERY 1 DAY
DO
BEGIN
UPDATE t1 SET id = id +1;
END;|
DELIMITER ;|
--echo Chceck Result
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
is not null;
let $s_mode_unsigned= `select @a like "%@@session.sql_mode=0%" /* must return 0 */`;
echo *** String sql_mode=0 is found: $s_mode_unsigned ***;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
--echo Clean Up
DROP PROCEDURE testProc;
DROP FUNCTION testFunc;
DROP TRIGGER testTrig;
DROP EVENT testEvent;
DROP VIEW testView;
DROP TABLE t1;
SET @@global.sql_mode= @old_sql_mode;
SET @@session.binlog_format=@old_binlog_format;
......@@ -8,6 +8,7 @@
# executed cannot be determined (e.g., INSERT DELAYED). Such
# statements should be marked unsafe. All unsafe statements should
# give a warning.
# Yet the warning/error message isn't issued when SQL_LOG_BIN is turned off.
#
# This test verifies that a warning is generated for statements that
# should be unsafe, when they are executed under statement mode
......@@ -32,14 +33,19 @@
# We try to insert the variables that should not be unsafe into a
# table, and verify that *no* warning is issued.
#
#
# Execute a unsafe statement calling a trigger or stored function
# or neither when SQL_LOG_BIN is turned ON, a warning/error should be issued
# Execute a unsafe statement calling a trigger or stored function
# or neither when @@SQL_LOG_BIN is turned OFF,
# no warning/error is issued
# ==== Related bugs and worklogs ====
#
# WL#3339: Issue warnings when statement-based replication may fail
# BUG#31168: @@hostname does not replicate
# BUG#34732: mysqlbinlog does not print default values for auto_increment variables
# BUG#34768: nondeterministic INSERT using LIMIT logged in stmt mode if binlog_format=mixed
#
# BUG#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0
#
# ==== Related test cases ====
#
......@@ -271,3 +277,96 @@ INSERT INTO t1 VALUES ('a','b');
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
DROP TABLE t1;
#
#For bug#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0
#
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1(i INT PRIMARY KEY);
CREATE TABLE t2(i INT PRIMARY KEY);
CREATE TABLE t3(i INT, ch CHAR(50));
--echo "Should issue message Statement is not safe to log in statement format."
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
DELIMITER |;
CREATE FUNCTION func6()
RETURNS INT
BEGIN
INSERT INTO t1 VALUES (10);
INSERT INTO t1 VALUES (11);
INSERT INTO t1 VALUES (12);
RETURN 0;
END|
DELIMITER ;|
--echo "Should issue message Statement is not safe to log in statement format only once"
INSERT INTO t3 VALUES(func6(), UUID());
--echo "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements"
DELIMITER |;
CREATE FUNCTION fun_check_log_bin() RETURNS INT
BEGIN
SET @@SQL_LOG_BIN = 0;
INSERT INTO t1 VALUES(@@global.sync_binlog);
RETURN 100;
END|
DELIMITER ;|
--echo "One unsafe warning should be issued in the following statement"
SELECT fun_check_log_bin();
--echo "SQL_LOG_BIN should be ON still"
SHOW VARIABLES LIKE "SQL_LOG_BIN";
set @save_log_bin = @@SESSION.SQL_LOG_BIN;
set @@SESSION.SQL_LOG_BIN = 0;
--echo "Should NOT have any warning message issued in the following statements"
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
DROP TABLE t1,t2;
--echo "Should NOT have any warning message issued in the following func7() and trig"
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a CHAR(40));
CREATE TABLE trigger_table (a CHAR(7));
DELIMITER |;
CREATE FUNCTION func7()
RETURNS INT
BEGIN
INSERT INTO t1 VALUES (@@global.sync_binlog);
INSERT INTO t1 VALUES (@@session.insert_id);
INSERT INTO t2 SELECT UUID();
INSERT INTO t2 VALUES (@@session.sql_mode);
INSERT INTO t2 VALUES (@@global.init_slave);
RETURN 0;
END|
DELIMITER ;|
SHOW VARIABLES LIKE "SQL_LOG_BIN";
SELECT func7();
--echo ---- Insert from trigger ----
DELIMITER |;
CREATE TRIGGER trig
BEFORE INSERT ON trigger_table
FOR EACH ROW
BEGIN
INSERT INTO t1 VALUES (@@global.sync_binlog);
INSERT INTO t1 VALUES (@@session.insert_id);
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
INSERT INTO t2 SELECT UUID();
INSERT INTO t2 VALUES (@@session.sql_mode);
INSERT INTO t2 VALUES (@@global.init_slave);
INSERT INTO t2 VALUES (@@hostname);
END|
DELIMITER ;|
INSERT INTO trigger_table VALUES ('bye.');
#clean up
DROP FUNCTION fun_check_log_bin;
DROP FUNCTION func6;
DROP FUNCTION func7;
DROP TRIGGER trig;
DROP TABLE t1, t2, t3, trigger_table;
set @@SESSION.SQL_LOG_BIN = @save_log_bin;
--echo "End of tests"
......@@ -21367,7 +21367,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
test.v1 check error Corrupt
test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
......
......@@ -21369,7 +21369,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
test.v1 check error Corrupt
test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
......
No preview for this file type
......@@ -21367,7 +21367,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
test.v1 check error Corrupt
test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
......
......@@ -17,7 +17,7 @@ Error 1205 Lock wait timeout exceeded; try restarting transaction
OPTIMIZE TABLE non_existing;
Table Op Msg_type Msg_text
test.non_existing optimize Error Table 'test.non_existing' doesn't exist
test.non_existing optimize error Corrupt
test.non_existing optimize status Operation failed
select * from t1;
a
1
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
CREATE TABLE t1 (`bit_key` bit, `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t2 (`bit_key` bit(4), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t3 (`bit_key` bit(7), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t4 (`bit_key` bit(8), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t5 (`bit_key` bit(9), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t6 (`bit_key` bit(14), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t7 (`bit_key` bit(15), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t8 (`bit_key` bit(16), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
INSERT INTO `t1` ( `bit` ) VALUES ( 0 );
DELETE FROM `t1` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t2` ( `bit` ) VALUES ( 0 );
DELETE FROM `t2` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t3` ( `bit` ) VALUES ( 0 );
DELETE FROM `t3` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t4` ( `bit` ) VALUES ( 0 );
DELETE FROM `t4` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t5` ( `bit` ) VALUES ( 0 );
DELETE FROM `t5` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t6` ( `bit` ) VALUES ( 0 );
DELETE FROM `t6` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t7` ( `bit` ) VALUES ( 0 );
DELETE FROM `t7` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t8` ( `bit` ) VALUES ( 0 );
DELETE FROM `t8` WHERE `bit` < 2 LIMIT 4;
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
#
# BUG
# ---
# BUG#39753: Replication failure on MIXED + bit + myisam + no PK
#
# Description
# -----------
# Simple statements against a bit column cause failure in mixed-mode
# replication.
#
# Implementation is as follows:
# i) A table with two bit fields is created. One of them is a key.
# ii) A record is inserted without specifying the key value.
# iii) The record is deleted using a where clause that matches it.
# iv) repeat i-iii) for bit key that has different size, generating
# different extra bits values
# v) The slave is synchronized with master
# vi) The table is dropped on master and the slave is re-synchronized
# with master.
#
# Step v) made the bug evident before the patch, as the slave would
# fail to find the correspondent row in its database (although it did
# the insert in step ii) ).
#
# Obs
# ---
# This test is based on the "how to repeat" section from the bug report.
#
#
--source include/master-slave.inc
--disable_warnings
# setup
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
CREATE TABLE t1 (`bit_key` bit, `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t2 (`bit_key` bit(4), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t3 (`bit_key` bit(7), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t4 (`bit_key` bit(8), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t5 (`bit_key` bit(9), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t6 (`bit_key` bit(14), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t7 (`bit_key` bit(15), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
CREATE TABLE t8 (`bit_key` bit(16), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
# insert and delete
INSERT INTO `t1` ( `bit` ) VALUES ( 0 );
DELETE FROM `t1` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t2` ( `bit` ) VALUES ( 0 );
DELETE FROM `t2` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t3` ( `bit` ) VALUES ( 0 );
DELETE FROM `t3` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t4` ( `bit` ) VALUES ( 0 );
DELETE FROM `t4` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t5` ( `bit` ) VALUES ( 0 );
DELETE FROM `t5` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t6` ( `bit` ) VALUES ( 0 );
DELETE FROM `t6` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t7` ( `bit` ) VALUES ( 0 );
DELETE FROM `t7` WHERE `bit` < 2 LIMIT 4;
INSERT INTO `t8` ( `bit` ) VALUES ( 0 );
DELETE FROM `t8` WHERE `bit` < 2 LIMIT 4;
--enable_warnings
sync_slave_with_master;
# clean up
connection master;
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
sync_slave_with_master;
......@@ -143,10 +143,12 @@ set names koi8r|
# - Dump mysqltest1;
--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
......@@ -161,7 +163,9 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
--exec $MYSQL test < $views_dump1
--remove_file $views_dump1
#
# Third-round checks.
......@@ -398,6 +402,9 @@ set names koi8r|
# - Dump mysqltest1, mysqltest2;
--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -406,7 +413,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -416,7 +423,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -432,10 +439,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
--exec $MYSQL test < $sp_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
--exec $MYSQL test < $sp_dump2
--remove_file $sp_dump1
--remove_file $sp_dump2
#
# Third-round checks.
......@@ -669,6 +679,9 @@ use mysqltest1|
# - Dump mysqltest1, mysqltest2;
--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -677,7 +690,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -687,7 +700,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -703,10 +716,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
--exec $MYSQL test < $triggers_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
--exec $MYSQL test < $triggers_dump2
--remove_file $triggers_dump1
--remove_file $triggers_dump2
#
# Third-round checks.
......@@ -924,6 +940,9 @@ set names koi8r|
# - Dump mysqltest1, mysqltest2;
--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -932,7 +951,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -942,7 +961,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -958,10 +977,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
--exec $MYSQL test < $events_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
--exec $MYSQL test < $events_dump2
--remove_file $events_dump1
--remove_file $events_dump2
#
# Third-round checks.
......
......@@ -143,10 +143,12 @@ set names utf8|
# - Dump mysqltest1;
--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
......@@ -161,7 +163,9 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
--exec $MYSQL test < $views_dump1
--remove_file $views_dump1
#
# Third-round checks.
......@@ -398,6 +402,9 @@ set names utf8|
# - Dump mysqltest1, mysqltest2;
--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -406,7 +413,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -416,7 +423,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -432,10 +439,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
--exec $MYSQL test < $sp_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
--exec $MYSQL test < $sp_dump2
--remove_file $sp_dump1
--remove_file $sp_dump2
#
# Third-round checks.
......@@ -669,6 +679,9 @@ use mysqltest1|
# - Dump mysqltest1, mysqltest2;
--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -677,7 +690,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -687,7 +700,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -703,10 +716,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
--exec $MYSQL test < $triggers_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
--exec $MYSQL test < $triggers_dump2
--remove_file $triggers_dump1
--remove_file $triggers_dump2
#
# Third-round checks.
......@@ -924,6 +940,9 @@ set names utf8|
# - Dump mysqltest1, mysqltest2;
--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
--echo
--echo ---> Dump of mysqltest1
......@@ -932,7 +951,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
......@@ -942,7 +961,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
......@@ -958,10 +977,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
--exec $MYSQL test < $events_dump1
--echo ---> Restoring mysqltest2...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
--exec $MYSQL test < $events_dump2
--remove_file $events_dump1
--remove_file $events_dump2
#
# Third-round checks.
......
......@@ -150,17 +150,30 @@ DROP DATABASE IF EXISTS mysql_test;
CREATE DATABASE mysql_test;
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm
--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD
--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI
--let $proc_frm = $MYSQLD_DATADIR/mysql/proc.frm
--let $proc_MYD = $MYSQLD_DATADIR/mysql/proc.MYD
--let $proc_MYI = $MYSQLD_DATADIR/mysql/proc.MYI
--let $copy_of_proc_frm = $MYSQLTEST_VARDIR/tmp/bug29958.copy.frm
--let $copy_of_proc_MYD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYD
--let $copy_of_proc_MYI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYI
--copy_file $proc_frm $copy_of_proc_frm
--copy_file $proc_MYD $copy_of_proc_MYD
--copy_file $proc_MYI $copy_of_proc_MYI
DROP TABLE mysql.proc;
DROP DATABASE mysql_test;
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm $MYSQLD_DATADIR/mysql/proc.frm
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
--copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
--copy_file $copy_of_proc_frm $proc_frm
--copy_file $copy_of_proc_MYD $proc_MYD
--copy_file $copy_of_proc_MYI $proc_MYI
--remove_file $copy_of_proc_frm
--remove_file $copy_of_proc_MYD
--remove_file $copy_of_proc_MYI
--echo
--echo # --
......
......@@ -18,6 +18,8 @@ insert into t1 values (3,5,"C");
insert into t1 values (3,6,"D");
# Test of MySQL field extension with and without matching records.
#### Note: The two following statements may fail if the execution plan
#### or optimizer is changed. The result for column c is undefined.
select a,c,sum(a) from t1 group by a;
select a,c,sum(a) from t1 where a > 10 group by a;
select sum(a) from t1 where a > 10;
......
......@@ -1139,4 +1139,22 @@ DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
#
# Bug#42567 Invalid GROUP BY error
#
# Setup of the subtest
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode='ONLY_FULL_GROUP_BY';
CREATE TABLE t1(i INT);
INSERT INTO t1 VALUES (1), (10);
# The actual test
SELECT COUNT(i) FROM t1;
SELECT COUNT(i) FROM t1 WHERE i > 1;
# Cleanup of subtest
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
......@@ -961,3 +961,25 @@ insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
select * from t1;
explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
drop table t1;
#
# Bug #41610: key_infix_len can be overwritten causing some group by queries
# to return no rows
#
CREATE TABLE t1 (a int, b int, c int, d int,
KEY foo (c,d,a,b), KEY bar (c,a,b,d));
INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
#Should be non-empty
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
SELECT DISTINCT c FROM t1 WHERE d=4;
DROP TABLE t1;
--echo End of 5.0 tests
......@@ -214,4 +214,34 @@ create view v_bug5719 as select * from t2;
--echo
drop table t2, t3;
--echo #
--echo # Bug#39843 DELETE requires write access to table in subquery in where clause
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
CREATE TABLE t1 (
table1_rowid SMALLINT NOT NULL
);
CREATE TABLE t2 (
table2_rowid SMALLINT NOT NULL
);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);
LOCK TABLES t1 WRITE, t2 READ;
--echo # Sub-select should not try to aquire a write lock.
DELETE FROM t1
WHERE EXISTS
(
SELECT 'x'
FROM t2
WHERE t1.table1_rowid = t2.table2_rowid
) ;
--echo # While implementing the patch we didn't break old behavior;
--echo # The following sub-select should still requires a write lock:
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
SELECT * FROM t1 WHERE 1 IN (SELECT * FROM t2 FOR UPDATE);
UNLOCK TABLES;
DROP TABLE t1,t2;
--echo End of 5.1 tests.
......@@ -98,35 +98,43 @@ drop table t1;
# Bug #20432: mysql client interprets commands in comments
#
--let $file = $MYSQLTEST_VARDIR/tmp/bug20432.sql
# if the client sees the 'use' within the comment, we haven't fixed
--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
--exec echo "/*" > $file
--exec echo "use" >> $file
--exec echo "*/" >> $file
--exec $MYSQL < $file 2>&1
# SQL can have embedded comments => workie
--exec echo "select /*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ 1" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
--exec echo "select /*" > $file
--exec echo "use" >> $file
--exec echo "*/ 1" >> $file
--exec $MYSQL < $file 2>&1
# client commands on the other hand must be at BOL => error
--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "xxx" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "*/ use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec echo "/*" > $file
--exec echo "xxx" >> $file
--exec echo "*/ use" >> $file
--error 1
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
--exec $MYSQL < $file 2>&1
# client comment recognized, but parameter missing => error
--exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
--exec echo "use" > $file
--exec $MYSQL < $file 2>&1
--remove_file $file
#
# Bug #20328: mysql client interprets commands in comments
#
--exec $MYSQL -e "help" > $MYSQLTEST_VARDIR/tmp/bug20328_1.result
--exec $MYSQL -e "help " > $MYSQLTEST_VARDIR/tmp/bug20328_2.result
--diff_files $MYSQLTEST_VARDIR/tmp/bug20328_1.result $MYSQLTEST_VARDIR/tmp/bug20328_2.result
--let $file1 = $MYSQLTEST_VARDIR/tmp/bug20328_1.result
--let $file2 = $MYSQLTEST_VARDIR/tmp/bug20328_2.result
--exec $MYSQL -e "help" > $file1
--exec $MYSQL -e "help " > $file2
--diff_files $file1 $file2
--remove_file $file1
--remove_file $file2
#
# Bug #19216: Client crashes on long SELECT
......@@ -152,13 +160,15 @@ EOF
#
# Bug #20103: Escaping with backslash does not work
#
--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
--let $file = $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $file
--exec echo "SELECT '\';" >> $file
--exec $MYSQL < $file 2>&1
--exec echo "SET SQL_MODE = '';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
--exec echo "SET SQL_MODE = '';" > $file
--exec echo "SELECT '\';';" >> $file
--exec $MYSQL < $file 2>&1
--remove_file $file
#
# Bug#17583: mysql drops connection when stdout is not writable
......
......@@ -5,9 +5,13 @@
# Bug #30126: semicolon before closing */ in /*!... CREATE DATABASE ;*/
#
--let $file = $MYSQLTEST_VARDIR/tmp/bug30126.sql
CREATE DATABASE mysqldump_30126;
USE mysqldump_30126;
CREATE TABLE t1 (c1 int);
--exec $MYSQL_DUMP --add-drop-database mysqldump_30126 > $MYSQLTEST_VARDIR/tmp/bug30126.sql
--exec $MYSQL mysqldump_30126 < $MYSQLTEST_VARDIR/tmp/bug30126.sql
--exec $MYSQL_DUMP --add-drop-database mysqldump_30126 > $file
--exec $MYSQL mysqldump_30126 < $file
DROP DATABASE mysqldump_30126;
--remove_file $file
......@@ -1463,7 +1463,7 @@ select "this will be executed";
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
--error 0,1
remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
--error 0,1
remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
......
......@@ -897,10 +897,12 @@ CREATE TABLE t1(
# Check:
# - Dump mysqltest1;
--let $outfile1=$MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
--echo
--echo ---> Dumping mysqltest1 to show_check.mysqltest1.sql
--echo ---> Dumping mysqltest1 to outfile1
--exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
--exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $outfile1
# - Clean mysqltest1;
......@@ -915,7 +917,8 @@ DROP DATABASE mysqltest1;
--echo
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
--exec $MYSQL test < $outfile1
--remove_file $outfile1
# - Check definition of the table.
......
......@@ -15,6 +15,9 @@ DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
connect (con1, 127.0.0.1, root, , test, $MASTER_MYPORT, );
--replace_column 1 #
select user();
--replace_column 1 <id> 3 <host> 5 <command> 6 <time> 7 <state> 8 <info>
# We are only interested in the fact that statement below doesn't
# crash server.
--disable_result_log
show processlist;
--enable_result_log
connection default;
......@@ -1163,11 +1163,11 @@ set @@sql_mode= @org_mode;
# Bug #13934 Silent truncation of table comments
#
set @@sql_mode='traditional';
--error 1105
--error ER_TOO_LONG_TABLE_COMMENT
create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*123456789*';
--error 1105
--error ER_TOO_LONG_FIELD_COMMENT
create table t1 (
i int comment
'123456789*123456789*123456789*123456789*
......
......@@ -173,21 +173,63 @@ select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select ROUND(RAND(),5);
show variables like '%alloc%';
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
set @@range_alloc_block_size=1024*16;
--echo
--echo ==+ Testing %alloc% system variables +==
--echo ==+ NOTE: These values *must* be a multiple of 1024 +==
--echo ==+ Other values will be rounded down to nearest multiple +==
--echo
--echo ==+ Show initial values +==
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
--echo ==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
--echo Testing values that are multiples of 1024
set @@range_alloc_block_size=1024*15+1024;
set @@query_alloc_block_size=1024*15+1024*2;
set @@query_prealloc_size=1024*18-1024;
set @@transaction_alloc_block_size=1024*21-1024*1;
set @@transaction_prealloc_size=1024*21-2048;
--echo ==+ Check manipulated values ==+
select @@query_alloc_block_size;
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
--echo ==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
--echo ==+ Manipulate variable values +==
--echo Testing values that are not 1024 multiples
set @@range_alloc_block_size=1024*16+1023;
set @@query_alloc_block_size=1024*17+2;
set @@query_prealloc_size=1024*18;
set @@query_prealloc_size=1024*18-1023;
set @@transaction_alloc_block_size=1024*20-1;
set @@transaction_prealloc_size=1024*21-1;
select @@query_alloc_block_size;
show variables like '%alloc%';
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
--echo ==+ Check manipulated values ==+
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
--echo ==+ information_schema data +==
SELECT * FROM information_schema.session_variables
WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
--echo ==+ Set values back to the default values +==
set @@range_alloc_block_size=default;
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
show variables like '%alloc%';
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
--echo ==+ Check the values now that they are reset +==
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
'transaction_alloc_block_size', 'transaction_prealloc_size');
#
# Bug #10904 Illegal mix of collations between
......@@ -1112,5 +1154,13 @@ SELECT @@global.expire_logs_days;
SET GLOBAL expire_logs_days = @old_eld;
#
# Bug#41030 Wrong meta data (incorrect fieldlen)
#
--enable_metadata
select @@storage_engine;
--disable_metadata
--echo End of 5.1 tests
......@@ -1191,6 +1191,46 @@ DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
#
# Bug #41354: Access control is bypassed when all columns of a view are
# selected by * wildcard
CREATE DATABASE db1;
USE db1;
CREATE TABLE t1(f1 INT, f2 INT);
CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
GRANT SELECT (f1) ON t1 TO foo;
GRANT SELECT (f1) ON v1 TO foo;
connect (addconfoo, localhost, foo,,);
connection addconfoo;
USE db1;
SELECT f1 FROM t1;
--error ER_COLUMNACCESS_DENIED_ERROR
SELECT f2 FROM t1;
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM t1;
SELECT f1 FROM v1;
--error ER_COLUMNACCESS_DENIED_ERROR
SELECT f2 FROM v1;
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM v1;
connection default;
USE test;
disconnect addconfoo;
REVOKE SELECT (f1) ON db1.t1 FROM foo;
REVOKE SELECT (f1) ON db1.v1 FROM foo;
DROP USER foo;
DROP VIEW db1.v1;
DROP TABLE db1.t1;
DROP DATABASE db1;
--echo End of 5.0 tests.
......
......@@ -4837,7 +4837,9 @@ bool Item_func_get_system_var::is_written_to_binlog()
void Item_func_get_system_var::fix_length_and_dec()
{
char *cptr;
maybe_null=0;
max_length= 0;
if (var->check_type(var_type))
{
......@@ -4867,8 +4869,14 @@ void Item_func_get_system_var::fix_length_and_dec()
break;
case SHOW_CHAR:
case SHOW_CHAR_PTR:
pthread_mutex_lock(&LOCK_global_system_variables);
cptr= var->show_type() == SHOW_CHAR_PTR ?
*(char**) var->value_ptr(current_thd, var_type, &component) :
(char*) var->value_ptr(current_thd, var_type, &component);
if (cptr)
max_length= strlen(cptr) * system_charset_info->mbmaxlen;
pthread_mutex_unlock(&LOCK_global_system_variables);
collation.set(system_charset_info, DERIVATION_SYSCONST);
max_length= MAX_BLOB_WIDTH;
decimals=NOT_FIXED_DEC;
break;
case SHOW_BOOL:
......
......@@ -4650,10 +4650,14 @@ bool flush_error_log()
uchar buf[IO_SIZE];
freopen(err_temp,"a+",stderr);
setbuf(stderr, NULL);
(void) my_delete(err_renamed, MYF(0));
my_rename(log_error_file,err_renamed,MYF(0));
if (freopen(log_error_file,"a+",stdout))
{
freopen(log_error_file,"a+",stderr);
setbuf(stderr, NULL);
}
if ((fd = my_open(err_temp, O_RDONLY, MYF(0))) >= 0)
{
......@@ -4669,7 +4673,10 @@ bool flush_error_log()
#else
my_rename(log_error_file,err_renamed,MYF(0));
if (freopen(log_error_file,"a+",stdout))
{
freopen(log_error_file,"a+",stderr);
setbuf(stderr, NULL);
}
else
result= 1;
#endif
......
......@@ -3703,7 +3703,10 @@ static int init_server_components()
#ifndef EMBEDDED_LIBRARY
if (freopen(log_error_file, "a+", stdout))
#endif
{
freopen(log_error_file, "a+", stderr);
setbuf(stderr, NULL);
}
}
}
......@@ -4331,6 +4334,7 @@ we force server id to 2, but this MySQL server will not act as a slave.");
{
freopen(log_error_file,"a+",stdout);
freopen(log_error_file,"a+",stderr);
setbuf(stderr, NULL);
FreeConsole(); // Remove window
}
#endif
......
......@@ -9239,32 +9239,37 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
KEY *cur_index_info= table->key_info;
KEY *cur_index_info_end= cur_index_info + table->s->keys;
KEY_PART_INFO *cur_part= NULL;
KEY_PART_INFO *end_part; /* Last part for loops. */
/* Last index part. */
KEY_PART_INFO *last_part= NULL;
KEY_PART_INFO *first_non_group_part= NULL;
KEY_PART_INFO *first_non_infix_part= NULL;
uint key_infix_parts= 0;
uint cur_group_key_parts= 0;
uint cur_group_prefix_len= 0;
/* Cost-related variables for the best index so far. */
double best_read_cost= DBL_MAX;
ha_rows best_records= 0;
SEL_ARG *best_index_tree= NULL;
ha_rows best_quick_prefix_records= 0;
uint best_param_idx= 0;
double cur_read_cost= DBL_MAX;
ha_rows cur_records;
const uint pk= param->table->s->primary_key;
SEL_ARG *cur_index_tree= NULL;
ha_rows cur_quick_prefix_records= 0;
uint cur_param_idx=MAX_KEY;
key_map cur_used_key_parts;
uint pk= param->table->s->primary_key;
for (uint cur_index= 0 ; cur_index_info != cur_index_info_end ;
cur_index_info++, cur_index++)
{
KEY_PART_INFO *cur_part;
KEY_PART_INFO *end_part; /* Last part for loops. */
/* Last index part. */
KEY_PART_INFO *last_part;
KEY_PART_INFO *first_non_group_part;
KEY_PART_INFO *first_non_infix_part;
uint key_infix_parts;
uint cur_group_key_parts= 0;
uint cur_group_prefix_len= 0;
double cur_read_cost;
ha_rows cur_records;
key_map used_key_parts_map;
uint cur_key_infix_len= 0;
uchar cur_key_infix[MAX_KEY_LENGTH];
uint cur_used_key_parts;
/* Check (B1) - if current index is covering. */
if (!table->covering_keys.is_set(cur_index))
goto next_index;
......@@ -9334,7 +9339,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
else if (join->select_distinct)
{
select_items_it.rewind();
cur_used_key_parts.clear_all();
used_key_parts_map.clear_all();
uint max_key_part= 0;
while ((item= select_items_it++))
{
......@@ -9345,13 +9350,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
Check if this attribute was already present in the select list.
If it was present, then its corresponding key part was alredy used.
*/
if (cur_used_key_parts.is_set(key_part_nr))
if (used_key_parts_map.is_set(key_part_nr))
continue;
if (key_part_nr < 1 || key_part_nr > join->fields_list.elements)
goto next_index;
cur_part= cur_index_info->key_part + key_part_nr - 1;
cur_group_prefix_len+= cur_part->store_length;
cur_used_key_parts.set_bit(key_part_nr);
used_key_parts_map.set_bit(key_part_nr);
++cur_group_key_parts;
max_key_part= max(max_key_part,key_part_nr);
}
......@@ -9363,7 +9368,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
ulonglong all_parts, cur_parts;
all_parts= (1<<max_key_part) - 1;
cur_parts= cur_used_key_parts.to_ulonglong() >> 1;
cur_parts= used_key_parts_map.to_ulonglong() >> 1;
if (all_parts != cur_parts)
goto next_index;
}
......@@ -9413,7 +9418,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
&dummy);
if (!get_constant_key_infix(cur_index_info, index_range_tree,
first_non_group_part, min_max_arg_part,
last_part, thd, key_infix, &key_infix_len,
last_part, thd, cur_key_infix,
&cur_key_infix_len,
&first_non_infix_part))
goto next_index;
}
......@@ -9467,9 +9473,9 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
}
/* If we got to this point, cur_index_info passes the test. */
key_infix_parts= key_infix_len ?
key_infix_parts= cur_key_infix_len ?
(first_non_infix_part - first_non_group_part) : 0;
used_key_parts= cur_group_key_parts + key_infix_parts;
cur_used_key_parts= cur_group_key_parts + key_infix_parts;
/* Compute the cost of using this index. */
if (tree)
......@@ -9481,7 +9487,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
cur_quick_prefix_records= check_quick_select(param, cur_param_idx,
cur_index_tree, TRUE);
}
cost_group_min_max(table, cur_index_info, used_key_parts,
cost_group_min_max(table, cur_index_info, cur_used_key_parts,
cur_group_key_parts, tree, cur_index_tree,
cur_quick_prefix_records, have_min, have_max,
&cur_read_cost, &cur_records);
......@@ -9492,7 +9498,6 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
if (cur_read_cost < best_read_cost - (DBL_EPSILON * cur_read_cost))
{
DBUG_ASSERT(tree != 0 || cur_param_idx == MAX_KEY);
index_info= cur_index_info;
index= cur_index;
best_read_cost= cur_read_cost;
......@@ -9502,11 +9507,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
best_param_idx= cur_param_idx;
group_key_parts= cur_group_key_parts;
group_prefix_len= cur_group_prefix_len;
key_infix_len= cur_key_infix_len;
if (key_infix_len)
memcpy (key_infix, cur_key_infix, sizeof (key_infix));
used_key_parts= cur_used_key_parts;
}
next_index:
cur_group_key_parts= 0;
cur_group_prefix_len= 0;
next_index:;
}
if (!index_info) /* No usable index found. */
DBUG_RETURN(NULL);
......
......@@ -598,7 +598,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
field.length / item->collation.collation->mbminlen :
field.length / item->collation.collation->mbmaxlen;
max_length*= thd_charset->mbmaxlen;
field_length= (max_length > UINT_MAX32) ? UINT_MAX32 : max_length;
field_length= (max_length > UINT_MAX32) ?
UINT_MAX32 : (uint32) max_length;
int4store(pos + 2, field_length);
}
pos[6]= field.type;
......
......@@ -297,21 +297,16 @@ unpack_row(Relay_log_info const *rli,
/**
Fills @c table->record[0] with default values.
First @c empty_record() is called and then, additionally, fields are
initialized explicitly with a call to @c set_default().
For optimization reasons, the explicit initialization can be skipped for
first @c skip fields. This is useful if later we are going to fill these
fields from other source (e.g. from a Rows replication event).
If @c check is true, fields are explicitly initialized only if they have
default value or can be NULL. Otherwise error is reported.
First @c restore_record() is called to restore the default values for
record concerning the given table. Then, if @c check is true,
a check is performed to see if fields are have default value or can
be NULL. Otherwise error is reported.
@param table Table whose record[0] buffer is prepared.
@param skip Number of columns for which default value initialization
@param skip Number of columns for which default/nullable check
should be skipped.
@param check Indicates if errors should be checked when setting default
values.
@param check Indicates if errors should be raised when checking
default/nullable field properties.
@returns 0 on success or a handler level error code
*/
......@@ -321,25 +316,28 @@ int prepare_record(TABLE *const table,
DBUG_ENTER("prepare_record");
int error= 0;
empty_record(table);
restore_record(table, s->default_values);
if (skip >= table->s->fields) // nothing to do
/*
This skip should be revisited in 6.0, because in 6.0 RBR one
can have holes in the row (as the grain of the writeset is
the column and not the entire row).
*/
if (skip >= table->s->fields || !check)
DBUG_RETURN(0);
/* Explicit initialization of fields */
/* Checking if exists default/nullable fields in the default values. */
for (Field **field_ptr= table->field+skip ; *field_ptr ; ++field_ptr)
{
uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
Field *const f= *field_ptr;
if (check && ((f->flags & mask) == mask))
if (((f->flags & mask) == mask))
{
my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), f->field_name);
error = HA_ERR_ROWS_EVENT_APPLY;
}
else
f->set_default();
}
DBUG_RETURN(error);
......
......@@ -110,6 +110,7 @@ static void sys_default_init_connect(THD*, enum_var_type type);
static bool sys_update_init_slave(THD*, set_var*);
static void sys_default_init_slave(THD*, enum_var_type type);
static bool set_option_bit(THD *thd, set_var *var);
static bool set_option_log_bin_bit(THD *thd, set_var *var);
static bool set_option_autocommit(THD *thd, set_var *var);
static int check_log_update(THD *thd, set_var *var);
static bool set_log_update(THD *thd, set_var *var);
......@@ -729,7 +730,7 @@ static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
OPTION_BIN_LOG);
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
check_log_update,
set_option_bit,
set_option_log_bin_bit,
OPTION_BIN_LOG);
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
set_option_bit,
......@@ -3033,6 +3034,16 @@ static bool set_option_bit(THD *thd, set_var *var)
return 0;
}
/*
Functions to be only used to update thd->options OPTION_BIN_LOG bit
*/
static bool set_option_log_bin_bit(THD *thd, set_var *var)
{
set_option_bit(thd, var);
if (!thd->in_sub_stmt)
thd->sql_log_bin_toplevel= thd->options & OPTION_BIN_LOG;
return 0;
}
static bool set_option_autocommit(THD *thd, set_var *var)
{
......
......@@ -6154,3 +6154,26 @@ WARN_PLUGIN_BUSY
ER_VARIABLE_IS_READONLY
eng "%s variable '%s' is read-only. Use SET %s to assign the value"
ER_WARN_ENGINE_TRANSACTION_ROLLBACK
eng "Storage engine %s does not support rollback for this statement. Transaction rolled back and must be restarted"
ER_SLAVE_HEARTBEAT_FAILURE
eng "Unexpected master's heartbeat data: %s"
ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
eng "The requested value for the heartbeat period %s %s"
ER_NDB_REPLICATION_SCHEMA_ERROR
eng "Bad schema for mysql.ndb_replication table. Message: %-.64s"
ER_CONFLICT_FN_PARSE_ERROR
eng "Error in parsing conflict function. Message: %-.64s"
ER_EXCEPTIONS_WRITE_ERROR
eng "Write to exceptions table failed. Message: %-.128s""
ER_TOO_LONG_TABLE_COMMENT
eng "Comment for table '%-.64s' is too long (max = %lu)"
por "Comentrio para a tabela '%-.64s' longo demais (max = %lu)"
ER_TOO_LONG_FIELD_COMMENT
eng "Comment for field '%-.64s' is too long (max = %lu)"
por "Comentrio para o campo '%-.64s' longo demais (max = %lu)"
......@@ -936,10 +936,12 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
ret= SP_INTERNAL_ERROR;
goto done;
}
/* restore sql_mode when binloging */
thd->variables.sql_mode= saved_mode;
/* Such a statement can always go directly to binlog, no trans cache */
thd->binlog_query(THD::MYSQL_QUERY_TYPE,
log_query.c_ptr(), log_query.length(), FALSE, FALSE);
thd->variables.sql_mode= 0;
}
}
......
......@@ -418,6 +418,43 @@ TYPELIB query_cache_type_typelib=
array_elements(query_cache_type_names)-1,"", query_cache_type_names, NULL
};
/**
Helper function for determine if a SELECT statement has a SQL_NO_CACHE
directive.
@param sql A pointer to the first white space character after SELECT
@return
@retval TRUE The character string contains SQL_NO_CACHE
@retval FALSE No directive found.
*/
static bool has_no_cache_directive(char *sql)
{
int i=0;
while (sql[i] == ' ')
++i;
if (my_toupper(system_charset_info, sql[i]) == 'S' &&
my_toupper(system_charset_info, sql[i+1]) == 'Q' &&
my_toupper(system_charset_info, sql[i+2]) == 'L' &&
my_toupper(system_charset_info, sql[i+3]) == '_' &&
my_toupper(system_charset_info, sql[i+4]) == 'N' &&
my_toupper(system_charset_info, sql[i+5]) == 'O' &&
my_toupper(system_charset_info, sql[i+6]) == '_' &&
my_toupper(system_charset_info, sql[i+7]) == 'C' &&
my_toupper(system_charset_info, sql[i+8]) == 'A' &&
my_toupper(system_charset_info, sql[i+9]) == 'C' &&
my_toupper(system_charset_info, sql[i+10]) == 'H' &&
my_toupper(system_charset_info, sql[i+11]) == 'E' &&
my_toupper(system_charset_info, sql[i+12]) == ' ')
return TRUE;
return FALSE;
}
/*****************************************************************************
Query_cache_block_table method(s)
*****************************************************************************/
......@@ -1233,6 +1270,16 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err;
}
if (query_length > 20 && has_no_cache_directive(&sql[i+6]))
{
/*
We do not increase 'refused' statistics here since it will be done
later when the query is parsed.
*/
DBUG_PRINT("qcache", ("The statement has a SQL_NO_CACHE directive"));
goto err;
}
}
STRUCT_LOCK(&structure_guard_mutex);
......
......@@ -538,6 +538,7 @@ THD::THD()
Open_tables_state(refresh_version), rli_fake(0),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
sql_log_bin_toplevel(false),
binlog_table_maps(0), binlog_flags(0UL),
table_map_for_update(0),
arg_of_last_insert_id_function(FALSE),
......@@ -787,6 +788,7 @@ void THD::init(void)
update_charset();
reset_current_stmt_binlog_row_based();
bzero((char *) &status_var, sizeof(status_var));
sql_log_bin_toplevel= options & OPTION_BIN_LOG;
}
......@@ -3662,7 +3664,7 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
If we are in statement mode and trying to log an unsafe statement,
we should print a warning.
*/
if (lex->is_stmt_unsafe() &&
if (sql_log_bin_toplevel && lex->is_stmt_unsafe() &&
variables.binlog_format == BINLOG_FORMAT_STMT)
{
push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
......
......@@ -1350,6 +1350,8 @@ class THD :public Statement,
/* <> 0 if we are inside of trigger or stored function. */
uint in_sub_stmt;
/* TRUE when the current top has SQL_LOG_BIN ON */
bool sql_log_bin_toplevel;
/* container for handler's private per-connection data */
Ha_data ha_data[MAX_HA];
......
......@@ -1559,6 +1559,7 @@ void st_select_lex::init_query()
exclude_from_table_unique_test= no_wrap_view_item= FALSE;
nest_level= 0;
link_next= 0;
lock_option= TL_READ_DEFAULT;
}
void st_select_lex::init_select()
......
......@@ -688,6 +688,15 @@ class st_select_lex: public st_select_lex_node
int cur_pos_in_select_list;
List<udf_func> udf_list; /* udf function calls stack */
/**
Per sub-query locking strategy.
Note: This variable might interfer with the corresponding statement-level
variable Lex::lock_option because on how different parser rules depend
on eachother.
*/
thr_lock_type lock_option;
/*
This is a copy of the original JOIN USING list that comes from
the parser. The parser :
......
......@@ -5580,6 +5580,14 @@ void mysql_reset_thd_for_next_command(THD *thd)
}
/**
Resets the lex->current_select object.
@note It is assumed that lex->current_select != NULL
This function is a wrapper around select_lex->init_select() with an added
check for the special situation when using INTO OUTFILE and LOAD DATA.
*/
void
mysql_init_select(LEX *lex)
{
......@@ -5594,6 +5602,18 @@ mysql_init_select(LEX *lex)
}
/**
Used to allocate a new SELECT_LEX object on the current thd mem_root and
link it into the relevant lists.
This function is always followed by mysql_init_select.
@see mysql_init_select
@retval TRUE An error occurred
@retval FALSE The new SELECT_LEX was successfully allocated.
*/
bool
mysql_new_select(LEX *lex, bool move_down)
{
......@@ -6411,7 +6431,6 @@ void st_select_lex::set_lock_for_tables(thr_lock_type lock_type)
DBUG_ENTER("set_lock_for_tables");
DBUG_PRINT("enter", ("lock_type: %d for_update: %d", lock_type,
for_update));
for (TABLE_LIST *tables= (TABLE_LIST*) table_list.first;
tables;
tables= tables->next_local)
......
......@@ -3796,8 +3796,19 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
cs);
table->field[4]->store((longlong) count, TRUE);
field->sql_type(type);
table->field[14]->store(type.ptr(), type.length(), cs);
table->field[14]->store(type.ptr(), type.length(), cs);
/*
MySQL column type has the following format:
base_type [(dimension)] [unsigned] [zerofill].
For DATA_TYPE column we extract only base type.
*/
tmp_buff= strchr(type.ptr(), '(');
if (!tmp_buff)
/*
if there is no dimention part then check the presence of
[unsigned] [zerofill] attributes and cut them of if exist.
*/
tmp_buff= strchr(type.ptr(), ' ');
table->field[7]->store(type.ptr(),
(tmp_buff ? tmp_buff - type.ptr() :
type.length()), cs);
......
......@@ -4297,7 +4297,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
result_code= HA_ADMIN_CORRUPT;
if (thd->main_da.is_error() &&
(thd->main_da.sql_errno() == ER_NO_SUCH_TABLE ||
thd->main_da.sql_errno() == ER_FILE_NOT_FOUND))
/* A missing table is just issued as a failed command */
result_code= HA_ADMIN_FAILED;
else
/* Default failure code is corrupt table */
result_code= HA_ADMIN_CORRUPT;
goto send_result;
}
......
......@@ -6489,7 +6489,8 @@ select_option:
{
if (check_simple_select())
MYSQL_YYABORT;
Lex->lock_option= TL_READ_HIGH_PRIORITY;
Lex->lock_option= TL_READ_HIGH_PRIORITY;
Lex->current_select->lock_option= TL_READ_HIGH_PRIORITY;
}
| DISTINCT { Select->options|= SELECT_DISTINCT; }
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
......@@ -6535,6 +6536,7 @@ select_lock_type:
{
LEX *lex=Lex;
lex->current_select->set_lock_for_tables(TL_WRITE);
lex->current_select->lock_option= TL_WRITE;
lex->safe_to_cache_query=0;
}
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
......@@ -6542,6 +6544,7 @@ select_lock_type:
LEX *lex=Lex;
lex->current_select->
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
lex->current_select->lock_option= TL_READ_WITH_SHARED_LOCKS;
lex->safe_to_cache_query=0;
}
;
......@@ -12909,6 +12912,18 @@ subselect_start:
subselect_end:
{
LEX *lex=Lex;
/*
Set the required lock level for the tables associated with the
current sub-select. This will overwrite previous lock options set
using st_select_lex::add_table_to_list in any of the following
rules: single_multi, table_wild_one, load_data, table_alias_ref,
table_factor.
The default lock level is TL_READ_DEFAULT but it can be modified
with query options specific for a certain (sub-)SELECT.
*/
lex->current_select->
set_lock_for_tables(lex->current_select->lock_option);
lex->pop_context();
SELECT_LEX *child= lex->current_select;
lex->current_select = lex->current_select->return_after_parsing();
......
......@@ -229,16 +229,16 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->comment.length, 60);
if (tmp_len < create_info->comment.length)
{
(void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'",
table);
if ((thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
{
my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len);
goto err;
}
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
ER_TOO_LONG_TABLE_COMMENT,
ER(ER_TOO_LONG_TABLE_COMMENT),
table, tmp_len);
create_info->comment.length= tmp_len;
}
......@@ -613,17 +613,16 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
255);
if (tmp_len < field->comment.length)
{
char buff[128];
(void) my_snprintf(buff,sizeof(buff), "Too long comment for field '%s'",
field->field_name);
if ((current_thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
{
my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len);
DBUG_RETURN(1);
}
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
ER_TOO_LONG_FIELD_COMMENT,
ER(ER_TOO_LONG_FIELD_COMMENT),
field->field_name, tmp_len);
field->comment.length= tmp_len;
}
......
......@@ -868,11 +868,11 @@ dict_load_table(
of the error condition, since the user may want to dump data from the
clustered index. However we load the foreign key information only if
all indexes were loaded. */
if (err != DB_SUCCESS && !srv_force_recovery) {
dict_mem_table_free(table);
table = NULL;
} else if (err == DB_SUCCESS) {
if (err == DB_SUCCESS) {
err = dict_load_foreigns(table->name, TRUE);
} else if (!srv_force_recovery) {
dict_table_remove_from_cache(table);
table = NULL;
}
#if 0
if (err != DB_SUCCESS && table != NULL) {
......
......@@ -365,8 +365,9 @@ rec_set_field_extern_bits(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
records. For new-style records, len must not be UNIV_SQL_NULL. */
is UNIV_SQL_NULL then the field is treated as an SQL null.
For records in ROW_FORMAT=COMPACT (new-style records), len must not be
UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
......@@ -375,11 +376,7 @@ rec_set_nth_field(
const ulint* offsets,/* in: array returned by rec_get_offsets() */
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data if not SQL null */
ulint len); /* in: length of the data or UNIV_SQL_NULL.
If not SQL null, must have the same
length as the previous value.
If SQL null, previous value must be
SQL null. */
ulint len); /* in: length of the data or UNIV_SQL_NULL */
/**************************************************************
The following function returns the data size of an old-style physical
record, that is the sum of field lengths. SQL null fields
......
......@@ -1219,8 +1219,9 @@ rec_get_nth_field_size(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
records. For new-style records, len must not be UNIV_SQL_NULL. */
is UNIV_SQL_NULL then the field is treated as an SQL null.
For records in ROW_FORMAT=COMPACT (new-style records), len must not be
UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
......@@ -1230,11 +1231,7 @@ rec_set_nth_field(
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data
if not SQL null */
ulint len) /* in: length of the data or UNIV_SQL_NULL.
If not SQL null, must have the same
length as the previous value.
If SQL null, previous value must be
SQL null. */
ulint len) /* in: length of the data or UNIV_SQL_NULL */
{
byte* data2;
ulint len2;
......@@ -1242,9 +1239,11 @@ rec_set_nth_field(
ut_ad(rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
if (len == UNIV_SQL_NULL) {
ut_ad(!rec_offs_comp(offsets));
rec_set_nth_field_sql_null(rec, n);
if (UNIV_UNLIKELY(len == UNIV_SQL_NULL)) {
if (!rec_offs_nth_sql_null(offsets, n)) {
ut_a(!rec_offs_comp(offsets));
rec_set_nth_field_sql_null(rec, n);
}
return;
}
......
......@@ -15,6 +15,8 @@ Created 3/26/1996 Heikki Tuuri
#include "mtr0mtr.h"
#include "trx0sys.h"
#define trx_roll_free_all_savepoints(s) trx_roll_savepoints_free((s), NULL)
/***********************************************************************
Returns a transaction savepoint taken at this point in time. */
......@@ -237,7 +239,17 @@ trx_release_savepoint_for_mysql(
const char* savepoint_name); /* in: savepoint name */
/***********************************************************************
Frees savepoint structs. */
Frees a single savepoint struct. */
void
trx_roll_savepoint_free(
/*=====================*/
trx_t* trx, /* in: transaction handle */
trx_named_savept_t* savep); /* in: savepoint to free */
/***********************************************************************
Frees savepoint structs starting from savep, if savep == NULL then
free all savepoints. */
void
trx_roll_savepoints_free(
......
......@@ -681,7 +681,10 @@ lock_is_table_exclusive(
lock_t* lock;
ibool ok = FALSE;
ut_ad(table && trx);
ut_ad(table);
ut_ad(trx);
lock_mutex_enter_kernel();
for (lock = UT_LIST_GET_FIRST(table->locks);
lock;
......@@ -689,7 +692,7 @@ lock_is_table_exclusive(
if (lock->trx != trx) {
/* A lock on the table is held
by some other transaction. */
return(FALSE);
goto not_ok;
}
if (!(lock_get_type(lock) & LOCK_TABLE)) {
......@@ -706,11 +709,16 @@ lock_is_table_exclusive(
auto_increment lock. */
break;
default:
not_ok:
/* Other table locks than LOCK_IX are not allowed. */
return(FALSE);
ok = FALSE;
goto func_exit;
}
}
func_exit:
lock_mutex_exit_kernel();
return(ok);
}
......@@ -3664,6 +3672,7 @@ lock_table_has_to_wait_in_queue(
dict_table_t* table;
lock_t* lock;
ut_ad(mutex_own(&kernel_mutex));
ut_ad(lock_get_wait(wait_lock));
table = wait_lock->un_member.tab_lock.table;
......
......@@ -185,7 +185,25 @@ trx_rollback_last_sql_stat_for_mysql(
}
/***********************************************************************
Frees savepoint structs. */
Frees a single savepoint struct. */
void
trx_roll_savepoint_free(
/*=====================*/
trx_t* trx, /* in: transaction handle */
trx_named_savept_t* savep) /* in: savepoint to free */
{
ut_a(savep != NULL);
ut_a(UT_LIST_GET_LEN(trx->trx_savepoints) > 0);
UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
mem_free(savep->name);
mem_free(savep);
}
/***********************************************************************
Frees savepoint structs starting from savep, if savep == NULL then
free all savepoints. */
void
trx_roll_savepoints_free(
......@@ -206,9 +224,7 @@ trx_roll_savepoints_free(
while (savep != NULL) {
next_savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
mem_free(savep->name);
mem_free(savep);
trx_roll_savepoint_free(trx, savep);
savep = next_savep;
}
......@@ -343,8 +359,8 @@ trx_savepoint_for_mysql(
}
/***********************************************************************
Releases a named savepoint. Savepoints which
were set after this savepoint are deleted. */
Releases only the named savepoint. Savepoints which were set after this
savepoint are left as is. */
ulint
trx_release_savepoint_for_mysql(
......@@ -360,31 +376,16 @@ trx_release_savepoint_for_mysql(
savep = UT_LIST_GET_FIRST(trx->trx_savepoints);
/* Search for the savepoint by name and free if found. */
while (savep != NULL) {
if (0 == ut_strcmp(savep->name, savepoint_name)) {
/* Found */
break;
trx_roll_savepoint_free(trx, savep);
return(DB_SUCCESS);
}
savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
}
if (savep == NULL) {
return(DB_NO_SAVEPOINT);
}
/* We can now free all savepoints strictly later than this one */
trx_roll_savepoints_free(trx, savep);
/* Now we can free this savepoint too */
UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
mem_free(savep->name);
mem_free(savep);
return(DB_SUCCESS);
return(DB_NO_SAVEPOINT);
}
/***********************************************************************
......
......@@ -930,8 +930,8 @@ trx_commit_off_kernel(
mutex_enter(&kernel_mutex);
}
/* Free savepoints */
trx_roll_savepoints_free(trx, NULL);
/* Free all savepoints */
trx_roll_free_all_savepoints(trx);
trx->conc_state = TRX_NOT_STARTED;
trx->rseg = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment