Merge 10.4 into 10.5

This commit is contained in:
Marko Mäkelä 2019-12-27 21:17:16 +02:00
commit 8cc15c036d
87 changed files with 1405 additions and 1032 deletions

View file

@ -85,7 +85,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right PointerAlignment: Right
ReflowComments: true ReflowComments: true
SortIncludes: true SortIncludes: false
SortUsingDeclarations: true SortUsingDeclarations: true
SpaceAfterCStyleCast: true SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true

View file

@ -2676,7 +2676,9 @@ static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn, bool last)
} }
} }
if (more_data && recv_parse_log_recs(0, STORE_NO, false)) { store_t store = STORE_NO;
if (more_data && recv_parse_log_recs(0, &store, 0, false)) {
msg("Error: copying the log failed"); msg("Error: copying the log failed");

View file

@ -80,7 +80,7 @@ while (<F>) {
s/table id \d+/table id #/; s/table id \d+/table id #/;
s/mapped to number \d+/mapped to number #/; s/mapped to number \d+/mapped to number #/;
s/CRC32 0x[0-9a-f]+/CRC32 0x########/; s/CRC32 0x[0-9a-f]+/CRC32 0x########/;
print if /GTID|BEGIN|COMMIT|Table_map|Write_rows|Update_rows|Delete_rows|generated by server|40005 TEMPORARY/; print if /\b(GTID|BEGIN|COMMIT|Table_map|Write_rows|Update_rows|Delete_rows|generated by server|40005 TEMPORARY)\b/;
} }
close F; close F;
EOF EOF

View file

@ -10548,6 +10548,36 @@ EXPLAIN
} }
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
#
# MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on
#
CREATE TABLE t1 (a INT, b DATE, c INT);
INSERT INTO t1 VALUES
(1,'2001-01-21',345),
(6,'2001-01-20',315),
(6,'2001-01-20',214);
CREATE TABLE t2 (a INT, b INT);
INSERT INTO t2 VALUES (2,19), (7,20);
CREATE VIEW v1 AS SELECT a, b, max(c) AS max_c FROM t1
GROUP BY a,b HAVING max_c < 707;
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a);
a b max_c a b dayname(v1.b)
1 2001-01-21 345 2 19 Sunday
1 2001-01-21 345 7 20 Sunday
6 2001-01-20 315 7 20 Saturday
SET optimizer_switch='condition_pushdown_for_derived=off';
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday';
a b max_c a b dayname(v1.b)
1 2001-01-21 345 2 19 Sunday
1 2001-01-21 345 7 20 Sunday
SET optimizer_switch='condition_pushdown_for_derived=on';
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday';
a b max_c a b dayname(v1.b)
1 2001-01-21 345 2 19 Sunday
1 2001-01-21 345 7 20 Sunday
DROP VIEW v1;
DROP TABLE t1, t2;
SET optimizer_switch=DEFAULT;
# End of 10.2 tests # End of 10.2 tests
# #
# MDEV-14579: pushdown conditions into materialized views/derived tables # MDEV-14579: pushdown conditions into materialized views/derived tables

View file

@ -2140,6 +2140,34 @@ SELECT * FROM (SELECT 1 FROM v1 UNION (SELECT 1 FROM v1 WHERE @a := uuid())) dt;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
--echo #
--echo # MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on
--echo #
CREATE TABLE t1 (a INT, b DATE, c INT);
INSERT INTO t1 VALUES
(1,'2001-01-21',345),
(6,'2001-01-20',315),
(6,'2001-01-20',214);
CREATE TABLE t2 (a INT, b INT);
INSERT INTO t2 VALUES (2,19), (7,20);
CREATE VIEW v1 AS SELECT a, b, max(c) AS max_c FROM t1
GROUP BY a,b HAVING max_c < 707;
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a);
SET optimizer_switch='condition_pushdown_for_derived=off';
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday';
SET optimizer_switch='condition_pushdown_for_derived=on';
SELECT *, dayname(v1.b) FROM v1,t2 WHERE (v1.max_c>214) AND (t2.a>v1.a) AND dayname(v1.b)='Sunday';
DROP VIEW v1;
DROP TABLE t1, t2;
SET optimizer_switch=DEFAULT;
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View file

@ -159,7 +159,9 @@ date_format('1999-12-31','%x-%v') date_format('2000-01-01','%x-%v')
1999-52 1999-52 1999-52 1999-52
select dayname("1962-03-03"),dayname("1962-03-03")+0; select dayname("1962-03-03"),dayname("1962-03-03")+0;
dayname("1962-03-03") dayname("1962-03-03")+0 dayname("1962-03-03") dayname("1962-03-03")+0
Saturday 5 Saturday 0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Saturday'
select monthname("1972-03-04"),monthname("1972-03-04")+0; select monthname("1972-03-04"),monthname("1972-03-04")+0;
monthname("1972-03-04") monthname("1972-03-04")+0 monthname("1972-03-04") monthname("1972-03-04")+0
March 0 March 0
@ -3512,6 +3514,19 @@ v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI
DROP VIEW v1,v2,v3; DROP VIEW v1,v2,v3;
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on
#
SELECT DAYNAME('2019-01-05')+0;
DAYNAME('2019-01-05')+0
0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Saturday'
SELECT CAST(DAYNAME('2019-01-05') AS SIGNED);
CAST(DAYNAME('2019-01-05') AS SIGNED)
0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'Saturday'
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View file

@ -1972,6 +1972,14 @@ show create view v3;
DROP VIEW v1,v2,v3; DROP VIEW v1,v2,v3;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on
--echo #
SELECT DAYNAME('2019-01-05')+0;
SELECT CAST(DAYNAME('2019-01-05') AS SIGNED);
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View file

@ -4,7 +4,7 @@
# Verbose run # Verbose run
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB;
@ -36,7 +36,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -46,7 +46,7 @@ END IF|
# Silent run # Silent run
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB;
@ -75,7 +75,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -93,7 +93,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
; ;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -105,21 +105,21 @@ END IF|
# #
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=InnoDB; ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
END IF| END IF|
\d ; \d ;
TRUNCATE TABLE time_zone_leap_second; TRUNCATE TABLE time_zone_leap_second;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=Aria; ALTER TABLE time_zone_leap_second ENGINE=Aria;
END IF| END IF|
\d ; \d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time; ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -131,7 +131,7 @@ END IF|
# #
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB;
@ -146,7 +146,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;

View file

@ -574,6 +574,22 @@ a b
SELECT * FROM t1 WHERE a IN ((SELECT MAX(b) FROM t1), (SELECT MIN(b) FROM t1)); SELECT * FROM t1 WHERE a IN ((SELECT MAX(b) FROM t1), (SELECT MIN(b) FROM t1));
a b a b
DROP TABLE t1; DROP TABLE t1;
SET time_zone='Europe/Moscow';
CREATE TABLE t1 (a TIMESTAMP);
CREATE TABLE t2 (a TIMESTAMP);
SET timestamp=1288479599 /*summer time in Mowcow*/;
INSERT INTO t1 VALUES (CURRENT_TIMESTAMP);
SET timestamp=1288479599+3600 /*winter time in Mowcow*/;
INSERT INTO t2 VALUES (CURRENT_TIMESTAMP);
SELECT t1.a, UNIX_TIMESTAMP(t1.a), t2.a, UNIX_TIMESTAMP(t2.a) FROM t1, t2;
a UNIX_TIMESTAMP(t1.a) a UNIX_TIMESTAMP(t2.a)
2010-10-31 02:59:59 1288479599 2010-10-31 02:59:59 1288483199
SELECT NULLIF(t1.a, t2.a) FROM t1,t2;
NULLIF(t1.a, t2.a)
2010-10-31 02:59:59
DROP TABLE t1, t2;
SET time_zone=DEFAULT;
SET timestamp=DEFAULT;
# #
# MDEV-17979 Assertion `0' failed in Item::val_native upon SELECT with timestamp, NULLIF, GROUP BY # MDEV-17979 Assertion `0' failed in Item::val_native upon SELECT with timestamp, NULLIF, GROUP BY
# #

View file

@ -521,6 +521,23 @@ SELECT * FROM t1 WHERE a = (SELECT MIN(b) FROM t1);
SELECT * FROM t1 WHERE a IN ((SELECT MAX(b) FROM t1), (SELECT MIN(b) FROM t1)); SELECT * FROM t1 WHERE a IN ((SELECT MAX(b) FROM t1), (SELECT MIN(b) FROM t1));
DROP TABLE t1; DROP TABLE t1;
# NULLIF
SET time_zone='Europe/Moscow';
CREATE TABLE t1 (a TIMESTAMP);
CREATE TABLE t2 (a TIMESTAMP);
SET timestamp=1288479599 /*summer time in Mowcow*/;
INSERT INTO t1 VALUES (CURRENT_TIMESTAMP);
SET timestamp=1288479599+3600 /*winter time in Mowcow*/;
INSERT INTO t2 VALUES (CURRENT_TIMESTAMP);
SELECT t1.a, UNIX_TIMESTAMP(t1.a), t2.a, UNIX_TIMESTAMP(t2.a) FROM t1, t2;
SELECT NULLIF(t1.a, t2.a) FROM t1,t2;
DROP TABLE t1, t2;
SET time_zone=DEFAULT;
SET timestamp=DEFAULT;
--echo # --echo #
--echo # MDEV-17979 Assertion `0' failed in Item::val_native upon SELECT with timestamp, NULLIF, GROUP BY --echo # MDEV-17979 Assertion `0' failed in Item::val_native upon SELECT with timestamp, NULLIF, GROUP BY
--echo # --echo #

View file

@ -1198,6 +1198,87 @@ Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41
#
CREATE TABLE t1
(
id INT NOT NULL PRIMARY KEY,
id2 INT,
k TINYINT,
j INT,
t DATETIME,
KEY k1 (id2,k,j,t)
);
INSERT INTO t1 VALUES
(53,54,1,0,'2019-12-13 10:09:59'),
(54,54,1,0,'2019-12-13 16:28:41'),
(55,54,1,0,'2019-12-13 16:29:10'),
(56,54,1,0,'2019-12-13 16:29:43'),
(57,54,1,0,'2019-12-13 16:30:16'),
(58,54,1,0,'2019-12-13 16:30:49'),
(59,54,1,0,'2019-12-13 16:31:23'),
(60,54,1,0,'2019-12-13 16:31:55'),
(61,54,1,0,'2019-12-13 16:32:28'),
(62,54,1,0,'2019-12-13 16:33:01'),
(63,54,1,0,'2019-12-13 16:33:34'),
(64,54,1,0,'2019-12-13 16:34:07'),
(65,54,1,0,'2019-12-13 16:34:40'),
(66,54,1,0,'2019-12-13 16:35:13'),
(67,54,1,0,'2019-12-13 16:35:46'),
(68,54,1,0,'2019-12-13 16:36:19');
SELECT t FROM t1 GROUP BY t HAVING t=max(t);
t
2019-12-13 10:09:59
2019-12-13 16:28:41
2019-12-13 16:29:10
2019-12-13 16:29:43
2019-12-13 16:30:16
2019-12-13 16:30:49
2019-12-13 16:31:23
2019-12-13 16:31:55
2019-12-13 16:32:28
2019-12-13 16:33:01
2019-12-13 16:33:34
2019-12-13 16:34:07
2019-12-13 16:34:40
2019-12-13 16:35:13
2019-12-13 16:35:46
2019-12-13 16:36:19
SELECT t FROM t1 WHERE id2=54 and j=0 and k=1 GROUP BY t HAVING t=max(t);
t
2019-12-13 10:09:59
2019-12-13 16:28:41
2019-12-13 16:29:10
2019-12-13 16:29:43
2019-12-13 16:30:16
2019-12-13 16:30:49
2019-12-13 16:31:23
2019-12-13 16:31:55
2019-12-13 16:32:28
2019-12-13 16:33:01
2019-12-13 16:33:34
2019-12-13 16:34:07
2019-12-13 16:34:40
2019-12-13 16:35:13
2019-12-13 16:35:46
2019-12-13 16:36:19
DROP TABLE t1;
CREATE TABLE t1 (pk INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1);
SELECT pk<DATE'2001-01-01' FROM t1 GROUP BY pk;
pk<DATE'2001-01-01'
1
Warnings:
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
SELECT pk<DATE'2001-01-01' FROM v1 GROUP BY pk;
pk<DATE'2001-01-01'
1
Warnings:
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
DROP VIEW v1;
DROP TABLE t1;
#
# End of 10.1 tests # End of 10.1 tests
# #
# #

View file

@ -747,6 +747,49 @@ DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41
--echo #
CREATE TABLE t1
(
id INT NOT NULL PRIMARY KEY,
id2 INT,
k TINYINT,
j INT,
t DATETIME,
KEY k1 (id2,k,j,t)
);
INSERT INTO t1 VALUES
(53,54,1,0,'2019-12-13 10:09:59'),
(54,54,1,0,'2019-12-13 16:28:41'),
(55,54,1,0,'2019-12-13 16:29:10'),
(56,54,1,0,'2019-12-13 16:29:43'),
(57,54,1,0,'2019-12-13 16:30:16'),
(58,54,1,0,'2019-12-13 16:30:49'),
(59,54,1,0,'2019-12-13 16:31:23'),
(60,54,1,0,'2019-12-13 16:31:55'),
(61,54,1,0,'2019-12-13 16:32:28'),
(62,54,1,0,'2019-12-13 16:33:01'),
(63,54,1,0,'2019-12-13 16:33:34'),
(64,54,1,0,'2019-12-13 16:34:07'),
(65,54,1,0,'2019-12-13 16:34:40'),
(66,54,1,0,'2019-12-13 16:35:13'),
(67,54,1,0,'2019-12-13 16:35:46'),
(68,54,1,0,'2019-12-13 16:36:19');
SELECT t FROM t1 GROUP BY t HAVING t=max(t);
SELECT t FROM t1 WHERE id2=54 and j=0 and k=1 GROUP BY t HAVING t=max(t);
DROP TABLE t1;
CREATE TABLE t1 (pk INT);
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1);
SELECT pk<DATE'2001-01-01' FROM t1 GROUP BY pk;
SELECT pk<DATE'2001-01-01' FROM v1 GROUP BY pk;
DROP VIEW v1;
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.1 tests --echo # End of 10.1 tests
--echo # --echo #

View file

@ -20,6 +20,19 @@ COALESCE(@a)
1 1
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-21065 UNIQUE constraint causes a query with string comparison to omit a row in the result set
#
CREATE TABLE t1 (c0 INT UNIQUE);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL), (NULL), (1), (0);
SELECT * FROM t1 WHERE c0 < '\n2';
c0
0
1
DROP TABLE t1;
SELECT CAST('\n2' AS INT);
CAST('\n2' AS INT)
2
#
# End of 5.5 tests # End of 5.5 tests
# #
# #

View file

@ -14,6 +14,18 @@ SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-21065 UNIQUE constraint causes a query with string comparison to omit a row in the result set
--echo #
CREATE TABLE t1 (c0 INT UNIQUE);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL), (NULL), (1), (0);
SELECT * FROM t1 WHERE c0 < '\n2';
DROP TABLE t1;
SELECT CAST('\n2' AS INT);
--echo # --echo #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #

View file

@ -1258,6 +1258,72 @@ drop table t1;
SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set @@old_mode= @save_old_mode; set @@old_mode= @save_old_mode;
# #
# MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41
#
CREATE OR REPLACE TABLE t1
(
id INT NOT NULL PRIMARY KEY,
id2 INT,
k TINYINT,
j INT,
t TIME,
KEY k1 (id2,k,j,t)
);
INSERT INTO t1 VALUES
(53,54,1,0,'10:09:59'),
(54,54,1,0,'16:28:41'),
(55,54,1,0,'16:29:10'),
(56,54,1,0,'16:29:43'),
(57,54,1,0,'16:30:16'),
(58,54,1,0,'16:30:49'),
(59,54,1,0,'16:31:23'),
(60,54,1,0,'16:31:55'),
(61,54,1,0,'16:32:28'),
(62,54,1,0,'16:33:01'),
(63,54,1,0,'16:33:34'),
(64,54,1,0,'16:34:07'),
(65,54,1,0,'16:34:40'),
(66,54,1,0,'16:35:13'),
(67,54,1,0,'16:35:46'),
(68,54,1,0,'16:36:19');
SELECT t FROM t1 GROUP BY t HAVING t=MAX(t);
t
10:09:59
16:28:41
16:29:10
16:29:43
16:30:16
16:30:49
16:31:23
16:31:55
16:32:28
16:33:01
16:33:34
16:34:07
16:34:40
16:35:13
16:35:46
16:36:19
SELECT t FROM t1 WHERE id2=54 AND j=0 AND k=1 GROUP BY t HAVING t=MAX(t);
t
10:09:59
16:28:41
16:29:10
16:29:43
16:30:16
16:30:49
16:31:23
16:31:55
16:32:28
16:33:01
16:33:34
16:34:07
16:34:40
16:35:13
16:35:46
16:36:19
DROP TABLE t1;
#
# End of 10.1 tests # End of 10.1 tests
# #
# #

View file

@ -751,6 +751,40 @@ drop table t1;
SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; SET @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set @@old_mode= @save_old_mode; set @@old_mode= @save_old_mode;
--echo #
--echo # MDEV-21319 COUNT(*) returns 1, actual SELECT returns no result in 10.3.21, but 1 result in 10.1.41
--echo #
CREATE OR REPLACE TABLE t1
(
id INT NOT NULL PRIMARY KEY,
id2 INT,
k TINYINT,
j INT,
t TIME,
KEY k1 (id2,k,j,t)
);
INSERT INTO t1 VALUES
(53,54,1,0,'10:09:59'),
(54,54,1,0,'16:28:41'),
(55,54,1,0,'16:29:10'),
(56,54,1,0,'16:29:43'),
(57,54,1,0,'16:30:16'),
(58,54,1,0,'16:30:49'),
(59,54,1,0,'16:31:23'),
(60,54,1,0,'16:31:55'),
(61,54,1,0,'16:32:28'),
(62,54,1,0,'16:33:01'),
(63,54,1,0,'16:33:34'),
(64,54,1,0,'16:34:07'),
(65,54,1,0,'16:34:40'),
(66,54,1,0,'16:35:13'),
(67,54,1,0,'16:35:46'),
(68,54,1,0,'16:36:19');
SELECT t FROM t1 GROUP BY t HAVING t=MAX(t);
SELECT t FROM t1 WHERE id2=54 AND j=0 AND k=1 GROUP BY t HAVING t=MAX(t);
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.1 tests --echo # End of 10.1 tests
--echo # --echo #

View file

