Merge branch '11.0' into 10.1
This commit is contained in:
commit
31081593aa
@ -1,60 +0,0 @@
|
||||
# Check the replication of the FOREIGN_KEY_CHECKS variable.
|
||||
|
||||
-- source include/master-slave.inc
|
||||
|
||||
eval CREATE TABLE t1 (a INT AUTO_INCREMENT KEY) ENGINE=$engine_type;
|
||||
eval CREATE TABLE t2 (b INT AUTO_INCREMENT KEY, c INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=$engine_type;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
INSERT INTO t1 VALUES (10);
|
||||
INSERT INTO t1 VALUES (NULL),(NULL),(NULL);
|
||||
INSERT INTO t2 VALUES (5,0);
|
||||
INSERT INTO t2 VALUES (NULL,LAST_INSERT_ID());
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY b;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY b;
|
||||
|
||||
connection master;
|
||||
SET TIMESTAMP=1000000000;
|
||||
CREATE TABLE t3 ( a INT UNIQUE );
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
--error ER_DUP_ENTRY
|
||||
INSERT INTO t3 VALUES (1),(1);
|
||||
sync_slave_with_master;
|
||||
|
||||
connection master;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# Bug #32468 delete rows event on a table with foreign key constraint fails
|
||||
#
|
||||
|
||||
connection master;
|
||||
|
||||
eval create table t1 (b int primary key) engine = $engine_type;
|
||||
eval create table t2 (a int primary key, b int, foreign key (b) references t1(b))
|
||||
engine = $engine_type;
|
||||
|
||||
insert into t1 set b=1;
|
||||
insert into t2 set a=1, b=1;
|
||||
|
||||
set foreign_key_checks=0;
|
||||
delete from t1;
|
||||
|
||||
--echo must sync w/o a problem (could not with the buggy code)
|
||||
sync_slave_with_master;
|
||||
select count(*) from t1 /* must be zero */;
|
||||
|
||||
|
||||
# cleanup for bug#32468
|
||||
|
||||
connection master;
|
||||
drop table t2,t1;
|
||||
|
||||
--source include/rpl_end.inc
|
@ -1447,7 +1447,7 @@ sub command_line_setup {
|
||||
|
||||
foreach my $fs (@tmpfs_locations)
|
||||
{
|
||||
if ( -d $fs && ! -l $fs )
|
||||
if ( -d $fs && ! -l $fs && -w $fs )
|
||||
{
|
||||
my $template= "var_${opt_build_thread}_XXXX";
|
||||
$opt_mem= tempdir( $template, DIR => $fs, CLEANUP => 0);
|
||||
|
@ -1733,6 +1733,22 @@ c2
|
||||
DROP TABLE t1;
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
|
||||
# optimizer_use_condition_selectivity>=3
|
||||
#
|
||||
CREATE TABLE t1 (a POINT);
|
||||
INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
set @@optimizer_use_condition_selectivity=3;
|
||||
SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
|
||||
COUNT(*)
|
||||
0
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
#
|
||||
# End 10.0 tests
|
||||
#
|
||||
SHOW CREATE TABLE information_schema.geometry_columns;
|
||||
|
@ -3733,6 +3733,34 @@ id MIN(a) MAX(a)
|
||||
4 2001-01-04 2001-01-04
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
|
||||
# and use_stat_tables= PREFERABLY
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables=PREFERABLY;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`)
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
|
||||
1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
|
||||
2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1_outer`.`a` AS `a` from <materialize> (select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where (`test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`)
|
||||
drop table t1;
|
||||
#
|
||||
# End of 10.0 tests
|
||||
#
|
||||
#
|
||||
|
@ -1519,11 +1519,13 @@ ERROR 42S22: Unknown column 'f' in 'from clause'
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (f INT);
|
||||
CALL p;
|
||||
ERROR 42S22: Unknown column 'f' in 'from clause'
|
||||
f
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (i INT);
|
||||
CALL p;
|
||||
ERROR 42S22: Unknown column 'f' in 'from clause'
|
||||
ERROR 42S22: Unknown column 't1.f' in 'field list'
|
||||
CALL p;
|
||||
ERROR 42S22: Unknown column 't1.f' in 'field list'
|
||||
DROP PROCEDURE p;
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t1 (a INT, b INT);
|
||||
|
@ -782,9 +782,9 @@ set optimizer_use_condition_selectivity=3;
|
||||
explain extended
|
||||
select * from t1 where a < 1 and a > 7;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` < 1) and (`test`.`t1`.`a` > 7))
|
||||
select * from t1 where a < 1 and a > 7;
|
||||
a
|
||||
drop table t1;
|
||||
@ -1595,3 +1595,43 @@ drop table t1,t0;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-15306: Wrong/Unexpected result with the value
|
||||
# optimizer_use_condition_selectivity set to 4
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
|
||||
BEGIN
|
||||
SET @cnt := @cnt + 1;
|
||||
RETURN 1;
|
||||
END;|
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@use_stat_tables='complementary';
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SET @cnt= 0;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
a
|
||||
1
|
||||
SELECT @cnt;
|
||||
@cnt
|
||||
1
|
||||
set @@use_stat_tables='preferably';
|
||||
analyze table t1 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
SET @cnt := 0;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
a
|
||||
1
|
||||
SELECT @cnt;
|
||||
@cnt
|
||||
2
|
||||
alter table t1 force;
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
|
@ -789,9 +789,9 @@ set optimizer_use_condition_selectivity=3;
|
||||
explain extended
|
||||
select * from t1 where a < 1 and a > 7;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` < 1) and (`test`.`t1`.`a` > 7))
|
||||
select * from t1 where a < 1 and a > 7;
|
||||
a
|
||||
drop table t1;
|
||||
@ -1605,6 +1605,46 @@ drop table t1,t0;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-15306: Wrong/Unexpected result with the value
|
||||
# optimizer_use_condition_selectivity set to 4
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
|
||||
BEGIN
|
||||
SET @cnt := @cnt + 1;
|
||||
RETURN 1;
|
||||
END;|
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@use_stat_tables='complementary';
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SET @cnt= 0;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
a
|
||||
1
|
||||
SELECT @cnt;
|
||||
@cnt
|
||||
1
|
||||
set @@use_stat_tables='preferably';
|
||||
analyze table t1 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
SET @cnt := 0;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
a
|
||||
1
|
||||
SELECT @cnt;
|
||||
@cnt
|
||||
2
|
||||
alter table t1 force;
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
|
||||
set @tmp_ust= @@use_stat_tables;
|
||||
set @tmp_oucs= @@optimizer_use_condition_selectivity;
|
||||
|
@ -7901,6 +7901,23 @@ SET S.CLOSE_YN = ''
|
||||
where 1=1;
|
||||
drop function if exists f1;
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-16957: Server crashes in Field_iterator_natural_join::next
|
||||
# upon 2nd execution of SP
|
||||
#
|
||||
CREATE TABLE t1 (a INT, b VARCHAR(32));
|
||||
CREATE PROCEDURE sp() SELECT * FROM t1 AS t1x JOIN t1 AS t1y USING (c);
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'c' in 'from clause'
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'c' in 'from clause'
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'c' in 'from clause'
|
||||
alter table t1 add column c int;
|
||||
CALL sp;
|
||||
c a b a b
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
# End of 5.5 test
|
||||
#
|
||||
# MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2
|
||||
|
@ -578,6 +578,19 @@ db_name table_name column_name min_value max_value nulls_ratio avg_length avg_fr
|
||||
DROP TABLE t1;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
|
||||
#
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
explain
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL
|
||||
1 SIMPLE user ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-16757: manual addition of min/max statistics for BLOB
|
||||
#
|
||||
SET use_stat_tables= PREFERABLY;
|
||||
|
@ -605,6 +605,19 @@ db_name table_name column_name min_value max_value nulls_ratio avg_length avg_fr
|
||||
DROP TABLE t1;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
|
||||
#
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
explain
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL
|
||||
1 SIMPLE user ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
#
|
||||
# MDEV-16757: manual addition of min/max statistics for BLOB
|
||||
#
|
||||
SET use_stat_tables= PREFERABLY;
|
||||
|
@ -14,3 +14,76 @@ ALTER TABLE `title` ADD FOREIGN KEY (`title_manager_fk`) REFERENCES `people`
|
||||
ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
drop table title, department, people;
|
||||
create table t1 (a int primary key, b int) engine=innodb;
|
||||
create table t2 (c int primary key, d int,
|
||||
foreign key (d) references t1 (a) on update cascade) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
insert t2 values (4,1),(5,2),(6,3);
|
||||
flush table t2 with read lock;
|
||||
connect con1,localhost,root;
|
||||
delete from t1 where a=2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
|
||||
update t1 set a=10 where a=1;
|
||||
connection default;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
connection default;
|
||||
lock table t2 write;
|
||||
connection con1;
|
||||
delete from t1 where a=2;
|
||||
connection default;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
|
||||
connection default;
|
||||
unlock tables;
|
||||
disconnect con1;
|
||||
create user foo;
|
||||
grant select,update on test.t1 to foo;
|
||||
connect foo,localhost,foo;
|
||||
update t1 set a=30 where a=3;
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from t2;
|
||||
c d
|
||||
5 2
|
||||
4 10
|
||||
6 30
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
create table t1 (f1 int primary key) engine=innodb;
|
||||
create table t2 (f2 int primary key) engine=innodb;
|
||||
create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t2 values (1),(2),(3),(4),(5);
|
||||
insert into t3 values (1),(2),(3),(4),(5);
|
||||
connect con1,localhost,root;
|
||||
set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
|
||||
alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
|
||||
connection default;
|
||||
set debug_sync='before_execute_sql_command wait_for g1';
|
||||
update t1 set f1 = f1 + 100000 limit 2;
|
||||
connect con2,localhost,root;
|
||||
kill query UPDATE;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
ERROR 70100: Query execution was interrupted
|
||||
set debug_sync='now signal g2';
|
||||
connection con1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`f2` int(11) NOT NULL,
|
||||
PRIMARY KEY (`f2`),
|
||||
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
disconnect con1;
|
||||
connection default;
|
||||
select * from t2 where f2 not in (select f1 from t1);
|
||||
f2
|
||||
select * from t3 where f3 not in (select f2 from t2);
|
||||
f3
|
||||
drop table t3;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set debug_sync='reset';
|
||||
|
19
mysql-test/suite/innodb/r/foreign_key.result
Normal file
19
mysql-test/suite/innodb/r/foreign_key.result
Normal file
@ -0,0 +1,19 @@
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
CREATE TABLE staff (
|
||||
staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
store_id TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (staff_id),
|
||||
KEY idx_fk_store_id (store_id),
|
||||
CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE store (
|
||||
store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
manager_staff_id TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (store_id),
|
||||
UNIQUE KEY idx_unique_manager (manager_staff_id),
|
||||
CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
SET FOREIGN_KEY_CHECKS=DEFAULT;
|
||||
LOCK TABLE staff WRITE;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLES staff, store;
|
@ -1,5 +1,8 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
|
||||
--enable_connect_log
|
||||
|
||||
--echo #
|
||||
--echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE
|
||||
@ -24,3 +27,87 @@ ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
|
||||
drop table title, department, people;
|
||||
|
||||
#
|
||||
# FK and prelocking:
|
||||
# child table accesses (reads and writes) wait for locks.
|
||||
#
|
||||
create table t1 (a int primary key, b int) engine=innodb;
|
||||
create table t2 (c int primary key, d int,
|
||||
foreign key (d) references t1 (a) on update cascade) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
insert t2 values (4,1),(5,2),(6,3);
|
||||
flush table t2 with read lock; # this takes MDL_SHARED_NO_WRITE
|
||||
connect (con1,localhost,root);
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t1 where a=2;
|
||||
send update t1 set a=10 where a=1;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
reap;
|
||||
connection default;
|
||||
lock table t2 write; # this takes MDL_SHARED_NO_READ_WRITE
|
||||
connection con1;
|
||||
send delete from t1 where a=2;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
reap;
|
||||
connection default;
|
||||
unlock tables;
|
||||
disconnect con1;
|
||||
|
||||
# but privileges should not be checked
|
||||
create user foo;
|
||||
grant select,update on test.t1 to foo;
|
||||
connect(foo,localhost,foo);
|
||||
update t1 set a=30 where a=3;
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from t2;
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
|
||||
#
|
||||
# MDEV-16465 Invalid (old?) table or database name or hang in ha_innobase::delete_table and log semaphore wait upon concurrent DDL with foreign keys
|
||||
#
|
||||
create table t1 (f1 int primary key) engine=innodb;
|
||||
create table t2 (f2 int primary key) engine=innodb;
|
||||
create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t2 values (1),(2),(3),(4),(5);
|
||||
insert into t3 values (1),(2),(3),(4),(5);
|
||||
connect con1,localhost,root;
|
||||
set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
|
||||
send alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
|
||||
connection default;
|
||||
let $conn=`select connection_id()`;
|
||||
set debug_sync='before_execute_sql_command wait_for g1';
|
||||
send update t1 set f1 = f1 + 100000 limit 2;
|
||||
connect con2,localhost,root;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock' and info like 'update t1 %';
|
||||
source include/wait_condition.inc;
|
||||
--replace_result $conn UPDATE
|
||||
eval kill query $conn;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
error ER_QUERY_INTERRUPTED;
|
||||
reap;
|
||||
set debug_sync='now signal g2';
|
||||
connection con1;
|
||||
reap;
|
||||
show create table t2;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
select * from t2 where f2 not in (select f1 from t1);
|
||||
select * from t3 where f3 not in (select f2 from t2);
|
||||
drop table t3;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set debug_sync='reset';
|
||||
|
25
mysql-test/suite/innodb/t/foreign_key.test
Normal file
25
mysql-test/suite/innodb/t/foreign_key.test
Normal file
@ -0,0 +1,25 @@
|
||||
--source include/have_innodb.inc
|
||||
|
||||
#
|
||||
# MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
|
||||
#
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
CREATE TABLE staff (
|
||||
staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
store_id TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (staff_id),
|
||||
KEY idx_fk_store_id (store_id),
|
||||
CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE store (
|
||||
store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
manager_staff_id TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (store_id),
|
||||
UNIQUE KEY idx_unique_manager (manager_staff_id),
|
||||
CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
SET FOREIGN_KEY_CHECKS=DEFAULT;
|
||||
|
||||
LOCK TABLE staff WRITE;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLES staff, store;
|
33
mysql-test/suite/maria/create.result
Normal file
33
mysql-test/suite/maria/create.result
Normal file
@ -0,0 +1,33 @@
|
||||
CREATE OR REPLACE TABLE t1 (
|
||||
f1 DECIMAL(43,0) NOT NULL,
|
||||
f2 TIME(4) NULL,
|
||||
f3 BINARY(101) NULL,
|
||||
f4 TIMESTAMP(4) NULL,
|
||||
f5 DATETIME(1) NULL,
|
||||
f6 SET('a','b','c') NOT NULL DEFAULT 'a',
|
||||
f7 VARBINARY(2332) NOT NULL DEFAULT '',
|
||||
f8 DATE NULL,
|
||||
f9 BLOB NULL,
|
||||
f10 MEDIUMINT(45) NOT NULL DEFAULT 0,
|
||||
f11 YEAR NULL,
|
||||
f12 BIT(58) NULL,
|
||||
v2 TIME(1) AS (f2) VIRTUAL,
|
||||
v3 BINARY(115) AS (f3) VIRTUAL,
|
||||
v4 TIMESTAMP(3) AS (f4) VIRTUAL,
|
||||
v7 VARBINARY(658) AS (f7) PERSISTENT,
|
||||
v8 DATE AS (f8) PERSISTENT,
|
||||
v9 TINYTEXT AS (f9) PERSISTENT,
|
||||
v11 YEAR AS (f11) VIRTUAL
|
||||
) ENGINE=Aria;
|
||||
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
|
||||
(0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'f1' at row 1
|
||||
DROP TABLE t1;
|
||||
CREATE OR REPLACE TABLE t1 (a INT(45));
|
||||
INSERT IGNORE INTO t1 VALUES (1),(2);
|
||||
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
|
||||
select * from t2;
|
||||
f1 f2
|
||||
3 qux
|
||||
DROP TABLE t1, t2;
|
42
mysql-test/suite/maria/create.test
Normal file
42
mysql-test/suite/maria/create.test
Normal file
@ -0,0 +1,42 @@
|
||||
--source include/have_maria.inc
|
||||
|
||||
# MDEV-17021
|
||||
# Server crash or assertion `length <= column->length' failure in
|
||||
# write_block_record
|
||||
#
|
||||
|
||||
CREATE OR REPLACE TABLE t1 (
|
||||
f1 DECIMAL(43,0) NOT NULL,
|
||||
f2 TIME(4) NULL,
|
||||
f3 BINARY(101) NULL,
|
||||
f4 TIMESTAMP(4) NULL,
|
||||
f5 DATETIME(1) NULL,
|
||||
f6 SET('a','b','c') NOT NULL DEFAULT 'a',
|
||||
f7 VARBINARY(2332) NOT NULL DEFAULT '',
|
||||
f8 DATE NULL,
|
||||
f9 BLOB NULL,
|
||||
f10 MEDIUMINT(45) NOT NULL DEFAULT 0,
|
||||
f11 YEAR NULL,
|
||||
f12 BIT(58) NULL,
|
||||
v2 TIME(1) AS (f2) VIRTUAL,
|
||||
v3 BINARY(115) AS (f3) VIRTUAL,
|
||||
v4 TIMESTAMP(3) AS (f4) VIRTUAL,
|
||||
v7 VARBINARY(658) AS (f7) PERSISTENT,
|
||||
v8 DATE AS (f8) PERSISTENT,
|
||||
v9 TINYTEXT AS (f9) PERSISTENT,
|
||||
v11 YEAR AS (f11) VIRTUAL
|
||||
) ENGINE=Aria;
|
||||
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
|
||||
(0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# MDEV-17067 Server crash in write_block_record
|
||||
#
|
||||
|
||||
CREATE OR REPLACE TABLE t1 (a INT(45));
|
||||
INSERT IGNORE INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
|
||||
select * from t2;
|
||||
DROP TABLE t1, t2;
|
@ -2732,6 +2732,10 @@ id name
|
||||
-1 dog
|
||||
2 cat
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (pk int, i2 int) ENGINE=Aria;
|
||||
INSERT INTO t1 VALUES (1,2), (2,3),(3,4);
|
||||
DELETE FROM tt.*, t1.* USING t1 AS tt LEFT JOIN t1 ON (tt.i2 = t1.pk);
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
|
@ -2002,6 +2002,16 @@ INSERT INTO t1 (name) VALUES ('cat');
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# MDEV-16682
|
||||
# Assertion `(buff[7] & 7) == HEAD_PAGE' failed.
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (pk int, i2 int) ENGINE=Aria;
|
||||
INSERT INTO t1 VALUES (1,2), (2,3),(3,4);
|
||||
DELETE FROM tt.*, t1.* USING t1 AS tt LEFT JOIN t1 ON (tt.i2 = t1.pk);
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
--echo #
|
||||
|
@ -37,8 +37,7 @@ SET FOREIGN_KEY_CHECKS=0;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
create table t1 (b int primary key) engine = INNODB;
|
||||
create table t2 (a int primary key, b int, foreign key (b) references t1(b))
|
||||
engine = INNODB;
|
||||
create table t2 (a int primary key, b int, foreign key (b) references t1(b)) engine = INNODB;
|
||||
insert into t1 set b=1;
|
||||
insert into t2 set a=1, b=1;
|
||||
set foreign_key_checks=0;
|
||||
|
@ -1,3 +1,61 @@
|
||||
-- source include/have_innodb.inc
|
||||
let $engine_type=INNODB;
|
||||
-- source extra/rpl_tests/rpl_foreign_key.test
|
||||
|
||||
# Check the replication of the FOREIGN_KEY_CHECKS variable.
|
||||
|
||||
-- source include/master-slave.inc
|
||||
|
||||
CREATE TABLE t1 (a INT AUTO_INCREMENT KEY) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (b INT AUTO_INCREMENT KEY, c INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=INNODB;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
INSERT INTO t1 VALUES (10);
|
||||
INSERT INTO t1 VALUES (NULL),(NULL),(NULL);
|
||||
INSERT INTO t2 VALUES (5,0);
|
||||
INSERT INTO t2 VALUES (NULL,LAST_INSERT_ID());
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY b;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY b;
|
||||
|
||||
connection master;
|
||||
SET TIMESTAMP=1000000000;
|
||||
CREATE TABLE t3 ( a INT UNIQUE );
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
--error ER_DUP_ENTRY
|
||||
INSERT INTO t3 VALUES (1),(1);
|
||||
sync_slave_with_master;
|
||||
|
||||
connection master;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
DROP TABLE IF EXISTS t1,t2,t3;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# Bug #32468 delete rows event on a table with foreign key constraint fails
|
||||
#
|
||||
|
||||
connection master;
|
||||
|
||||
create table t1 (b int primary key) engine = INNODB;
|
||||
create table t2 (a int primary key, b int, foreign key (b) references t1(b)) engine = INNODB;
|
||||
|
||||
insert into t1 set b=1;
|
||||
insert into t2 set a=1, b=1;
|
||||
|
||||
set foreign_key_checks=0;
|
||||
delete from t1;
|
||||
|
||||
--echo must sync w/o a problem (could not with the buggy code)
|
||||
sync_slave_with_master;
|
||||
select count(*) from t1 /* must be zero */;
|
||||
|
||||
|
||||
# cleanup for bug#32468
|
||||
|
||||
connection master;
|
||||
drop table t2,t1;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
@ -1478,6 +1478,21 @@ SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FR
|
||||
DROP TABLE t1;
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
|
||||
--echo # optimizer_use_condition_selectivity>=3
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a POINT);
|
||||
INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
set @@optimizer_use_condition_selectivity=3;
|
||||
SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End 10.0 tests
|
||||
|
@ -1519,6 +1519,23 @@ ALTER TABLE t1 ADD KEY(id,a);
|
||||
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=DATE'2001-01-04' GROUP BY id;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
|
||||
--echo # and use_stat_tables= PREFERABLY
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
|
||||
INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
|
||||
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
|
||||
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables=PREFERABLY;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set @@use_stat_tables=@save_use_stat_tables;
|
||||
explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.0 tests
|
||||
|
@ -1185,12 +1185,13 @@ CREATE TABLE t (f INT);
|
||||
#
|
||||
# The following shouldn't fail as the table is now matching the using
|
||||
#
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL p;
|
||||
DROP TABLE t;
|
||||
CREATE TABLE t (i INT);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL p;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL p;
|
||||
DROP PROCEDURE p;
|
||||
DROP TABLE t;
|
||||
|
||||
|
@ -1066,3 +1066,39 @@ drop table t1,t0;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-15306: Wrong/Unexpected result with the value
|
||||
--echo # optimizer_use_condition_selectivity set to 4
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
|
||||
delimiter |;
|
||||
CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
|
||||
BEGIN
|
||||
SET @cnt := @cnt + 1;
|
||||
RETURN 1;
|
||||
END;|
|
||||
delimiter ;|
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @save_use_stat_tables= @@use_stat_tables;
|
||||
set @@use_stat_tables='complementary';
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SET @cnt= 0;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
SELECT @cnt;
|
||||
|
||||
set @@use_stat_tables='preferably';
|
||||
analyze table t1 persistent for all;
|
||||
SET @cnt := 0;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
SELECT * FROM t1 WHERE a = f1();
|
||||
SELECT @cnt;
|
||||
alter table t1 force;
|
||||
set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
|
||||
|
@ -9349,6 +9349,27 @@ where 1=1;
|
||||
drop function if exists f1;
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16957: Server crashes in Field_iterator_natural_join::next
|
||||
--echo # upon 2nd execution of SP
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT, b VARCHAR(32));
|
||||
CREATE PROCEDURE sp() SELECT * FROM t1 AS t1x JOIN t1 AS t1y USING (c);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
alter table t1 add column c int;
|
||||
CALL sp;
|
||||
|
||||
# Cleanup
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo # End of 5.5 test
|
||||
|
||||
--echo #
|
||||
|
@ -357,6 +357,18 @@ DROP TABLE t1;
|
||||
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables= PREFERABLY;
|
||||
explain
|
||||
SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16757: manual addition of min/max statistics for BLOB
|
||||
--echo #
|
||||
|
@ -238,7 +238,7 @@ cannot_find_file()
|
||||
echo
|
||||
echo "If you compiled from source, you need to either run 'make install' to"
|
||||
echo "copy the software into the correct location ready for operation."
|
||||
echo "If you don't want to do a full install, you can use the --srcddir"
|
||||
echo "If you don't want to do a full install, you can use the --srcdir"
|
||||
echo "option to only install the mysql database and privilege tables"
|
||||
echo
|
||||
echo "If you compiled from source, you need to either run 'make install' to"
|
||||
|
17
sql/field.cc
17
sql/field.cc
@ -9782,13 +9782,18 @@ void Create_field::create_length_to_internal_length(void)
|
||||
}
|
||||
break;
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
key_length= pack_length=
|
||||
my_decimal_get_binary_size(my_decimal_length_to_precision(length,
|
||||
decimals,
|
||||
flags &
|
||||
UNSIGNED_FLAG),
|
||||
decimals);
|
||||
{
|
||||
/*
|
||||
This code must be identical to code in
|
||||
Field_new_decimal::Field_new_decimal as otherwise the record layout
|
||||
gets out of sync.
|
||||
*/
|
||||
uint precision= my_decimal_length_to_precision(length, decimals,
|
||||
flags & UNSIGNED_FLAG);
|
||||
set_if_smaller(precision, DECIMAL_MAX_PRECISION);
|
||||
key_length= pack_length= my_decimal_get_binary_size(precision, decimals);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
key_length= pack_length= calc_pack_length(sql_type, length);
|
||||
break;
|
||||
|
10
sql/item.cc
10
sql/item.cc
@ -8650,13 +8650,11 @@ void Item_trigger_field::cleanup()
|
||||
|
||||
Item_result item_cmp_type(Item_result a,Item_result b)
|
||||
{
|
||||
if (a == STRING_RESULT && b == STRING_RESULT)
|
||||
return STRING_RESULT;
|
||||
if (a == INT_RESULT && b == INT_RESULT)
|
||||
return INT_RESULT;
|
||||
else if (a == ROW_RESULT || b == ROW_RESULT)
|
||||
if (a == b)
|
||||
return a;
|
||||
if (a == ROW_RESULT || b == ROW_RESULT)
|
||||
return ROW_RESULT;
|
||||
else if (a == TIME_RESULT || b == TIME_RESULT)
|
||||
if (a == TIME_RESULT || b == TIME_RESULT)
|
||||
return TIME_RESULT;
|
||||
if ((a == INT_RESULT || a == DECIMAL_RESULT) &&
|
||||
(b == INT_RESULT || b == DECIMAL_RESULT))
|
||||
|
@ -633,7 +633,7 @@ static SYMBOL symbols[] = {
|
||||
{ "UPGRADE", SYM(UPGRADE_SYM)},
|
||||
{ "USAGE", SYM(USAGE)},
|
||||
{ "USE", SYM(USE_SYM)},
|
||||
{ "USER", SYM(USER)},
|
||||
{ "USER", SYM(USER_SYM)},
|
||||
{ "USER_RESOURCES", SYM(RESOURCES)},
|
||||
{ "USE_FRM", SYM(USE_FRM)},
|
||||
{ "USING", SYM(USING)},
|
||||
@ -690,7 +690,7 @@ static SYMBOL sql_functions[] = {
|
||||
{ "MIN", SYM(MIN_SYM)},
|
||||
{ "NOW", SYM(NOW_SYM)},
|
||||
{ "POSITION", SYM(POSITION_SYM)},
|
||||
{ "SESSION_USER", SYM(USER)},
|
||||
{ "SESSION_USER", SYM(USER_SYM)},
|
||||
{ "STD", SYM(STD_SYM)},
|
||||
{ "STDDEV", SYM(STD_SYM)},
|
||||
{ "STDDEV_POP", SYM(STD_SYM)},
|
||||
@ -700,7 +700,7 @@ static SYMBOL sql_functions[] = {
|
||||
{ "SUBSTRING", SYM(SUBSTRING)},
|
||||
{ "SUM", SYM(SUM_SYM)},
|
||||
{ "SYSDATE", SYM(SYSDATE)},
|
||||
{ "SYSTEM_USER", SYM(USER)},
|
||||
{ "SYSTEM_USER", SYM(USER_SYM)},
|
||||
{ "TRIM", SYM(TRIM)},
|
||||
{ "VARIANCE", SYM(VARIANCE_SYM)},
|
||||
{ "VAR_POP", SYM(VARIANCE_SYM)},
|
||||
|
@ -2738,13 +2738,19 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
|
||||
|
||||
for (field_ptr= table->field; *field_ptr; field_ptr++)
|
||||
{
|
||||
if (bitmap_is_set(used_fields, (*field_ptr)->field_index))
|
||||
Column_statistics* col_stats= (*field_ptr)->read_stats;
|
||||
if (bitmap_is_set(used_fields, (*field_ptr)->field_index)
|
||||
&& col_stats && !col_stats->no_stat_values_provided()
|
||||
&& !((*field_ptr)->type() == MYSQL_TYPE_GEOMETRY))
|
||||
parts++;
|
||||
}
|
||||
|
||||
KEY_PART *key_part;
|
||||
uint keys= 0;
|
||||
|
||||
if (!parts)
|
||||
return TRUE;
|
||||
|
||||
if (!(key_part= (KEY_PART *) alloc_root(param->mem_root,
|
||||
sizeof(KEY_PART) * parts)))
|
||||
return TRUE;
|
||||
@ -2756,6 +2762,9 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
|
||||
if (bitmap_is_set(used_fields, (*field_ptr)->field_index))
|
||||
{
|
||||
Field *field= *field_ptr;
|
||||
if (field->type() == MYSQL_TYPE_GEOMETRY)
|
||||
continue;
|
||||
|
||||
uint16 store_length;
|
||||
uint16 max_key_part_length= (uint16) table->file->max_key_part_length();
|
||||
key_part->key= keys;
|
||||
@ -2913,7 +2922,18 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
|
||||
|
||||
table->cond_selectivity= 1.0;
|
||||
|
||||
if (!*cond || table_records == 0)
|
||||
if (table_records == 0)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
QUICK_SELECT_I *quick;
|
||||
if ((quick=table->reginfo.join_tab->quick) &&
|
||||
quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
|
||||
{
|
||||
table->cond_selectivity*= (quick->records/table_records);
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
if (!*cond)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
if (table->pos_in_table_list->schema_table)
|
||||
@ -3030,7 +3050,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
|
||||
*/
|
||||
|
||||
if (thd->variables.optimizer_use_condition_selectivity > 2 &&
|
||||
!bitmap_is_clear_all(used_fields))
|
||||
!bitmap_is_clear_all(used_fields) &&
|
||||
thd->variables.use_stat_tables > 0)
|
||||
{
|
||||
PARAM param;
|
||||
MEM_ROOT alloc;
|
||||
|
@ -4236,7 +4236,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||
if (stab->temp)
|
||||
continue;
|
||||
|
||||
if (!(tab_buff= (char *)thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST)) *
|
||||
if (!(tab_buff= (char *)thd->alloc(ALIGN_SIZE(sizeof(TABLE_LIST)) *
|
||||
stab->lock_count)) ||
|
||||
!(key_buff= (char*)thd->memdup(stab->qname.str,
|
||||
stab->qname.length)))
|
||||
@ -4245,32 +4245,11 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
||||
for (uint j= 0; j < stab->lock_count; j++)
|
||||
{
|
||||
table= (TABLE_LIST *)tab_buff;
|
||||
|
||||
table->db= key_buff;
|
||||
table->db_length= stab->db_length;
|
||||
table->table_name= table->db + table->db_length + 1;
|
||||
table->table_name_length= stab->table_name_length;
|
||||
table->alias= table->table_name + table->table_name_length + 1;
|
||||
table->lock_type= stab->lock_type;
|
||||
table->cacheable_table= 1;
|
||||
table->prelocking_placeholder= 1;
|
||||
table->belong_to_view= belong_to_view;
|
||||
table->trg_event_map= stab->trg_event_map;
|
||||
/*
|
||||
Since we don't allow DDL on base tables in prelocked mode it
|
||||
is safe to infer the type of metadata lock from the type of
|
||||
table lock.
|
||||
*/
|
||||
table->mdl_request.init(MDL_key::TABLE, table->db, table->table_name,
|
||||
table->lock_type >= TL_WRITE_ALLOW_WRITE ?
|
||||
MDL_SHARED_WRITE : MDL_SHARED_READ,
|
||||
MDL_TRANSACTION);
|
||||
|
||||
/* Everyting else should be zeroed */
|
||||
|
||||
**query_tables_last_ptr= table;
|
||||
table->prev_global= *query_tables_last_ptr;
|
||||
*query_tables_last_ptr= &table->next_global;
|
||||
table->init_one_table_for_prelocking(key_buff, stab->db_length,
|
||||
key_buff + stab->db_length + 1, stab->table_name_length,
|
||||
key_buff + stab->db_length + stab->table_name_length + 2,
|
||||
stab->lock_type, true, belong_to_view, stab->trg_event_map,
|
||||
query_tables_last_ptr);
|
||||
|
||||
tab_buff+= ALIGN_SIZE(sizeof(TABLE_LIST));
|
||||
result= TRUE;
|
||||
|
@ -4870,6 +4870,25 @@ handle_routine(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@note this can be changed to use a hash, instead of scanning the linked
|
||||
list, if the performance of this function will ever become an issue
|
||||
*/
|
||||
bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
|
||||
LEX_STRING *table, thr_lock_type lock_type)
|
||||
{
|
||||
for (; tl; tl= tl->next_global )
|
||||
{
|
||||
if (tl->lock_type >= lock_type &&
|
||||
tl->prelocking_placeholder == TABLE_LIST::FK &&
|
||||
strcmp(tl->db, db->str) == 0 &&
|
||||
strcmp(tl->table_name, table->str) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Defines how prelocking algorithm for DML statements should handle table list
|
||||
elements:
|
||||
@ -4909,6 +4928,52 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
add_tables_and_routines_for_triggers(thd, prelocking_ctx, table_list))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (table_list->table->file->referenced_by_foreign_key())
|
||||
{
|
||||
List <FOREIGN_KEY_INFO> fk_list;
|
||||
List_iterator<FOREIGN_KEY_INFO> fk_list_it(fk_list);
|
||||
FOREIGN_KEY_INFO *fk;
|
||||
Query_arena *arena, backup;
|
||||
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
table_list->table->file->get_parent_foreign_key_list(thd, &fk_list);
|
||||
if (thd->is_error())
|
||||
{
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*need_prelocking= TRUE;
|
||||
|
||||
while ((fk= fk_list_it++))
|
||||
{
|
||||
// FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access
|
||||
uint8 op= table_list->trg_event_map;
|
||||
thr_lock_type lock_type;
|
||||
|
||||
if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method))
|
||||
|| (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method)))
|
||||
lock_type= TL_WRITE_ALLOW_WRITE;
|
||||
else
|
||||
lock_type= TL_READ;
|
||||
|
||||
if (table_already_fk_prelocked(prelocking_ctx->query_tables,
|
||||
fk->foreign_db, fk->foreign_table,
|
||||
lock_type))
|
||||
continue;
|
||||
|
||||
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
|
||||
tl->init_one_table_for_prelocking(fk->foreign_db->str, fk->foreign_db->length,
|
||||
fk->foreign_table->str, fk->foreign_table->length,
|
||||
NULL, lock_type, false, table_list->belong_to_view,
|
||||
op, &prelocking_ctx->query_tables_last);
|
||||
}
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -7544,10 +7609,22 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join,
|
||||
|
||||
result= FALSE;
|
||||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(result);
|
||||
|
||||
err:
|
||||
/*
|
||||
Actually we failed to build join columns list, so we have to
|
||||
clear it to avoid problems with half-build join on next run.
|
||||
The list was created in mark_common_columns().
|
||||
*/
|
||||
table_ref_1->remove_join_columns();
|
||||
table_ref_2->remove_join_columns();
|
||||
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,6 +148,8 @@ my_bool mysql_rm_tmp_tables(void);
|
||||
bool rm_temporary_table(handlerton *base, const char *path);
|
||||
void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
|
||||
const MDL_savepoint &start_of_statement_svp);
|
||||
bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_STRING *db,
|
||||
LEX_STRING *table, thr_lock_type lock_type);
|
||||
TABLE_LIST *find_table_in_list(TABLE_LIST *table,
|
||||
TABLE_LIST *TABLE_LIST::*link,
|
||||
const char *db_name,
|
||||
|
@ -5575,7 +5575,8 @@ has_write_table_with_auto_increment_and_select(TABLE_LIST *tables)
|
||||
for(TABLE_LIST *table= tables; table; table= table->next_global)
|
||||
{
|
||||
if (!table->placeholder() &&
|
||||
(table->lock_type <= TL_READ_NO_INSERT))
|
||||
table->lock_type <= TL_READ_NO_INSERT &&
|
||||
table->prelocking_placeholder != TABLE_LIST::FK)
|
||||
{
|
||||
has_select= true;
|
||||
break;
|
||||
|
@ -342,8 +342,6 @@ class Foreign_key: public Key {
|
||||
public:
|
||||
enum fk_match_opt { FK_MATCH_UNDEF, FK_MATCH_FULL,
|
||||
FK_MATCH_PARTIAL, FK_MATCH_SIMPLE};
|
||||
enum fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
|
||||
FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_DEFAULT};
|
||||
|
||||
LEX_STRING ref_db;
|
||||
LEX_STRING ref_table;
|
||||
|
@ -2592,8 +2592,8 @@ public:
|
||||
uint profile_options;
|
||||
uint grant, grant_tot_col, which_columns;
|
||||
enum Foreign_key::fk_match_opt fk_match_option;
|
||||
enum Foreign_key::fk_option fk_update_opt;
|
||||
enum Foreign_key::fk_option fk_delete_opt;
|
||||
enum_fk_option fk_update_opt;
|
||||
enum_fk_option fk_delete_opt;
|
||||
uint slave_thd_opt, start_transaction_opt;
|
||||
int nest_level;
|
||||
/*
|
||||
|
@ -25242,7 +25242,7 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
|
||||
const char *t_alias= alias;
|
||||
|
||||
str->append(' ');
|
||||
if (lower_case_table_names== 1)
|
||||
if (lower_case_table_names == 1)
|
||||
{
|
||||
if (alias && alias[0])
|
||||
{
|
||||
|
@ -7388,6 +7388,7 @@ get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
|
||||
LEX_STRING *db_name, LEX_STRING *table_name)
|
||||
{
|
||||
CHARSET_INFO *cs= system_charset_info;
|
||||
LEX_CSTRING *s;
|
||||
DBUG_ENTER("get_referential_constraints_record");
|
||||
|
||||
if (res)
|
||||
@ -7432,10 +7433,10 @@ get_referential_constraints_record(THD *thd, TABLE_LIST *tables,
|
||||
else
|
||||
table->field[5]->set_null();
|
||||
table->field[6]->store(STRING_WITH_LEN("NONE"), cs);
|
||||
table->field[7]->store(f_key_info->update_method->str,
|
||||
f_key_info->update_method->length, cs);
|
||||
table->field[8]->store(f_key_info->delete_method->str,
|
||||
f_key_info->delete_method->length, cs);
|
||||
s= fk_option_name(f_key_info->update_method);
|
||||
table->field[7]->store(s->str, s->length, cs);
|
||||
s= fk_option_name(f_key_info->delete_method);
|
||||
table->field[8]->store(s->str, s->length, cs);
|
||||
if (schema_table_store_record(thd, table))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -3268,6 +3268,9 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables)
|
||||
if (!tl->is_view_or_derived() && !is_temporary_table(tl) && tl->table)
|
||||
{
|
||||
TABLE_SHARE *table_share= tl->table->s;
|
||||
if (table_share && !(table_share->table_category == TABLE_CATEGORY_USER))
|
||||
continue;
|
||||
|
||||
if (table_share &&
|
||||
table_share->stats_cb.stats_can_be_read &&
|
||||
!table_share->stats_cb.stats_is_read)
|
||||
|
@ -345,12 +345,17 @@ private:
|
||||
public:
|
||||
|
||||
Histogram histogram;
|
||||
|
||||
uint32 no_values_provided_bitmap()
|
||||
{
|
||||
return
|
||||
((1 << (COLUMN_STAT_HISTOGRAM-COLUMN_STAT_COLUMN_NAME))-1) <<
|
||||
(COLUMN_STAT_COLUMN_NAME+1);
|
||||
}
|
||||
|
||||
void set_all_nulls()
|
||||
{
|
||||
column_stat_nulls=
|
||||
((1 << (COLUMN_STAT_HISTOGRAM-COLUMN_STAT_COLUMN_NAME))-1) <<
|
||||
(COLUMN_STAT_COLUMN_NAME+1);
|
||||
column_stat_nulls= no_values_provided_bitmap();
|
||||
}
|
||||
|
||||
void set_not_null(uint stat_field_no)
|
||||
@ -396,8 +401,22 @@ public:
|
||||
bool min_max_values_are_provided()
|
||||
{
|
||||
return !is_null(COLUMN_STAT_MIN_VALUE) &&
|
||||
!is_null(COLUMN_STAT_MIN_VALUE);
|
||||
}
|
||||
!is_null(COLUMN_STAT_MAX_VALUE);
|
||||
}
|
||||
/*
|
||||
This function checks whether the values for the fields of the statistical
|
||||
tables that were NULL by DEFAULT for a column have changed or not.
|
||||
|
||||
@retval
|
||||
TRUE: Statistics are not present for a column
|
||||
FALSE: Statisitics are present for a column
|
||||
*/
|
||||
bool no_stat_values_provided()
|
||||
{
|
||||
if (column_stat_nulls == no_values_provided_bitmap())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -3316,6 +3316,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
}
|
||||
}
|
||||
|
||||
/* Virtual fields are always NULL */
|
||||
if (sql_field->vcol_info)
|
||||
sql_field->flags&= ~NOT_NULL_FLAG;
|
||||
|
||||
if (sql_field->sql_type == MYSQL_TYPE_SET ||
|
||||
sql_field->sql_type == MYSQL_TYPE_ENUM)
|
||||
{
|
||||
@ -9129,8 +9133,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
alter_ctx.tmp_name, strlen(alter_ctx.tmp_name),
|
||||
alter_ctx.tmp_name, TL_READ_NO_INSERT);
|
||||
/* Table is in thd->temporary_tables */
|
||||
(void) open_temporary_table(thd, &tbl);
|
||||
if (open_temporary_table(thd, &tbl))
|
||||
goto err_new_table_cleanup;
|
||||
new_table= tbl.table;
|
||||
DBUG_ASSERT(new_table);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9140,9 +9146,59 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
alter_ctx.get_tmp_path(),
|
||||
alter_ctx.new_db, alter_ctx.tmp_name,
|
||||
true, true);
|
||||
if (!new_table)
|
||||
goto err_new_table_cleanup;
|
||||
|
||||
/*
|
||||
Normally, an attempt to modify an FK parent table will cause
|
||||
FK children to be prelocked, so the table-being-altered cannot
|
||||
be modified by a cascade FK action, because ALTER holds a lock
|
||||
and prelocking will wait.
|
||||
|
||||
But if a new FK is being added by this very ALTER, then the target
|
||||
table is not locked yet (it's a temporary table). So, we have to
|
||||
lock FK parents explicitly.
|
||||
*/
|
||||
if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
|
||||
{
|
||||
List <FOREIGN_KEY_INFO> fk_list;
|
||||
List_iterator<FOREIGN_KEY_INFO> fk_list_it(fk_list);
|
||||
FOREIGN_KEY_INFO *fk;
|
||||
|
||||
/* tables_opened can be > 1 only for MERGE tables */
|
||||
DBUG_ASSERT(tables_opened == 1);
|
||||
DBUG_ASSERT(&table_list->next_global == thd->lex->query_tables_last);
|
||||
|
||||
new_table->file->get_foreign_key_list(thd, &fk_list);
|
||||
while ((fk= fk_list_it++))
|
||||
{
|
||||
if (lower_case_table_names)
|
||||
{
|
||||
char buf[NAME_LEN];
|
||||
uint len;
|
||||
strmake_buf(buf, fk->referenced_db->str);
|
||||
len = my_casedn_str(files_charset_info, buf);
|
||||
thd->make_lex_string(fk->referenced_db, buf, len);
|
||||
strmake_buf(buf, fk->referenced_table->str);
|
||||
len = my_casedn_str(files_charset_info, buf);
|
||||
thd->make_lex_string(fk->referenced_table, buf, len);
|
||||
}
|
||||
if (table_already_fk_prelocked(table_list, fk->referenced_db,
|
||||
fk->referenced_table, TL_READ_NO_INSERT))
|
||||
continue;
|
||||
|
||||
TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST));
|
||||
tl->init_one_table_for_prelocking(fk->referenced_db->str, fk->referenced_db->length,
|
||||
fk->referenced_table->str, fk->referenced_table->length,
|
||||
NULL, TL_READ_NO_INSERT, false, NULL, 0,
|
||||
&thd->lex->query_tables_last);
|
||||
}
|
||||
|
||||
if (open_tables(thd, &table_list->next_global, &tables_opened, 0,
|
||||
&alter_prelocking_strategy))
|
||||
goto err_new_table_cleanup;
|
||||
}
|
||||
}
|
||||
if (!new_table)
|
||||
goto err_new_table_cleanup;
|
||||
/*
|
||||
Note: In case of MERGE table, we do not attach children. We do not
|
||||
copy data for MERGE tables. Only the children have data.
|
||||
|
@ -997,7 +997,7 @@ bool LEX::set_bincmp(CHARSET_INFO *cs, bool bin)
|
||||
enum enum_diag_condition_item_name diag_condition_item_name;
|
||||
enum Diagnostics_information::Which_area diag_area;
|
||||
enum Field::geometry_type geom_type;
|
||||
enum Foreign_key::fk_option m_fk_option;
|
||||
enum enum_fk_option m_fk_option;
|
||||
enum Item_udftype udf_type;
|
||||
enum Key::Keytype key_type;
|
||||
enum Statement_information_item::Name stmt_info_item_name;
|
||||
@ -1651,7 +1651,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
%token UPDATE_SYM /* SQL-2003-R */
|
||||
%token UPGRADE_SYM
|
||||
%token USAGE /* SQL-2003-N */
|
||||
%token USER /* SQL-2003-R */
|
||||
%token USER_SYM /* SQL-2003-R */
|
||||
%token USE_FRM
|
||||
%token USE_SYM
|
||||
%token USING /* SQL-2003-R */
|
||||
@ -2539,7 +2539,7 @@ create:
|
||||
Lex->create_view_suid= TRUE;
|
||||
}
|
||||
view_or_trigger_or_sp_or_event { }
|
||||
| create_or_replace USER opt_if_not_exists clear_privileges grant_list
|
||||
| create_or_replace USER_SYM opt_if_not_exists clear_privileges grant_list
|
||||
{
|
||||
if (Lex->set_command_with_check(SQLCOM_CREATE_USER, $1 | $3))
|
||||
MYSQL_YYABORT;
|
||||
@ -2581,7 +2581,7 @@ server_options_list:
|
||||
;
|
||||
|
||||
server_option:
|
||||
USER TEXT_STRING_sys
|
||||
USER_SYM TEXT_STRING_sys
|
||||
{
|
||||
MYSQL_YYABORT_UNLESS(Lex->server_options.username.str == 0);
|
||||
Lex->server_options.username= $2;
|
||||
@ -6704,19 +6704,19 @@ opt_on_update_delete:
|
||||
/* empty */
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
|
||||
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
|
||||
lex->fk_update_opt= FK_OPTION_UNDEF;
|
||||
lex->fk_delete_opt= FK_OPTION_UNDEF;
|
||||
}
|
||||
| ON UPDATE_SYM delete_option
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->fk_update_opt= $3;
|
||||
lex->fk_delete_opt= Foreign_key::FK_OPTION_UNDEF;
|
||||
lex->fk_delete_opt= FK_OPTION_UNDEF;
|
||||
}
|
||||
| ON DELETE_SYM delete_option
|
||||
{
|
||||
LEX *lex= Lex;
|
||||
lex->fk_update_opt= Foreign_key::FK_OPTION_UNDEF;
|
||||
lex->fk_update_opt= FK_OPTION_UNDEF;
|
||||
lex->fk_delete_opt= $3;
|
||||
}
|
||||
| ON UPDATE_SYM delete_option
|
||||
@ -6736,11 +6736,11 @@ opt_on_update_delete:
|
||||
;
|
||||
|
||||
delete_option:
|
||||
RESTRICT { $$= Foreign_key::FK_OPTION_RESTRICT; }
|
||||
| CASCADE { $$= Foreign_key::FK_OPTION_CASCADE; }
|
||||
| SET NULL_SYM { $$= Foreign_key::FK_OPTION_SET_NULL; }
|
||||
| NO_SYM ACTION { $$= Foreign_key::FK_OPTION_NO_ACTION; }
|
||||
| SET DEFAULT { $$= Foreign_key::FK_OPTION_DEFAULT; }
|
||||
RESTRICT { $$= FK_OPTION_RESTRICT; }
|
||||
| CASCADE { $$= FK_OPTION_CASCADE; }
|
||||
| SET NULL_SYM { $$= FK_OPTION_SET_NULL; }
|
||||
| NO_SYM ACTION { $$= FK_OPTION_NO_ACTION; }
|
||||
| SET DEFAULT { $$= FK_OPTION_SET_DEFAULT; }
|
||||
;
|
||||
|
||||
constraint_key_type:
|
||||
@ -8038,7 +8038,7 @@ rename:
|
||||
}
|
||||
table_to_table_list
|
||||
{}
|
||||
| RENAME USER clear_privileges rename_list
|
||||
| RENAME USER_SYM clear_privileges rename_list
|
||||
{
|
||||
Lex->sql_command = SQLCOM_RENAME_USER;
|
||||
}
|
||||
@ -9383,7 +9383,7 @@ function_call_keyword:
|
||||
if ($$ == NULL)
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| USER '(' ')'
|
||||
| USER_SYM '(' ')'
|
||||
{
|
||||
$$= new (thd->mem_root) Item_func_user(thd);
|
||||
if ($$ == NULL)
|
||||
@ -11639,7 +11639,7 @@ drop:
|
||||
lex->set_command(SQLCOM_DROP_PROCEDURE, $3);
|
||||
lex->spname= $4;
|
||||
}
|
||||
| DROP USER opt_if_exists clear_privileges user_list
|
||||
| DROP USER_SYM opt_if_exists clear_privileges user_list
|
||||
{
|
||||
Lex->set_command(SQLCOM_DROP_USER, $3);
|
||||
}
|
||||
@ -12947,7 +12947,7 @@ kill_expr:
|
||||
{
|
||||
Lex->value_list.push_front($$, thd->mem_root);
|
||||
}
|
||||
| USER user
|
||||
| USER_SYM user
|
||||
{
|
||||
Lex->users_list.push_back($2, thd->mem_root);
|
||||
Lex->kill_type= KILL_TYPE_USER;
|
||||
@ -14274,7 +14274,7 @@ keyword_sp:
|
||||
| UNDOFILE_SYM {}
|
||||
| UNKNOWN_SYM {}
|
||||
| UNTIL_SYM {}
|
||||
| USER {}
|
||||
| USER_SYM {}
|
||||
| USE_FRM {}
|
||||
| VARIABLES {}
|
||||
| VIEW_SYM {}
|
||||
@ -15185,7 +15185,7 @@ object_privilege:
|
||||
| SHOW VIEW_SYM { Lex->grant |= SHOW_VIEW_ACL; }
|
||||
| CREATE ROUTINE_SYM { Lex->grant |= CREATE_PROC_ACL; }
|
||||
| ALTER ROUTINE_SYM { Lex->grant |= ALTER_PROC_ACL; }
|
||||
| CREATE USER { Lex->grant |= CREATE_USER_ACL; }
|
||||
| CREATE USER_SYM { Lex->grant |= CREATE_USER_ACL; }
|
||||
| EVENT_SYM { Lex->grant |= EVENT_ACL;}
|
||||
| TRIGGER_SYM { Lex->grant |= TRIGGER_ACL; }
|
||||
| CREATE TABLESPACE { Lex->grant |= CREATE_TABLESPACE_ACL; }
|
||||
|
21
sql/table.cc
21
sql/table.cc
@ -411,6 +411,7 @@ void TABLE_SHARE::destroy()
|
||||
ha_share= NULL; // Safety
|
||||
}
|
||||
|
||||
delete_stat_values_for_table_share(this);
|
||||
free_root(&stats_cb.mem_root, MYF(0));
|
||||
stats_cb.stats_can_be_read= FALSE;
|
||||
stats_cb.stats_is_read= FALSE;
|
||||
@ -7509,3 +7510,23 @@ double KEY::actual_rec_per_key(uint i)
|
||||
return (is_statistics_from_stat_tables ?
|
||||
read_stats->get_avg_frequency(i) : (double) rec_per_key[i]);
|
||||
}
|
||||
|
||||
LEX_CSTRING *fk_option_name(enum_fk_option opt)
|
||||
{
|
||||
static LEX_CSTRING names[]=
|
||||
{
|
||||
{ STRING_WITH_LEN("???") },
|
||||
{ STRING_WITH_LEN("RESTRICT") },
|
||||
{ STRING_WITH_LEN("CASCADE") },
|
||||
{ STRING_WITH_LEN("SET NULL") },
|
||||
{ STRING_WITH_LEN("NO ACTION") },
|
||||
{ STRING_WITH_LEN("SET DEFAULT") }
|
||||
};
|
||||
return names + opt;
|
||||
}
|
||||
|
||||
bool fk_modifies_child(enum_fk_option opt)
|
||||
{
|
||||
static bool can_write[]= { false, false, true, true, false, true };
|
||||
return can_write[opt];
|
||||
}
|
||||
|
59
sql/table.h
59
sql/table.h
@ -1499,6 +1499,9 @@ enum enum_schema_table_state
|
||||
PROCESSED_BY_JOIN_EXEC
|
||||
};
|
||||
|
||||
enum enum_fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
|
||||
FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_SET_DEFAULT};
|
||||
|
||||
typedef struct st_foreign_key_info
|
||||
{
|
||||
LEX_STRING *foreign_id;
|
||||
@ -1506,13 +1509,16 @@ typedef struct st_foreign_key_info
|
||||
LEX_STRING *foreign_table;
|
||||
LEX_STRING *referenced_db;
|
||||
LEX_STRING *referenced_table;
|
||||
LEX_STRING *update_method;
|
||||
LEX_STRING *delete_method;
|
||||
enum_fk_option update_method;
|
||||
enum_fk_option delete_method;
|
||||
LEX_STRING *referenced_key_name;
|
||||
List<LEX_STRING> foreign_fields;
|
||||
List<LEX_STRING> referenced_fields;
|
||||
} FOREIGN_KEY_INFO;
|
||||
|
||||
LEX_CSTRING *fk_option_name(enum_fk_option opt);
|
||||
bool fk_modifies_child(enum_fk_option opt);
|
||||
|
||||
#define MY_I_S_MAYBE_NULL 1
|
||||
#define MY_I_S_UNSIGNED 2
|
||||
|
||||
@ -1760,6 +1766,14 @@ struct TABLE_LIST
|
||||
const char *alias_arg,
|
||||
enum thr_lock_type lock_type_arg)
|
||||
{
|
||||
enum enum_mdl_type mdl_type;
|
||||
if (lock_type_arg >= TL_WRITE_ALLOW_WRITE)
|
||||
mdl_type= MDL_SHARED_WRITE;
|
||||
else if (lock_type_arg == TL_READ_NO_INSERT)
|
||||
mdl_type= MDL_SHARED_NO_WRITE;
|
||||
else
|
||||
mdl_type= MDL_SHARED_READ;
|
||||
|
||||
bzero((char*) this, sizeof(*this));
|
||||
db= (char*) db_name_arg;
|
||||
db_length= db_length_arg;
|
||||
@ -1767,10 +1781,31 @@ struct TABLE_LIST
|
||||
table_name_length= table_name_length_arg;
|
||||
alias= (char*) (alias_arg ? alias_arg : table_name_arg);
|
||||
lock_type= lock_type_arg;
|
||||
mdl_request.init(MDL_key::TABLE, db, table_name,
|
||||
(lock_type >= TL_WRITE_ALLOW_WRITE) ?
|
||||
MDL_SHARED_WRITE : MDL_SHARED_READ,
|
||||
MDL_TRANSACTION);
|
||||
mdl_request.init(MDL_key::TABLE, db, table_name, mdl_type, MDL_TRANSACTION);
|
||||
}
|
||||
|
||||
inline void init_one_table_for_prelocking(const char *db_name_arg,
|
||||
size_t db_length_arg,
|
||||
const char *table_name_arg,
|
||||
size_t table_name_length_arg,
|
||||
const char *alias_arg,
|
||||
enum thr_lock_type lock_type_arg,
|
||||
bool routine,
|
||||
TABLE_LIST *belong_to_view_arg,
|
||||
uint8 trg_event_map_arg,
|
||||
TABLE_LIST ***last_ptr)
|
||||
{
|
||||
init_one_table(db_name_arg, db_length_arg, table_name_arg,
|
||||
table_name_length_arg, alias_arg, lock_type_arg);
|
||||
cacheable_table= 1;
|
||||
prelocking_placeholder= routine ? ROUTINE : FK;
|
||||
open_type= routine ? OT_TEMPORARY_OR_BASE : OT_BASE_ONLY;
|
||||
belong_to_view= belong_to_view_arg;
|
||||
trg_event_map= trg_event_map_arg;
|
||||
|
||||
**last_ptr= this;
|
||||
prev_global= *last_ptr;
|
||||
*last_ptr= &next_global;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2049,7 +2084,7 @@ struct TABLE_LIST
|
||||
This TABLE_LIST object is just placeholder for prelocking, it will be
|
||||
used for implicit LOCK TABLES only and won't be used in real statement.
|
||||
*/
|
||||
bool prelocking_placeholder;
|
||||
enum { USER, ROUTINE, FK } prelocking_placeholder;
|
||||
/**
|
||||
Indicates that if TABLE_LIST object corresponds to the table/view
|
||||
which requires special handling.
|
||||
@ -2366,6 +2401,16 @@ struct TABLE_LIST
|
||||
}
|
||||
void set_lock_type(THD* thd, enum thr_lock_type lock);
|
||||
|
||||
void remove_join_columns()
|
||||
{
|
||||
if (join_columns)
|
||||
{
|
||||
join_columns->empty();
|
||||
join_columns= NULL;
|
||||
is_join_columns_complete= FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool prep_check_option(THD *thd, uint8 check_opt_type);
|
||||
bool prep_where(THD *thd, Item **conds, bool no_where_clause);
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "lf.h"
|
||||
#include "table.h"
|
||||
#include "sql_base.h"
|
||||
#include "sql_statistics.h"
|
||||
|
||||
|
||||
/** Configuration. */
|
||||
@ -787,7 +786,6 @@ void tdc_release_share(TABLE_SHARE *share)
|
||||
}
|
||||
if (share->tdc->flushed || tdc_records() > tdc_size)
|
||||
{
|
||||
delete_stat_values_for_table_share(share);
|
||||
mysql_mutex_unlock(&LOCK_unused_shares);
|
||||
tdc_delete_share_from_hash(share->tdc);
|
||||
DBUG_VOID_RETURN;
|
||||
|
@ -153,7 +153,7 @@ bool JAVAConn::Check(jint rc)
|
||||
|
||||
if (exc != nullptr && tid != nullptr) {
|
||||
jstring s = (jstring)env->CallObjectMethod(exc, tid);
|
||||
const char *utf = env->GetStringUTFChars(s, (jboolean)false);
|
||||
const char *utf = env->GetStringUTFChars(s, NULL);
|
||||
env->DeleteLocalRef(s);
|
||||
Msg = PlugDup(m_G, utf);
|
||||
} else
|
||||
@ -162,7 +162,7 @@ bool JAVAConn::Check(jint rc)
|
||||
env->ExceptionClear();
|
||||
} else if (rc < 0) {
|
||||
s = (jstring)env->CallObjectMethod(job, errid);
|
||||
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
|
||||
Msg = (char*)env->GetStringUTFChars(s, NULL);
|
||||
} else
|
||||
Msg = NULL;
|
||||
|
||||
@ -456,7 +456,7 @@ bool JAVAConn::Open(PGLOBAL g)
|
||||
|
||||
//=============== load and initialize Java VM and JNI interface =============
|
||||
rc = CreateJavaVM(&jvm, (void**)&env, &vm_args); // YES !!
|
||||
delete options; // we then no longer need the initialisation options.
|
||||
delete[] options; // we then no longer need the initialisation options.
|
||||
|
||||
switch (rc) {
|
||||
case JNI_OK:
|
||||
|
@ -828,11 +828,11 @@ bool JDBConn::Connect(PJPARM sop)
|
||||
jstring s = (jstring)env->CallObjectMethod(job, qcid);
|
||||
|
||||
if (s != nullptr) {
|
||||
char *qch = (char*)env->GetStringUTFChars(s, (jboolean)false);
|
||||
char *qch = (char*)env->GetStringUTFChars(s, NULL);
|
||||
m_IDQuoteChar[0] = *qch;
|
||||
} else {
|
||||
s = (jstring)env->CallObjectMethod(job, errid);
|
||||
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
|
||||
Msg = (char*)env->GetStringUTFChars(s, NULL);
|
||||
} // endif s
|
||||
|
||||
} // endif qcid
|
||||
@ -1010,7 +1010,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
cn = nullptr;
|
||||
|
||||
if (cn) {
|
||||
field = env->GetStringUTFChars(cn, (jboolean)false);
|
||||
field = env->GetStringUTFChars(cn, NULL);
|
||||
val->SetValue_psz((PSZ)field);
|
||||
} else
|
||||
val->Reset();
|
||||
@ -1084,7 +1084,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
|
||||
cn = nullptr;
|
||||
|
||||
if (cn) {
|
||||
const char *field = env->GetStringUTFChars(cn, (jboolean)false);
|
||||
const char *field = env->GetStringUTFChars(cn, NULL);
|
||||
val->SetValue_psz((PSZ)field);
|
||||
} else
|
||||
val->Reset();
|
||||
@ -1462,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
|
||||
return NULL;
|
||||
} // endif label
|
||||
|
||||
name = env->GetStringUTFChars(label, (jboolean)false);
|
||||
name = env->GetStringUTFChars(label, NULL);
|
||||
crp = qrp->Colresp; // Column_Name
|
||||
crp->Kdata->SetValue((char*)name, i);
|
||||
n = env->GetIntArrayElements(val, 0);
|
||||
|
@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
|
||||
jdc = (jstring)env->CallObjectMethod(job, getdocid);
|
||||
|
||||
if (jdc)
|
||||
doc = (PSZ)env->GetStringUTFChars(jdc, (jboolean)false);
|
||||
doc = (PSZ)env->GetStringUTFChars(jdc, NULL);
|
||||
|
||||
} // endif getdocid
|
||||
|
||||
@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
|
||||
fn = (jstring)env->CallObjectMethod(job, objfldid, jn);
|
||||
|
||||
if (fn)
|
||||
fld = (PSZ)env->GetStringUTFChars(fn, (jboolean)false);
|
||||
fld = (PSZ)env->GetStringUTFChars(fn, NULL);
|
||||
|
||||
} // endif objfldid
|
||||
|
||||
|
@ -101,7 +101,7 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
|
||||
continue;
|
||||
|
||||
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid);
|
||||
key = Jcp->env->GetStringUTFChars(jkey, (jboolean)false);
|
||||
key = Jcp->env->GetStringUTFChars(jkey, NULL);
|
||||
|
||||
if (pcn) {
|
||||
strncpy(colname, pcn, 64);
|
||||
|
@ -14427,7 +14427,7 @@ get_foreign_key_info(
|
||||
|
||||
/* Referenced (parent) table name */
|
||||
ptr = dict_remove_db_name(foreign->referenced_table_name);
|
||||
len = filename_to_tablename(ptr, name_buff, sizeof(name_buff));
|
||||
len = filename_to_tablename(ptr, name_buff, sizeof(name_buff), 1);
|
||||
f_key_info.referenced_table = thd_make_lex_string(
|
||||
thd, 0, name_buff, static_cast<unsigned int>(len), 1);
|
||||
|
||||
@ -14443,7 +14443,7 @@ get_foreign_key_info(
|
||||
|
||||
/* Dependent (child) table name */
|
||||
ptr = dict_remove_db_name(foreign->foreign_table_name);
|
||||
len = filename_to_tablename(ptr, name_buff, sizeof(name_buff));
|
||||
len = filename_to_tablename(ptr, name_buff, sizeof(name_buff), 1);
|
||||
f_key_info.foreign_table = thd_make_lex_string(
|
||||
thd, 0, name_buff, static_cast<unsigned int>(len), 1);
|
||||
|
||||
@ -14459,41 +14459,25 @@ get_foreign_key_info(
|
||||
} while (++i < foreign->n_fields);
|
||||
|
||||
if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) {
|
||||
len = 7;
|
||||
ptr = "CASCADE";
|
||||
f_key_info.delete_method = FK_OPTION_CASCADE;
|
||||
} else if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) {
|
||||
len = 8;
|
||||
ptr = "SET NULL";
|
||||
f_key_info.delete_method = FK_OPTION_SET_NULL;
|
||||
} else if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) {
|
||||
len = 9;
|
||||
ptr = "NO ACTION";
|
||||
f_key_info.delete_method = FK_OPTION_NO_ACTION;
|
||||
} else {
|
||||
len = 8;
|
||||
ptr = "RESTRICT";
|
||||
f_key_info.delete_method = FK_OPTION_RESTRICT;
|
||||
}
|
||||
|
||||
f_key_info.delete_method = thd_make_lex_string(
|
||||
thd, f_key_info.delete_method, ptr,
|
||||
static_cast<unsigned int>(len), 1);
|
||||
|
||||
if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
|
||||
len = 7;
|
||||
ptr = "CASCADE";
|
||||
f_key_info.update_method = FK_OPTION_CASCADE;
|
||||
} else if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
|
||||
len = 8;
|
||||
ptr = "SET NULL";
|
||||
f_key_info.update_method = FK_OPTION_SET_NULL;
|
||||
} else if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) {
|
||||
len = 9;
|
||||
ptr = "NO ACTION";
|
||||
f_key_info.update_method = FK_OPTION_NO_ACTION;
|
||||
} else {
|
||||
len = 8;
|
||||
ptr = "RESTRICT";
|
||||
f_key_info.update_method = FK_OPTION_RESTRICT;
|
||||
}
|
||||
|
||||
f_key_info.update_method = thd_make_lex_string(
|
||||
thd, f_key_info.update_method, ptr,
|
||||
static_cast<unsigned int>(len), 1);
|
||||
|
||||
if (foreign->referenced_index && foreign->referenced_index->name) {
|
||||
referenced_key_name = thd_make_lex_string(thd,
|
||||
f_key_info.referenced_key_name,
|
||||
|
@ -752,29 +752,29 @@ innobase_set_foreign_key_option(
|
||||
ut_ad(!foreign->type);
|
||||
|
||||
switch (fk_key->delete_opt) {
|
||||
case Foreign_key::FK_OPTION_NO_ACTION:
|
||||
case Foreign_key::FK_OPTION_RESTRICT:
|
||||
case Foreign_key::FK_OPTION_DEFAULT:
|
||||
case FK_OPTION_NO_ACTION:
|
||||
case FK_OPTION_RESTRICT:
|
||||
case FK_OPTION_SET_DEFAULT:
|
||||
foreign->type = DICT_FOREIGN_ON_DELETE_NO_ACTION;
|
||||
break;
|
||||
case Foreign_key::FK_OPTION_CASCADE:
|
||||
case FK_OPTION_CASCADE:
|
||||
foreign->type = DICT_FOREIGN_ON_DELETE_CASCADE;
|
||||
break;
|
||||
case Foreign_key::FK_OPTION_SET_NULL:
|
||||
case FK_OPTION_SET_NULL:
|
||||
foreign->type = DICT_FOREIGN_ON_DELETE_SET_NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (fk_key->update_opt) {
|
||||
case Foreign_key::FK_OPTION_NO_ACTION:
|
||||
case Foreign_key::FK_OPTION_RESTRICT:
|
||||
case Foreign_key::FK_OPTION_DEFAULT:
|
||||
case FK_OPTION_NO_ACTION:
|
||||
case FK_OPTION_RESTRICT:
|
||||
case FK_OPTION_SET_DEFAULT:
|
||||
foreign->type |= DICT_FOREIGN_ON_UPDATE_NO_ACTION;
|
||||
break;
|
||||
case Foreign_key::FK_OPTION_CASCADE:
|
||||
case FK_OPTION_CASCADE:
|
||||
foreign->type |= DICT_FOREIGN_ON_UPDATE_CASCADE;
|
||||
break;
|
||||
case Foreign_key::FK_OPTION_SET_NULL:
|
||||
case FK_OPTION_SET_NULL:
|
||||
foreign->type |= DICT_FOREIGN_ON_UPDATE_SET_NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -53,10 +53,10 @@
|
||||
Page header:
|
||||
|
||||
LSN 7 bytes Log position for last page change
|
||||
PAGE_TYPE 1 uchar 1 for head / 2 for tail / 3 for blob
|
||||
PAGE_TYPE 1 uchar 0 unalloced / 1 for head / 2 for tail / 3 for blob
|
||||
DIR_COUNT 1 uchar Number of row/tail entries on page
|
||||
FREE_DIR_LINK 1 uchar Pointer to first free director entry or 255 if no
|
||||
empty space 2 bytes Empty space on page
|
||||
empty space 2 bytes Bytes of empty space on page
|
||||
|
||||
The most significant bit in PAGE_TYPE is set to 1 if the data on the page
|
||||
can be compacted to get more space. (PAGE_CAN_BE_COMPACTED)
|
||||
@ -5161,11 +5161,19 @@ int _ma_read_block_record(MARIA_HA *info, uchar *record,
|
||||
info->buff, share->page_type,
|
||||
PAGECACHE_LOCK_LEFT_UNLOCKED, 0)))
|
||||
DBUG_RETURN(my_errno);
|
||||
|
||||
/*
|
||||
Unallocated page access can happen if this is an access to a page where
|
||||
all rows where deleted as part of this statement.
|
||||
*/
|
||||
DBUG_ASSERT((buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK) == HEAD_PAGE ||
|
||||
(buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK) == UNALLOCATED_PAGE);
|
||||
|
||||
DBUG_ASSERT((buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK) == HEAD_PAGE);
|
||||
if (!(data= get_record_position(share, buff, offset, &end_of_data)))
|
||||
{
|
||||
DBUG_ASSERT(!maria_assert_if_crashed_table);
|
||||
DBUG_PRINT("error", ("Wrong directory entry in data block"));
|
||||
DBUG_PRINT("warning", ("Wrong directory entry in data block"));
|
||||
my_errno= HA_ERR_RECORD_DELETED; /* File crashed */
|
||||
DBUG_RETURN(HA_ERR_RECORD_DELETED);
|
||||
}
|
||||
|
@ -16761,15 +16761,8 @@ int ha_mroonga::storage_get_foreign_key_list(THD *thd,
|
||||
ref_table_buff,
|
||||
ref_table_name_length,
|
||||
TRUE);
|
||||
#ifdef MRN_FOREIGN_KEY_USE_METHOD_ENUM
|
||||
f_key_info.update_method = FK_OPTION_RESTRICT;
|
||||
f_key_info.delete_method = FK_OPTION_RESTRICT;
|
||||
#else
|
||||
f_key_info.update_method = thd_make_lex_string(thd, NULL, "RESTRICT",
|
||||
8, TRUE);
|
||||
f_key_info.delete_method = thd_make_lex_string(thd, NULL, "RESTRICT",
|
||||
8, TRUE);
|
||||
#endif
|
||||
f_key_info.referenced_key_name = thd_make_lex_string(thd, NULL, "PRIMARY",
|
||||
7, TRUE);
|
||||
LEX_STRING *field_name = thd_make_lex_string(thd,
|
||||
|
@ -211,10 +211,6 @@ extern "C" {
|
||||
# define MRN_FOREIGN_KEY_USE_CONST_STRING
|
||||
#endif
|
||||
|
||||
#if MYSQL_VERSION_ID >= 100203 && defined(MRN_MARIADB_P)
|
||||
# define MRN_FOREIGN_KEY_USE_METHOD_ENUM
|
||||
#endif
|
||||
|
||||
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
|
||||
# define MRN_HANDLER_IS_FATAL_ERROR_HAVE_FLAGS
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
SET(TOKUDB_VERSION 5.6.39-83.1)
|
||||
SET(TOKUDB_VERSION 5.6.41-84.1)
|
||||
# PerconaFT only supports x86-64 and cmake-2.8.9+
|
||||
IF(CMAKE_VERSION VERSION_LESS "2.8.9")
|
||||
MESSAGE(STATUS "CMake 2.8.9 or higher is required by TokuDB")
|
||||
@ -105,7 +105,11 @@ ELSEIF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ft-index/")
|
||||
MESSAGE(WARNING "Found ft-index sources, ft-index is deprecated and replaced with PerconaFT.")
|
||||
SET(TOKU_FT_DIR_NAME "ft-index")
|
||||
ELSE ()
|
||||
MESSAGE(FATAL_ERROR "Could not find PerconaFT sources.")
|
||||
MESSAGE(FATAL_ERROR "Could not find PerconaFT sources.")
|
||||
ENDIF ()
|
||||
|
||||
IF (WITH_VALGRIND)
|
||||
SET(USE_VALGRIND "ON")
|
||||
ENDIF ()
|
||||
|
||||
ADD_SUBDIRECTORY(${TOKU_FT_DIR_NAME})
|
||||
|
@ -14,7 +14,8 @@ MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-address-of-packed-member")
|
||||
|
||||
# detect when we are being built as a subproject
|
||||
if (DEFINED MYSQL_PROJECT_NAME_DOCSTRING)
|
||||
add_definitions( -DMYSQL_TOKUDB_ENGINE=1)
|
||||
add_definitions(-DMYSQL_TOKUDB_ENGINE=1)
|
||||
add_definitions(-DMYSQL_VERSION_ID=${MYSQL_VERSION_ID})
|
||||
# Extended PFS instrumentation:
|
||||
# -DTOKU_PFS_MUTEX_EXTENDED_CACHETABLEMMUTEX=1
|
||||
if (WITH_PERFSCHEMA_STORAGE_ENGINE)
|
||||
|
@ -107,6 +107,9 @@ set_cflags_if_supported(
|
||||
-Wno-error=strict-overflow
|
||||
)
|
||||
|
||||
# new flag sets in MySQL 8.0 seem to explicitly disable this
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
||||
|
||||
## set extra debugging flags and preprocessor definitions
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 ${CMAKE_C_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
|
@ -1290,7 +1290,6 @@ int toku_cachetable_get_and_pin (
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long *sizep,
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
@ -1311,7 +1310,6 @@ int toku_cachetable_get_and_pin (
|
||||
key,
|
||||
fullhash,
|
||||
value,
|
||||
sizep,
|
||||
write_callback,
|
||||
fetch_callback,
|
||||
pf_req_callback,
|
||||
@ -1559,7 +1557,6 @@ int toku_cachetable_get_and_pin_with_dep_pairs (
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long *sizep,
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
@ -1743,7 +1740,6 @@ beginning:
|
||||
}
|
||||
got_value:
|
||||
*value = p->value_data;
|
||||
if (sizep) *sizep = p->attr.size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1856,6 +1852,22 @@ int toku_cachetable_maybe_get_and_pin_clean (CACHEFILE cachefile, CACHEKEY key,
|
||||
return r;
|
||||
}
|
||||
|
||||
int toku_cachetable_get_attr (CACHEFILE cachefile, CACHEKEY key, uint32_t fullhash, PAIR_ATTR *attr) {
|
||||
CACHETABLE ct = cachefile->cachetable;
|
||||
int r;
|
||||
ct->list.pair_lock_by_fullhash(fullhash);
|
||||
PAIR p = ct->list.find_pair(cachefile, key, fullhash);
|
||||
if (p) {
|
||||
// Assumes pair lock and full hash lock are the same mutex
|
||||
*attr = p->attr;
|
||||
r = 0;
|
||||
} else {
|
||||
r = -1;
|
||||
}
|
||||
ct->list.pair_unlock_by_fullhash(fullhash);
|
||||
return r;
|
||||
}
|
||||
|
||||
//
|
||||
// internal function to unpin a PAIR.
|
||||
// As of Clayface, this is may be called in two ways:
|
||||
@ -1997,7 +2009,6 @@ int toku_cachetable_get_and_pin_nonblocking(
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long* UU(sizep),
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
|
@ -352,7 +352,6 @@ int toku_cachetable_get_and_pin_with_dep_pairs (
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long *sizep,
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
@ -374,7 +373,6 @@ int toku_cachetable_get_and_pin (
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long *sizep,
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
@ -408,7 +406,6 @@ int toku_cachetable_get_and_pin_nonblocking (
|
||||
CACHEKEY key,
|
||||
uint32_t fullhash,
|
||||
void**value,
|
||||
long *sizep,
|
||||
CACHETABLE_WRITE_CALLBACK write_callback,
|
||||
CACHETABLE_FETCH_CALLBACK fetch_callback,
|
||||
CACHETABLE_PARTIAL_FETCH_REQUIRED_CALLBACK pf_req_callback,
|
||||
@ -428,6 +425,11 @@ int toku_cachetable_maybe_get_and_pin (CACHEFILE, CACHEKEY, uint32_t /*fullhash*
|
||||
int toku_cachetable_maybe_get_and_pin_clean (CACHEFILE, CACHEKEY, uint32_t /*fullhash*/, pair_lock_type, void**);
|
||||
// Effect: Like maybe get and pin, but may pin a clean pair.
|
||||
|
||||
int toku_cachetable_get_attr(CACHEFILE, CACHEKEY, uint32_t /*fullhash*/, PAIR_ATTR *);
|
||||
// Effect: get the attributes for cachekey
|
||||
// Returns: 0 if success, non-zero if cachekey is not cached
|
||||
// Notes: this function exists for tests
|
||||
|
||||
int toku_cachetable_unpin(CACHEFILE, PAIR, enum cachetable_dirty dirty, PAIR_ATTR size);
|
||||
// Effect: Unpin a memory object
|
||||
// Modifies: If the memory object is in the cachetable, then OR the dirty flag,
|
||||
|
@ -178,7 +178,6 @@ toku_pin_ftnode_for_query(
|
||||
blocknum,
|
||||
fullhash,
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft_handle->ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
@ -209,7 +208,6 @@ toku_pin_ftnode_for_query(
|
||||
blocknum,
|
||||
fullhash,
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft_handle->ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
@ -289,7 +287,6 @@ toku_pin_ftnode_with_dep_nodes(
|
||||
blocknum,
|
||||
fullhash,
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
|
@ -130,7 +130,6 @@ int toku_testsetup_get_sersize(FT_HANDLE ft_handle, BLOCKNUM diskoff) // Return
|
||||
ft_handle->ft->cf, diskoff,
|
||||
toku_cachetable_hash(ft_handle->ft->cf, diskoff),
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft_handle->ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
@ -158,7 +157,6 @@ int toku_testsetup_insert_to_leaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, const
|
||||
blocknum,
|
||||
toku_cachetable_hash(ft_handle->ft->cf, blocknum),
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft_handle->ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
@ -236,7 +234,6 @@ int toku_testsetup_insert_to_nonleaf (FT_HANDLE ft_handle, BLOCKNUM blocknum, en
|
||||
blocknum,
|
||||
toku_cachetable_hash(ft_handle->ft->cf, blocknum),
|
||||
&node_v,
|
||||
NULL,
|
||||
get_write_callbacks_for_node(ft_handle->ft),
|
||||
toku_ftnode_fetch_callback,
|
||||
toku_ftnode_pf_req_callback,
|
||||
|
@ -44,6 +44,9 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
|
||||
#include "ft/ft-ops.h"
|
||||
#include "ft/logger/log.h"
|
||||
#include "util/dbt.h"
|
||||
#ifndef TOKU_MYSQL_WITH_PFS
|
||||
#include <my_global.h>
|
||||
#endif
|
||||
|
||||
typedef struct ft *FT;
|
||||
typedef struct ft_options *FT_OPTIONS;
|
||||
|
@ -156,6 +156,8 @@ void toku_evict_bn_from_memory(FTNODE node, int childnum, FT ft) {
|
||||
assert(!node->dirty);
|
||||
BASEMENTNODE bn = BLB(node, childnum);
|
||||
toku_ft_decrease_stats(&ft->in_memory_stats, bn->stat64_delta);
|
||||
toku_ft_adjust_logical_row_count(ft, -BLB_LRD(node, childnum));
|
||||
BLB_LRD(node, childnum) = 0;
|
||||
destroy_basement_node(bn);
|
||||
set_BNULL(node, childnum);
|
||||
BP_STATE(node, childnum) = PT_ON_DISK;
|
||||
|
@ -49,7 +49,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
|
||||
#include "ft/serialize/block_allocator.h"
|
||||
#include "ft/serialize/rbtree_mhs.h"
|
||||
|
||||
#if TOKU_DEBUG_PARANOID
|
||||
#if defined(TOKU_DEBUG_PARANOID) && TOKU_DEBUG_PARANOID
|
||||
#define VALIDATE() Validate()
|
||||
#else
|
||||
#define VALIDATE()
|
||||
|
@ -42,13 +42,11 @@ CACHEFILE f1;
|
||||
|
||||
static void *pin_nonblocking(void *arg) {
|
||||
void* v1;
|
||||
long s1;
|
||||
int r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
toku_cachetable_hash(f1, make_blocknum(1)),
|
||||
&v1,
|
||||
&s1,
|
||||
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_WRITE_EXPENSIVE,
|
||||
NULL,
|
||||
@ -70,12 +68,10 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
r = toku_cachetable_get_and_pin(f1,
|
||||
make_blocknum(1),
|
||||
toku_cachetable_hash(f1, make_blocknum(1)),
|
||||
&v1,
|
||||
&s1,
|
||||
def_write_callback(NULL),
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -42,13 +42,11 @@ CACHEFILE f1;
|
||||
|
||||
static void *pin_nonblocking(void *arg) {
|
||||
void* v1;
|
||||
long s1;
|
||||
int r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
toku_cachetable_hash(f1, make_blocknum(1)),
|
||||
&v1,
|
||||
&s1,
|
||||
def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_WRITE_EXPENSIVE,
|
||||
NULL,
|
||||
@ -92,12 +90,10 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
r = toku_cachetable_get_and_pin(f1,
|
||||
make_blocknum(1),
|
||||
toku_cachetable_hash(f1, make_blocknum(1)),
|
||||
&v1,
|
||||
&s1,
|
||||
def_write_callback(nullptr),
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -88,7 +88,6 @@ flush (CACHEFILE f __attribute__((__unused__)),
|
||||
static void *f2_pin(void *arg) {
|
||||
int r;
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
//
|
||||
// these booleans for pe_callback just ensure that the
|
||||
@ -98,7 +97,7 @@ static void *f2_pin(void *arg) {
|
||||
// This is just to ensure that the bug is being exercised
|
||||
//
|
||||
check_pe_callback = true;
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f2, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert(r == 0);
|
||||
ct->ev.signal_eviction_thread();
|
||||
usleep(1*1024*1024);
|
||||
@ -141,13 +140,12 @@ cachetable_test (void) {
|
||||
assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.pe_callback = pe_callback;
|
||||
wc.flush_callback = flush;
|
||||
// pin and unpin a node 20 times, just to get clock count up
|
||||
for (int i = 0; i < 20; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert(r == 0);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert(r == 0);
|
||||
|
@ -131,13 +131,11 @@ static void *repin_one(void *UU(arg)) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
struct unlockers unlockers = {true, unpin_two, NULL, NULL};
|
||||
void* v1;
|
||||
long s1;
|
||||
int r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&v1,
|
||||
&s1,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -164,13 +162,12 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
|
||||
// bring pairs 1 and 2 into memory, then unpin
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch_one, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch_one, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, &s1, wc, fetch_two, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, wc, fetch_two, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
|
||||
toku_pthread_t tid1;
|
||||
|
@ -125,13 +125,11 @@ static void *repin_one(void *UU(arg)) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
struct unlockers unlockers = {true, unpin_four, NULL, NULL};
|
||||
void* v1;
|
||||
long s1;
|
||||
int r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&v1,
|
||||
&s1,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -149,13 +147,11 @@ static void *repin_two(void *UU(arg)) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
struct unlockers unlockers = {true, unpin_three, NULL, NULL};
|
||||
void* v1;
|
||||
long s1;
|
||||
int r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
make_blocknum(2),
|
||||
2,
|
||||
&v1,
|
||||
&s1,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -181,20 +177,19 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
|
||||
// bring pairs 1 and 2 into memory, then unpin
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
|
||||
|
||||
// now pin pairs 3 and 4
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v1, &s1, wc, fetch_three, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v1, wc, fetch_three, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v1, &s1, wc, fetch_four, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v1, wc, fetch_four, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
|
||||
toku_pthread_t tid1;
|
||||
|
@ -73,12 +73,11 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
|
||||
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
@ -99,13 +99,15 @@ do_update (void *UU(ignore))
|
||||
CACHEKEY key = make_blocknum(i);
|
||||
uint32_t hi = toku_cachetable_hash(cf, key);
|
||||
void *vv;
|
||||
long size;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, &size, wc, fetch_die, def_pf_req_callback, def_pf_callback, true, 0);
|
||||
int r = toku_cachetable_get_and_pin(cf, key, hi, &vv, wc, fetch_die, def_pf_req_callback, def_pf_callback, true, 0);
|
||||
//printf("g");
|
||||
assert(r==0);
|
||||
assert(size==sizeof(int));
|
||||
PAIR_ATTR attr;
|
||||
r = toku_cachetable_get_attr(cf, key, hi, &attr);
|
||||
assert(r==0);
|
||||
assert(attr.size==sizeof(int));
|
||||
int *CAST_FROM_VOIDP(v, vv);
|
||||
assert(*v==42);
|
||||
*v = 43;
|
||||
|
@ -110,13 +110,11 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1;
|
||||
long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(&dirty_val);
|
||||
wc.flush_callback = flush;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, true, &dirty_val);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, def_pf_req_callback, def_pf_callback, true, &dirty_val);
|
||||
wc.write_extraargs = NULL;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
|
||||
//
|
||||
// Here is the test, we have two pairs, v1 is dirty, v2 is clean, but both are currently pinned
|
||||
|
@ -103,13 +103,10 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.cleaner_callback = cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 8;
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, attr);
|
||||
|
@ -103,13 +103,10 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.cleaner_callback = cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 8;
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, attr);
|
||||
|
@ -107,15 +107,12 @@ run_test (void) {
|
||||
assert(STATUS_VALUE(CT_SIZE_CACHEPRESSURE) == 0);
|
||||
|
||||
void* vs[n_pairs];
|
||||
//void* v2;
|
||||
long ss[n_pairs];
|
||||
//long s2;
|
||||
PAIR_ATTR expect = { .size = 0, .nonleaf_size = 0, .leaf_size = 0, .rollback_size = 0, .cache_pressure_size = 0 };
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.write_extraargs = &expect;
|
||||
for (int i = 0; i < n_pairs; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -139,8 +136,7 @@ run_test (void) {
|
||||
assert(STATUS_VALUE(CT_SIZE_CACHEPRESSURE) == (uint64_t) expect.cache_pressure_size);
|
||||
|
||||
void *big_v;
|
||||
long big_s;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, &big_v, &big_s,
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(n_pairs + 1), n_pairs + 1, &big_v,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -71,13 +71,10 @@ run_test (void) {
|
||||
assert(r==0);
|
||||
|
||||
void* vs[8];
|
||||
//void* v2;
|
||||
long ss[8];
|
||||
//long s2;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.cleaner_callback = everything_pinned_cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -69,13 +69,10 @@ run_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* vs[8];
|
||||
//void* v2;
|
||||
long ss[8];
|
||||
//long s2;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.cleaner_callback = everything_pinned_cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -76,12 +76,9 @@ run_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* vs[5];
|
||||
//void* v2;
|
||||
long ss[5];
|
||||
//long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.cleaner_callback = my_cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &vs[0], &ss[0],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &vs[0],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -92,7 +89,7 @@ run_test (void) {
|
||||
attr.cache_pressure_size = 100;
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, attr);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 1, &vs[1], &ss[1],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 1, &vs[1],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -77,12 +77,9 @@ run_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* vs[5];
|
||||
//void* v2;
|
||||
long ss[5];
|
||||
//long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.cleaner_callback = my_cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(100), 100, &vs[4], &ss[4],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(100), 100, &vs[4],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -94,7 +91,7 @@ run_test (void) {
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(100), 100, CACHETABLE_CLEAN, attr);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i], &ss[i],
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i+1), i+1, &vs[i],
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -99,25 +99,24 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
flush_may_occur = false;
|
||||
check_flush = true;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
flush_may_occur = true;
|
||||
|
@ -142,34 +142,33 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
flush_may_occur = false;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
flush_may_occur = false;
|
||||
|
@ -159,14 +159,13 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
flush_may_occur = false;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_est_callback = pe_est_callback;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
@ -174,7 +173,7 @@ cachetable_test (void) {
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_est_callback = pe_est_callback;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@ -182,7 +181,7 @@ cachetable_test (void) {
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_est_callback = pe_est_callback;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@ -190,7 +189,7 @@ cachetable_test (void) {
|
||||
wc.flush_callback = flush;
|
||||
wc.pe_est_callback = pe_est_callback;
|
||||
wc.pe_callback = pe_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(4));
|
||||
}
|
||||
flush_may_occur = false;
|
||||
|
@ -137,7 +137,6 @@ cachetable_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1, s2;
|
||||
flush_may_occur = false;
|
||||
check_flush = true;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
@ -145,19 +144,19 @@ cachetable_test (void) {
|
||||
wc.pe_est_callback = pe_est_callback;
|
||||
wc.pe_callback = pe_callback;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(3), 3, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(3), 3, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, &s2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(4), 4, &v2, wc, fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(4), 4, CACHETABLE_CLEAN, make_pair_attr(1));
|
||||
}
|
||||
flush_may_occur = true;
|
||||
|
@ -101,11 +101,10 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
wc.clone_callback = clone_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
@ -124,7 +123,7 @@ cachetable_test (void) {
|
||||
|
||||
usleep(1 * 1024 * 1024);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
assert(clone_flush_started && !clone_flush_completed);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
@ -95,12 +95,11 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.clone_callback = clone_callback;
|
||||
wc.flush_callback = flush;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
@ -109,13 +108,13 @@ cachetable_test (void) {
|
||||
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
|
||||
toku_cachetable_begin_checkpoint(cp, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
|
||||
pf_called = false;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
assert(!pf_called);
|
||||
toku_cachetable_pf_pinned_pair(v1, true_pf_callback, NULL, f1, make_blocknum(1), 1);
|
||||
|
@ -100,12 +100,11 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.clone_callback = clone_callback;
|
||||
wc.flush_callback = flush;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
@ -114,13 +113,13 @@ cachetable_test (void) {
|
||||
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
|
||||
toku_cachetable_begin_checkpoint(cp, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
|
||||
pf_called = false;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, true_pf_req_callback, true_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, true_pf_req_callback, true_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
|
@ -82,23 +82,22 @@ cachetable_test (enum cachetable_dirty dirty, bool cloneable) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.clone_callback = cloneable ? clone_callback : NULL;
|
||||
wc.flush_callback = flush;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, dirty, make_pair_attr(8));
|
||||
|
||||
// test that having a pin that passes false for may_modify_value does not stall behind checkpoint
|
||||
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
|
||||
toku_cachetable_begin_checkpoint(cp, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_READ, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_READ, NULL, NULL);
|
||||
assert(r == 0);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
assert(r == 0);
|
||||
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
assert(r == 0);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
|
@ -93,12 +93,11 @@ cachetable_test (void) {
|
||||
create_dummy_functions(f1);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.clone_callback = clone_callback;
|
||||
wc.flush_callback = flush;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), CACHETABLE_DIRTY, make_pair_attr(8));
|
||||
assert_zero(r);
|
||||
@ -108,7 +107,7 @@ cachetable_test (void) {
|
||||
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
|
||||
toku_cachetable_begin_checkpoint(cp, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), toku_cachetable_hash(f1, make_blocknum(1)), &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
r = toku_test_cachetable_unpin_and_remove(f1, make_blocknum(1), NULL, NULL);
|
||||
assert_zero(r);
|
||||
|
@ -113,9 +113,7 @@ static void cachetable_eviction_full_test (void) {
|
||||
uint32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
|
||||
|
||||
void* value1;
|
||||
long size1;
|
||||
void* value2;
|
||||
long size2;
|
||||
//
|
||||
// let's pin a node multiple times
|
||||
// and really bring up its clock count
|
||||
@ -129,7 +127,6 @@ static void cachetable_eviction_full_test (void) {
|
||||
key,
|
||||
fullhash,
|
||||
&value1,
|
||||
&size1,
|
||||
wc,
|
||||
fetch,
|
||||
def_pf_req_callback,
|
||||
@ -150,7 +147,6 @@ static void cachetable_eviction_full_test (void) {
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
wc,
|
||||
fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -126,9 +126,7 @@ static void cachetable_eviction_full_test (void) {
|
||||
uint32_t fullhash = toku_cachetable_hash(f1, make_blocknum(0));
|
||||
|
||||
void* value1;
|
||||
long size1;
|
||||
void* value2;
|
||||
long size2;
|
||||
//
|
||||
// let's pin a node multiple times
|
||||
// and really bring up its clock count
|
||||
@ -143,7 +141,6 @@ static void cachetable_eviction_full_test (void) {
|
||||
key,
|
||||
fullhash,
|
||||
&value1,
|
||||
&size1,
|
||||
wc,
|
||||
fetch,
|
||||
def_pf_req_callback,
|
||||
@ -165,7 +162,6 @@ static void cachetable_eviction_full_test (void) {
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
wc,
|
||||
fetch,
|
||||
def_pf_req_callback,
|
||||
|
@ -83,7 +83,6 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
|
||||
// let's get and pin this node a bunch of times to drive up the clock count
|
||||
for (int i = 0; i < 20; i++) {
|
||||
void* value;
|
||||
long size;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
r = toku_cachetable_get_and_pin(
|
||||
@ -91,7 +90,6 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
|
||||
key,
|
||||
fullhash,
|
||||
&value,
|
||||
&size,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -109,14 +107,12 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
|
||||
// def_fetch another block, causing an eviction of the first block we made above
|
||||
do_sleep = true;
|
||||
void* value2;
|
||||
long size2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
r = toku_cachetable_get_and_pin(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -131,14 +127,16 @@ static void cachetable_predef_fetch_maybegetandpin_test (void) {
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
void *v = 0;
|
||||
long size = 0;
|
||||
// now verify that the block we are trying to evict is gone
|
||||
wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, &size, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, key, fullhash, &v, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
assert(r == TOKUDB_TRY_AGAIN);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, &size, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert(r == 0 && v == 0 && size == 8);
|
||||
r = toku_cachetable_get_and_pin(f1, key, fullhash, &v, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert(r == 0 && v == 0);
|
||||
PAIR_ATTR attr;
|
||||
r = toku_cachetable_get_attr(f1, key, fullhash, &attr);
|
||||
assert(r == 0 && attr.size == 8);
|
||||
do_sleep = false;
|
||||
|
||||
struct timeval tend;
|
||||
|
@ -93,13 +93,11 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
wc.pe_callback = pe_callback;
|
||||
for (int i = 0; i < 20; i++) {
|
||||
void* value;
|
||||
long size;
|
||||
r = toku_cachetable_get_and_pin(
|
||||
f1,
|
||||
key,
|
||||
fullhash,
|
||||
&value,
|
||||
&size,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -116,13 +114,11 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
|
||||
// fetch another block, causing an eviction of the first block we made above
|
||||
void* value2;
|
||||
long size2;
|
||||
r = toku_cachetable_get_and_pin(
|
||||
f1,
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&value2,
|
||||
&size2,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -139,14 +135,12 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
toku_cachetable_verify(ct);
|
||||
|
||||
void *v = 0;
|
||||
long size = 0;
|
||||
// now verify that the block we are trying to evict may be pinned
|
||||
r = toku_cachetable_get_and_pin_nonblocking(
|
||||
f1,
|
||||
key,
|
||||
fullhash,
|
||||
&v,
|
||||
&size,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -161,7 +155,6 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
key,
|
||||
fullhash,
|
||||
&v,
|
||||
&size,
|
||||
wc,
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
@ -169,7 +162,10 @@ static void cachetable_prefetch_maybegetandpin_test (void) {
|
||||
true,
|
||||
NULL
|
||||
);
|
||||
assert(r == 0 && v == 0 && size == 1);
|
||||
assert(r == 0 && v == 0);
|
||||
PAIR_ATTR attr;
|
||||
r = toku_cachetable_get_attr(f1, key, fullhash, &attr);
|
||||
assert(r == 0 && attr.size == 1);
|
||||
|
||||
struct timeval tend;
|
||||
gettimeofday(&tend, NULL);
|
||||
|
@ -70,9 +70,8 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
// at this point, we should have 8 bytes of data in a cachetable that supports 7
|
||||
@ -82,11 +81,11 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
|
||||
if (test_type == pin_in_memory) {
|
||||
old_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
if (nonblocking) {
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
assert_zero(r);
|
||||
}
|
||||
else {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
}
|
||||
new_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
@ -97,13 +96,13 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
|
||||
else if (test_type == pin_fetch) {
|
||||
old_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
if (nonblocking) {
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(2), 2, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(2), 2, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
assert(r == TOKUDB_TRY_AGAIN);
|
||||
new_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
assert(new_num_ev_runs > old_num_ev_runs);
|
||||
}
|
||||
else {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
new_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
assert(new_num_ev_runs > old_num_ev_runs);
|
||||
@ -114,13 +113,13 @@ cachetable_test (enum pin_evictor_test_type test_type, bool nonblocking) {
|
||||
else if (test_type == pin_partial_fetch) {
|
||||
old_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
if (nonblocking) {
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, pf_req_callback, pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
r = toku_cachetable_get_and_pin_nonblocking(f1, make_blocknum(1), 1, &v1, wc, def_fetch, pf_req_callback, pf_callback, PL_WRITE_EXPENSIVE, NULL, NULL);
|
||||
assert(r == TOKUDB_TRY_AGAIN);
|
||||
new_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
assert(new_num_ev_runs > old_num_ev_runs);
|
||||
}
|
||||
else {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, pf_req_callback, pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, pf_req_callback, pf_callback, true, NULL);
|
||||
assert_zero(r);
|
||||
new_num_ev_runs = evictor_test_helpers::get_num_eviction_runs(&ct->ev);
|
||||
assert(new_num_ev_runs > old_num_ev_runs);
|
||||
|
@ -73,11 +73,10 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.cleaner_callback = cleaner_callback;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), i, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
PAIR_ATTR attr = make_pair_attr(8);
|
||||
attr.cache_pressure_size = 8;
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(i), i, CACHETABLE_DIRTY, attr);
|
||||
|
@ -93,12 +93,14 @@ cachetable_getandpin_test (int n) {
|
||||
for (i=1; i<=n; i++) {
|
||||
uint32_t hi;
|
||||
hi = toku_cachetable_hash(f1, make_blocknum(i));
|
||||
void *v; long size;
|
||||
void *v;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, &size, wc, fetch, def_pf_req_callback, def_pf_callback, true, 0);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(i), hi, &v, wc, fetch, def_pf_req_callback, def_pf_callback, true, 0);
|
||||
assert(r == 0);
|
||||
assert(size == i);
|
||||
PAIR_ATTR attr;
|
||||
r = toku_cachetable_get_attr(f1, make_blocknum(i), hi, &attr);
|
||||
assert(r == 0 && attr.size == i);
|
||||
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(i), hi, CACHETABLE_CLEAN, make_pair_attr(i));
|
||||
assert(r == 0);
|
||||
|
@ -69,10 +69,9 @@ run_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
foo = false;
|
||||
cachefile_kibbutz_enq(f1, kibbutz_work, f1);
|
||||
toku_cachefile_close(&f1, false, ZERO_LSN);
|
||||
|
@ -121,11 +121,8 @@ cachetable_test (void) {
|
||||
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||
|
||||
void* v1;
|
||||
//void* v2;
|
||||
long s1;
|
||||
//long s2;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, fetch, pf_req_callback, pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, fetch, pf_req_callback, pf_callback, true, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
//
|
||||
// verify that a prefetch of this node will fail
|
||||
@ -148,16 +145,19 @@ cachetable_test (void) {
|
||||
//
|
||||
// now get and pin node again, and make sure that partial fetch and fetch are not called
|
||||
//
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
//
|
||||
// now make sure that if we say a partial fetch is required, that we get a partial fetch
|
||||
// and that read_extraargs properly passed down
|
||||
//
|
||||
pf_req_called = false;
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, true_pf_req_callback, true_pf_callback, true, &fetch_val);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, err_fetch, true_pf_req_callback, true_pf_callback, true, &fetch_val);
|
||||
assert(pf_req_called);
|
||||
assert(s1 == sizeof(fetch_val)+1);
|
||||
PAIR_ATTR attr;
|
||||
r = toku_cachetable_get_attr(f1, make_blocknum(1), 1, &attr);
|
||||
assert(r == 0);
|
||||
assert(attr.size == sizeof(fetch_val)+1);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
// close and reopen cachefile so we can do some simple prefetch tests
|
||||
@ -185,7 +185,7 @@ cachetable_test (void) {
|
||||
//
|
||||
// now verify we can pin it, and NO fetch callback should get called
|
||||
//
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
@ -205,7 +205,7 @@ cachetable_test (void) {
|
||||
&doing_prefetch
|
||||
);
|
||||
assert(doing_prefetch);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, wc, err_fetch, pf_req_callback, err_pf_callback, true, NULL);
|
||||
assert(&fetch_val == v1);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8));
|
||||
|
||||
|
@ -171,7 +171,6 @@ static void *move_numbers(void *arg) {
|
||||
*/
|
||||
|
||||
void* v1;
|
||||
long s1;
|
||||
CACHEKEY less_key;
|
||||
less_key.b = less;
|
||||
uint32_t less_fullhash = less;
|
||||
@ -184,7 +183,6 @@ static void *move_numbers(void *arg) {
|
||||
less_key,
|
||||
less,
|
||||
&v1,
|
||||
&s1,
|
||||
wc, fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_WRITE_CHEAP,
|
||||
NULL,
|
||||
@ -205,7 +203,6 @@ static void *move_numbers(void *arg) {
|
||||
make_blocknum(greater),
|
||||
greater,
|
||||
&v1,
|
||||
&s1,
|
||||
wc, fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_WRITE_CHEAP,
|
||||
NULL,
|
||||
@ -238,7 +235,6 @@ static void *move_numbers(void *arg) {
|
||||
make_blocknum(third),
|
||||
third,
|
||||
&v1,
|
||||
&s1,
|
||||
wc, fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_WRITE_CHEAP,
|
||||
NULL,
|
||||
@ -264,7 +260,6 @@ static void *read_random_numbers(void *arg) {
|
||||
while(run_test) {
|
||||
int rand_key1 = random() % NUM_ELEMENTS;
|
||||
void* v1;
|
||||
long s1;
|
||||
int r1;
|
||||
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
|
||||
wc.flush_callback = flush;
|
||||
@ -274,7 +269,6 @@ static void *read_random_numbers(void *arg) {
|
||||
make_blocknum(rand_key1),
|
||||
rand_key1,
|
||||
&v1,
|
||||
&s1,
|
||||
wc, fetch, def_pf_req_callback, def_pf_callback,
|
||||
PL_READ,
|
||||
NULL,
|
||||
|
@ -57,18 +57,16 @@ run_test (void) {
|
||||
|
||||
void* v1;
|
||||
void* v2;
|
||||
long s1;
|
||||
long s2;
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, &s1, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v1, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(1), 1, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(2), 2, &v2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_test_cachetable_unpin(f1, make_blocknum(2), 2, CACHETABLE_CLEAN, make_pair_attr(8)); assert(r==0);
|
||||
}
|
||||
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, &s2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
r = toku_cachetable_get_and_pin(f1, make_blocknum(1), 1, &v2, def_write_callback(NULL), def_fetch, def_pf_req_callback, def_pf_callback, true, NULL);
|
||||
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
|
||||
toku_cachetable_begin_checkpoint(cp, NULL);
|
||||
// mark nodes as pending a checkpoint, so that get_and_pin_nonblocking on block 1 will return TOKUDB_TRY_AGAIN
|
||||
@ -79,7 +77,6 @@ run_test (void) {
|
||||
make_blocknum(1),
|
||||
1,
|
||||
&v1,
|
||||
&s1,
|
||||
def_write_callback(NULL),
|
||||
def_fetch,
|
||||
def_pf_req_callback,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user