@ -3642,6 +3642,87 @@ x
foo foo
drop table t1; drop table t1;
# #
# MDEV-16579: Wrong result of query using DISTINCT COUNT(*) OVER (*)
#
CREATE TABLE t1 (i int) ;
INSERT INTO t1 VALUES (1),(0),(1),(2),(0),(1),(2),(1),(2);
SELECT DISTINCT COUNT(*) OVER (), MOD(MIN(i),2) FROM t1 GROUP BY i ;
COUNT(*) OVER () MOD(MIN(i),2)
3 0
3 1
drop table t1;
#
# MDEV-21318: Wrong results with window functions and implicit grouping
#
CREATE TABLE t1 (a INT);
#
# With empty const table
# The expected result here is 1, NULL
#
explain
SELECT row_number() over(), sum(1) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 Const row not found; Using temporary
SELECT row_number() over(), sum(1) FROM t1;
row_number() over() sum(1)
1 NULL
insert into t1 values (2);
#
# Const table has 1 row, but still impossible where
# The expected result here is 1, NULL
#
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT row_number() over(), sum(1) FROM t1 where a=1;
row_number() over() sum(1)
1 NULL
#
# Impossible HAVING
# Empty result is expected
#
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
row_number() over() sum(1)
#
# const table has 1 row, no impossible where
# The expected result here is 1, 2
#
EXPLAIN SELECT row_number() over(), sum(a) FROM t1 where a=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1 Using temporary
SELECT row_number() over(), sum(a) FROM t1 where a=2;
row_number() over() sum(a)
1 2
drop table t1;
#
# Impossible Where
#
create table t1(a int);
insert into t1 values (1);
#
# Expected result is NULL, 0, NULL
#
EXPLAIN SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
MAX(a) OVER () COUNT(a) abs(a)
NULL 0 NULL
#
# Expected result is 1, 0, NULL
#
EXPLAIN
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
MAX(1) OVER () COUNT(a) abs(a)
1 0 NULL
drop table t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View file

@ -2350,6 +2350,81 @@ INSERT INTO t1 VALUES (1),(2),(3);
SELECT (SELECT MIN('foo') OVER() FROM t1 LIMIT 1) as x; SELECT (SELECT MIN('foo') OVER() FROM t1 LIMIT 1) as x;
drop table t1; drop table t1;
--echo #
--echo # MDEV-16579: Wrong result of query using DISTINCT COUNT(*) OVER (*)
--echo #
CREATE TABLE t1 (i int) ;
INSERT INTO t1 VALUES (1),(0),(1),(2),(0),(1),(2),(1),(2);
SELECT DISTINCT COUNT(*) OVER (), MOD(MIN(i),2) FROM t1 GROUP BY i ;
drop table t1;
--echo #
--echo # MDEV-21318: Wrong results with window functions and implicit grouping
--echo #
CREATE TABLE t1 (a INT);
--echo #
--echo # With empty const table
--echo # The expected result here is 1, NULL
--echo #
explain
SELECT row_number() over(), sum(1) FROM t1;
SELECT row_number() over(), sum(1) FROM t1;
insert into t1 values (2);
--echo #
--echo # Const table has 1 row, but still impossible where
--echo # The expected result here is 1, NULL
--echo #
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1;
SELECT row_number() over(), sum(1) FROM t1 where a=1;
--echo #
--echo # Impossible HAVING
--echo # Empty result is expected
--echo #
EXPLAIN SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
SELECT row_number() over(), sum(1) FROM t1 where a=1 having 1=0;
--echo #
--echo # const table has 1 row, no impossible where
--echo # The expected result here is 1, 2
--echo #
EXPLAIN SELECT row_number() over(), sum(a) FROM t1 where a=2;
SELECT row_number() over(), sum(a) FROM t1 where a=2;
drop table t1;
--echo #
--echo # Impossible Where
--echo #
create table t1(a int);
insert into t1 values (1);
--echo #
--echo # Expected result is NULL, 0, NULL
--echo #
EXPLAIN SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
SELECT MAX(a) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
--echo #
--echo # Expected result is 1, 0, NULL
--echo #
EXPLAIN
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
SELECT MAX(1) OVER (), COUNT(a), abs(a) FROM t1 WHERE FALSE;
drop table t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View file

@ -4675,6 +4675,8 @@ sub extract_warning_lines ($$) {
qr/missing DBUG_RETURN/, qr/missing DBUG_RETURN/,
qr/Attempting backtrace/, qr/Attempting backtrace/,
qr/Assertion .* failed/, qr/Assertion .* failed/,
qr/Sanitizer/,
qr/runtime error:/,
); );
# These are taken from the include/mtr_warnings.sql global suppression # These are taken from the include/mtr_warnings.sql global suppression
# list. They occur delayed, so they can be parsed during shutdown rather # list. They occur delayed, so they can be parsed during shutdown rather

View file

@ -1,121 +0,0 @@
#
# MDEV-17323: Backport INFORMATION_SCHEMA.CHECK_CONSTRAINTS to 10.2
#
CREATE user boo1;
GRANT select,create,alter,drop on foo.* to boo1;
SHOW GRANTS for boo1;
Grants for boo1@%
GRANT USAGE ON *.* TO 'boo1'@'%'
GRANT SELECT, CREATE, DROP, ALTER ON `foo`.* TO 'boo1'@'%'
CREATE user boo2;
create database foo;
CONNECT con1,localhost, boo1,, foo;
SET check_constraint_checks=1;
CREATE TABLE t0
(
t int, check (t>32) # table constraint
) ENGINE=myisam;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CONSTRAINT_1 t0 `t` > 32
ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100);
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CHK_t0_t t0 `t` < 100
def foo CONSTRAINT_1 t0 `t` > 32
ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CONSTRAINT_1 t0 `t` > 32
ALTER TABLE t0
ADD CONSTRAINT CHECK(t<50);
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_2 t0 `t` < 50
CREATE TABLE t1
( t int CHECK(t>2), # field constraint
tt int,
CONSTRAINT CHECK (tt > 32), CONSTRAINT CHECK (tt <50),# autogenerated names table constraints
CONSTRAINT CHK_tt CHECK(tt<100) # named table constraint
) ENGINE=InnoDB;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CHK_tt t1 `tt` < 100
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_1 t1 `tt` > 32
def foo CONSTRAINT_2 t0 `t` < 50
def foo CONSTRAINT_2 t1 `tt` < 50
def foo t t1 `t` > 2
ALTER TABLE t1
DROP CONSTRAINT CHK_tt;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_1 t1 `tt` > 32
def foo CONSTRAINT_2 t0 `t` < 50
def foo CONSTRAINT_2 t1 `tt` < 50
def foo t t1 `t` > 2
CREATE TABLE t2
(
name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint
start_date DATE,
end_date DATE,
CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint
)ENGINE=Innodb;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CHK_dates t2 `start_date` is null
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_1 t1 `tt` > 32
def foo CONSTRAINT_2 t0 `t` < 50
def foo CONSTRAINT_2 t1 `tt` < 50
def foo name t2 char_length(`name`) > 2
def foo t t1 `t` > 2
ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt);
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CHK_dates t2 `start_date` is null
def foo CHK_new_ t1 `t` > `tt`
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_1 t1 `tt` > 32
def foo CONSTRAINT_2 t0 `t` < 50
def foo CONSTRAINT_2 t1 `tt` < 50
def foo name t2 char_length(`name`) > 2
def foo t t1 `t` > 2
CREATE TABLE t3
(
a int,
b int check (b>0), # field constraint named 'b'
CONSTRAINT b check (b>10) # table constraint
) ENGINE=InnoDB;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
def foo CHK_dates t2 `start_date` is null
def foo CHK_new_ t1 `t` > `tt`
def foo CONSTRAINT_1 t0 `t` > 32
def foo CONSTRAINT_1 t1 `tt` > 32
def foo CONSTRAINT_2 t0 `t` < 50
def foo CONSTRAINT_2 t1 `tt` < 50
def foo b t3 `b` > 0
def foo b t3 `b` > 10
def foo name t2 char_length(`name`) > 2
def foo t t1 `t` > 2
disconnect con1;
CONNECT con2, localhost, boo2,, test;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE
disconnect con2;
CONNECT con1, localhost, boo1,,foo;
DROP TABLE t0;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP DATABASE foo;
disconnect con1;
connection default;
DROP USER boo1;
DROP USER boo2;

View file

@ -1,180 +1,148 @@
# #
# MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS # MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS
# #
set check_constraint_checks=1; CREATE user boo1;
use test; GRANT select,create,alter,drop on foo.* to boo1;
create table t0 SHOW GRANTS for boo1;
Grants for boo1@%
GRANT USAGE ON *.* TO 'boo1'@'%'
GRANT SELECT, CREATE, DROP, ALTER ON `foo`.* TO 'boo1'@'%'
CREATE user boo2;
create database foo;
CONNECT con1,localhost, boo1,, foo;
SET check_constraint_checks=1;
CREATE TABLE t0
( (
t int, check (t>32) # table constraint t int, check (t>32) # table constraint
) ENGINE=myisam; ) ENGINE=myisam;
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA mysql def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME Priv
TABLE_NAME global_priv
CHECK_CLAUSE json_valid(`Priv`)
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
ALTER TABLE t0 ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100); ADD CONSTRAINT CHK_t0_t CHECK(t<100);
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA mysql def foo t0 CHK_t0_t `t` < 100
CONSTRAINT_NAME Priv def foo t0 CONSTRAINT_1 `t` > 32
TABLE_NAME global_priv
CHECK_CLAUSE json_valid(`Priv`)
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CHK_t0_t
TABLE_NAME t0
CHECK_CLAUSE `t` < 100
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
ALTER TABLE t0 ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t; DROP CONSTRAINT CHK_t0_t;
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA mysql def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME Priv ALTER TABLE t0
TABLE_NAME global_priv ADD CONSTRAINT CHECK(t<50);
CHECK_CLAUSE json_valid(`Priv`) SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA test def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME CONSTRAINT_1 def foo t0 CONSTRAINT_2 `t` < 50
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
CREATE TABLE t1 CREATE TABLE t1
( t int CHECK(t>2), # field constraint ( t int CHECK(t>2), # field constraint
tt int, CONSTRAINT CHK_tt CHECK(tt<100) # table constraint tt int,
CONSTRAINT CHECK (tt > 32), CONSTRAINT CHECK (tt <50),# autogenerated names table constraints
CONSTRAINT CHK_tt CHECK(tt<100) # named table constraint
) ENGINE=InnoDB; ) ENGINE=InnoDB;
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA mysql def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME Priv def foo t0 CONSTRAINT_2 `t` < 50
TABLE_NAME global_priv def foo t1 CHK_tt `tt` < 100
CHECK_CLAUSE json_valid(`Priv`) def foo t1 CONSTRAINT_1 `tt` > 32
CONSTRAINT_CATALOG def def foo t1 CONSTRAINT_2 `tt` < 50
CONSTRAINT_SCHEMA test def foo t1 t `t` > 2
CONSTRAINT_NAME CHK_tt
TABLE_NAME t1
CHECK_CLAUSE `tt` < 100
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME t
TABLE_NAME t1
CHECK_CLAUSE `t` > 2
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
ALTER TABLE t1 ALTER TABLE t1
DROP CONSTRAINT CHK_tt; DROP CONSTRAINT CHK_tt;
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA mysql def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME Priv def foo t0 CONSTRAINT_2 `t` < 50
TABLE_NAME global_priv def foo t1 CONSTRAINT_1 `tt` > 32
CHECK_CLAUSE json_valid(`Priv`) def foo t1 CONSTRAINT_2 `tt` < 50
CONSTRAINT_CATALOG def def foo t1 t `t` > 2
CONSTRAINT_SCHEMA test CREATE TABLE t2
CONSTRAINT_NAME t
TABLE_NAME t1
CHECK_CLAUSE `t` > 2
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
create table t2
( (
name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint
start_date DATE, start_date DATE,
end_date DATE, end_date DATE,
CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint
)ENGINE=Innodb; )ENGINE=Innodb;
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA test def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME name def foo t0 CONSTRAINT_2 `t` < 50
TABLE_NAME t2 def foo t1 CONSTRAINT_1 `tt` > 32
CHECK_CLAUSE char_length(`name`) > 2 def foo t1 CONSTRAINT_2 `tt` < 50
CONSTRAINT_CATALOG def def foo t1 t `t` > 2
CONSTRAINT_SCHEMA mysql def foo t2 CHK_dates `start_date` is null
CONSTRAINT_NAME Priv def foo t2 name char_length(`name`) > 2
TABLE_NAME global_priv
CHECK_CLAUSE json_valid(`Priv`)
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CHK_dates
TABLE_NAME t2
CHECK_CLAUSE `start_date` is null
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME t
TABLE_NAME t1
CHECK_CLAUSE `t` > 2
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
ALTER TABLE t1 ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt); ADD CONSTRAINT CHK_new_ CHECK(t>tt);
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG def CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
CONSTRAINT_SCHEMA test def foo t0 CONSTRAINT_1 `t` > 32
CONSTRAINT_NAME name def foo t0 CONSTRAINT_2 `t` < 50
TABLE_NAME t2 def foo t1 CHK_new_ `t` > `tt`
CHECK_CLAUSE char_length(`name`) > 2 def foo t1 CONSTRAINT_1 `tt` > 32
CONSTRAINT_CATALOG def def foo t1 CONSTRAINT_2 `tt` < 50
CONSTRAINT_SCHEMA mysql def foo t1 t `t` > 2
CONSTRAINT_NAME Priv def foo t2 CHK_dates `start_date` is null
TABLE_NAME global_priv def foo t2 name char_length(`name`) > 2
CHECK_CLAUSE json_valid(`Priv`) CREATE TABLE t3
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CHK_dates
TABLE_NAME t2
CHECK_CLAUSE `start_date` is null
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME t
TABLE_NAME t1
CHECK_CLAUSE `t` > 2
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CONSTRAINT_1
TABLE_NAME t0
CHECK_CLAUSE `t` > 32
CONSTRAINT_CATALOG def
CONSTRAINT_SCHEMA test
CONSTRAINT_NAME CHK_new_
TABLE_NAME t1
CHECK_CLAUSE `t` > `tt`
create table t3
( (
a int, a int,
b int check (b>0), # field constraint named 'b' b int check (b>0), # field constraint named 'b'
CONSTRAINT b check (b>10) # table constraint CONSTRAINT b check (b>10) # table constraint
) ENGINE=InnoDB; ) ENGINE=InnoDB;
select * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_NAME CHECK_CLAUSE CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
def test name t2 char_length(`name`) > 2 def foo t0 CONSTRAINT_1 `t` > 32
def mysql Priv global_priv json_valid(`Priv`) def foo t0 CONSTRAINT_2 `t` < 50
def test b t3 `b` > 0 def foo t1 CHK_new_ `t` > `tt`
def test b t3 `b` > 10 def foo t1 CONSTRAINT_1 `tt` > 32
def test CHK_dates t2 `start_date` is null def foo t1 CONSTRAINT_2 `tt` < 50
def test t t1 `t` > 2 def foo t1 t `t` > 2
def test CONSTRAINT_1 t0 `t` > 32 def foo t2 CHK_dates `start_date` is null
def test CHK_new_ t1 `t` > `tt` def foo t2 name char_length(`name`) > 2
drop table t0; def foo t3 b `b` > 0
drop table t1; def foo t3 b `b` > 10
drop table t2; disconnect con1;
drop table t3; CONNECT con2, localhost, boo2,, test;
SELECT * from information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
disconnect con2;
CONNECT con1, localhost, boo1,,foo;
DROP TABLE t0;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP DATABASE foo;
disconnect con1;
connection default;
DROP USER boo1;
DROP USER boo2;
#
# MDEV-18440: Information_schema.check_constraints possible data leak
#
CREATE USER foo;
CREATE DATABASE db;
USE db;
CREATE TABLE t1 (a int, b int, CONSTRAINT CHECK (b > 0));
INSERT INTO t1 VALUES (1, 2), (2, 3);
GRANT SELECT (a) ON t1 TO foo;
SHOW GRANTS FOR foo;
Grants for foo@%
GRANT USAGE ON *.* TO 'foo'@'%'
GRANT SELECT (a) ON `db`.`t1` TO 'foo'@'%'
SELECT * FROM information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
def db t1 CONSTRAINT_1 `b` > 0
def mysql global_priv Priv json_valid(`Priv`)
CONNECT con1,localhost, foo,, db;
SELECT a FROM t1;
a
1
2
SELECT * FROM information_schema.check_constraints;
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE
connection default;
DROP USER foo;
DROP DATABASE db;

View file

@ -26,9 +26,9 @@ def information_schema CHARACTER_SETS DESCRIPTION 3 '' NO varchar 60 180 NULL NU
def information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select NEVER NULL def information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) select NEVER NULL
def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 5 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 5 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) select NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 3 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 4 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema CHECK_CONSTRAINTS TABLE_NAME 4 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema CHECK_CONSTRAINTS TABLE_NAME 3 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL
def information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL def information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL
def information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL def information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL
def information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double select NEVER NULL def information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double select NEVER NULL
@ -570,8 +570,8 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3) NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64)
NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS bigint NULL NULL NULL NULL bigint(21)

View file

@ -26,9 +26,9 @@ def information_schema CHARACTER_SETS DESCRIPTION 3 '' NO varchar 60 180 NULL NU
def information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) NEVER NULL def information_schema CHARACTER_SETS MAXLEN 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(3) NEVER NULL
def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 5 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema CHECK_CONSTRAINTS CHECK_CLAUSE 5 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG 1 '' NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512) NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 3 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME 4 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA 2 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema CHECK_CONSTRAINTS TABLE_NAME 4 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema CHECK_CONSTRAINTS TABLE_NAME 3 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL
def information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL def information_schema CLIENT_STATISTICS ACCESS_DENIED 22 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL
def information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL def information_schema CLIENT_STATISTICS BINLOG_BYTES_WRITTEN 9 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL
def information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double NEVER NULL def information_schema CLIENT_STATISTICS BUSY_TIME 5 0 NO double NULL NULL 21 NULL NULL NULL NULL double NEVER NULL
@ -570,8 +570,8 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3) NULL information_schema CHARACTER_SETS MAXLEN bigint NULL NULL NULL NULL bigint(3)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CHECK_CONSTRAINTS CHECK_CLAUSE varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema CLIENT_STATISTICS CLIENT varchar 64 192 utf8 utf8_general_ci varchar(64)
NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS bigint NULL NULL NULL NULL bigint(21) NULL information_schema CLIENT_STATISTICS TOTAL_CONNECTIONS bigint NULL NULL NULL NULL bigint(21)

View file

@ -1,92 +0,0 @@
--source include/have_innodb.inc
--source include/not_embedded.inc
--echo #
--echo # MDEV-17323: Backport INFORMATION_SCHEMA.CHECK_CONSTRAINTS to 10.2
--echo #
CREATE user boo1;
GRANT select,create,alter,drop on foo.* to boo1;
SHOW GRANTS for boo1;
CREATE user boo2;
create database foo;
# Connect with user boo1
CONNECT(con1,localhost, boo1,, foo);
SET check_constraint_checks=1;
CREATE TABLE t0
(
t int, check (t>32) # table constraint
) ENGINE=myisam;
--sorted_result
SELECT * from information_schema.check_constraints;
ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100);
--sorted_result
SELECT * from information_schema.check_constraints;
ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t;
--sorted_result
SELECT * from information_schema.check_constraints;
ALTER TABLE t0
ADD CONSTRAINT CHECK(t<50);
--sorted_result
SELECT * from information_schema.check_constraints;
CREATE TABLE t1
( t int CHECK(t>2), # field constraint
tt int,
CONSTRAINT CHECK (tt > 32), CONSTRAINT CHECK (tt <50),# autogenerated names table constraints
CONSTRAINT CHK_tt CHECK(tt<100) # named table constraint
) ENGINE=InnoDB;
--sorted_result
SELECT * from information_schema.check_constraints;
ALTER TABLE t1
DROP CONSTRAINT CHK_tt;
--sorted_result
SELECT * from information_schema.check_constraints;
CREATE TABLE t2
(
name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint
start_date DATE,
end_date DATE,
CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint
)ENGINE=Innodb;
--sorted_result
SELECT * from information_schema.check_constraints;
ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt);
--sorted_result
SELECT * from information_schema.check_constraints;
# Create table with same field and table check constraint name
CREATE TABLE t3
(
a int,
b int check (b>0), # field constraint named 'b'
CONSTRAINT b check (b>10) # table constraint
) ENGINE=InnoDB;
--sorted_result
SELECT * from information_schema.check_constraints;
DISCONNECT con1;
CONNECT(con2, localhost, boo2,, test);
--sorted_result
SELECT * from information_schema.check_constraints;
DISCONNECT con2;
CONNECT(con1, localhost, boo1,,foo);
DROP TABLE t0;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP DATABASE foo;
DISCONNECT con1;
--CONNECTION default
DROP USER boo1;
DROP USER boo2;

View file

@ -1,69 +1,118 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/not_embedded.inc
--echo # --echo #
--echo # MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS --echo # MDEV-14474: Create INFORMATION_SCHEMA.CHECK_CONSTRAINTS
--echo # --echo #
set check_constraint_checks=1; CREATE user boo1;
GRANT select,create,alter,drop on foo.* to boo1;
SHOW GRANTS for boo1;
CREATE user boo2;
create database foo;
# Connect with user boo1
CONNECT(con1,localhost, boo1,, foo);
use test; SET check_constraint_checks=1;
create table t0 CREATE TABLE t0
( (
t int, check (t>32) # table constraint t int, check (t>32) # table constraint
) ENGINE=myisam; ) ENGINE=myisam;
--sorted_result
--vertical_results SELECT * from information_schema.check_constraints;
SELECT * from information_schema.check_constraints order by check_clause;
ALTER TABLE t0 ALTER TABLE t0
ADD CONSTRAINT CHK_t0_t CHECK(t<100); ADD CONSTRAINT CHK_t0_t CHECK(t<100);
--sorted_result
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
ALTER TABLE t0 ALTER TABLE t0
DROP CONSTRAINT CHK_t0_t; DROP CONSTRAINT CHK_t0_t;
--sorted_result
SELECT * from information_schema.check_constraints;
SELECT * from information_schema.check_constraints order by check_clause; ALTER TABLE t0
ADD CONSTRAINT CHECK(t<50);
--sorted_result
SELECT * from information_schema.check_constraints;
CREATE TABLE t1 CREATE TABLE t1
( t int CHECK(t>2), # field constraint ( t int CHECK(t>2), # field constraint
tt int, CONSTRAINT CHK_tt CHECK(tt<100) # table constraint tt int,
CONSTRAINT CHECK (tt > 32), CONSTRAINT CHECK (tt <50),# autogenerated names table constraints
CONSTRAINT CHK_tt CHECK(tt<100) # named table constraint
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--sorted_result
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
ALTER TABLE t1 ALTER TABLE t1
DROP CONSTRAINT CHK_tt; DROP CONSTRAINT CHK_tt;
--sorted_result
SELECT * from information_schema.check_constraints;
SELECT * from information_schema.check_constraints order by check_clause; CREATE TABLE t2
create table t2
( (
name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint name VARCHAR(30) CHECK(CHAR_LENGTH(name)>2), #field constraint
start_date DATE, start_date DATE,
end_date DATE, end_date DATE,
CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint CONSTRAINT CHK_dates CHECK(start_date IS NULL) #table constraint
)ENGINE=Innodb; )ENGINE=Innodb;
--sorted_result
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
ALTER TABLE t1 ALTER TABLE t1
ADD CONSTRAINT CHK_new_ CHECK(t>tt); ADD CONSTRAINT CHK_new_ CHECK(t>tt);
--sorted_result
SELECT * from information_schema.check_constraints order by check_clause; SELECT * from information_schema.check_constraints;
# Create table with same field and table check constraint name # Create table with same field and table check constraint name
create table t3 CREATE TABLE t3
( (
a int, a int,
b int check (b>0), # field constraint named 'b' b int check (b>0), # field constraint named 'b'
CONSTRAINT b check (b>10) # table constraint CONSTRAINT b check (b>10) # table constraint
) ENGINE=InnoDB; ) ENGINE=InnoDB;
--sorted_result
SELECT * from information_schema.check_constraints;
--horizontal_results DISCONNECT con1;
select * from information_schema.check_constraints order by check_clause; CONNECT(con2, localhost, boo2,, test);
--sorted_result
SELECT * from information_schema.check_constraints;
drop table t0; DISCONNECT con2;
drop table t1; CONNECT(con1, localhost, boo1,,foo);
drop table t2; DROP TABLE t0;
drop table t3; DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP DATABASE foo;
DISCONNECT con1;
--CONNECTION default
DROP USER boo1;
DROP USER boo2;
--echo #
--echo # MDEV-18440: Information_schema.check_constraints possible data leak
--echo #
CREATE USER foo;
CREATE DATABASE db;
USE db;
CREATE TABLE t1 (a int, b int, CONSTRAINT CHECK (b > 0));
INSERT INTO t1 VALUES (1, 2), (2, 3);
GRANT SELECT (a) ON t1 TO foo;
SHOW GRANTS FOR foo;
--sorted_result
SELECT * FROM information_schema.check_constraints;
CONNECT(con1,localhost, foo,, db);
SELECT a FROM t1;
--sorted_result
SELECT * FROM information_schema.check_constraints;
--CONNECTION default
DROP USER foo;
DROP DATABASE db;

View file

@ -43,6 +43,5 @@ galera_var_reject_queries : assertion in inline_mysql_socket_send
galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var_retry_autocommit galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var_retry_autocommit
galera_wan : MDEV-17259 Test failure on galera.galera_wan galera_wan : MDEV-17259 Test failure on galera.galera_wan
mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed. mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed.
galera_partition : MDEV-21189 test timeout
partition : MDEV-19958 Galera test failure on galera.partition partition : MDEV-19958 Galera test failure on galera.partition
query_cache: MDEV-15805 Test failure on galera.query_cache query_cache: MDEV-15805 Test failure on galera.query_cache

View file

@ -3,7 +3,6 @@ connection node_1;
CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,B INTEGER) ENGINE=InnoDB; CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,B INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1); INSERT INTO t1 VALUES (1,1);
connection node_2; connection node_2;
SET SESSION wsrep_sync_wait=15;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
1 1

View file

@ -1,9 +1,10 @@
connection node_2;
connection node_1;
connection node_1; connection node_1;
call mtr.add_suppression("WSREP: RSU failed due to pending transactions, schema: test, query ALTER.*"); call mtr.add_suppression("WSREP: RSU failed due to pending transactions, schema: test, query ALTER.*");
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure"); call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4; connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4;
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connection node_1; connection node_1;
CREATE TABLE t1( CREATE TABLE t1(
id bigint unsigned NOT NULL AUTO_INCREMENT, id bigint unsigned NOT NULL AUTO_INCREMENT,
@ -396,13 +397,14 @@ SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
350 350
connection node_2; connection node_2;
call p1(100);; call mtr.add_suppression("WSREP: Sending JOIN failed:");
connection node_1a; call p1(10);
call p1(100);;
connection node_3; connection node_3;
call p1(100);; call mtr.add_suppression("WSREP: Sending JOIN failed:");
call p1(10);
connection node_4; connection node_4;
call p1(100);; call mtr.add_suppression("WSREP: Sending JOIN failed:");
call p1(10);
connection node_1; connection node_1;
SET SESSION wsrep_OSU_method='RSU'; SET SESSION wsrep_OSU_method='RSU';
SELECT @@wsrep_OSU_method; SELECT @@wsrep_OSU_method;
@ -419,6 +421,6 @@ TOI
connection node_2; connection node_2;
connection node_3; connection node_3;
connection node_4; connection node_4;
connection node_1a; connection node_1;
DROP TABLE t1; DROP TABLE t1;
DROP PROCEDURE p1; DROP PROCEDURE p1;

View file

@ -3,13 +3,16 @@
# #
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_innodb.inc --source include/big_test.inc
--source include/force_restart.inc
CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,B INTEGER) ENGINE=InnoDB; CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,B INTEGER) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,1); INSERT INTO t1 VALUES (1,1);
--connection node_2 --connection node_2
SET SESSION wsrep_sync_wait=15; --let $wait_condition = SELECT COUNT(*)=1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options`
@ -53,5 +56,6 @@ SELECT COUNT(*) FROM t1;
--disable_query_log --disable_query_log
--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; --eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig';
--enable_query_log --enable_query_log
--source include/wait_until_connected_again.inc
DROP TABLE t1; DROP TABLE t1;

View file

@ -1,5 +1,6 @@
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_partition.inc --source include/have_partition.inc
--source include/big_test.inc
--connection node_1 --connection node_1
@ -8,7 +9,6 @@ call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 --connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1 --connection node_1
@ -407,16 +407,16 @@ insert into t1 (id, dt) values (350, '2010-12-17 00:00:00');
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
--connection node_2 --connection node_2
--send call p1(100); call mtr.add_suppression("WSREP: Sending JOIN failed:");
send call p1(10);
--connection node_1a
--send call p1(100);
--connection node_3 --connection node_3
--send call p1(100); call mtr.add_suppression("WSREP: Sending JOIN failed:");
send call p1(10);
--connection node_4 --connection node_4
--send call p1(100); call mtr.add_suppression("WSREP: Sending JOIN failed:");
send call p1(10);
--connection node_1 --connection node_1
SET SESSION wsrep_OSU_method='RSU'; SET SESSION wsrep_OSU_method='RSU';
@ -445,9 +445,7 @@ reap;
--error 0,ER_LOCK_DEADLOCK --error 0,ER_LOCK_DEADLOCK
reap; reap;
--connection node_1a --connection node_1
--error 0,ER_LOCK_DEADLOCK
reap;
DROP TABLE t1; DROP TABLE t1;
DROP PROCEDURE p1; DROP PROCEDURE p1;

View file

@ -10,7 +10,4 @@
# #
############################################################################## ##############################################################################
foreign_key : MENT-535 Galera test failures on wsrep suite
wsrep.pool_of_threads : Sporadic failure "WSREP has not yet prepared node for application use"
variables : MDEV-20581 Crash on wsrep.variables test case variables : MDEV-20581 Crash on wsrep.variables test case
pool_of_threads : MENT-535 Galera test failures on wsrep suite

View file

@ -2,7 +2,7 @@
!include include/default_mysqld.cnf !include include/default_mysqld.cnf
[mysqld.1] [mysqld.1]
wsrep-on=OFF wsrep-on=ON
#galera_port=@OPT.port #galera_port=@OPT.port
#ist_port=@OPT.port #ist_port=@OPT.port
#sst_port=@OPT.port #sst_port=@OPT.port

View file

@ -4,7 +4,7 @@
# Verbose run # Verbose run
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB;
@ -36,7 +36,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -46,7 +46,7 @@ END IF|
# Silent run # Silent run
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB;
@ -75,7 +75,7 @@ ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -93,7 +93,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
; ;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;
@ -105,21 +105,21 @@ END IF|
# #
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=InnoDB; ALTER TABLE time_zone_leap_second ENGINE=InnoDB;
END IF| END IF|
\d ; \d ;
TRUNCATE TABLE time_zone_leap_second; TRUNCATE TABLE time_zone_leap_second;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone_leap_second ENGINE=Aria; ALTER TABLE time_zone_leap_second ENGINE=Aria;
END IF| END IF|
\d ; \d ;
ALTER TABLE time_zone_leap_second ORDER BY Transition_time; ALTER TABLE time_zone_leap_second ORDER BY Transition_time;
\d | \d |
IF (select count(*) from information_schema.global_variables where IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on') = 1 THEN variable_name='wsrep_on' and variable_value='ON') = 1 THEN
ALTER TABLE time_zone ENGINE=Aria; ALTER TABLE time_zone ENGINE=Aria;
ALTER TABLE time_zone_name ENGINE=Aria; ALTER TABLE time_zone_name ENGINE=Aria;
ALTER TABLE time_zone_transition ENGINE=Aria; ALTER TABLE time_zone_transition ENGINE=Aria;

View file

@ -2,7 +2,7 @@
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
# #
# Verbose run # Verbose run
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1; prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle; set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
@ -29,7 +29,7 @@ Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid in
ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time;
ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
# Silent run # Silent run
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1; prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle; set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone;
@ -55,7 +55,7 @@ ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id;
# #
# Testing with explicit timezonefile # Testing with explicit timezonefile
# #
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1; prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle; set @toggle=0; execute set_wsrep_write_binlog using @toggle;
INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); INSERT INTO time_zone (Use_leap_seconds) VALUES ('N');
@ -67,7 +67,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset,
# #
# Testing --leap # Testing --leap
# #
set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');
prepare set_wsrep_write_binlog from @prep1; prepare set_wsrep_write_binlog from @prep1;
set @toggle=0; execute set_wsrep_write_binlog using @toggle; set @toggle=0; execute set_wsrep_write_binlog using @toggle;
TRUNCATE TABLE time_zone_leap_second; TRUNCATE TABLE time_zone_leap_second;

View file

@ -21,119 +21,123 @@ SET GLOBAL wsrep_provider=none;
CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*"); CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*");
SHOW GLOBAL STATUS LIKE 'wsrep%'; SHOW GLOBAL STATUS LIKE 'wsrep%';
Variable_name Value Variable_name Value
wsrep_applier_thread_count # wsrep_local_state_uuid #
wsrep_protocol_version #
wsrep_last_committed #
wsrep_replicated #
wsrep_replicated_bytes #
wsrep_repl_keys #
wsrep_repl_keys_bytes #
wsrep_repl_data_bytes #
wsrep_repl_other_bytes #
wsrep_received #
wsrep_received_bytes #
wsrep_local_commits #
wsrep_local_cert_failures #
wsrep_local_replays #
wsrep_local_send_queue #
wsrep_local_send_queue_max #
wsrep_local_send_queue_min #
wsrep_local_send_queue_avg #
wsrep_local_recv_queue #
wsrep_local_recv_queue_max #
wsrep_local_recv_queue_min #
wsrep_local_recv_queue_avg #
wsrep_local_cached_downto #
wsrep_flow_control_paused_ns #
wsrep_flow_control_paused #
wsrep_flow_control_sent #
wsrep_flow_control_recv #
wsrep_cert_deps_distance #
wsrep_apply_oooe # wsrep_apply_oooe #
wsrep_apply_oool # wsrep_apply_oool #
wsrep_apply_window # wsrep_apply_window #
wsrep_causal_reads # wsrep_commit_oooe #
wsrep_cert_deps_distance # wsrep_commit_oool #
wsrep_commit_window #
wsrep_local_state #
wsrep_local_state_comment #
wsrep_cert_index_size # wsrep_cert_index_size #
wsrep_causal_reads #
wsrep_cert_interval # wsrep_cert_interval #
wsrep_open_transactions #
wsrep_open_connections #
wsrep_incoming_addresses #
wsrep_applier_thread_count #
wsrep_cluster_capabilities #
wsrep_cluster_conf_id # wsrep_cluster_conf_id #
wsrep_cluster_size # wsrep_cluster_size #
wsrep_cluster_state_uuid # wsrep_cluster_state_uuid #
wsrep_cluster_status # wsrep_cluster_status #
wsrep_commit_oooe #
wsrep_commit_oool #
wsrep_commit_window #
wsrep_connected # wsrep_connected #
wsrep_flow_control_paused #
wsrep_flow_control_paused_ns #
wsrep_flow_control_recv #
wsrep_flow_control_sent #
wsrep_incoming_addresses #
wsrep_last_committed #
wsrep_local_bf_aborts # wsrep_local_bf_aborts #
wsrep_local_cached_downto #
wsrep_local_cert_failures #
wsrep_local_commits #
wsrep_local_index # wsrep_local_index #
wsrep_local_recv_queue # wsrep_provider_capabilities #
wsrep_local_recv_queue_avg #
wsrep_local_recv_queue_max #
wsrep_local_recv_queue_min #
wsrep_local_replays #
wsrep_local_send_queue #
wsrep_local_send_queue_avg #
wsrep_local_send_queue_max #
wsrep_local_send_queue_min #
wsrep_local_state #
wsrep_local_state_comment #
wsrep_local_state_uuid #
wsrep_open_connections #
wsrep_open_transactions #
wsrep_protocol_version #
wsrep_provider_name # wsrep_provider_name #
wsrep_provider_vendor # wsrep_provider_vendor #
wsrep_provider_version # wsrep_provider_version #
wsrep_ready # wsrep_ready #
wsrep_received #
wsrep_received_bytes #
wsrep_repl_data_bytes #
wsrep_repl_keys #
wsrep_repl_keys_bytes #
wsrep_repl_other_bytes #
wsrep_replicated #
wsrep_replicated_bytes #
wsrep_rollbacker_thread_count # wsrep_rollbacker_thread_count #
wsrep_thread_count # wsrep_thread_count #
SHOW GLOBAL STATUS LIKE 'wsrep_%'; SHOW GLOBAL STATUS LIKE 'wsrep_%';
Variable_name Value Variable_name Value
wsrep_applier_thread_count # wsrep_local_state_uuid #
wsrep_protocol_version #
wsrep_last_committed #
wsrep_replicated #
wsrep_replicated_bytes #
wsrep_repl_keys #
wsrep_repl_keys_bytes #
wsrep_repl_data_bytes #
wsrep_repl_other_bytes #
wsrep_received #
wsrep_received_bytes #
wsrep_local_commits #
wsrep_local_cert_failures #
wsrep_local_replays #
wsrep_local_send_queue #
wsrep_local_send_queue_max #
wsrep_local_send_queue_min #
wsrep_local_send_queue_avg #
wsrep_local_recv_queue #
wsrep_local_recv_queue_max #
wsrep_local_recv_queue_min #
wsrep_local_recv_queue_avg #
wsrep_local_cached_downto #
wsrep_flow_control_paused_ns #
wsrep_flow_control_paused #
wsrep_flow_control_sent #
wsrep_flow_control_recv #
wsrep_cert_deps_distance #
wsrep_apply_oooe # wsrep_apply_oooe #
wsrep_apply_oool # wsrep_apply_oool #
wsrep_apply_window # wsrep_apply_window #
wsrep_causal_reads # wsrep_commit_oooe #
wsrep_cert_deps_distance # wsrep_commit_oool #
wsrep_commit_window #
wsrep_local_state #
wsrep_local_state_comment #
wsrep_cert_index_size # wsrep_cert_index_size #
wsrep_causal_reads #
wsrep_cert_interval # wsrep_cert_interval #
wsrep_open_transactions #
wsrep_open_connections #
wsrep_incoming_addresses #
wsrep_applier_thread_count #
wsrep_cluster_capabilities #
wsrep_cluster_conf_id # wsrep_cluster_conf_id #
wsrep_cluster_size # wsrep_cluster_size #
wsrep_cluster_state_uuid # wsrep_cluster_state_uuid #
wsrep_cluster_status # wsrep_cluster_status #
wsrep_commit_oooe #
wsrep_commit_oool #
wsrep_commit_window #
wsrep_connected # wsrep_connected #
wsrep_flow_control_paused #
wsrep_flow_control_paused_ns #
wsrep_flow_control_recv #
wsrep_flow_control_sent #
wsrep_incoming_addresses #
wsrep_last_committed #
wsrep_local_bf_aborts # wsrep_local_bf_aborts #
wsrep_local_cached_downto #
wsrep_local_cert_failures #
wsrep_local_commits #
wsrep_local_index # wsrep_local_index #
wsrep_local_recv_queue # wsrep_provider_capabilities #
wsrep_local_recv_queue_avg #
wsrep_local_recv_queue_max #
wsrep_local_recv_queue_min #
wsrep_local_replays #
wsrep_local_send_queue #
wsrep_local_send_queue_avg #
wsrep_local_send_queue_max #
wsrep_local_send_queue_min #
wsrep_local_state #
wsrep_local_state_comment #
wsrep_local_state_uuid #
wsrep_open_connections #
wsrep_open_transactions #
wsrep_protocol_version #
wsrep_provider_name # wsrep_provider_name #
wsrep_provider_vendor # wsrep_provider_vendor #
wsrep_provider_version # wsrep_provider_version #
wsrep_ready # wsrep_ready #
wsrep_received #
wsrep_received_bytes #
wsrep_repl_data_bytes #
wsrep_repl_keys #
wsrep_repl_keys_bytes #
wsrep_repl_other_bytes #
wsrep_replicated #
wsrep_replicated_bytes #
wsrep_rollbacker_thread_count # wsrep_rollbacker_thread_count #
wsrep_thread_count # wsrep_thread_count #
SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment'; SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';
@ -159,7 +163,7 @@ SET GLOBAL wsrep_provider=none;
call mtr.add_suppression("WSREP: Failed to get provider options"); call mtr.add_suppression("WSREP: Failed to get provider options");
SELECT @@global.wsrep_provider; SELECT @@global.wsrep_provider;
@@global.wsrep_provider @@global.wsrep_provider
libgalera_smm.so /usr/lib/libgalera_4_smm.so
SELECT @@global.wsrep_slave_threads; SELECT @@global.wsrep_slave_threads;
@@global.wsrep_slave_threads @@global.wsrep_slave_threads
1 1
@ -175,7 +179,7 @@ wsrep_thread_count 0
SELECT @@global.wsrep_provider; SELECT @@global.wsrep_provider;
@@global.wsrep_provider @@global.wsrep_provider
libgalera_smm.so /usr/lib/libgalera_4_smm.so
SELECT @@global.wsrep_cluster_address; SELECT @@global.wsrep_cluster_address;
@@global.wsrep_cluster_address @@global.wsrep_cluster_address
@ -202,7 +206,7 @@ EXPECT_2
2 2
SELECT @@global.wsrep_provider; SELECT @@global.wsrep_provider;
@@global.wsrep_provider @@global.wsrep_provider
libgalera_smm.so /usr/lib/libgalera_4_smm.so
SELECT @@global.wsrep_cluster_address; SELECT @@global.wsrep_cluster_address;
@@global.wsrep_cluster_address @@global.wsrep_cluster_address
gcomm:// gcomm://
@ -256,7 +260,6 @@ SELECT @@global.wsrep_sst_auth;
NULL NULL
SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved; SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
SET GLOBAL wsrep_slave_threads= @wsrep_slave_threads_saved; SET GLOBAL wsrep_slave_threads= @wsrep_slave_threads_saved;
SET GLOBAL wsrep_provider= none;
SET GLOBAL wsrep_cluster_address= @wsrep_cluster_address_saved; SET GLOBAL wsrep_cluster_address= @wsrep_cluster_address_saved;
SET GLOBAL wsrep_provider_options= @wsrep_provider_options_saved; SET GLOBAL wsrep_provider_options= @wsrep_provider_options_saved;
# End of test. # End of test.

View file

@ -0,0 +1,12 @@
!include include/default_mysqld.cnf
[mysqld]
wsrep-on=0
[mysqld.1]
wsrep-on=0
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M'
wsrep_cluster_address='not empty but invalid'

View file

@ -1 +0,0 @@
--wsrep-on=0

View file

@ -1,6 +1,15 @@
!include ../my.cnf !include include/default_mysqld.cnf
[mysqld]
wsrep-on=0
[mysqld.1] [mysqld.1]
wsrep-on=OFF wsrep-on=0
wsrep-provider=@ENV.WSREP_PROVIDER #galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M'
wsrep_cluster_address='not empty but invalid'
innodb_autoinc_lock_mode=2
wsrep-provider=$WSREP_PROVIDER
wsrep-cluster-address=gcomm:// wsrep-cluster-address=gcomm://

View file

@ -0,0 +1 @@
--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep_on=1 --binlog_format=ROW

View file

@ -1,6 +1,7 @@
--source include/have_wsrep.inc --source include/have_wsrep.inc
--source include/have_symlink.inc --source include/have_symlink.inc
--source include/not_windows.inc --source include/not_windows.inc
--source include/have_innodb.inc
--echo # --echo #
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above --echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above

View file

@ -0,0 +1 @@
--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep_on=1 --binlog_format=ROW

View file

@ -1,6 +1,7 @@
--source include/have_wsrep.inc --source include/have_wsrep.inc
--source include/have_symlink.inc --source include/have_symlink.inc
--source include/not_windows.inc --source include/not_windows.inc
--source include/have_innodb.inc
--echo # --echo #
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above --echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above

View file

@ -0,0 +1 @@
--binlog_format=ROW --log-bin --wsrep-on=1 --innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm://

View file

@ -1,4 +1,5 @@
--source include/have_wsrep.inc --source include/have_wsrep.inc
--source include/have_innodb.inc
# #
# MDEV-7604: wsrep plugin lists its status as Unknown # MDEV-7604: wsrep plugin lists its status as Unknown

View file

@ -1,8 +0,0 @@
!include ../my.cnf
[mysqld.1]
wsrep-on=ON
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep-cluster-address=gcomm://
thread_handling=pool-of-threads

View file

@ -1 +1 @@
--innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --thread_handling=pool-of-threads wsrep-on=1 --innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --thread_handling=pool-of-threads --wsrep-on=1

View file

@ -0,0 +1 @@
--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep_on=1 --binlog_format=ROW

View file

@ -0,0 +1 @@
--wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm:// --wsrep_on=1 --binlog_format=ROW

View file

@ -1,5 +1,6 @@
--source include/have_wsrep.inc --source include/have_wsrep.inc
--source include/force_restart.inc --source include/force_restart.inc
--source include/have_innodb.inc
SET @wsrep_provider_options_saved= @@global.wsrep_provider_options; SET @wsrep_provider_options_saved= @@global.wsrep_provider_options;
SET @wsrep_cluster_address_saved= @@global.wsrep_cluster_address; SET @wsrep_cluster_address_saved= @@global.wsrep_cluster_address;
@ -30,8 +31,6 @@ CALL mtr.add_suppression("WSREP: Could not open saved state file for reading.*")
--disable_query_log --disable_query_log
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER'; eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--let $galera_version=25.3.24
source include/check_galera_version.inc;
--enable_query_log --enable_query_log
--replace_column 2 # --replace_column 2 #
@ -158,9 +157,11 @@ SET @@global.wsrep_sst_auth= @wsrep_sst_auth_saved;
# Reset (for mtr internal checks) # Reset (for mtr internal checks)
SET GLOBAL wsrep_slave_threads= @wsrep_slave_threads_saved; SET GLOBAL wsrep_slave_threads= @wsrep_slave_threads_saved;
SET GLOBAL wsrep_provider= none;
SET GLOBAL wsrep_cluster_address= @wsrep_cluster_address_saved; SET GLOBAL wsrep_cluster_address= @wsrep_cluster_address_saved;
SET GLOBAL wsrep_provider_options= @wsrep_provider_options_saved; SET GLOBAL wsrep_provider_options= @wsrep_provider_options_saved;
--disable_query_log
eval SET GLOBAL wsrep_provider= '$WSREP_PROVIDER';
--enable_query_log
--echo # End of test. --echo # End of test.

View file

@ -449,15 +449,18 @@ IF(WIN32 AND TARGET mysqld AND NOT CMAKE_CROSSCOMPILING)
ENDIF() ENDIF()
MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep OUTPUT initdb.dep
COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} COMMAND ${CMAKE_COMMAND} -E remove_directory data
COMMAND ${CMAKE_COMMAND} -E make_directory data
COMMAND ${CMAKE_COMMAND} -E chdir data ${CMAKE_COMMAND}
${CONFIG_PARAM}
-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}" -DTOP_SRCDIR="${CMAKE_SOURCE_DIR}"
-DBINDIR="${CMAKE_CURRENT_BINARY_DIR}" -DBINDIR="${CMAKE_CURRENT_BINARY_DIR}"
-DMYSQLD_EXECUTABLE="$<TARGET_FILE:mysqld>" -DMYSQLD_EXECUTABLE="$<TARGET_FILE:mysqld>"
-DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}" -DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}"
-P ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake -P ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/
DEPENDS mysqld DEPENDS mysqld
) )
ADD_CUSTOM_TARGET(initial_database ADD_CUSTOM_TARGET(initial_database

View file

@ -3229,12 +3229,13 @@ bool Item_field::get_date(THD *thd, MYSQL_TIME *ltime,date_mode_t fuzzydate)
bool Item_field::get_date_result(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool Item_field::get_date_result(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ {
if (result_field->is_null() || result_field->get_date(ltime,fuzzydate)) if ((null_value= result_field->is_null()) ||
result_field->get_date(ltime, fuzzydate))
{ {
bzero((char*) ltime,sizeof(*ltime)); bzero((char*) ltime,sizeof(*ltime));
return (null_value= 1); return true;
} }
return (null_value= 0); return false;
} }
@ -8238,7 +8239,7 @@ bool Item_ref::val_native(THD *thd, Native *to)
longlong Item_ref::val_datetime_packed(THD *thd) longlong Item_ref::val_datetime_packed(THD *thd)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed);
longlong tmp= (*ref)->val_datetime_packed(thd); longlong tmp= (*ref)->val_datetime_packed_result(thd);
null_value= (*ref)->null_value; null_value= (*ref)->null_value;
return tmp; return tmp;
} }
@ -8247,7 +8248,7 @@ longlong Item_ref::val_datetime_packed(THD *thd)
longlong Item_ref::val_time_packed(THD *thd) longlong Item_ref::val_time_packed(THD *thd)
{ {
DBUG_ASSERT(fixed); DBUG_ASSERT(fixed);
longlong tmp= (*ref)->val_time_packed(thd); longlong tmp= (*ref)->val_time_packed_result(thd);
null_value= (*ref)->null_value; null_value= (*ref)->null_value;
return tmp; return tmp;
} }

View file

@ -1093,19 +1093,6 @@ void Aggregator_distinct::endup()
} }
String *
Item_sum_num::val_str(String *str)
{
return val_string_from_real(str);
}
my_decimal *Item_sum_num::val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_real(decimal_value);
}
String * String *
Item_sum_int::val_str(String *str) Item_sum_int::val_str(String *str)
{ {
@ -2185,7 +2172,7 @@ double Stddev::result(bool is_sample_variance)
Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item): Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item):
Item_sum_num(thd, item), Item_sum_double(thd, item),
m_stddev(item->m_stddev), sample(item->sample), m_stddev(item->m_stddev), sample(item->sample),
prec_increment(item->prec_increment) prec_increment(item->prec_increment)
{ } { }
@ -2309,13 +2296,6 @@ double Item_sum_variance::val_real()
} }
my_decimal *Item_sum_variance::val_decimal(my_decimal *dec_buf)
{
DBUG_ASSERT(fixed == 1);
return val_decimal_from_real(dec_buf);
}
void Item_sum_variance::reset_field() void Item_sum_variance::reset_field()
{ {
double nr; double nr;

View file

@ -588,6 +588,7 @@ public:
virtual void setup_caches(THD *thd) {}; virtual void setup_caches(THD *thd) {};
bool with_sum_func() const { return true; } bool with_sum_func() const { return true; }
virtual void set_partition_row_count(ulonglong count) { DBUG_ASSERT(0); }
}; };
@ -734,13 +735,33 @@ public:
Item_sum_num(THD *thd, Item_sum_num *item): Item_sum_num(THD *thd, Item_sum_num *item):
Item_sum(thd, item) {} Item_sum(thd, item) {}
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
longlong val_int() { return val_int_from_real(); /* Real as default */ } };
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
class Item_sum_double :public Item_sum_num
{
public:
Item_sum_double(THD *thd): Item_sum_num(thd) {}
Item_sum_double(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {}
Item_sum_double(THD *thd, List<Item> &list): Item_sum_num(thd, list) {}
Item_sum_double(THD *thd, Item_sum_double *item) :Item_sum_num(thd, item) {}
longlong val_int()
{
return val_int_from_real();
}
String *val_str(String*str)
{
return val_string_from_real(str);
}
my_decimal *val_decimal(my_decimal *to)
{
return val_decimal_from_real(to);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{ {
return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); return get_date_from_real(thd, ltime, fuzzydate);
} }
const Type_handler *type_handler() const { return &type_handler_double; }
}; };
@ -754,6 +775,10 @@ public:
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
String *val_str(String*str); String *val_str(String*str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
return get_date_from_int(thd, ltime, fuzzydate);
}
bool fix_length_and_dec() bool fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; return FALSE; } { decimals=0; max_length=21; maybe_null=null_value=0; return FALSE; }
}; };
@ -794,6 +819,10 @@ public:
longlong val_int(); longlong val_int();
String *val_str(String*str); String *val_str(String*str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
}
const Type_handler *type_handler() const const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); } { return Type_handler_hybrid_field_type::type_handler(); }
void fix_length_and_dec_double(); void fix_length_and_dec_double();
@ -986,7 +1015,7 @@ public:
class Item_sum_variance : public Item_sum_num class Item_sum_variance : public Item_sum_double
{ {
Stddev m_stddev; Stddev m_stddev;
bool fix_length_and_dec(); bool fix_length_and_dec();
@ -996,7 +1025,7 @@ public:
uint prec_increment; uint prec_increment;
Item_sum_variance(THD *thd, Item *item_par, uint sample_arg): Item_sum_variance(THD *thd, Item *item_par, uint sample_arg):
Item_sum_num(thd, item_par), Item_sum_double(thd, item_par),
sample(sample_arg) sample(sample_arg)
{} {}
Item_sum_variance(THD *thd, Item_sum_variance *item); Item_sum_variance(THD *thd, Item_sum_variance *item);
@ -1006,7 +1035,6 @@ public:
void clear(); void clear();
bool add(); bool add();
double val_real(); double val_real();
my_decimal *val_decimal(my_decimal *);
void reset_field(); void reset_field();
void update_field(); void update_field();
Item *result_item(THD *thd, Field *field); Item *result_item(THD *thd, Field *field);
@ -1015,11 +1043,10 @@ public:
{ return sample ? "var_samp(" : "variance("; } { return sample ? "var_samp(" : "variance("; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table);
const Type_handler *type_handler() const { return &type_handler_double; }
void cleanup() void cleanup()
{ {
m_stddev= Stddev(); m_stddev= Stddev();
Item_sum_num::cleanup(); Item_sum_double::cleanup();
} }
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_variance>(thd, this); } { return get_item_copy<Item_sum_variance>(thd, this); }
@ -1732,15 +1759,15 @@ public:
#else /* Dummy functions to get sql_yacc.cc compiled */ #else /* Dummy functions to get sql_yacc.cc compiled */
class Item_sum_udf_float :public Item_sum_num class Item_sum_udf_float :public Item_sum_double
{ {
public: public:
Item_sum_udf_float(THD *thd, udf_func *udf_arg): Item_sum_udf_float(THD *thd, udf_func *udf_arg):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list): Item_sum_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) Item_sum_udf_float(THD *thd, Item_sum_udf_float *item)
:Item_sum_num(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
void clear() {} void clear() {}
@ -1750,15 +1777,15 @@ class Item_sum_udf_float :public Item_sum_num
}; };
class Item_sum_udf_int :public Item_sum_num class Item_sum_udf_int :public Item_sum_double
{ {
public: public:
Item_sum_udf_int(THD *thd, udf_func *udf_arg): Item_sum_udf_int(THD *thd, udf_func *udf_arg):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list): Item_sum_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) Item_sum_udf_int(THD *thd, Item_sum_udf_int *item)
:Item_sum_num(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; } longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0; }
@ -1769,15 +1796,15 @@ public:
}; };
class Item_sum_udf_decimal :public Item_sum_num class Item_sum_udf_decimal :public Item_sum_double
{ {
public: public:
Item_sum_udf_decimal(THD *thd, udf_func *udf_arg): Item_sum_udf_decimal(THD *thd, udf_func *udf_arg):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): Item_sum_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item) Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item)
:Item_sum_num(thd, item) {} :Item_sum_double(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; } my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; }
@ -1788,15 +1815,15 @@ class Item_sum_udf_decimal :public Item_sum_num
}; };
class Item_sum_udf_str :public Item_sum_num class Item_sum_udf_str :public Item_sum_double
{ {
public: public:
Item_sum_udf_str(THD *thd, udf_func *udf_arg): Item_sum_udf_str(THD *thd, udf_func *udf_arg):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): Item_sum_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list):
Item_sum_num(thd) {} Item_sum_double(thd) {}
Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) Item_sum_udf_str(THD *thd, Item_sum_udf_str *item)
:Item_sum_num(thd, item) {} :Item_sum_double(thd, item) {}
String *val_str(String *) String *val_str(String *)
{ DBUG_ASSERT(fixed == 1); null_value=1; return 0; } { DBUG_ASSERT(fixed == 1); null_value=1; return 0; }
double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; } double val_real() { DBUG_ASSERT(fixed == 1); null_value=1; return 0.0; }

View file

@ -1101,9 +1101,10 @@ longlong Item_func_weekday::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
THD *thd= current_thd; THD *thd= current_thd;
Datetime d(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd)); Datetime dt(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
return ((null_value= !d.is_valid_datetime())) ? 0 : if ((null_value= !dt.is_valid_datetime()))
calc_weekday(d.daynr(), odbc_type) + MY_TEST(odbc_type); return 0;
return dt.weekday(odbc_type) + MY_TEST(odbc_type);
} }
bool Item_func_dayname::fix_length_and_dec() bool Item_func_dayname::fix_length_and_dec()
@ -1122,14 +1123,15 @@ bool Item_func_dayname::fix_length_and_dec()
String* Item_func_dayname::val_str(String* str) String* Item_func_dayname::val_str(String* str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
uint weekday=(uint) val_int(); // Always Item_func_weekday()
const char *day_name; const char *day_name;
uint err; uint err;
THD *thd= current_thd;
Datetime dt(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
if (null_value) if ((null_value= !dt.is_valid_datetime()))
return (String*) 0; return (String*) 0;
day_name= locale->day_names->type_names[weekday]; day_name= locale->day_names->type_names[dt.weekday(false)];
str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8mb3_bin, str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8mb3_bin,
collation.collation, &err); collation.collation, &err);
return str; return str;

View file

@ -166,32 +166,13 @@ public:
}; };
class Item_func_month :public Item_func class Item_func_month :public Item_long_func
{ {
public: public:
Item_func_month(THD *thd, Item *a): Item_func(thd, a) Item_func_month(THD *thd, Item *a): Item_long_func(thd, a)
{ collation= DTCollation_numeric(); } { }
longlong val_int(); longlong val_int();
double val_real()
{ DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
longlong nr= val_int();
if (null_value)
return 0;
str->set(nr, collation.collation);
return str;
}
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
return get_date_from_int(thd, ltime, fuzzydate);
}
const char *func_name() const { return "month"; } const char *func_name() const { return "month"; }
const Type_handler *type_handler() const { return &type_handler_slong; }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
@ -441,24 +422,13 @@ public:
}; };
class Item_func_weekday :public Item_func class Item_func_weekday :public Item_long_func
{ {
bool odbc_type; bool odbc_type;
public: public:
Item_func_weekday(THD *thd, Item *a, bool type_arg): Item_func_weekday(THD *thd, Item *a, bool type_arg):
Item_func(thd, a), odbc_type(type_arg) { collation= DTCollation_numeric(); } Item_long_func(thd, a), odbc_type(type_arg) { }
longlong val_int(); longlong val_int();
double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
String *val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
str->set(val_int(), &my_charset_bin);
return null_value ? 0 : str;
}
my_decimal *val_decimal(my_decimal *decimal_value)
{
return val_decimal_from_int(decimal_value);
}
const char *func_name() const const char *func_name() const
{ {
return (odbc_type ? "dayofweek" : "weekday"); return (odbc_type ? "dayofweek" : "weekday");
@ -467,7 +437,6 @@ public:
{ {
return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate); return type_handler()->Item_get_date_with_warn(thd, this, ltime, fuzzydate);
} }
const Type_handler *type_handler() const { return &type_handler_slong; }
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
decimals= 0; decimals= 0;
@ -485,11 +454,11 @@ public:
{ return get_item_copy<Item_func_weekday>(thd, this); } { return get_item_copy<Item_func_weekday>(thd, this); }
}; };
class Item_func_dayname :public Item_func_weekday class Item_func_dayname :public Item_str_func
{ {
MY_LOCALE *locale; MY_LOCALE *locale;
public: public:
Item_func_dayname(THD *thd, Item *a): Item_func_weekday(thd, a, 0) {} Item_func_dayname(THD *thd, Item *a): Item_str_func(thd, a) {}
const char *func_name() const { return "dayname"; } const char *func_name() const { return "dayname"; }
String *val_str(String *str); String *val_str(String *str);
const Type_handler *type_handler() const { return &type_handler_varchar; } const Type_handler *type_handler() const { return &type_handler_varchar; }
@ -499,6 +468,12 @@ class Item_func_dayname :public Item_func_weekday
{ {
return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC); return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
} }
bool check_valid_arguments_processor(void *int_arg)
{
return !has_date_args();
}
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_dayname>(thd, this); }
}; };

View file

@ -1,5 +1,5 @@
/* /*
Copyright (c) 2016,2017 MariaDB Copyright (c) 2016,2019 MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -445,28 +445,38 @@ class Item_sum_lag : public Item_sum_hybrid_simple
{ return get_item_copy<Item_sum_lag>(thd, this); } { return get_item_copy<Item_sum_lag>(thd, this); }
}; };
/*
A base window function (aggregate) that also holds a counter for the number class Partition_row_count
of rows.
*/
class Item_sum_window_with_row_count : public Item_sum_num
{ {
public: public:
Item_sum_window_with_row_count(THD *thd) : Item_sum_num(thd), Partition_row_count() :partition_row_count_(0) { }
partition_row_count_(0) {} void set_partition_row_count(ulonglong count)
{
Item_sum_window_with_row_count(THD *thd, Item *arg) : partition_row_count_ = count;
Item_sum_num(thd, arg), partition_row_count_(0) {}; }
double calc_val_real(bool *null_value,
void set_row_count(ulonglong count) { partition_row_count_ = count; } ulonglong current_row_count)
{
void reset_field() { DBUG_ASSERT(0); } if ((*null_value= (partition_row_count_ == 0)))
return 0;
return static_cast<double>(current_row_count) / partition_row_count_;
}
protected: protected:
longlong get_row_count() { return partition_row_count_; } longlong get_row_count() { return partition_row_count_; }
private:
ulonglong partition_row_count_; ulonglong partition_row_count_;
}; };
class Current_row_count
{
public:
Current_row_count() :current_row_count_(0) { }
protected:
ulonglong get_row_number() { return current_row_count_ ; }
ulonglong current_row_count_;
};
/* /*
@detail @detail
"The relative rank of a row R is defined as (RK-1)/(NR-1), where RK is "The relative rank of a row R is defined as (RK-1)/(NR-1), where RK is
@ -478,11 +488,12 @@ class Item_sum_window_with_row_count : public Item_sum_num
This is held within the row_count context. This is held within the row_count context.
- Second pass to compute rank of current row and the value of the function - Second pass to compute rank of current row and the value of the function
*/ */
class Item_sum_percent_rank: public Item_sum_window_with_row_count class Item_sum_percent_rank: public Item_sum_double,
public Partition_row_count
{ {
public: public:
Item_sum_percent_rank(THD *thd) Item_sum_percent_rank(THD *thd)
: Item_sum_window_with_row_count(thd), cur_rank(1), peer_tracker(NULL) {} : Item_sum_double(thd), cur_rank(1), peer_tracker(NULL) {}
longlong val_int() longlong val_int()
{ {
@ -535,6 +546,14 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
} }
void setup_window_func(THD *thd, Window_spec *window_spec); void setup_window_func(THD *thd, Window_spec *window_spec);
void reset_field() { DBUG_ASSERT(0); }
void set_partition_row_count(ulonglong count)
{
Partition_row_count::set_partition_row_count(count);
}
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_percent_rank>(thd, this); } { return get_item_copy<Item_sum_percent_rank>(thd, this); }
@ -569,25 +588,17 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
two passes. two passes.
*/ */
class Item_sum_cume_dist: public Item_sum_window_with_row_count class Item_sum_cume_dist: public Item_sum_double,
public Partition_row_count,
public Current_row_count
{ {
public: public:
Item_sum_cume_dist(THD *thd) : Item_sum_window_with_row_count(thd), Item_sum_cume_dist(THD *thd) :Item_sum_double(thd) { }
current_row_count_(0) {} Item_sum_cume_dist(THD *thd, Item *arg) :Item_sum_double(thd, arg) { }
Item_sum_cume_dist(THD *thd, Item *arg) : Item_sum_window_with_row_count(thd,arg),
current_row_count_(0) {}
double val_real() double val_real()
{ {
if (get_row_count() == 0) return calc_val_real(&null_value, current_row_count_);
{
null_value= true;
return 0;
}
ulonglong partition_row_count= get_row_count();
null_value= false;
return static_cast<double>(current_row_count_) / partition_row_count;
} }
bool add() bool add()
@ -604,7 +615,7 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
void clear() void clear()
{ {
current_row_count_= 0; current_row_count_= 0;
set_row_count(0); partition_row_count_= 0;
} }
const char*func_name() const const char*func_name() const
@ -622,29 +633,26 @@ class Item_sum_cume_dist: public Item_sum_window_with_row_count
return FALSE; return FALSE;
} }
void reset_field() { DBUG_ASSERT(0); }
void set_partition_row_count(ulonglong count)
{
Partition_row_count::set_partition_row_count(count);
}
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_cume_dist>(thd, this); } { return get_item_copy<Item_sum_cume_dist>(thd, this); }
ulonglong get_row_number()
{
return current_row_count_ ;
}
private:
ulonglong current_row_count_;
}; };
class Item_sum_ntile : public Item_sum_window_with_row_count class Item_sum_ntile : public Item_sum_int,
public Partition_row_count,
public Current_row_count
{ {
public: public:
Item_sum_ntile(THD* thd, Item* num_quantiles_expr) : Item_sum_ntile(THD* thd, Item* num_quantiles_expr) :
Item_sum_window_with_row_count(thd, num_quantiles_expr), Item_sum_int(thd, num_quantiles_expr)
current_row_count_(0) {}; { }
double val_real()
{
return (double) val_int();
}
longlong val_int() longlong val_int()
{ {
@ -685,7 +693,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
void clear() void clear()
{ {
current_row_count_= 0; current_row_count_= 0;
set_row_count(0); partition_row_count_= 0;
} }
const char*func_name() const const char*func_name() const
@ -697,19 +705,27 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
const Type_handler *type_handler() const { return &type_handler_slonglong; } const Type_handler *type_handler() const { return &type_handler_slonglong; }
void reset_field() { DBUG_ASSERT(0); }
void set_partition_row_count(ulonglong count)
{
Partition_row_count::set_partition_row_count(count);
}
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_ntile>(thd, this); } { return get_item_copy<Item_sum_ntile>(thd, this); }
private: private:
longlong get_num_quantiles() { return args[0]->val_int(); } longlong get_num_quantiles() { return args[0]->val_int(); }
ulong current_row_count_;
}; };
class Item_sum_percentile_disc : public Item_sum_cume_dist, class Item_sum_percentile_disc : public Item_sum_num,
public Type_handler_hybrid_field_type public Type_handler_hybrid_field_type,
public Partition_row_count,
public Current_row_count
{ {
public: public:
Item_sum_percentile_disc(THD *thd, Item* arg) : Item_sum_cume_dist(thd, arg), Item_sum_percentile_disc(THD *thd, Item* arg) : Item_sum_num(thd, arg),
Type_handler_hybrid_field_type(&type_handler_slonglong), Type_handler_hybrid_field_type(&type_handler_slonglong),
value(NULL), val_calculated(FALSE), first_call(TRUE), value(NULL), val_calculated(FALSE), first_call(TRUE),
prev_value(0), order_item(NULL){} prev_value(0), order_item(NULL){}
@ -758,6 +774,17 @@ public:
return value->val_str(str); return value->val_str(str);
} }
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
if (get_row_count() == 0 || get_arg(0)->is_null())
{
null_value= true;
return 0;
}
null_value= false;
return value->get_date(thd, ltime, fuzzydate);
}
bool add() bool add()
{ {
Item *arg= get_arg(0); Item *arg= get_arg(0);
@ -791,8 +818,8 @@ public:
if (value->null_value) if (value->null_value)
return false; return false;
Item_sum_cume_dist::add(); current_row_count_++;
double val= Item_sum_cume_dist::val_real(); double val= calc_val_real(&null_value, current_row_count_);
if (val >= prev_value && !val_calculated) if (val >= prev_value && !val_calculated)
val_calculated= true; val_calculated= true;
@ -809,7 +836,8 @@ public:
val_calculated= false; val_calculated= false;
first_call= true; first_call= true;
value->clear(); value->clear();
Item_sum_cume_dist::clear(); partition_row_count_= 0;
current_row_count_= 0;
} }
const char*func_name() const const char*func_name() const
@ -818,7 +846,6 @@ public:
} }
void update_field() {} void update_field() {}
void set_type_handler(Window_spec *window_spec);
const Type_handler *type_handler() const const Type_handler *type_handler() const
{return Type_handler_hybrid_field_type::type_handler();} {return Type_handler_hybrid_field_type::type_handler();}
@ -829,6 +856,13 @@ public:
return FALSE; return FALSE;
} }
void reset_field() { DBUG_ASSERT(0); }
void set_partition_row_count(ulonglong count)
{
Partition_row_count::set_partition_row_count(count);
}
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_percentile_disc>(thd, this); } { return get_item_copy<Item_sum_percentile_disc>(thd, this); }
void setup_window_func(THD *thd, Window_spec *window_spec); void setup_window_func(THD *thd, Window_spec *window_spec);
@ -843,12 +877,12 @@ private:
Item *order_item; Item *order_item;
}; };
class Item_sum_percentile_cont : public Item_sum_cume_dist, class Item_sum_percentile_cont : public Item_sum_double,
public Type_handler_hybrid_field_type public Partition_row_count,
public Current_row_count
{ {
public: public:
Item_sum_percentile_cont(THD *thd, Item* arg) : Item_sum_cume_dist(thd, arg), Item_sum_percentile_cont(THD *thd, Item* arg) : Item_sum_double(thd, arg),
Type_handler_hybrid_field_type(&type_handler_double),
floor_value(NULL), ceil_value(NULL), first_call(TRUE),prev_value(0), floor_value(NULL), ceil_value(NULL), first_call(TRUE),prev_value(0),
ceil_val_calculated(FALSE), floor_val_calculated(FALSE), order_item(NULL){} ceil_val_calculated(FALSE), floor_val_calculated(FALSE), order_item(NULL){}
@ -918,7 +952,7 @@ public:
return false; return false;
} }
Item_sum_cume_dist::add(); current_row_count_++;
double val= 1 + prev_value * (get_row_count()-1); double val= 1 + prev_value * (get_row_count()-1);
if (!floor_val_calculated && get_row_number() == floor(val)) if (!floor_val_calculated && get_row_number() == floor(val))
@ -941,7 +975,8 @@ public:
ceil_value->clear(); ceil_value->clear();
floor_val_calculated= false; floor_val_calculated= false;
ceil_val_calculated= false; ceil_val_calculated= false;
Item_sum_cume_dist::clear(); partition_row_count_= 0;
current_row_count_= 0;
} }
const char*func_name() const const char*func_name() const
@ -949,9 +984,6 @@ public:
return "percentile_cont"; return "percentile_cont";
} }
void update_field() {} void update_field() {}
void set_type_handler(Window_spec *window_spec);
const Type_handler *type_handler() const
{return Type_handler_hybrid_field_type::type_handler();}
bool fix_length_and_dec() bool fix_length_and_dec()
{ {
@ -960,6 +992,13 @@ public:
return FALSE; return FALSE;
} }
void reset_field() { DBUG_ASSERT(0); }
void set_partition_row_count(ulonglong count)
{
Partition_row_count::set_partition_row_count(count);
}
Item *get_copy(THD *thd) Item *get_copy(THD *thd)
{ return get_item_copy<Item_sum_percentile_cont>(thd, this); } { return get_item_copy<Item_sum_percentile_cont>(thd, this); }
void setup_window_func(THD *thd, Window_spec *window_spec); void setup_window_func(THD *thd, Window_spec *window_spec);

View file

@ -284,7 +284,9 @@ void mysql_audit_notify_connection_change_user(THD *thd)
} }
static inline static inline
void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock) void mysql_audit_external_lock_ex(THD *thd, my_thread_id thread_id,
const char *user, const char *host, const char *ip, query_id_t query_id,
TABLE_SHARE *share, int lock)
{ {
if (lock != F_UNLCK && mysql_audit_table_enabled()) if (lock != F_UNLCK && mysql_audit_table_enabled())
{ {
@ -293,24 +295,32 @@ void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock)
event.event_subclass= MYSQL_AUDIT_TABLE_LOCK; event.event_subclass= MYSQL_AUDIT_TABLE_LOCK;
event.read_only= lock == F_RDLCK; event.read_only= lock == F_RDLCK;
event.thread_id= (unsigned long)thd->thread_id; event.thread_id= (unsigned long)thread_id;
event.user= sctx->user; event.user= user;
event.priv_user= sctx->priv_user; event.priv_user= sctx->priv_user;
event.priv_host= sctx->priv_host; event.priv_host= sctx->priv_host;
event.external_user= sctx->external_user; event.external_user= sctx->external_user;
event.proxy_user= sctx->proxy_user; event.proxy_user= sctx->proxy_user;
event.host= sctx->host; event.host= host;
event.ip= sctx->ip; event.ip= ip;
event.database= share->db; event.database= share->db;
event.table= share->table_name; event.table= share->table_name;
event.new_database= null_clex_str; event.new_database= null_clex_str;
event.new_table= null_clex_str; event.new_table= null_clex_str;
event.query_id= thd->query_id; event.query_id= query_id;
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event); mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
} }
} }
static inline
void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock)
{
mysql_audit_external_lock_ex(thd, thd->thread_id, thd->security_ctx->user,
thd->security_ctx->host, thd->security_ctx->ip, thd->query_id,
share, lock);
}
static inline static inline
void mysql_audit_create_table(TABLE *table) void mysql_audit_create_table(TABLE *table)
{ {

View file

@ -2203,36 +2203,16 @@ public:
passed from connection thread to the handler thread. passed from connection thread to the handler thread.
*/ */
MDL_request grl_protection; MDL_request grl_protection;
my_thread_id orig_thread_id;
void set_default_user()
{
thd.security_ctx->user=(char*) delayed_user;
thd.security_ctx->host=(char*) my_localhost;
thd.security_ctx->ip= NULL;
thd.query_id= 0;
thd.thread_id= orig_thread_id;
}
void set_user_from_row(const delayed_row *r)
{
if (r)
{
thd.security_ctx->user= r->user;
thd.security_ctx->host= r->host;
thd.security_ctx->ip= r->ip;
thd.query_id= r->query_id;
thd.thread_id= r->thread_id;
}
}
Delayed_insert(SELECT_LEX *current_select) Delayed_insert(SELECT_LEX *current_select)
:locks_in_memory(0), thd(next_thread_id()), :locks_in_memory(0), thd(next_thread_id()),
table(0),tables_in_use(0), stacked_inserts(0), table(0),tables_in_use(0), stacked_inserts(0),
status(0), retry(0), handler_thread_initialized(FALSE), group_count(0) status(0), retry(0), handler_thread_initialized(FALSE), group_count(0)
{ {
DBUG_ENTER("Delayed_insert constructor"); DBUG_ENTER("Delayed_insert constructor");
orig_thread_id= thd.thread_id; thd.security_ctx->user=(char*) delayed_user;
set_default_user(); thd.security_ctx->host=(char*) my_localhost;
thd.security_ctx->ip= NULL;
thd.query_id= 0;
strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user); strmake_buf(thd.security_ctx->priv_user, thd.security_ctx->user);
thd.current_tablenr=0; thd.current_tablenr=0;
thd.set_command(COM_DELAYED_INSERT); thd.set_command(COM_DELAYED_INSERT);
@ -3218,7 +3198,6 @@ pthread_handler_t handle_delayed_insert(void *arg)
if (di->tables_in_use && ! thd->lock && if (di->tables_in_use && ! thd->lock &&
(!thd->killed || di->stacked_inserts)) (!thd->killed || di->stacked_inserts))
{ {
di->set_user_from_row(di->rows.head());
/* /*
Request for new delayed insert. Request for new delayed insert.
Lock the table, but avoid to be blocked by a global read lock. Lock the table, but avoid to be blocked by a global read lock.
@ -3240,16 +3219,18 @@ pthread_handler_t handle_delayed_insert(void *arg)
{ {
delayed_row *row; delayed_row *row;
I_List_iterator<delayed_row> it(di->rows); I_List_iterator<delayed_row> it(di->rows);
my_thread_id cur_thd= di->thd.thread_id;
while ((row= it++)) while ((row= it++))
{ {
if (di->thd.thread_id != row->thread_id) if (cur_thd != row->thread_id)
{ {
di->set_user_from_row(row); mysql_audit_external_lock_ex(&di->thd, row->thread_id,
mysql_audit_external_lock(&di->thd, di->table->s, F_WRLCK); row->user, row->host, row->ip, row->query_id,
di->table->s, F_WRLCK);
cur_thd= row->thread_id;
} }
} }
di->set_default_user();
if (di->handle_inserts()) if (di->handle_inserts())
{ {
/* Some fatal error */ /* Some fatal error */

View file

@ -1712,28 +1712,6 @@ public:
Sroutine_hash_entry **sroutines_list_own_last; Sroutine_hash_entry **sroutines_list_own_last;
uint sroutines_list_own_elements; uint sroutines_list_own_elements;
/**
Locking state of tables in this particular statement.
If we under LOCK TABLES or in prelocked mode we consider tables
for the statement to be "locked" if there was a call to lock_tables()
(which called handler::start_stmt()) for tables of this statement
and there was no matching close_thread_tables() call.
As result this state may differ significantly from one represented
by Open_tables_state::lock/locked_tables_mode more, which are always
"on" under LOCK TABLES or in prelocked mode.
*/
enum enum_lock_tables_state {
LTS_NOT_LOCKED = 0,
LTS_LOCKED
};
enum_lock_tables_state lock_tables_state;
bool is_query_tables_locked()
{
return (lock_tables_state == LTS_LOCKED);
}
/** /**
Number of tables which were open by open_tables() and to be locked Number of tables which were open by open_tables() and to be locked
by lock_tables(). by lock_tables().

View file

@ -2128,6 +2128,7 @@ JOIN::optimize_inner()
zero_result_cause= "Zero limit"; zero_result_cause= "Zero limit";
} }
table_count= top_join_tab_count= 0; table_count= top_join_tab_count= 0;
handle_implicit_grouping_with_window_funcs();
error= 0; error= 0;
subq_exit_fl= true; subq_exit_fl= true;
goto setup_subq_exit; goto setup_subq_exit;
@ -2175,6 +2176,7 @@ JOIN::optimize_inner()
table_count= top_join_tab_count= 0; table_count= top_join_tab_count= 0;
error=0; error=0;
subq_exit_fl= true; subq_exit_fl= true;
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit; goto setup_subq_exit;
} }
if (res > 1) if (res > 1)
@ -2190,6 +2192,7 @@ JOIN::optimize_inner()
tables_list= 0; // All tables resolved tables_list= 0; // All tables resolved
select_lex->min_max_opt_list.empty(); select_lex->min_max_opt_list.empty();
const_tables= top_join_tab_count= table_count; const_tables= top_join_tab_count= table_count;
handle_implicit_grouping_with_window_funcs();
/* /*
Extract all table-independent conditions and replace the WHERE Extract all table-independent conditions and replace the WHERE
clause with them. All other conditions were computed by opt_sum_query clause with them. All other conditions were computed by opt_sum_query
@ -2338,6 +2341,7 @@ int JOIN::optimize_stage2()
zero_result_cause= "no matching row in const table"; zero_result_cause= "no matching row in const table";
DBUG_PRINT("error",("Error: %s", zero_result_cause)); DBUG_PRINT("error",("Error: %s", zero_result_cause));
error= 0; error= 0;
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit; goto setup_subq_exit;
} }
if (!(thd->variables.option_bits & OPTION_BIG_SELECTS) && if (!(thd->variables.option_bits & OPTION_BIG_SELECTS) &&
@ -2369,6 +2373,7 @@ int JOIN::optimize_stage2()
zero_result_cause= zero_result_cause=
"Impossible WHERE noticed after reading const tables"; "Impossible WHERE noticed after reading const tables";
select_lex->mark_const_derived(zero_result_cause); select_lex->mark_const_derived(zero_result_cause);
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit; goto setup_subq_exit;
} }
@ -2531,6 +2536,7 @@ int JOIN::optimize_stage2()
zero_result_cause= zero_result_cause=
"Impossible WHERE noticed after reading const tables"; "Impossible WHERE noticed after reading const tables";
select_lex->mark_const_derived(zero_result_cause); select_lex->mark_const_derived(zero_result_cause);
handle_implicit_grouping_with_window_funcs();
goto setup_subq_exit; goto setup_subq_exit;
} }
@ -15746,7 +15752,7 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab,
} }
} }
else if (cond->type() == Item::FUNC_ITEM && else if (cond->type() == Item::FUNC_ITEM &&
((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
{ {
item_equal= (Item_equal *) cond; item_equal= (Item_equal *) cond;
item_equal->sort(&compare_fields_by_table_order, table_join_idx); item_equal->sort(&compare_fields_by_table_order, table_join_idx);
@ -19722,7 +19728,8 @@ void set_postjoin_aggr_write_func(JOIN_TAB *tab)
} }
} }
else if (join->sort_and_group && !tmp_tbl->precomputed_group_by && else if (join->sort_and_group && !tmp_tbl->precomputed_group_by &&
!join->sort_and_group_aggr_tab && join->tables_list) !join->sort_and_group_aggr_tab && join->tables_list &&
join->top_join_tab_count)
{ {
DBUG_PRINT("info",("Using end_write_group")); DBUG_PRINT("info",("Using end_write_group"));
aggr->set_write_func(end_write_group); aggr->set_write_func(end_write_group);
@ -25154,7 +25161,8 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
for (uint i= 0; (item= it++); i++) for (uint i= 0; (item= it++); i++)
{ {
Field *field; Field *field;
if (item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) ||
item->with_window_func)
item_field= item; item_field= item;
else if (item->type() == Item::FIELD_ITEM) else if (item->type() == Item::FIELD_ITEM)
{ {
@ -28696,6 +28704,28 @@ Item *remove_pushed_top_conjuncts(THD *thd, Item *cond)
} }
/*
There are 5 cases in which we shortcut the join optimization process as we
conclude that the join would be a degenerate one
1) IMPOSSIBLE WHERE
2) MIN/MAX optimization (@see opt_sum_query)
3) EMPTY CONST TABLE
If a window function is present in any of the above cases then to get the
result of the window function, we need to execute it. So we need to
create a temporary table for its execution. Here we need to take in mind
that aggregate functions and non-aggregate function need not be executed.
*/
void JOIN::handle_implicit_grouping_with_window_funcs()
{
if (select_lex->have_window_funcs() && send_row_on_empty_set())
{
const_tables= top_join_tab_count= table_count= 0;
}
}
/** /**
@brief @brief
Look for provision of the select_handler interface by a foreign engine Look for provision of the select_handler interface by a foreign engine

View file

@ -1127,6 +1127,7 @@ protected:
Join_plan_state *save_to); Join_plan_state *save_to);
/* Choose a subquery plan for a table-less subquery. */ /* Choose a subquery plan for a table-less subquery. */
bool choose_tableless_subquery_plan(); bool choose_tableless_subquery_plan();
void handle_implicit_grouping_with_window_funcs();
public: public:
void save_query_plan(Join_plan_state *save_to); void save_query_plan(Join_plan_state *save_to);

View file

@ -6795,23 +6795,35 @@ static int get_check_constraints_record(THD *thd, TABLE_LIST *tables,
thd->clear_error(); thd->clear_error();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
else if (!tables->view) if (!tables->view)
{
if (tables->table->s->table_check_constraints)
{
for (uint i= 0; i < tables->table->s->table_check_constraints; i++)
{ {
StringBuffer<MAX_FIELD_WIDTH> str(system_charset_info); StringBuffer<MAX_FIELD_WIDTH> str(system_charset_info);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
TABLE_LIST table_acl_check;
bzero((char*) &table_acl_check, sizeof(table_acl_check));
#endif
for (uint i= 0; i < tables->table->s->table_check_constraints; i++)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (!(thd->col_access & TABLE_ACLS))
{
table_acl_check.db= *db_name;
table_acl_check.table_name= *table_name;
table_acl_check.grant.privilege= thd->col_access;
if (check_grant(thd, TABLE_ACLS, &table_acl_check, FALSE, 1, TRUE))
continue;
}
#endif
Virtual_column_info *check= tables->table->check_constraints[i]; Virtual_column_info *check= tables->table->check_constraints[i];
restore_record(table, s->default_values);
table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info); table->field[0]->store(STRING_WITH_LEN("def"), system_charset_info);
table->field[1]->store(db_name->str, db_name->length, system_charset_info); table->field[3]->store(check->name.str, check->name.length,
table->field[2]->store(check->name.str, check->name.length, system_charset_info); system_charset_info);
table->field[3]->store(table_name->str, table_name->length, system_charset_info); /* Make sure the string is empty between each print. */
str.length(0);
check->print(&str); check->print(&str);
table->field[4]->store(str.ptr(), str.length(), system_charset_info); table->field[4]->store(str.ptr(), str.length(), system_charset_info);
schema_table_store_record(thd, table); if (schema_table_store_record(thd, table))
} DBUG_RETURN(1);
} }
} }
DBUG_RETURN(res); DBUG_RETURN(res);
@ -9370,8 +9382,8 @@ ST_FIELD_INFO check_constraints_fields_info[]=
{ {
Column("CONSTRAINT_CATALOG", Catalog(), NOT_NULL, OPEN_FULL_TABLE), Column("CONSTRAINT_CATALOG", Catalog(), NOT_NULL, OPEN_FULL_TABLE),
Column("CONSTRAINT_SCHEMA", Name(), NOT_NULL, OPEN_FULL_TABLE), Column("CONSTRAINT_SCHEMA", Name(), NOT_NULL, OPEN_FULL_TABLE),
Column("CONSTRAINT_NAME", Name(), NOT_NULL, OPEN_FULL_TABLE),
Column("TABLE_NAME", Name(), NOT_NULL, OPEN_FULL_TABLE), Column("TABLE_NAME", Name(), NOT_NULL, OPEN_FULL_TABLE),
Column("CONSTRAINT_NAME", Name(), NOT_NULL, OPEN_FULL_TABLE),
Column("CHECK_CLAUSE", Name(), NOT_NULL, OPEN_FULL_TABLE), Column("CHECK_CLAUSE", Name(), NOT_NULL, OPEN_FULL_TABLE),
CEnd() CEnd()
}; };
@ -9402,7 +9414,8 @@ ST_SCHEMA_TABLE schema_tables[]=
{"CHARACTER_SETS", Show::charsets_fields_info, 0, {"CHARACTER_SETS", Show::charsets_fields_info, 0,
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0}, fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
{"CHECK_CONSTRAINTS", Show::check_constraints_fields_info, 0, {"CHECK_CONSTRAINTS", Show::check_constraints_fields_info, 0,
get_all_tables, 0, get_check_constraints_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, get_all_tables, 0,
get_check_constraints_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
{"COLLATIONS", Show::collation_fields_info, 0, {"COLLATIONS", Show::collation_fields_info, 0,
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0}, fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
{"COLLATION_CHARACTER_SET_APPLICABILITY", Show::coll_charset_app_fields_info, {"COLLATION_CHARACTER_SET_APPLICABILITY", Show::coll_charset_app_fields_info,

View file

@ -1887,6 +1887,10 @@ protected:
{ {
return (ulong) ::calc_daynr((uint) year, (uint) month, (uint) day); return (ulong) ::calc_daynr((uint) year, (uint) month, (uint) day);
} }
int weekday(bool sunday_first_day_of_week) const
{
return ::calc_weekday(daynr(), sunday_first_day_of_week);
}
ulong dayofyear() const ulong dayofyear() const
{ {
return (ulong) (daynr() - ::calc_daynr(year, 1, 1) + 1); return (ulong) (daynr() - ::calc_daynr(year, 1, 1) + 1);
@ -2267,6 +2271,11 @@ public:
DBUG_ASSERT(is_valid_datetime_slow()); DBUG_ASSERT(is_valid_datetime_slow());
return Temporal_with_date::daynr(); return Temporal_with_date::daynr();
} }
int weekday(bool sunday_first_day_of_week) const
{
DBUG_ASSERT(is_valid_datetime_slow());
return Temporal_with_date::weekday(sunday_first_day_of_week);
}
ulong dayofyear() const ulong dayofyear() const
{ {
DBUG_ASSERT(is_valid_datetime_slow()); DBUG_ASSERT(is_valid_datetime_slow());

View file

@ -1779,11 +1779,7 @@ protected:
List_iterator_fast<Item_sum> it(sum_functions); List_iterator_fast<Item_sum> it(sum_functions);
Item_sum* item; Item_sum* item;
while ((item= it++)) while ((item= it++))
{ item->set_partition_row_count(num_rows_in_partition);
Item_sum_window_with_row_count* item_with_row_count =
static_cast<Item_sum_window_with_row_count *>(item);
item_with_row_count->set_row_count(num_rows_in_partition);
}
} }
}; };

View file

@ -1237,7 +1237,7 @@ void wait_begin(thread_group_t *thread_group)
DBUG_ASSERT(thread_group->connection_count > 0); DBUG_ASSERT(thread_group->connection_count > 0);
if ((thread_group->active_thread_count == 0) && if ((thread_group->active_thread_count == 0) &&
(is_queue_empty(thread_group) || !thread_group->listener)) (!is_queue_empty(thread_group) || !thread_group->listener))
{ {
/* /*
Group might stall while this thread waits, thus wake Group might stall while this thread waits, thus wake

View file

@ -2432,7 +2432,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
if (!opt_skip_write_binlog) if (!opt_skip_write_binlog)
printf("\\d |\n" printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n" "IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n" "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"
"ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n" "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n"
"END IF|\n" "END IF|\n"
"\\d ;\n"); "\\d ;\n");
@ -2452,7 +2452,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp)
if (!opt_skip_write_binlog) if (!opt_skip_write_binlog)
printf("\\d |\n" printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n" "IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n" "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"
"ALTER TABLE time_zone_leap_second ENGINE=Aria;\n" "ALTER TABLE time_zone_leap_second ENGINE=Aria;\n"
"END IF|\n" "END IF|\n"
"\\d ;\n"); "\\d ;\n");
@ -2708,7 +2708,7 @@ main(int argc, char **argv)
sql_log_bin and wsrep_on to avoid Galera replicating below sql_log_bin and wsrep_on to avoid Galera replicating below
truncate table clauses. This will allow user to set different truncate table clauses. This will allow user to set different
time zones to nodes in Galera cluster. */ time zones to nodes in Galera cluster. */
printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n"
"prepare set_wsrep_write_binlog from @prep1;\n" "prepare set_wsrep_write_binlog from @prep1;\n"
"set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n");
@ -2724,7 +2724,7 @@ main(int argc, char **argv)
// to allow changes to them to replicate with Galera // to allow changes to them to replicate with Galera
printf("\\d |\n" printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n" "IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n" "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"
"ALTER TABLE time_zone ENGINE=InnoDB;\n" "ALTER TABLE time_zone ENGINE=InnoDB;\n"
"ALTER TABLE time_zone_name ENGINE=InnoDB;\n" "ALTER TABLE time_zone_name ENGINE=InnoDB;\n"
"ALTER TABLE time_zone_transition ENGINE=InnoDB;\n" "ALTER TABLE time_zone_transition ENGINE=InnoDB;\n"
@ -2779,7 +2779,7 @@ main(int argc, char **argv)
// Fall back to Aria // Fall back to Aria
printf("\\d |\n" printf("\\d |\n"
"IF (select count(*) from information_schema.global_variables where\n" "IF (select count(*) from information_schema.global_variables where\n"
"variable_name='wsrep_on') = 1 THEN\n" "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n"
"ALTER TABLE time_zone ENGINE=Aria;\n" "ALTER TABLE time_zone ENGINE=Aria;\n"
"ALTER TABLE time_zone_name ENGINE=Aria;\n" "ALTER TABLE time_zone_name ENGINE=Aria;\n"
"ALTER TABLE time_zone_transition ENGINE=Aria;\n" "ALTER TABLE time_zone_transition ENGINE=Aria;\n"

View file

@ -538,6 +538,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
pos+= reclength; pos+= reclength;
int2store(pos, create_info->connect_string.length); int2store(pos, create_info->connect_string.length);
pos+= 2; pos+= 2;
if (create_info->connect_string.length)
memcpy(pos, create_info->connect_string.str, create_info->connect_string.length); memcpy(pos, create_info->connect_string.str, create_info->connect_string.length);
pos+= create_info->connect_string.length; pos+= create_info->connect_string.length;
int2store(pos, str_db_type.length); int2store(pos, str_db_type.length);

View file

@ -2296,6 +2296,7 @@ int wsrep_wait_committing_connections_close(int wait_time)
{ {
int sleep_time= 100; int sleep_time= 100;
WSREP_DEBUG("wait for committing transaction to close: %d sleep: %d", wait_time, sleep_time);
while (server_threads.iterate(have_committing_connections) && wait_time > 0) while (server_threads.iterate(have_committing_connections) && wait_time > 0)
{ {
WSREP_DEBUG("wait for committing transaction to close: %d", wait_time); WSREP_DEBUG("wait for committing transaction to close: %d", wait_time);

View file

@ -314,9 +314,6 @@ ENDIF(CONNECT_WITH_MONGO)
OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON) OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)
IF(CONNECT_WITH_REST) IF(CONNECT_WITH_REST)
MESSAGE(STATUS "=====> REST support is ON")
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
FIND_PACKAGE(cpprestsdk QUIET) FIND_PACKAGE(cpprestsdk QUIET)
IF (cpprestsdk_FOUND) IF (cpprestsdk_FOUND)
IF(UNIX) IF(UNIX)
@ -330,12 +327,8 @@ IF(CONNECT_WITH_REST)
# Comment it out if not needed depending on your cpprestsdk installation. # Comment it out if not needed depending on your cpprestsdk installation.
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
ENDIF(UNIX) ENDIF(UNIX)
# IF(REST_LIBRARY) why this? how about Windows SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} restget.cpp) add_definitions(-DREST_SUPPORT)
add_definitions(-DREST_SOURCE)
# ENDIF()
ELSE(NOT cpprestsdk_FOUND)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND) ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST) ENDIF(CONNECT_WITH_REST)

View file

@ -87,6 +87,7 @@ struct set_numa_interleave_t
" policy to MPOL_INTERLEAVE: " " policy to MPOL_INTERLEAVE: "
<< strerror(errno); << strerror(errno);
} }
numa_bitmask_free(numa_mems_allowed);
} }
} }
@ -1590,6 +1591,7 @@ buf_chunk_init(
" buffer pool page frames to MPOL_INTERLEAVE" " buffer pool page frames to MPOL_INTERLEAVE"
" (error: " << strerror(errno) << ")."; " (error: " << strerror(errno) << ").";
} }
numa_bitmask_free(numa_mems_allowed);
} }
#endif /* HAVE_LIBNUMA */ #endif /* HAVE_LIBNUMA */

View file

@ -2233,45 +2233,3 @@ dict_replace_tablespace_in_dictionary(
return(error); return(error);
} }
/** Delete records from SYS_TABLESPACES and SYS_DATAFILES associated
with a particular tablespace ID.
@param[in] space Tablespace ID
@param[in,out] trx Current transaction
@return DB_SUCCESS if OK, dberr_t if the operation failed */
dberr_t
dict_delete_tablespace_and_datafiles(
ulint space,
trx_t* trx)
{
dberr_t err = DB_SUCCESS;
ut_d(dict_sys.assert_locked());
ut_ad(srv_sys_tablespaces_open);
trx->op_info = "delete tablespace and datafiles from dictionary";
pars_info_t* info = pars_info_create();
ut_a(!is_system_tablespace(space));
pars_info_add_int4_literal(info, "space", space);
err = que_eval_sql(info,
"PROCEDURE P () IS\n"
"BEGIN\n"
"DELETE FROM SYS_TABLESPACES\n"
"WHERE SPACE = :space;\n"
"DELETE FROM SYS_DATAFILES\n"
"WHERE SPACE = :space;\n"
"END;\n",
FALSE, trx);
if (err != DB_SUCCESS) {
ib::warn() << "Could not delete space_id "
<< space << " from data dictionary";
}
trx->op_info = "";
return(err);
}

View file

@ -630,6 +630,27 @@ buf_page_is_corrupted(
ulint fsp_flags) ulint fsp_flags)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
inline void *aligned_malloc(size_t size, size_t align)
{
#ifdef _MSC_VER
return _aligned_malloc(size, align);
#else
void *result;
if (posix_memalign(&result, align, size))
result= NULL;
return result;
#endif
}
inline void aligned_free(void *ptr)
{
#ifdef _MSC_VER
_aligned_free(ptr);
#else
free(ptr);
#endif
}
/** Read the key version from the page. In full crc32 format, /** Read the key version from the page. In full crc32 format,
key version is stored at {0-3th} bytes. In other format, it is key version is stored at {0-3th} bytes. In other format, it is
stored in 26th position. stored in 26th position.
@ -687,34 +708,6 @@ inline uint buf_page_full_crc32_size(const byte* buf, bool* comp, bool* cr)
return page_size; return page_size;
} }
# ifdef UNIV_LINUX
# include <stdlib.h>
# endif
inline void* aligned_malloc(size_t size, size_t align)
{
#ifdef _MSC_VER
return _aligned_malloc(size, align);
#elif defined HAVE_POSIX_MEMALIGN
void *result;
if (posix_memalign(&result, align, size))
result= NULL;
return result;
#else
/* Use unaligned malloc as fallback */
return malloc(size);
#endif
}
inline void aligned_free(void *ptr)
{
#ifdef _MSC_VER
_aligned_free(ptr);
#else
free(ptr);
#endif
}
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************************//** /**********************************************************************//**
Gets the hash value of a block. This can be used in searches in the Gets the hash value of a block. This can be used in searches in the

View file

@ -113,7 +113,17 @@ ulint
buf_pool_get_n_pages(void) buf_pool_get_n_pages(void)
/*======================*/ /*======================*/
{ {
if (!buf_pool_ptr)
return buf_pool_get_curr_size() >> srv_page_size_shift; return buf_pool_get_curr_size() >> srv_page_size_shift;
ulint chunk_size= 0;
for (uint i= 0; i < srv_buf_pool_instances; i++)
{
buf_pool_t* buf_pool = buf_pool_from_array(i);
for (uint j= 0; j < buf_pool->n_chunks; j++)
chunk_size+= buf_pool->chunks[j].size;
}
return chunk_size;
} }
/********************************************************************//** /********************************************************************//**

View file

@ -198,16 +198,6 @@ dict_replace_tablespace_in_dictionary(
const char* path, const char* path,
trx_t* trx); trx_t* trx);
/** Delete records from SYS_TABLESPACES and SYS_DATAFILES associated
with a particular tablespace ID.
@param[in] space Tablespace ID
@param[in,out] trx Current transaction
@return DB_SUCCESS if OK, dberr_t if the operation failed */
dberr_t
dict_delete_tablespace_and_datafiles(
ulint space,
trx_t* trx);
/********************************************************************//** /********************************************************************//**
Add a foreign key definition to the data dictionary tables. Add a foreign key definition to the data dictionary tables.
@return error code or DB_SUCCESS */ @return error code or DB_SUCCESS */

View file

@ -102,16 +102,21 @@ recv_sys.parse_start_lsn is non-zero.
@return true if more data added */ @return true if more data added */
bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn); bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn);
/** Parse log records from a buffer and optionally store them in recv_sys.pages /** Parse log records from a buffer and optionally store them to recv_sys.pages
to wait merging to file pages. to wait merging to file pages.
@param[in] checkpoint_lsn the LSN of the latest checkpoint @param[in] checkpoint_lsn the LSN of the latest checkpoint
@param[in] store whether to store page operations @param[in] store whether to store page operations
@param[in] available_memory memory to read the redo logs
@param[in] apply whether to apply the records @param[in] apply whether to apply the records
@return whether MLOG_CHECKPOINT record was seen the first time, @return whether MLOG_CHECKPOINT record was seen the first time,
or corruption was noticed */ or corruption was noticed */
bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply); bool recv_parse_log_recs(
lsn_t checkpoint_lsn,
store_t* store,
ulint available_memory,
bool apply);
/** Moves the parsing buffer data left to the buffer start. */ /** Moves the parsing buffer data left to the buffer start */
void recv_sys_justify_left_parsing_buf(); void recv_sys_justify_left_parsing_buf();
/** Report optimized DDL operation (without redo log), /** Report optimized DDL operation (without redo log),

View file

@ -60,14 +60,6 @@ mlog_catenate_string(
const byte* str, /*!< in: string to write */ const byte* str, /*!< in: string to write */
ulint len); /*!< in: string length */ ulint len); /*!< in: string length */
/********************************************************//** /********************************************************//**
Catenates a compressed ulint to mlog. */
UNIV_INLINE
void
mlog_catenate_ulint_compressed(
/*===========================*/
mtr_t* mtr, /*!< in: mtr */
ulint val); /*!< in: value to write */
/********************************************************//**
Opens a buffer to mlog. It must be closed with mlog_close. Opens a buffer to mlog. It must be closed with mlog_close.
@return buffer, NULL if log mode MTR_LOG_NONE */ @return buffer, NULL if log mode MTR_LOG_NONE */
UNIV_INLINE UNIV_INLINE

View file

@ -117,30 +117,6 @@ mlog_catenate_ulint(
mlog_catenate_ulint(mtr->get_log(), val, type); mlog_catenate_ulint(mtr->get_log(), val, type);
} }
/********************************************************//**
Catenates a compressed ulint to mlog. */
UNIV_INLINE
void
mlog_catenate_ulint_compressed(
/*===========================*/
mtr_t* mtr, /*!< in: mtr */
ulint val) /*!< in: value to write */
{
byte* log_ptr;
log_ptr = mlog_open(mtr, 10);
/* If no logging is requested, we may return now */
if (log_ptr == NULL) {
return;
}
log_ptr += mach_write_compressed(log_ptr, val);
mlog_close(mtr, log_ptr);
}
/** Writes a log record about an operation. /** Writes a log record about an operation.
@param[in] type redo log record type @param[in] type redo log record type
@param[in] space_id tablespace identifier @param[in] space_id tablespace identifier

View file

@ -612,6 +612,7 @@ page_rec_get_next_low(
} }
ut_ad(page_rec_is_infimum(rec) ut_ad(page_rec_is_infimum(rec)
|| (!page_is_leaf(page) && !page_has_prev(page))
|| !(rec_get_info_bits(page + offs, comp) || !(rec_get_info_bits(page + offs, comp)
& REC_INFO_MIN_REC_FLAG)); & REC_INFO_MIN_REC_FLAG));

View file

@ -135,11 +135,6 @@ IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1) SET_SOURCE_FILES_PROPERTIES(trx/trx0rec.cc PROPERTIES COMPILE_FLAGS -O1)
ENDIF() ENDIF()
CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN)
IF(HAVE_POSIX_MEMALIGN)
ADD_DEFINITIONS(-DHAVE_POSIX_MEMALIGN)
ENDIF()
# Only use futexes on Linux if GCC atomics are available # Only use futexes on Linux if GCC atomics are available
IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING) IF(NOT MSVC AND NOT CMAKE_CROSSCOMPILING)
CHECK_C_SOURCE_RUNS( CHECK_C_SOURCE_RUNS(

View file

@ -505,8 +505,7 @@ fil_name_process(char* name, ulint len, ulint space_id, bool deleted)
/** Parse or process a MLOG_FILE_* record. /** Parse or process a MLOG_FILE_* record.
@param[in,out] ptr redo log record @param[in,out] ptr redo log record
@param[in] end end of the redo log buffer @param[in] end end of the redo log buffer
@param[in] space_id the tablespace ID @param[in] page_id first page number in the file
@param[in] first_page_no first page number in the file
@param[in] type MLOG_FILE_NAME or MLOG_FILE_DELETE @param[in] type MLOG_FILE_NAME or MLOG_FILE_DELETE
or MLOG_FILE_CREATE2 or MLOG_FILE_RENAME2 or MLOG_FILE_CREATE2 or MLOG_FILE_RENAME2
@param[in] apply whether to apply the record @param[in] apply whether to apply the record
@ -517,8 +516,7 @@ const byte*
fil_name_parse( fil_name_parse(
byte* ptr, byte* ptr,
const byte* end, const byte* end,
ulint space_id, const page_id_t page_id,
ulint first_page_no,
mlog_id_t type, mlog_id_t type,
bool apply) bool apply)
{ {
@ -542,9 +540,9 @@ fil_name_parse(
/* MLOG_FILE_* records should only be written for /* MLOG_FILE_* records should only be written for
user-created tablespaces. The name must be long enough user-created tablespaces. The name must be long enough
and end in .ibd. */ and end in .ibd. */
bool corrupt = is_predefined_tablespace(space_id) bool corrupt = is_predefined_tablespace(page_id.space())
|| len < sizeof "/a.ibd\0" || len < sizeof "/a.ibd\0"
|| (!first_page_no != !memcmp(ptr + len - 5, DOT_IBD, 5)); || (!page_id.page_no() != !memcmp(ptr + len - 5, DOT_IBD, 5));
if (!corrupt && !memchr(ptr, OS_PATH_SEPARATOR, len)) { if (!corrupt && !memchr(ptr, OS_PATH_SEPARATOR, len)) {
if (byte* c = static_cast<byte*> if (byte* c = static_cast<byte*>
@ -575,7 +573,8 @@ fil_name_parse(
} }
fil_name_process( fil_name_process(
reinterpret_cast<char*>(ptr), len, space_id, false); reinterpret_cast<char*>(ptr), len, page_id.space(),
false);
break; break;
case MLOG_FILE_DELETE: case MLOG_FILE_DELETE:
if (corrupt) { if (corrupt) {
@ -584,23 +583,23 @@ fil_name_parse(
break; break;
} }
fil_name_process( fil_name_process(reinterpret_cast<char*>(ptr), len,
reinterpret_cast<char*>(ptr), len, space_id, true); page_id.space(), true);
/* fall through */ /* fall through */
case MLOG_FILE_CREATE2: case MLOG_FILE_CREATE2:
if (first_page_no) { if (page_id.page_no()) {
ut_ad(first_page_no ut_ad(page_id.page_no()
== SRV_UNDO_TABLESPACE_SIZE_IN_PAGES); == SRV_UNDO_TABLESPACE_SIZE_IN_PAGES);
ut_a(srv_is_undo_tablespace(space_id)); ut_a(srv_is_undo_tablespace(page_id.space()));
compile_time_assert( compile_time_assert(
UT_ARR_SIZE(recv_sys.truncated_undo_spaces) UT_ARR_SIZE(recv_sys.truncated_undo_spaces)
== TRX_SYS_MAX_UNDO_SPACES); == TRX_SYS_MAX_UNDO_SPACES);
recv_sys_t::trunc& t = recv_sys.truncated_undo_spaces[ recv_sys_t::trunc& t = recv_sys.truncated_undo_spaces[
space_id - srv_undo_space_id_start]; page_id.space() - srv_undo_space_id_start];
t.lsn = recv_sys.recovered_lsn; t.lsn = recv_sys.recovered_lsn;
t.pages = uint32_t(first_page_no); t.pages = uint32_t(page_id.page_no());
} else if (log_file_op) { } else if (log_file_op) {
log_file_op(space_id, log_file_op(page_id.space(),
type == MLOG_FILE_CREATE2 ? ptr - 4 : NULL, type == MLOG_FILE_CREATE2 ? ptr - 4 : NULL,
ptr, len, NULL, 0); ptr, len, NULL, 0);
} }
@ -656,13 +655,13 @@ fil_name_parse(
fil_name_process( fil_name_process(
reinterpret_cast<char*>(ptr), len, reinterpret_cast<char*>(ptr), len,
space_id, false); page_id.space(), false);
fil_name_process( fil_name_process(
reinterpret_cast<char*>(new_name), new_len, reinterpret_cast<char*>(new_name), new_len,
space_id, false); page_id.space(), false);
if (log_file_op) { if (log_file_op) {
log_file_op(space_id, NULL, log_file_op(page_id.space(), NULL,
ptr, len, new_name, new_len); ptr, len, new_name, new_len);
} }
@ -670,7 +669,7 @@ fil_name_parse(
break; break;
} }
if (!fil_op_replay_rename( if (!fil_op_replay_rename(
space_id, first_page_no, page_id.space(), page_id.page_no(),
reinterpret_cast<const char*>(ptr), reinterpret_cast<const char*>(ptr),
reinterpret_cast<const char*>(new_name))) { reinterpret_cast<const char*>(new_name))) {
recv_sys.found_corrupt_fs = true; recv_sys.found_corrupt_fs = true;
@ -730,7 +729,6 @@ recv_sys_var_init(void)
recv_previous_parsed_rec_type = MLOG_SINGLE_REC_FLAG; recv_previous_parsed_rec_type = MLOG_SINGLE_REC_FLAG;
recv_previous_parsed_rec_offset = 0; recv_previous_parsed_rec_offset = 0;
recv_previous_parsed_rec_is_multi = 0; recv_previous_parsed_rec_is_multi = 0;
recv_n_pool_free_frames = 384;
recv_max_page_lsn = 0; recv_max_page_lsn = 0;
} }
@ -813,12 +811,7 @@ void recv_sys_t::create()
apply_log_recs = false; apply_log_recs = false;
apply_batch_on = false; apply_batch_on = false;
ulint size = buf_pool_get_curr_size(); recv_n_pool_free_frames = buf_pool_get_n_pages() / 3;
/* Set appropriate value of recv_n_pool_free_frames. */
if (size >= 10 << 20) {
/* Buffer pool of size greater than 10 MB. */
recv_n_pool_free_frames = 512;
}
buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE)); buf = static_cast<byte*>(ut_malloc_dontdump(RECV_PARSING_BUF_SIZE));
buf_size = RECV_PARSING_BUF_SIZE; buf_size = RECV_PARSING_BUF_SIZE;
@ -1278,8 +1271,7 @@ specified.
@param[in] type redo log entry type @param[in] type redo log entry type
@param[in] ptr redo log record body @param[in] ptr redo log record body
@param[in] end_ptr end of buffer @param[in] end_ptr end of buffer
@param[in] space_id tablespace identifier @param[in] page_id page identifier
@param[in] page_no page number
@param[in] apply whether to apply the record @param[in] apply whether to apply the record
@param[in,out] block buffer block, or NULL if @param[in,out] block buffer block, or NULL if
a page log record should not be applied a page log record should not be applied
@ -1293,8 +1285,7 @@ recv_parse_or_apply_log_rec_body(
mlog_id_t type, mlog_id_t type,
const byte* ptr, const byte* ptr,
const byte* end_ptr, const byte* end_ptr,
ulint space_id, const page_id_t page_id,
ulint page_no,
bool apply, bool apply,
buf_block_t* block, buf_block_t* block,
mtr_t* mtr) mtr_t* mtr)
@ -1311,7 +1302,7 @@ recv_parse_or_apply_log_rec_body(
/* Collect the file names when parsing the log, /* Collect the file names when parsing the log,
before applying any log records. */ before applying any log records. */
return fil_name_parse(const_cast<byte*>(ptr), end_ptr, return fil_name_parse(const_cast<byte*>(ptr), end_ptr,
space_id, page_no, type, apply); page_id, type, apply);
case MLOG_INDEX_LOAD: case MLOG_INDEX_LOAD:
if (end_ptr < ptr + 8) { if (end_ptr < ptr + 8) {
return(NULL); return(NULL);
@ -1340,21 +1331,20 @@ recv_parse_or_apply_log_rec_body(
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
ut_d(page_type = fil_page_get_type(page)); ut_d(page_type = fil_page_get_type(page));
} else if (apply } else if (apply
&& !is_predefined_tablespace(space_id) && !is_predefined_tablespace(page_id.space())
&& recv_spaces.find(space_id) == recv_spaces.end()) { && recv_spaces.find(page_id.space()) == recv_spaces.end()) {
if (recv_sys.recovered_lsn < recv_sys.mlog_checkpoint_lsn) { if (recv_sys.recovered_lsn < recv_sys.mlog_checkpoint_lsn) {
/* We have not seen all records between the /* We have not seen all records between the
checkpoint and MLOG_CHECKPOINT. There should be checkpoint and MLOG_CHECKPOINT. There should be
a MLOG_FILE_DELETE for this tablespace later. */ a MLOG_FILE_DELETE for this tablespace later. */
recv_spaces.insert( recv_spaces.insert(
std::make_pair(space_id, std::make_pair(page_id.space(),
file_name_t("", false))); file_name_t("", false)));
goto parse_log; goto parse_log;
} }
ib::error() << "Missing MLOG_FILE_NAME or MLOG_FILE_DELETE" ib::error() << "Missing MLOG_FILE_NAME or MLOG_FILE_DELETE"
" for redo log record " << type << " (page " " for redo log record " << type << page_id << " at "
<< space_id << ":" << page_no << ") at "
<< recv_sys.recovered_lsn << "."; << recv_sys.recovered_lsn << ".";
recv_sys.found_corrupt_log = true; recv_sys.found_corrupt_log = true;
return(NULL); return(NULL);
@ -1393,7 +1383,8 @@ parse_log:
redo log been written with something redo log been written with something
older than InnoDB Plugin 1.0.4. */ older than InnoDB Plugin 1.0.4. */
ut_ad(offs == FIL_PAGE_TYPE ut_ad(offs == FIL_PAGE_TYPE
|| srv_is_undo_tablespace(space_id) || srv_is_undo_tablespace(
page_id.space())
|| offs == IBUF_TREE_SEG_HEADER || offs == IBUF_TREE_SEG_HEADER
+ IBUF_HEADER + FSEG_HDR_OFFSET + IBUF_HEADER + FSEG_HDR_OFFSET
|| offs == PAGE_BTR_IBUF_FREE_LIST || offs == PAGE_BTR_IBUF_FREE_LIST
@ -1419,7 +1410,8 @@ parse_log:
ut_ad(0 ut_ad(0
/* fil_crypt_rotate_page() writes this */ /* fil_crypt_rotate_page() writes this */
|| offs == FIL_PAGE_SPACE_ID || offs == FIL_PAGE_SPACE_ID
|| srv_is_undo_tablespace(space_id) || srv_is_undo_tablespace(
page_id.space())
|| offs == IBUF_TREE_SEG_HEADER || offs == IBUF_TREE_SEG_HEADER
+ IBUF_HEADER + FSEG_HDR_SPACE + IBUF_HEADER + FSEG_HDR_SPACE
|| offs == IBUF_TREE_SEG_HEADER || offs == IBUF_TREE_SEG_HEADER
@ -1450,7 +1442,7 @@ parse_log:
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
ptr = mlog_parse_nbytes(type, ptr, end_ptr, page, page_zip); ptr = mlog_parse_nbytes(type, ptr, end_ptr, page, page_zip);
if (ptr && page && !page_no && type == MLOG_4BYTES) { if (ptr && page && !page_id.page_no() && type == MLOG_4BYTES) {
switch (ulint offs = mach_read_from_2(old_ptr)) { switch (ulint offs = mach_read_from_2(old_ptr)) {
fil_space_t* space; fil_space_t* space;
ulint val; ulint val;
@ -1460,7 +1452,7 @@ parse_log:
case FSP_HEADER_OFFSET + FSP_SIZE: case FSP_HEADER_OFFSET + FSP_SIZE:
case FSP_HEADER_OFFSET + FSP_FREE_LIMIT: case FSP_HEADER_OFFSET + FSP_FREE_LIMIT:
case FSP_HEADER_OFFSET + FSP_FREE + FLST_LEN: case FSP_HEADER_OFFSET + FSP_FREE + FLST_LEN:
space = fil_space_get(space_id); space = fil_space_get(page_id.space());
ut_a(space != NULL); ut_a(space != NULL);
val = mach_read_from_4(page + offs); val = mach_read_from_4(page + offs);
@ -1648,11 +1640,11 @@ parse_log:
this record yet. */ this record yet. */
break; break;
case MLOG_WRITE_STRING: case MLOG_WRITE_STRING:
if (page_no || mach_read_from_2(ptr + 2) if (page_id.page_no() || mach_read_from_2(ptr + 2)
!= 11 + MY_AES_BLOCK_SIZE) { != 11 + MY_AES_BLOCK_SIZE) {
/* Not writing crypt_info */ /* Not writing crypt_info */
} else if (fil_space_t* space } else if (fil_space_t* space
= fil_space_acquire_silent(space_id)) { = fil_space_acquire_silent(page_id.space())) {
if (mach_read_from_2(ptr) if (mach_read_from_2(ptr)
== FSP_HEADER_OFFSET + XDES_ARR_OFFSET + MAGIC_SZ == FSP_HEADER_OFFSET + XDES_ARR_OFFSET + MAGIC_SZ
+ space->physical_size() * XDES_SIZE + space->physical_size() * XDES_SIZE
@ -1947,8 +1939,7 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr,
recv_parse_or_apply_log_rec_body( recv_parse_or_apply_log_rec_body(
recv->type, recs, recs + recv->len, recv->type, recs, recs + recv->len,
block->page.id.space(), block->page.id, true, block, &mtr);
block->page.id.page_no(), true, block, &mtr);
end_lsn = recv->start_lsn + recv->len; end_lsn = recv->start_lsn + recv->len;
mach_write_to_8(FIL_PAGE_LSN + page, end_lsn); mach_write_to_8(FIL_PAGE_LSN + page, end_lsn);
@ -2386,7 +2377,8 @@ recv_parse_log_rec(
const byte* old_ptr = new_ptr; const byte* old_ptr = new_ptr;
new_ptr = recv_parse_or_apply_log_rec_body( new_ptr = recv_parse_or_apply_log_rec_body(
*type, new_ptr, end_ptr, *space, *page_no, apply, NULL, NULL); *type, new_ptr, end_ptr, page_id_t(*space, *page_no), apply,
NULL, NULL);
if (UNIV_UNLIKELY(new_ptr == NULL)) { if (UNIV_UNLIKELY(new_ptr == NULL)) {
return(0); return(0);
@ -2509,14 +2501,39 @@ recv_mlog_index_load(ulint space_id, ulint page_no, lsn_t lsn)
} }
} }
/** Check whether read redo log memory exceeds the available memory
of buffer pool. Store last_stored_lsn if it is not in last phase
@param[in] store whether to store page operations
@param[in] available_mem Available memory in buffer pool to
read redo logs. */
static bool recv_sys_heap_check(store_t* store, ulint available_mem)
{
if (*store != STORE_NO && mem_heap_get_size(recv_sys.heap) >= available_mem)
{
if (*store == STORE_YES)
recv_sys.last_stored_lsn= recv_sys.recovered_lsn;
*store= STORE_NO;
DBUG_PRINT("ib_log",("Ran out of memory and last "
"stored lsn " LSN_PF " last stored offset "
ULINTPF "\n",
recv_sys.recovered_lsn, recv_sys.recovered_offset));
return true;
}
return false;
}
/** Parse log records from a buffer and optionally store them to a /** Parse log records from a buffer and optionally store them to a
hash table to wait merging to file pages. hash table to wait merging to file pages.
@param[in] checkpoint_lsn the LSN of the latest checkpoint @param[in] checkpoint_lsn the LSN of the latest checkpoint
@param[in] store whether to store page operations @param[in] store whether to store page operations
@param[in] available_mem memory to read the redo logs
@param[in] apply whether to apply the records @param[in] apply whether to apply the records
@return whether MLOG_CHECKPOINT record was seen the first time, @return whether MLOG_CHECKPOINT record was seen the first time,
or corruption was noticed */ or corruption was noticed */
bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply) bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t* store,
ulint available_mem, bool apply)
{ {
bool single_rec; bool single_rec;
ulint len; ulint len;
@ -2526,6 +2543,7 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
ulint space; ulint space;
ulint page_no; ulint page_no;
const byte* body; const byte* body;
const bool last_phase = (*store == STORE_IF_EXISTS);
ut_ad(log_mutex_own()); ut_ad(log_mutex_own());
ut_ad(mutex_own(&recv_sys.mutex)); ut_ad(mutex_own(&recv_sys.mutex));
@ -2539,6 +2557,12 @@ loop:
return(false); return(false);
} }
/* Check for memory overflow and ignore the parsing of remaining
redo log records if InnoDB ran out of memory */
if (recv_sys_heap_check(store, available_mem) && last_phase) {
return false;
}
switch (*ptr) { switch (*ptr) {
case MLOG_CHECKPOINT: case MLOG_CHECKPOINT:
case MLOG_DUMMY_RECORD: case MLOG_DUMMY_RECORD:
@ -2629,7 +2653,7 @@ loop:
} }
break; break;
default: default:
switch (store) { switch (*store) {
case STORE_NO: case STORE_NO:
break; break;
case STORE_IF_EXISTS: case STORE_IF_EXISTS:
@ -2805,7 +2829,7 @@ corrupted_log:
recv_parse_or_apply_log_rec_body(). */ recv_parse_or_apply_log_rec_body(). */
break; break;
default: default:
switch (store) { switch (*store) {
case STORE_NO: case STORE_NO:
break; break;
case STORE_IF_EXISTS: case STORE_IF_EXISTS:
@ -2848,7 +2872,6 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn)
if (!recv_sys.parse_start_lsn) { if (!recv_sys.parse_start_lsn) {
/* Cannot start parsing yet because no start point for /* Cannot start parsing yet because no start point for
it found */ it found */
return(false); return(false);
} }
@ -2869,7 +2892,6 @@ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn)
} }
if (more_len == 0) { if (more_len == 0) {
return(false); return(false);
} }
@ -2911,26 +2933,30 @@ void recv_sys_justify_left_parsing_buf()
/** Scan redo log from a buffer and stores new log data to the parsing buffer. /** Scan redo log from a buffer and stores new log data to the parsing buffer.
Parse and hash the log records if new data found. Parse and hash the log records if new data found.
Apply log records automatically when the hash table becomes full. Apply log records automatically when the hash table becomes full.
@param[in] available_mem we let the hash table of recs to
grow to this size, at the maximum
@param[in,out] store_to_hash whether the records should be
stored to the hash table; this is
reset if just debug checking is
needed, or when the available_mem
runs out
@param[in] log_block log segment
@param[in] checkpoint_lsn latest checkpoint LSN
@param[in] start_lsn buffer start LSN
@param[in] end_lsn buffer end LSN
@param[in,out] contiguous_lsn it is known that all groups contain
contiguous log data upto this lsn
@param[out] group_scanned_lsn scanning succeeded upto this lsn
@return true if not able to scan any more in this log group */ @return true if not able to scan any more in this log group */
static static bool recv_scan_log_recs(
bool ulint available_mem,
recv_scan_log_recs( store_t* store_to_hash,
/*===============*/ const byte* log_block,
ulint available_memory,/*!< in: we let the hash table of recs lsn_t checkpoint_lsn,
to grow to this size, at the maximum */ lsn_t start_lsn,
store_t* store_to_hash, /*!< in,out: whether the records should be lsn_t end_lsn,
stored to the hash table; this is reset lsn_t* contiguous_lsn,
if just debug checking is needed, or lsn_t* group_scanned_lsn)
when the available_memory runs out */
const byte* log_block, /*!< in: log segment */
lsn_t checkpoint_lsn, /*!< in: latest checkpoint LSN */
lsn_t start_lsn, /*!< in: buffer start LSN */
lsn_t end_lsn, /*!< in: buffer end LSN */
lsn_t* contiguous_lsn, /*!< in/out: it is known that all log
groups contain contiguous log data up
to this lsn */
lsn_t* group_scanned_lsn)/*!< out: scanning succeeded up to
this lsn */
{ {
lsn_t scanned_lsn = start_lsn; lsn_t scanned_lsn = start_lsn;
bool finished = false; bool finished = false;
@ -2938,14 +2964,13 @@ recv_scan_log_recs(
bool more_data = false; bool more_data = false;
bool apply = recv_sys.mlog_checkpoint_lsn != 0; bool apply = recv_sys.mlog_checkpoint_lsn != 0;
ulint recv_parsing_buf_size = RECV_PARSING_BUF_SIZE; ulint recv_parsing_buf_size = RECV_PARSING_BUF_SIZE;
const bool last_phase = (*store_to_hash == STORE_IF_EXISTS);
ut_ad(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(end_lsn % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(end_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(end_lsn >= start_lsn + OS_FILE_LOG_BLOCK_SIZE); ut_ad(end_lsn >= start_lsn + OS_FILE_LOG_BLOCK_SIZE);
const byte* const log_end = log_block const byte* const log_end = log_block
+ ulint(end_lsn - start_lsn); + ulint(end_lsn - start_lsn);
do { do {
ut_ad(!finished); ut_ad(!finished);
@ -3056,6 +3081,13 @@ recv_scan_log_recs(
= log_block_get_checkpoint_no(log_block); = log_block_get_checkpoint_no(log_block);
} }
/* During last phase of scanning, there can be redo logs
left in recv_sys.buf to parse & store it in recv_sys.heap */
if (last_phase
&& recv_sys.recovered_lsn < recv_sys.scanned_lsn) {
more_data = true;
}
if (data_len < OS_FILE_LOG_BLOCK_SIZE) { if (data_len < OS_FILE_LOG_BLOCK_SIZE) {
/* Log data for this group ends here */ /* Log data for this group ends here */
finished = true; finished = true;
@ -3073,7 +3105,8 @@ recv_scan_log_recs(
/* Try to parse more log records */ /* Try to parse more log records */
if (recv_parse_log_recs(checkpoint_lsn, if (recv_parse_log_recs(checkpoint_lsn,
*store_to_hash, apply)) { store_to_hash, available_mem,
apply)) {
ut_ad(recv_sys.found_corrupt_log ut_ad(recv_sys.found_corrupt_log
|| recv_sys.found_corrupt_fs || recv_sys.found_corrupt_fs
|| recv_sys.mlog_checkpoint_lsn || recv_sys.mlog_checkpoint_lsn
@ -3082,22 +3115,18 @@ recv_scan_log_recs(
goto func_exit; goto func_exit;
} }
if (*store_to_hash != STORE_NO recv_sys_heap_check(store_to_hash, available_mem);
&& mem_heap_get_size(recv_sys.heap) > available_memory) {
DBUG_PRINT("ib_log", ("Ran out of memory and last "
"stored lsn " LSN_PF,
recv_sys.recovered_lsn));
recv_sys.last_stored_lsn = recv_sys.recovered_lsn;
*store_to_hash = STORE_NO;
}
if (recv_sys.recovered_offset > recv_parsing_buf_size / 4) { if (recv_sys.recovered_offset > recv_parsing_buf_size / 4) {
/* Move parsing buffer data to the buffer start */ /* Move parsing buffer data to the buffer start */
recv_sys_justify_left_parsing_buf(); recv_sys_justify_left_parsing_buf();
} }
/* Need to re-parse the redo log which're stored
in recv_sys.buf */
if (last_phase && *store_to_hash == STORE_NO) {
finished = false;
}
} }
func_exit: func_exit:
@ -3154,6 +3183,8 @@ recv_group_scan_log_recs(
if (last_phase && store_to_hash == STORE_NO) { if (last_phase && store_to_hash == STORE_NO) {
store_to_hash = STORE_IF_EXISTS; store_to_hash = STORE_IF_EXISTS;
recv_apply_hashed_log_recs(false); recv_apply_hashed_log_recs(false);
/* Rescan the redo logs from last stored lsn */
end_lsn = recv_sys.recovered_lsn;
} }
start_lsn = ut_uint64_align_down(end_lsn, start_lsn = ut_uint64_align_down(end_lsn,

View file

@ -153,6 +153,12 @@ os_mem_free_large(
{ {
ut_a(os_total_large_mem_allocated >= size); ut_a(os_total_large_mem_allocated >= size);
// We could have manually poisoned that memory for ASAN.
// And we must unpoison it by ourself as specified in documentation
// for __asan_poison_memory_region() in sanitizer/asan_interface.h
// munmap() doesn't do it for us automatically.
UNIV_MEM_ALLOC(ptr, size);
#ifdef HAVE_LINUX_LARGE_PAGES #ifdef HAVE_LINUX_LARGE_PAGES
if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) { if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) {
os_total_large_mem_allocated -= size; os_total_large_mem_allocated -= size;

View file

@ -248,6 +248,8 @@ IF(MSVC)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
ENDIF() ENDIF()
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS "-Wno-error")
ENDIF() ENDIF()
# Enable ZSTD if available. Upstream rocksdb cmake will use WITH_ZSTD and set # Enable ZSTD if available. Upstream rocksdb cmake will use WITH_ZSTD and set

View file

@ -471,5 +471,5 @@ list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/build_version.cc)
ADD_CONVENIENCE_LIBRARY(rocksdblib ${SOURCES}) ADD_CONVENIENCE_LIBRARY(rocksdblib ${SOURCES})
target_link_libraries(rocksdblib ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) target_link_libraries(rocksdblib ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_target_properties(rocksdblib PROPERTIES COMPILE_FLAGS "-fPIC -fno-builtin-memcmp") set_target_properties(rocksdblib PROPERTIES COMPILE_FLAGS "-fPIC -fno-builtin-memcmp -Wno-error")
endif() endif()

View file

@ -1598,7 +1598,8 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)),
int shift= 0, digits= 0, negative, addon; int shift= 0, digits= 0, negative, addon;
/* Skip leading spaces and tabs */ /* Skip leading spaces and tabs */
for ( ; str < end && (*str == ' ' || *str == '\t') ; str++); for ( ; str < end && my_isspace(&my_charset_latin1, *str) ; )
str++;
if (str >= end) if (str >= end)
goto ret_edom; goto ret_edom;

View file

@ -98,18 +98,25 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error)
if (endptr) if (endptr)
{ {
end= *endptr; end= *endptr;
while (s != end && (*s == ' ' || *s == '\t')) /* Skip leading spaces */
for ( ; s < end && my_isspace(&my_charset_latin1, *s) ; )
s++; s++;
if (s == end) if (s == end)
goto no_conv; goto no_conv;
} }
else else
{ {
endptr= &dummy; /* Easier end test */ endptr= &dummy; /* Easier end test */
while (*s == ' ' || *s == '\t') /* Skip leading spaces */
s++; for ( ; ; s++)
{
if (!*s) if (!*s)
goto no_conv; goto no_conv;
if (!my_isspace(&my_charset_latin1, *s))
break;
}
/* This number must be big to guard against a lot of pre-zeros */ /* This number must be big to guard against a lot of pre-zeros */
end= s+65535; /* Can't be longer than this */ end= s+65535; /* Can't be longer than this */
} }

View file

@ -131,6 +131,13 @@ UMask=007
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
PrivateTmp=false PrivateTmp=false
# Set an explicit Start and Stop timeout of 900 seconds (15 minutes!)
# this is the same value as used in SysV init scripts in the past
# Galera might need a longer timeout, check the KB if you want to change this:
# https://mariadb.com/kb/en/library/systemd/#configuring-the-systemd-service-timeout
TimeoutStartSec=900
TimeoutStopSec=900
## ##
## Options previously available to be set via [mysqld_safe] ## Options previously available to be set via [mysqld_safe]
## that now needs to be set by systemd config files as mysqld_safe ## that now needs to be set by systemd config files as mysqld_safe

View file

@ -243,6 +243,13 @@ UMask=007
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
PrivateTmp=false PrivateTmp=false
# Set an explicit Start and Stop timeout of 900 seconds (15 minutes!)
# this is the same value as used in SysV init scripts in the past
# if you need a longer timeout, check the KB:
# https://mariadb.com/kb/en/library/systemd/#configuring-the-systemd-service-timeout
TimeoutStartSec=900
TimeoutStopSec=900
# Controlling how multiple instances are separated. See top of this file. # Controlling how multiple instances are separated. See top of this file.
# Note: This service isn't User=mysql by default so we need to be explicit. # Note: This service isn't User=mysql by default so we need to be explicit.
# It is as an option here as a user may want to use the MYSQLD_MULTI_INSTANCE # It is as an option here as a user may want to use the MYSQLD_MULTI_INSTANCE