Merge 5.5->mwl248
This commit is contained in:
commit
f8bfb65b13
2
VERSION
2
VERSION
@ -1,4 +1,4 @@
|
||||
MYSQL_VERSION_MAJOR=5
|
||||
MYSQL_VERSION_MINOR=5
|
||||
MYSQL_VERSION_PATCH=28
|
||||
MYSQL_VERSION_EXTRA=
|
||||
MYSQL_VERSION_EXTRA=a
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2011, Oracle and/or its affiliates.
|
||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2012, Monty Program Ab
|
||||
|
||||
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
|
||||
|
@ -65,7 +65,7 @@ MACRO(GET_MYSQL_VERSION)
|
||||
MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}${EXTRA_VERSION})
|
||||
ENDMACRO()
|
||||
|
||||
# Get mysql version and other interesting variables
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2011, Oracle and/or its affiliates
|
||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
|
||||
|
||||
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
|
||||
|
@ -282,6 +282,9 @@ enum ha_base_keytype {
|
||||
#define HA_USES_BLOCK_SIZE ((uint) 32768)
|
||||
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
|
||||
|
||||
/* This flag can be used only in KEY::ext_key_flags */
|
||||
#define HA_EXT_NOSAME 131072
|
||||
|
||||
/* These flags can be added to key-seg-flag */
|
||||
|
||||
#define HA_SPACE_PACK 1 /* Pack space in key-seg */
|
||||
|
@ -47,9 +47,6 @@ extern "C" {
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef __LCC__
|
||||
#include <winsock2.h> /* For windows */
|
||||
#endif
|
||||
typedef char my_bool;
|
||||
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
|
||||
#define __WIN__
|
||||
@ -61,11 +58,13 @@ typedef char my_bool;
|
||||
#endif
|
||||
|
||||
#ifndef my_socket_defined
|
||||
#ifdef __WIN__
|
||||
#define my_socket SOCKET
|
||||
#if defined (_WIN64)
|
||||
#define my_socket unsigned long long
|
||||
#elif defined (_WIN32)
|
||||
#define my_socket unsigned int
|
||||
#else
|
||||
typedef int my_socket;
|
||||
#endif /* __WIN__ */
|
||||
#endif /* _WIN64 */
|
||||
#endif /* my_socket_defined */
|
||||
#endif /* _global_h */
|
||||
|
||||
|
@ -57,9 +57,6 @@
|
||||
#define LOCAL_HOST "localhost"
|
||||
#define LOCAL_HOST_NAMEDPIPE "."
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
|
||||
#define MYSQL_NAMEDPIPE "MySQL"
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (c) 2010, 2012, Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates.
|
||||
Copyright (c) 2011, 2012, Monty Program Ab
|
||||
|
||||
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
|
||||
|
@ -4,6 +4,9 @@ plugin-load=$HA_INNODB_SO
|
||||
innodb
|
||||
innodb-cmpmem
|
||||
innodb-trx
|
||||
innodb-buffer-pool-stats
|
||||
innodb-buffer-page
|
||||
innodb-buffer-page-lru
|
||||
|
||||
[xtradb_plugin]
|
||||
ignore-builtin-innodb
|
||||
@ -11,8 +14,14 @@ plugin-load=$HA_XTRADB_SO
|
||||
innodb
|
||||
innodb-cmpmem
|
||||
innodb-trx
|
||||
innodb-buffer-pool-stats
|
||||
innodb-buffer-page
|
||||
innodb-buffer-page-lru
|
||||
|
||||
[xtradb]
|
||||
innodb
|
||||
innodb-cmpmem
|
||||
innodb-trx
|
||||
innodb-buffer-pool-stats
|
||||
innodb-buffer-page
|
||||
innodb-buffer-page-lru
|
||||
|
@ -282,4 +282,74 @@ CREATE TABLE t1 ( i INT );
|
||||
INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) );
|
||||
drop table t1;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# MDEV-3801 Reproducible sub select join crash on 5.3.8 and 5.3.9
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
a char(2) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY a (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 (a)
|
||||
VALUES (NULL),(NULL),(NULL),('AB'),(NULL),('CD'),(NULL),(NULL);
|
||||
INSERT INTO t1 SELECT NULL, a1.a FROM t1 a1, t1 a2, t1 a3, t1 a4, t1 a5;
|
||||
CREATE TABLE t2 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
|
||||
INSERT INTO t2 SELECT NULL FROM t2 a1, t2 a2, t2 a3, t2 a4, t2 a5;
|
||||
CREATE TABLE t3 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
|
||||
INSERT INTO t3 SELECT NULL FROM t3 a1, t3 a2, t3 a3, t3 a4, t3 a5;
|
||||
CREATE TABLE t4 (
|
||||
a char(2) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t4 VALUES ('CD');
|
||||
set @@tmp_table_size=8192;
|
||||
EXPLAIN
|
||||
SELECT * FROM t3 AS tx JOIN t2 AS ty ON (tx.pk = ty.pk)
|
||||
WHERE
|
||||
tx.pk IN
|
||||
(SELECT *
|
||||
FROM (SELECT DISTINCT ta.pk
|
||||
FROM t3 AS ta
|
||||
JOIN t2 AS tb ON (ta.pk = tb.pk)
|
||||
JOIN t1 AS tc ON (tb.pk = tc.pk)
|
||||
JOIN t4 AS td ON tc.a = td.a) tu)
|
||||
limit 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL #
|
||||
1 PRIMARY tx eq_ref PRIMARY PRIMARY 4 tu.pk # Using index
|
||||
1 PRIMARY ty eq_ref PRIMARY PRIMARY 4 tu.pk # Using index
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL #
|
||||
3 DERIVED td system PRIMARY NULL NULL NULL # Using temporary
|
||||
3 DERIVED tc ref PRIMARY,a a 3 const #
|
||||
3 DERIVED ta eq_ref PRIMARY PRIMARY 4 test.tc.pk # Using index
|
||||
3 DERIVED tb eq_ref PRIMARY PRIMARY 4 test.tc.pk # Using index; Distinct
|
||||
SELECT * FROM t3 AS tX JOIN t2 AS tY ON (tX.pk = tY.pk)
|
||||
WHERE
|
||||
tX.pk IN
|
||||
(SELECT *
|
||||
FROM (SELECT DISTINCT tA.pk
|
||||
FROM t3 AS tA
|
||||
JOIN t2 AS tB ON (tA.pk = tB.pk)
|
||||
JOIN t1 AS tC ON (tB.pk = tC.pk)
|
||||
JOIN t4 AS tD ON tC.a = tD.a) tU)
|
||||
limit 10;
|
||||
pk pk
|
||||
6 6
|
||||
16 16
|
||||
24 24
|
||||
32 32
|
||||
40 40
|
||||
48 48
|
||||
56 56
|
||||
64 64
|
||||
72 72
|
||||
80 80
|
||||
drop table t1, t2, t3, t4;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
@ -2119,6 +2119,17 @@ FROM t2
|
||||
GROUP BY 1;
|
||||
a
|
||||
DROP TABLE t1, t2;
|
||||
FLUSH STATUS;
|
||||
CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob);
|
||||
INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob');
|
||||
SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1;
|
||||
f3 MIN(f2)
|
||||
blob NULL
|
||||
DROP TABLE t1;
|
||||
the value below *must* be 1
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
Variable_name Value
|
||||
Created_tmp_disk_tables 1
|
||||
# End of 5.3 tests
|
||||
#
|
||||
# Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00
|
||||
|
@ -1684,6 +1684,12 @@ SELECT length(CAST(b AS CHAR)) FROM ubig;
|
||||
length(CAST(b AS CHAR))
|
||||
20
|
||||
DROP TABLE ubig;
|
||||
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
|
||||
1
|
||||
grant usage on *.* to mysqltest_1@localhost;
|
||||
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
|
||||
1
|
||||
drop user mysqltest_1@localhost;
|
||||
End of 5.1 tests.
|
||||
#
|
||||
# Additional test for WL#3726 "DDL locking for all metadata objects"
|
||||
|
@ -613,6 +613,26 @@ Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
#
|
||||
# Bug mdev-3851: ref access used instead of expected eq_ref access
|
||||
# when extended_keys=on
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (1), (2), (3), (4), (5);
|
||||
create index i_p_size on part(p_size);
|
||||
set optimizer_switch='extended_keys=on';
|
||||
explain
|
||||
select * from t0, part ignore index (primary)
|
||||
where p_partkey=t0.a and p_size=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t0 ALL NULL NULL NULL NULL 5 Using where
|
||||
1 SIMPLE part eq_ref i_p_size i_p_size 9 const,dbt3_s001.t0.a 1
|
||||
select * from t0, part ignore index (primary)
|
||||
where p_partkey=t0.a and p_size=1;
|
||||
a p_partkey p_name p_mfgr p_brand p_type p_size p_container p_retailprice p_comment
|
||||
2 2 blush rosy metallic lemon navajo Manufacturer#1 Brand#13 LARGE BRUSHED BRASS 1 LG CASE 902 final platelets hang f
|
||||
drop table t0;
|
||||
drop index i_p_size on part;
|
||||
DROP DATABASE dbt3_s001;
|
||||
use test;
|
||||
#
|
||||
@ -724,5 +744,33 @@ SELECT * FROM t1, t2 WHERE b=a;
|
||||
a b
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# Bug mdev-3888: INSERT with UPDATE on duplicate keys
|
||||
# with extended_keys=on
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
c2 bigint(20) unsigned NOT NULL,
|
||||
c3 bigint(20) unsigned NOT NULL,
|
||||
c4 varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (c1),
|
||||
UNIQUE KEY uq (c2,c3),
|
||||
KEY c3 (c3),
|
||||
KEY c4 (c4)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set session optimizer_switch='extended_keys=off';
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
DELETE FROM t1;
|
||||
set session optimizer_switch='extended_keys=on';
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1;
|
||||
set optimizer_switch=@save_ext_key_optimizer_switch;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
@ -83,7 +83,7 @@ Ssl_cipher AES128-SHA
|
||||
SHOW STATUS LIKE 'Ssl_cipher';
|
||||
Variable_name Value
|
||||
Ssl_cipher AES128-SHA
|
||||
mysqltest: Could not open connection 'default': 2026 SSL connection error: SSL_CTX_new failed
|
||||
mysqltest: Could not open connection 'default': 2026 SSL connection error: Failed to set ciphers to use
|
||||
CREATE TABLE t1(a int);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
|
||||
|
@ -1945,3 +1945,79 @@ f0 f1 f2
|
||||
set sort_buffer_size= @save_sort_buffer_size;
|
||||
DROP TABLE t1;
|
||||
End of 5.3 tests
|
||||
#
|
||||
# Bug 54599: discarded fast range scan for query with
|
||||
# GROUP BY + ORDER BY + LIMIT
|
||||
#
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
|
||||
create table t1 (a int, b int, index idx1(a,b), index idx2(b,a));
|
||||
insert into t1
|
||||
select 1000*s4.a+100*s3.a+10*s2.a + s1.a, 1000*s4.a+100*s3.a+10*s2.a+s1.a
|
||||
from t0 s1, t0 s2, t0 s3, t0 s4;
|
||||
analyze table t1;
|
||||
explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 502 Using where; Using index; Using temporary; Using filesort
|
||||
flush status;
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 250
|
||||
Handler_read_last 0
|
||||
Handler_read_next 249
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 249
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 250
|
||||
explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx1 idx1 5 NULL 502 Using where; Using index; Using temporary; Using filesort
|
||||
flush status;
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 250
|
||||
Handler_read_last 0
|
||||
Handler_read_next 249
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 1
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 250
|
||||
drop table t0, t1;
|
||||
#
|
||||
# LP bug #1002508 : the number of expected rows to be examined is off
|
||||
# (bug #13528826)
|
||||
#
|
||||
CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
|
||||
INSERT INTO t1 VALUES
|
||||
(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
|
||||
CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
|
||||
INSERT INTO t2 VALUES
|
||||
(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
|
||||
(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
|
||||
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
|
||||
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
|
||||
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.5 tests
|
||||
|
@ -2394,6 +2394,12 @@ HAVING b > geomfromtext("")
|
||||
);
|
||||
1
|
||||
DROP TABLE t1;
|
||||
|
||||
MDEV-612 Valgrind error in ha_maria::check_if_incompatible_data
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2;
|
||||
ALTER TABLE t1 ADD KEY (b);
|
||||
drop table t1;
|
||||
End of 5.1 tests
|
||||
#
|
||||
# BUG#55385: UPDATE statement throws an error, but still updates
|
||||
|
@ -1221,6 +1221,153 @@ Lugansk UKR 469000
|
||||
Seattle USA 563374
|
||||
Caracas VEN 1975294
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n
|
||||
# (LP bug #637962)
|
||||
#
|
||||
DROP INDEX CountryPopulation ON City;
|
||||
DROP INDEX CountryName ON City;
|
||||
DROP INDEX CityName on City;
|
||||
CREATE INDEX Name ON City(Name);
|
||||
CREATE INDEX Population ON City(Population);
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Country,Name,Population Name,Country 35,3 NULL # Using sort_union(Name,Country); Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
ID Name Country Population
|
||||
384 Cabo Frio BRA 119503
|
||||
387 Camaragibe BRA 118968
|
||||
403 Catanduva BRA 107761
|
||||
412 Cachoeirinha BRA 103240
|
||||
508 Watford GBR 113080
|
||||
509 Ipswich GBR 114000
|
||||
510 Slough GBR 112000
|
||||
511 Exeter GBR 111000
|
||||
512 Cheltenham GBR 106000
|
||||
513 Gloucester GBR 107000
|
||||
514 Saint Helens GBR 106293
|
||||
515 Sutton Coldfield GBR 106001
|
||||
516 York GBR 104425
|
||||
517 Oldham GBR 103931
|
||||
518 Basildon GBR 100924
|
||||
519 Worthing GBR 100000
|
||||
635 Mallawi EGY 119283
|
||||
636 Bilbays EGY 113608
|
||||
637 Mit Ghamr EGY 101801
|
||||
638 al-Arish EGY 100447
|
||||
701 Tarragona ESP 113016
|
||||
702 Lleida (Lérida) ESP 112207
|
||||
703 Jaén ESP 109247
|
||||
704 Ourense (Orense) ESP 109120
|
||||
705 Mataró ESP 104095
|
||||
706 Algeciras ESP 103106
|
||||
707 Marbella ESP 101144
|
||||
759 Gonder ETH 112249
|
||||
869 Cabuyao PHL 106630
|
||||
870 Calapan PHL 105910
|
||||
873 Cauayan PHL 103952
|
||||
903 Serekunda GMB 102600
|
||||
909 Sohumi GEO 111700
|
||||
913 Tema GHA 109975
|
||||
914 Sekondi-Takoradi GHA 103653
|
||||
924 Villa Nueva GTM 101295
|
||||
1844 Cape Breton CAN 114733
|
||||
1847 Cambridge CAN 109186
|
||||
2406 Herakleion GRC 116178
|
||||
2407 Kallithea GRC 114233
|
||||
2408 Larisa GRC 113090
|
||||
2908 Cajamarca PER 108009
|
||||
3002 Besançon FRA 117733
|
||||
3003 Caen FRA 113987
|
||||
3004 Orléans FRA 113126
|
||||
3005 Mulhouse FRA 110359
|
||||
3006 Rouen FRA 106592
|
||||
3007 Boulogne-Billancourt FRA 106367
|
||||
3008 Perpignan FRA 105115
|
||||
3009 Nancy FRA 103605
|
||||
3411 Ceyhan TUR 102412
|
||||
3567 Carúpano VEN 119639
|
||||
3568 Catia La Mar VEN 117012
|
||||
3571 Calabozo VEN 107146
|
||||
3786 Cam Ranh VNM 114041
|
||||
3792 Tartu EST 101246
|
||||
4002 Carrollton USA 109576
|
||||
4027 Cape Coral USA 102286
|
||||
4032 Cambridge USA 101355
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 2
|
||||
Handler_read_last 0
|
||||
Handler_read_next 385
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 377
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
ID Name Country Population
|
||||
519 Worthing GBR 100000
|
||||
638 al-Arish EGY 100447
|
||||
518 Basildon GBR 100924
|
||||
707 Marbella ESP 101144
|
||||
3792 Tartu EST 101246
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_last 0
|
||||
Handler_read_next 59
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
set optimizer_switch='index_merge=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
ID Name Country Population
|
||||
519 Worthing GBR 100000
|
||||
638 al-Arish EGY 100447
|
||||
518 Basildon GBR 100924
|
||||
707 Marbella ESP 101144
|
||||
3792 Tartu EST 101246
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_last 0
|
||||
Handler_read_next 59
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP DATABASE world;
|
||||
use test;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- r/range_vs_index_merge_innodb.result 2012-03-24 17:12:02.124422000 +0100
|
||||
+++ r/range_vs_index_merge_innodb,innodb_plugin.reject 2012-03-24 18:00:13.647902620 +0100
|
||||
--- ./r/range_vs_index_merge_innodb.result 2012-11-21 19:35:14.000000000 +0100
|
||||
+++ ./r/range_vs_index_merge_innodb,innodb_plugin.reject 2012-11-21 20:56:00.000000000 +0100
|
||||
@@ -50,14 +50,14 @@
|
||||
WHERE (Population >= 100000 OR Name LIKE 'P%') AND Country='CAN' OR
|
||||
(Population < 100000 OR Name Like 'T%') AND Country='ARG';
|
||||
@ -269,3 +269,12 @@
|
||||
SELECT Name, Country, Population FROM City WHERE
|
||||
(Name='Manila' AND Country='PHL') OR
|
||||
(Name='Addis Abeba' AND Country='ETH') OR
|
||||
@@ -1346,7 +1346,7 @@
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
-1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where
|
||||
+1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
|
@ -1222,6 +1222,153 @@ Lugansk UKR 469000
|
||||
Seattle USA 563374
|
||||
Caracas VEN 1975294
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n
|
||||
# (LP bug #637962)
|
||||
#
|
||||
DROP INDEX CountryPopulation ON City;
|
||||
DROP INDEX CountryName ON City;
|
||||
DROP INDEX CityName on City;
|
||||
CREATE INDEX Name ON City(Name);
|
||||
CREATE INDEX Population ON City(Population);
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City index_merge Country,Name,Population Name,Country 35,3 NULL # Using sort_union(Name,Country); Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
ID Name Country Population
|
||||
384 Cabo Frio BRA 119503
|
||||
387 Camaragibe BRA 118968
|
||||
403 Catanduva BRA 107761
|
||||
412 Cachoeirinha BRA 103240
|
||||
508 Watford GBR 113080
|
||||
509 Ipswich GBR 114000
|
||||
510 Slough GBR 112000
|
||||
511 Exeter GBR 111000
|
||||
512 Cheltenham GBR 106000
|
||||
513 Gloucester GBR 107000
|
||||
514 Saint Helens GBR 106293
|
||||
515 Sutton Coldfield GBR 106001
|
||||
516 York GBR 104425
|
||||
517 Oldham GBR 103931
|
||||
518 Basildon GBR 100924
|
||||
519 Worthing GBR 100000
|
||||
635 Mallawi EGY 119283
|
||||
636 Bilbays EGY 113608
|
||||
637 Mit Ghamr EGY 101801
|
||||
638 al-Arish EGY 100447
|
||||
701 Tarragona ESP 113016
|
||||
702 Lleida (Lérida) ESP 112207
|
||||
703 Jaén ESP 109247
|
||||
704 Ourense (Orense) ESP 109120
|
||||
705 Mataró ESP 104095
|
||||
706 Algeciras ESP 103106
|
||||
707 Marbella ESP 101144
|
||||
759 Gonder ETH 112249
|
||||
869 Cabuyao PHL 106630
|
||||
870 Calapan PHL 105910
|
||||
873 Cauayan PHL 103952
|
||||
903 Serekunda GMB 102600
|
||||
909 Sohumi GEO 111700
|
||||
913 Tema GHA 109975
|
||||
914 Sekondi-Takoradi GHA 103653
|
||||
924 Villa Nueva GTM 101295
|
||||
1844 Cape Breton CAN 114733
|
||||
1847 Cambridge CAN 109186
|
||||
2406 Herakleion GRC 116178
|
||||
2407 Kallithea GRC 114233
|
||||
2408 Larisa GRC 113090
|
||||
2908 Cajamarca PER 108009
|
||||
3002 Besançon FRA 117733
|
||||
3003 Caen FRA 113987
|
||||
3004 Orléans FRA 113126
|
||||
3005 Mulhouse FRA 110359
|
||||
3006 Rouen FRA 106592
|
||||
3007 Boulogne-Billancourt FRA 106367
|
||||
3008 Perpignan FRA 105115
|
||||
3009 Nancy FRA 103605
|
||||
3411 Ceyhan TUR 102412
|
||||
3567 Carúpano VEN 119639
|
||||
3568 Catia La Mar VEN 117012
|
||||
3571 Calabozo VEN 107146
|
||||
3786 Cam Ranh VNM 114041
|
||||
3792 Tartu EST 101246
|
||||
4002 Carrollton USA 109576
|
||||
4027 Cape Coral USA 102286
|
||||
4032 Cambridge USA 101355
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 2
|
||||
Handler_read_last 0
|
||||
Handler_read_next 385
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 377
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,Name,Population Population 4 NULL # Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
ID Name Country Population
|
||||
519 Worthing GBR 100000
|
||||
638 al-Arish EGY 100447
|
||||
518 Basildon GBR 100924
|
||||
707 Marbella ESP 101144
|
||||
3792 Tartu EST 101246
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_last 0
|
||||
Handler_read_next 59
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
set optimizer_switch='index_merge=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE City range Country,Name,Population Population 4 NULL # Using index condition; Using where
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
ID Name Country Population
|
||||
519 Worthing GBR 100000
|
||||
638 al-Arish EGY 100447
|
||||
518 Basildon GBR 100924
|
||||
707 Marbella ESP 101144
|
||||
3792 Tartu EST 101246
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 1
|
||||
Handler_read_last 0
|
||||
Handler_read_next 59
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 0
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
DROP DATABASE world;
|
||||
use test;
|
||||
CREATE TABLE t1 (
|
||||
|
@ -6060,6 +6060,116 @@ WHERE (col_varchar_nokey, 'x') IN
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
#
|
||||
# MDEV-746
|
||||
# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
# HAS AN EMPTY RESULT
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
Testcase without inner subquery
|
||||
EXPLAIN SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
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 @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
|
||||
Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
EXPLAIN SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
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
|
||||
3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
@ -6860,7 +6970,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -6894,6 +7004,6 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -180,6 +180,32 @@ SET optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-536: LP:1050806 - different result for a query using subquery
|
||||
#
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
CREATE TABLE `t1` (
|
||||
`node_uid` bigint(20) unsigned DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`mirror_date` datetime DEFAULT NULL,
|
||||
KEY `date` (`date`)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
node_uid date mirror_date result
|
||||
2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0
|
||||
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-567: Wrong result from a query with correlated subquery if ICP is allowed
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int, INDEX idx(a));
|
||||
@ -197,5 +223,76 @@ a b
|
||||
1 0
|
||||
1 1
|
||||
1 3
|
||||
DROP TABLE t1, t2, t3;
|
||||
set @tmp_mdev567=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
SELECT * FROM t3
|
||||
WHERE a = (SELECT COUNT(DISTINCT t2.b) FROM t1, t2
|
||||
WHERE t1.a = t2.a AND t2.a BETWEEN 7 AND 9
|
||||
AND t3.b = t1.b
|
||||
GROUP BY t1.b);
|
||||
a b
|
||||
1 0
|
||||
1 1
|
||||
1 3
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp_mdev567;
|
||||
#
|
||||
# MDEV-614, also MDEV-536, also LP:1050806:
|
||||
# different result for a query using subquery between 5.5.25 and 5.5.27
|
||||
#
|
||||
CREATE TABLE `t1` (
|
||||
`node_uid` bigint(20) unsigned DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`mirror_date` datetime DEFAULT NULL,
|
||||
KEY `date` (`date`)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
|
||||
explain
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 range date date 9 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
node_uid date mirror_date result
|
||||
2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0
|
||||
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
|
||||
set @tmp_mdev614=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
explain
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> ALL NULL NULL NULL NULL 2
|
||||
2 DERIVED t1 range date date 9 NULL 2 Using index condition; Using where; Using filesort
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
node_uid date mirror_date result
|
||||
2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0
|
||||
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
|
||||
set optimizer_switch=@tmp_mdev614;
|
||||
DROP TABLE t1;
|
||||
set optimizer_switch=@subselect2_test_tmp;
|
||||
|
@ -6059,6 +6059,116 @@ WHERE (col_varchar_nokey, 'x') IN
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
#
|
||||
# MDEV-746
|
||||
# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
# HAS AN EMPTY RESULT
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
Testcase without inner subquery
|
||||
EXPLAIN SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
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 @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
|
||||
Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
EXPLAIN SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
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
|
||||
3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
@ -6858,7 +6968,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -6891,7 +7001,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
set optimizer_switch=default;
|
||||
|
@ -6055,6 +6055,116 @@ WHERE (col_varchar_nokey, 'x') IN
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
#
|
||||
# MDEV-746
|
||||
# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
# HAS AN EMPTY RESULT
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
Testcase without inner subquery
|
||||
EXPLAIN SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
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 @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
|
||||
Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
EXPLAIN SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
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
|
||||
3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
@ -6855,7 +6965,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -6889,7 +6999,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
@ -6066,6 +6066,116 @@ WHERE (col_varchar_nokey, 'x') IN
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
#
|
||||
# MDEV-746
|
||||
# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
# HAS AN EMPTY RESULT
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
Testcase without inner subquery
|
||||
EXPLAIN SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
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 @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
|
||||
Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
EXPLAIN SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
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
|
||||
3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
@ -6866,7 +6976,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -6900,7 +7010,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
set optimizer_switch=default;
|
||||
|
@ -6055,6 +6055,116 @@ WHERE (col_varchar_nokey, 'x') IN
|
||||
col_int_nokey
|
||||
1
|
||||
DROP TABLE ot,it1,it2;
|
||||
#
|
||||
# MDEV-746
|
||||
# Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
# HAS AN EMPTY RESULT
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
Testcase without inner subquery
|
||||
EXPLAIN SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
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 @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
EXPLAIN SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM ( SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3 ) AS alias3;
|
||||
@var3:=12 pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
SELECT @var3;
|
||||
@var3
|
||||
8
|
||||
|
||||
Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
EXPLAIN SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
EXPLAIN SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
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
|
||||
3 DEPENDENT SUBQUERY c_sq1_alias1 system PRIMARY NULL NULL NULL 1
|
||||
SELECT * FROM ( SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3)) ) AS alias3;
|
||||
pk col_int_nokey col_int_key col_time_key col_varchar_key col_varchar_nokey
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.2 tests
|
||||
#
|
||||
# BUG#779885: Crash in eliminate_item_equal with materialization=on in
|
||||
@ -6855,7 +6965,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
@ -6889,7 +6999,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
|
||||
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index a a 5 NULL 1 Using where; Using index
|
||||
2 SUBQUERY t1 index a a 5 NULL 2 Using where; Using index
|
||||
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
|
||||
DROP TABLE t1,t2;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
@ -498,4 +498,36 @@ DROP TABLE t1;
|
||||
#
|
||||
SET @bug12408412=1;
|
||||
SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0);
|
||||
SELECT DISTINCT POW(COUNT(*), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a))
|
||||
AS b FROM t1 GROUP BY a;
|
||||
b
|
||||
1
|
||||
SELECT @a;
|
||||
@a
|
||||
1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(f1 INT, f2 INT);
|
||||
INSERT INTO t1 VALUES (1,2),(2,3),(3,1);
|
||||
CREATE TABLE t2(a INT);
|
||||
INSERT INTO t2 VALUES (1);
|
||||
SET @var=NULL;
|
||||
SELECT @var:=(SELECT f2 FROM t2 WHERE @var) FROM t1 GROUP BY f1 ORDER BY f2 DESC
|
||||
LIMIT 1;
|
||||
@var:=(SELECT f2 FROM t2 WHERE @var)
|
||||
NULL
|
||||
SELECT @var;
|
||||
@var
|
||||
NULL
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0),(1),(3);
|
||||
SELECT DISTINCT POW(COUNT(distinct a), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a limit 1)) AS b FROM t1 GROUP BY a;
|
||||
b
|
||||
1
|
||||
SELECT @a;
|
||||
@a
|
||||
1
|
||||
DROP TABLE t1;
|
||||
End of 5.5 tests
|
||||
|
@ -1999,4 +1999,4 @@ connection slave;
|
||||
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
|
||||
|
||||
connection default;
|
||||
source suite/federated/include/federated_cleanup.inc;
|
||||
source include/federated_cleanup.inc;
|
||||
|
@ -382,6 +382,26 @@ INSERT INTO t1 VALUES('A ', 'A ');
|
||||
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
#
|
||||
# MDEV-568 (AKA LP BUG#1007981, AKA MySQL bug#44771)
|
||||
# Wrong result for a hash index look-up if the index is unique and
|
||||
# the key is NULL
|
||||
#
|
||||
CREATE TABLE t1 ( pk INT PRIMARY KEY, val INT, UNIQUE KEY USING HASH(val)) ENGINE=MEMORY;
|
||||
INSERT INTO t1 VALUES (1, NULL);
|
||||
INSERT INTO t1 VALUES (2, NULL);
|
||||
INSERT INTO t1 VALUES (3, 1);
|
||||
INSERT INTO t1 VALUES (4, NULL);
|
||||
EXPLAIN SELECT * FROM t1 WHERE val IS NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref val val 5 const 1 Using where
|
||||
SELECT * FROM t1 WHERE val IS NULL;
|
||||
pk val
|
||||
4 NULL
|
||||
2 NULL
|
||||
1 NULL
|
||||
drop table t1;
|
||||
End of 5.2 tests
|
||||
# bit index in heap tables
|
||||
create table t1 (a bit(63) not null) engine=heap;
|
||||
insert into t1 values (869751),(736494),(226312),(802616),(728912);
|
||||
|
@ -285,6 +285,23 @@ DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-568 (AKA LP BUG#1007981, AKA MySQL bug#44771)
|
||||
--echo # Wrong result for a hash index look-up if the index is unique and
|
||||
--echo # the key is NULL
|
||||
--echo #
|
||||
CREATE TABLE t1 ( pk INT PRIMARY KEY, val INT, UNIQUE KEY USING HASH(val)) ENGINE=MEMORY;
|
||||
|
||||
INSERT INTO t1 VALUES (1, NULL);
|
||||
INSERT INTO t1 VALUES (2, NULL);
|
||||
INSERT INTO t1 VALUES (3, 1);
|
||||
INSERT INTO t1 VALUES (4, NULL);
|
||||
EXPLAIN SELECT * FROM t1 WHERE val IS NULL;
|
||||
SELECT * FROM t1 WHERE val IS NULL;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.2 tests
|
||||
|
||||
-- echo # bit index in heap tables
|
||||
|
||||
create table t1 (a bit(63) not null) engine=heap;
|
||||
|
@ -3,11 +3,6 @@
|
||||
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
if (`select plugin_auth_version <= "1.1.8-29.0" from information_schema.plugins where plugin_name='innodb'`)
|
||||
{
|
||||
--skip Not fixed in XtraDB 1.1.8-29.0 or earlier
|
||||
}
|
||||
|
||||
-- disable_result_log
|
||||
SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
|
||||
|
||||
|
29
mysql-test/suite/plugins/r/audit_null.result
Normal file
29
mysql-test/suite/plugins/r/audit_null.result
Normal file
@ -0,0 +1,29 @@
|
||||
set @old_global_general_log=@@global.general_log;
|
||||
set global general_log=OFF;
|
||||
install plugin audit_null soname 'adt_null';
|
||||
select 1;
|
||||
1
|
||||
1
|
||||
select foobar;
|
||||
ERROR 42S22: Unknown column 'foobar' in 'field list'
|
||||
show status like 'audit_null%';
|
||||
Variable_name Value
|
||||
Audit_null_called 9
|
||||
Audit_null_general_error 1
|
||||
Audit_null_general_log 3
|
||||
Audit_null_general_result 2
|
||||
create procedure au1(x char(16)) select concat("test1", x);
|
||||
call au1("-12");
|
||||
concat("test1", x)
|
||||
test1-12
|
||||
show status like 'audit_null%';
|
||||
Variable_name Value
|
||||
Audit_null_called 19
|
||||
Audit_null_general_error 1
|
||||
Audit_null_general_log 7
|
||||
Audit_null_general_result 5
|
||||
uninstall plugin audit_null;
|
||||
Warnings:
|
||||
Warning 1620 Plugin is busy and will be uninstalled on shutdown
|
||||
drop procedure au1;
|
||||
set global general_log=@old_global_general_log;
|
30
mysql-test/suite/plugins/t/audit_null.test
Normal file
30
mysql-test/suite/plugins/t/audit_null.test
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
--source include/not_embedded.inc
|
||||
|
||||
if (!$ADT_NULL_SO) {
|
||||
skip No NULL_AUDIT plugin;
|
||||
}
|
||||
|
||||
set @old_global_general_log=@@global.general_log;
|
||||
set global general_log=OFF;
|
||||
|
||||
--disable_ps_protocol
|
||||
install plugin audit_null soname 'adt_null';
|
||||
|
||||
select 1;
|
||||
--error 1054
|
||||
select foobar;
|
||||
|
||||
show status like 'audit_null%';
|
||||
|
||||
create procedure au1(x char(16)) select concat("test1", x);
|
||||
call au1("-12");
|
||||
|
||||
show status like 'audit_null%';
|
||||
|
||||
uninstall plugin audit_null;
|
||||
--enable_ps_protocol
|
||||
|
||||
drop procedure au1;
|
||||
set global general_log=@old_global_general_log;
|
||||
|
@ -0,0 +1 @@
|
||||
XtraDB extension
|
@ -0,0 +1 @@
|
||||
--echo XtraDB extension
|
@ -108,3 +108,44 @@ select * from t1;
|
||||
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-3845: values of virtual columns are not computed for triggers
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a INTEGER UNSIGNED NULL DEFAULT NULL,
|
||||
b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL
|
||||
);
|
||||
|
||||
CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL);
|
||||
|
||||
DELIMITER |;
|
||||
|
||||
CREATE TRIGGER t1_ins_aft
|
||||
AFTER INSERT
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (NEW.b);
|
||||
END |
|
||||
|
||||
CREATE TRIGGER t1_del_bef
|
||||
BEFORE DELETE
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (OLD.b);
|
||||
END |
|
||||
|
||||
DELIMITER ;|
|
||||
|
||||
INSERT INTO t1 (a) VALUES (1), (2), (3);
|
||||
SELECT * FROM t2;
|
||||
DELETE FROM t1;
|
||||
SELECT * FROM t2;
|
||||
|
||||
DROP TRIGGER t1_ins_aft;
|
||||
DROP TRIGGER t1_del_bef;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
@ -85,3 +85,43 @@ a b c
|
||||
300 30 30
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
||||
#
|
||||
# Bug mdev-3845: values of virtual columns are not computed for triggers
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a INTEGER UNSIGNED NULL DEFAULT NULL,
|
||||
b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL
|
||||
);
|
||||
CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL);
|
||||
CREATE TRIGGER t1_ins_aft
|
||||
AFTER INSERT
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (NEW.b);
|
||||
END |
|
||||
CREATE TRIGGER t1_del_bef
|
||||
BEFORE DELETE
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (OLD.b);
|
||||
END |
|
||||
INSERT INTO t1 (a) VALUES (1), (2), (3);
|
||||
SELECT * FROM t2;
|
||||
c
|
||||
1
|
||||
2
|
||||
3
|
||||
DELETE FROM t1;
|
||||
SELECT * FROM t2;
|
||||
c
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
DROP TRIGGER t1_ins_aft;
|
||||
DROP TRIGGER t1_del_bef;
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -85,3 +85,43 @@ a b c
|
||||
300 30 30
|
||||
drop table t1,t2;
|
||||
drop procedure p1;
|
||||
#
|
||||
# Bug mdev-3845: values of virtual columns are not computed for triggers
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a INTEGER UNSIGNED NULL DEFAULT NULL,
|
||||
b INTEGER UNSIGNED GENERATED ALWAYS AS (a) VIRTUAL
|
||||
);
|
||||
CREATE TABLE t2 (c INTEGER UNSIGNED NOT NULL);
|
||||
CREATE TRIGGER t1_ins_aft
|
||||
AFTER INSERT
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (NEW.b);
|
||||
END |
|
||||
CREATE TRIGGER t1_del_bef
|
||||
BEFORE DELETE
|
||||
ON t1
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO t2 (c) VALUES (OLD.b);
|
||||
END |
|
||||
INSERT INTO t1 (a) VALUES (1), (2), (3);
|
||||
SELECT * FROM t2;
|
||||
c
|
||||
1
|
||||
2
|
||||
3
|
||||
DELETE FROM t1;
|
||||
SELECT * FROM t2;
|
||||
c
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
DROP TRIGGER t1_ins_aft;
|
||||
DROP TRIGGER t1_del_bef;
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -212,5 +212,65 @@ INSERT INTO t1 VALUES ( (SELECT 1 FROM ( SELECT * FROM t1 ) as a) );
|
||||
drop table t1;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-3801 Reproducible sub select join crash on 5.3.8 and 5.3.9
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
a char(2) DEFAULT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY a (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 (a)
|
||||
VALUES (NULL),(NULL),(NULL),('AB'),(NULL),('CD'),(NULL),(NULL);
|
||||
INSERT INTO t1 SELECT NULL, a1.a FROM t1 a1, t1 a2, t1 a3, t1 a4, t1 a5;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
|
||||
INSERT INTO t2 SELECT NULL FROM t2 a1, t2 a2, t2 a3, t2 a4, t2 a5;
|
||||
|
||||
CREATE TABLE t3 (
|
||||
pk int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
|
||||
INSERT INTO t3 SELECT NULL FROM t3 a1, t3 a2, t3 a3, t3 a4, t3 a5;
|
||||
|
||||
CREATE TABLE t4 (
|
||||
a char(2) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (a)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t4 VALUES ('CD');
|
||||
|
||||
set @@tmp_table_size=8192;
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM t3 AS tx JOIN t2 AS ty ON (tx.pk = ty.pk)
|
||||
WHERE
|
||||
tx.pk IN
|
||||
(SELECT *
|
||||
FROM (SELECT DISTINCT ta.pk
|
||||
FROM t3 AS ta
|
||||
JOIN t2 AS tb ON (ta.pk = tb.pk)
|
||||
JOIN t1 AS tc ON (tb.pk = tc.pk)
|
||||
JOIN t4 AS td ON tc.a = td.a) tu)
|
||||
limit 10;
|
||||
|
||||
SELECT * FROM t3 AS tX JOIN t2 AS tY ON (tX.pk = tY.pk)
|
||||
WHERE
|
||||
tX.pk IN
|
||||
(SELECT *
|
||||
FROM (SELECT DISTINCT tA.pk
|
||||
FROM t3 AS tA
|
||||
JOIN t2 AS tB ON (tA.pk = tB.pk)
|
||||
JOIN t1 AS tC ON (tB.pk = tC.pk)
|
||||
JOIN t4 AS tD ON tC.a = tD.a) tU)
|
||||
limit 10;
|
||||
|
||||
drop table t1, t2, t3, t4;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
@ -1469,6 +1469,20 @@ WHERE a = (
|
||||
GROUP BY 1;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
#
|
||||
# MDEV-736 LP:1004615 - Unexpected warnings "Encountered illegal value '' when converting to DECIMAL" on a query with aggregate functions and GROUP BY
|
||||
#
|
||||
|
||||
FLUSH STATUS; # this test case *must* use Aria temp tables
|
||||
|
||||
CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob);
|
||||
INSERT INTO t1 values(11,NULL,'blob'),(11,NULL,'blob');
|
||||
SELECT f3, MIN(f2) FROM t1 GROUP BY f1 LIMIT 1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo the value below *must* be 1
|
||||
show status like 'Created_tmp_disk_tables';
|
||||
|
||||
--echo # End of 5.3 tests
|
||||
|
||||
--echo #
|
||||
|
@ -1444,6 +1444,17 @@ SELECT length(CAST(b AS CHAR)) FROM ubig;
|
||||
|
||||
DROP TABLE ubig;
|
||||
|
||||
#
|
||||
# Bug #13889741: HANDLE_FATAL_SIGNAL IN _DB_ENTER_ | HANDLE_FATAL_SIGNAL IN STRNLEN
|
||||
#
|
||||
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
|
||||
grant usage on *.* to mysqltest_1@localhost;
|
||||
connect (con1, localhost, mysqltest_1,,);
|
||||
connection con1;
|
||||
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
|
||||
connection default;
|
||||
disconnect con1;
|
||||
drop user mysqltest_1@localhost;
|
||||
|
||||
--echo End of 5.1 tests.
|
||||
|
||||
|
@ -15,6 +15,7 @@ show tables;
|
||||
# Bug#18925: subqueries with MIN/MAX functions on INFORMATION_SCHEMA
|
||||
#
|
||||
|
||||
--sorted_result
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
@ -29,6 +30,7 @@ SELECT t.table_name, c1.column_name
|
||||
c2.table_name = t.table_name AND
|
||||
c2.column_name LIKE '%SCHEMA%'
|
||||
) order by t.table_name;
|
||||
--sorted_result
|
||||
SELECT t.table_name, c1.column_name
|
||||
FROM information_schema.tables t
|
||||
INNER JOIN
|
||||
|
@ -287,6 +287,27 @@ select o_orderkey, p_partkey
|
||||
and o_orderkey=l_orderkey and p_partkey=l_partkey;
|
||||
show status like 'handler_read%';
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-3851: ref access used instead of expected eq_ref access
|
||||
--echo # when extended_keys=on
|
||||
--echo #
|
||||
|
||||
create table t0 (a int);
|
||||
insert into t0 values (1), (2), (3), (4), (5);
|
||||
create index i_p_size on part(p_size);
|
||||
|
||||
set optimizer_switch='extended_keys=on';
|
||||
|
||||
explain
|
||||
select * from t0, part ignore index (primary)
|
||||
where p_partkey=t0.a and p_size=1;
|
||||
|
||||
select * from t0, part ignore index (primary)
|
||||
where p_partkey=t0.a and p_size=1;
|
||||
|
||||
drop table t0;
|
||||
drop index i_p_size on part;
|
||||
|
||||
DROP DATABASE dbt3_s001;
|
||||
|
||||
use test;
|
||||
@ -407,5 +428,44 @@ set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-3888: INSERT with UPDATE on duplicate keys
|
||||
--echo # with extended_keys=on
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
c2 bigint(20) unsigned NOT NULL,
|
||||
c3 bigint(20) unsigned NOT NULL,
|
||||
c4 varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (c1),
|
||||
UNIQUE KEY uq (c2,c3),
|
||||
KEY c3 (c3),
|
||||
KEY c4 (c4)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
set session optimizer_switch='extended_keys=off';
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
|
||||
DELETE FROM t1;
|
||||
|
||||
set session optimizer_switch='extended_keys=on';
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
INSERT INTO t1 (c2, c3, c4) VALUES (58291525, 2580, 'foobar')
|
||||
ON DUPLICATE KEY UPDATE c4 = VALUES(c4);
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
set optimizer_switch=@save_ext_key_optimizer_switch;
|
||||
SET SESSION STORAGE_ENGINE=DEFAULT;
|
||||
|
||||
|
@ -29,7 +29,7 @@ select "---- -v -v -t ------" as "";
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
|
||||
if (`select count(*) from information_schema.plugins where plugin_name='innodb' and plugin_auth_version > "1.1.8-29.0"`)
|
||||
if (`select count(*) from information_schema.plugins where plugin_name='innodb' and plugin_auth_version > "1.1.8-29.1"`)
|
||||
{
|
||||
# because of lp:1066512 this test shows xtradb I_S plugins, even when
|
||||
# xtradb is supposed to be disabled
|
||||
|
@ -1652,3 +1652,68 @@ DROP TABLE t1;
|
||||
|
||||
--echo End of 5.3 tests
|
||||
|
||||
--echo #
|
||||
--echo # Bug 54599: discarded fast range scan for query with
|
||||
--echo # GROUP BY + ORDER BY + LIMIT
|
||||
--echo #
|
||||
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
|
||||
|
||||
create table t1 (a int, b int, index idx1(a,b), index idx2(b,a));
|
||||
insert into t1
|
||||
select 1000*s4.a+100*s3.a+10*s2.a + s1.a, 1000*s4.a+100*s3.a+10*s2.a+s1.a
|
||||
from t0 s1, t0 s2, t0 s3, t0 s4;
|
||||
--disable_result_log
|
||||
analyze table t1;
|
||||
--enable_result_log
|
||||
|
||||
explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
flush status;
|
||||
--disable_result_log
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt;
|
||||
--enable_result_log
|
||||
show status like '%Handler_read%';
|
||||
|
||||
explain
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
flush status;
|
||||
--disable_result_log
|
||||
select b, count(*) num_cnt from t1
|
||||
where a > 9750 group by b order by num_cnt limit 1;
|
||||
--enable_result_log
|
||||
show status like '%Handler_read%';
|
||||
|
||||
drop table t0, t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #1002508 : the number of expected rows to be examined is off
|
||||
--echo # (bug #13528826)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
|
||||
INSERT INTO t1 VALUES
|
||||
(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
|
||||
CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
|
||||
INSERT INTO t2 VALUES
|
||||
(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
|
||||
(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
|
||||
|
||||
EXPLAIN
|
||||
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
||||
|
||||
|
@ -2395,6 +2395,14 @@ SELECT 1 FROM t1 WHERE b < SOME
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo
|
||||
--echo MDEV-612 Valgrind error in ha_maria::check_if_incompatible_data
|
||||
--echo
|
||||
|
||||
CREATE TABLE t1 (a INT, b INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2;
|
||||
ALTER TABLE t1 ADD KEY (b);
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
--echo #
|
||||
|
@ -675,6 +675,64 @@ SELECT Name, Country, Population FROM City WHERE
|
||||
$cond;
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-585: range vs index-merge with ORDER BY ... LIMIT n
|
||||
--echo # (LP bug #637962)
|
||||
--echo #
|
||||
|
||||
DROP INDEX CountryPopulation ON City;
|
||||
DROP INDEX CountryName ON City;
|
||||
DROP INDEX CityName on City;
|
||||
|
||||
CREATE INDEX Name ON City(Name);
|
||||
CREATE INDEX Population ON City(Population);
|
||||
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000);
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
|
||||
|
||||
set optimizer_switch='index_merge=off';
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
|
||||
FLUSH STATUS;
|
||||
SELECT * FROM City
|
||||
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
|
||||
AND (Population >= 100000 AND Population < 120000)
|
||||
ORDER BY Population LIMIT 5;
|
||||
SHOW STATUS LIKE 'Handler_read_%';
|
||||
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
|
||||
DROP DATABASE world;
|
||||
|
@ -5078,6 +5078,82 @@ SELECT col_int_nokey FROM ot
|
||||
|
||||
DROP TABLE ot,it1,it2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-746
|
||||
--echo # Bug#13651009 WRONG RESULT FROM DERIVED TABLE IF THE SUBQUERY
|
||||
--echo # HAS AN EMPTY RESULT
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk int NOT NULL,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
pk int NOT NULL AUTO_INCREMENT,
|
||||
col_int_nokey int NOT NULL,
|
||||
col_int_key int NOT NULL,
|
||||
col_time_key time NOT NULL,
|
||||
col_varchar_key varchar(1) NOT NULL,
|
||||
col_varchar_nokey varchar(1) NOT NULL,
|
||||
PRIMARY KEY (pk),
|
||||
KEY col_int_key (col_int_key),
|
||||
KEY col_time_key (col_time_key),
|
||||
KEY col_varchar_key (col_varchar_key,col_int_key)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO t2 VALUES (1,4,4,'00:00:00','b','b');
|
||||
|
||||
SET @var2:=4, @var3:=8;
|
||||
|
||||
--echo
|
||||
--echo Testcase without inner subquery
|
||||
|
||||
let $subq=
|
||||
SELECT @var3:=12, sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR
|
||||
sq4_alias1.col_varchar_key = @var3;
|
||||
|
||||
eval EXPLAIN $subq;
|
||||
eval $subq;
|
||||
SELECT @var3;
|
||||
|
||||
# Now as derived table:
|
||||
eval EXPLAIN SELECT * FROM ( $subq ) AS alias3;
|
||||
eval SELECT * FROM ( $subq ) AS alias3;
|
||||
SELECT @var3;
|
||||
|
||||
--echo
|
||||
--echo Testcase with inner subquery; crashed WL#6095
|
||||
SET @var3=8;
|
||||
let $subq=
|
||||
SELECT sq4_alias1.*
|
||||
FROM t1 AS sq4_alias1
|
||||
WHERE (sq4_alias1.col_varchar_key , sq4_alias1.col_varchar_nokey)
|
||||
NOT IN
|
||||
(SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1,
|
||||
c_sq1_alias1.col_varchar_nokey AS c_sq1_field2
|
||||
FROM t2 AS c_sq1_alias1
|
||||
WHERE (c_sq1_alias1.col_int_nokey != @var2
|
||||
OR c_sq1_alias1.pk != @var3));
|
||||
|
||||
eval EXPLAIN $subq;
|
||||
eval $subq;
|
||||
# Now as derived table:
|
||||
eval EXPLAIN SELECT * FROM ( $subq ) AS alias3;
|
||||
eval SELECT * FROM ( $subq ) AS alias3;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo End of 5.2 tests
|
||||
|
||||
--echo #
|
||||
|
@ -203,6 +203,32 @@ SET optimizer_switch=@tmp_optimizer_switch;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-536: LP:1050806 - different result for a query using subquery
|
||||
--echo #
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
|
||||
CREATE TABLE `t1` (
|
||||
`node_uid` bigint(20) unsigned DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`mirror_date` datetime DEFAULT NULL,
|
||||
KEY `date` (`date`)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
|
||||
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-567: Wrong result from a query with correlated subquery if ICP is allowed
|
||||
--echo #
|
||||
@ -220,7 +246,75 @@ SELECT * FROM t3
|
||||
WHERE t1.a = t2.a AND t2.a BETWEEN 7 AND 9
|
||||
AND t3.b = t1.b
|
||||
GROUP BY t1.b);
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
|
||||
set @tmp_mdev567=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
SELECT * FROM t3
|
||||
WHERE a = (SELECT COUNT(DISTINCT t2.b) FROM t1, t2
|
||||
WHERE t1.a = t2.a AND t2.a BETWEEN 7 AND 9
|
||||
AND t3.b = t1.b
|
||||
GROUP BY t1.b);
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@tmp_mdev567;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-614, also MDEV-536, also LP:1050806:
|
||||
--echo # different result for a query using subquery between 5.5.25 and 5.5.27
|
||||
--echo #
|
||||
|
||||
CREATE TABLE `t1` (
|
||||
`node_uid` bigint(20) unsigned DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`mirror_date` datetime DEFAULT NULL,
|
||||
KEY `date` (`date`)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
INSERT INTO `t1` VALUES (2085,'2012-01-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2084,'2012-02-01 00:00:00','2013-01-01 00:00:00');
|
||||
INSERT INTO `t1` VALUES (2088,'2012-03-01 00:00:00','2013-01-01 00:00:00');
|
||||
|
||||
explain
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
|
||||
set @tmp_mdev614=@@optimizer_switch;
|
||||
set optimizer_switch='mrr=off';
|
||||
explain
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
|
||||
SELECT * FROM (
|
||||
SELECT node_uid, date, mirror_date, @result := 0 AS result
|
||||
FROM t1
|
||||
WHERE date < '2012-12-12 12:12:12'
|
||||
AND node_uid in (2085, 2084)
|
||||
ORDER BY mirror_date ASC
|
||||
) AS calculated_result;
|
||||
|
||||
set optimizer_switch=@tmp_mdev614;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
set optimizer_switch=@subselect2_test_tmp;
|
||||
|
||||
|
@ -424,4 +424,32 @@ DROP TABLE t1;
|
||||
SET @bug12408412=1;
|
||||
SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412;
|
||||
|
||||
#
|
||||
# MDEV-616 LP BUG#1002126
|
||||
# Bug #11764371 57196: MORE FUN WITH ASSERTION: !TABLE->FILE ||
|
||||
# TABLE->FILE->INITED == HANDLER::
|
||||
#
|
||||
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0);
|
||||
SELECT DISTINCT POW(COUNT(*), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a))
|
||||
AS b FROM t1 GROUP BY a;
|
||||
SELECT @a;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(f1 INT, f2 INT);
|
||||
INSERT INTO t1 VALUES (1,2),(2,3),(3,1);
|
||||
CREATE TABLE t2(a INT);
|
||||
INSERT INTO t2 VALUES (1);
|
||||
SET @var=NULL;
|
||||
SELECT @var:=(SELECT f2 FROM t2 WHERE @var) FROM t1 GROUP BY f1 ORDER BY f2 DESC
|
||||
LIMIT 1;
|
||||
SELECT @var;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES (0),(1),(3);
|
||||
SELECT DISTINCT POW(COUNT(distinct a), @a:=(SELECT 1 FROM t1 LEFT JOIN t1 AS t2 ON @a limit 1)) AS b FROM t1 GROUP BY a;
|
||||
SELECT @a;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
|
||||
Copyright (c) 2012, Monty Program Ab
|
||||
|
||||
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
|
||||
@ -30,7 +31,7 @@ void pack_dirname(char * to, const char *from)
|
||||
int cwd_err;
|
||||
size_t d_length,length,UNINIT_VAR(buff_length);
|
||||
char * start;
|
||||
char buff[FN_REFLEN];
|
||||
char buff[FN_REFLEN + 1];
|
||||
DBUG_ENTER("pack_dirname");
|
||||
|
||||
(void) intern_filename(to,from); /* Change to intern name */
|
||||
@ -127,7 +128,7 @@ size_t cleanup_dirname(register char *to, const char *from)
|
||||
reg3 char * from_ptr;
|
||||
reg4 char * start;
|
||||
char parent[5], /* for "FN_PARENTDIR" */
|
||||
buff[FN_REFLEN+1],*end_parentdir;
|
||||
buff[FN_REFLEN + 1],*end_parentdir;
|
||||
#ifdef BACKSLASH_MBTAIL
|
||||
CHARSET_INFO *fs= fs_character_set();
|
||||
#endif
|
||||
@ -241,7 +242,7 @@ my_bool my_use_symdir=0; /* Set this if you want to use symdirs */
|
||||
#ifdef USE_SYMDIR
|
||||
void symdirget(char *dir)
|
||||
{
|
||||
char buff[FN_REFLEN+1];
|
||||
char buff[FN_REFLEN + 1];
|
||||
char *pos=strend(dir);
|
||||
if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
|
||||
{
|
||||
@ -291,7 +292,7 @@ void symdirget(char *dir)
|
||||
size_t normalize_dirname(char *to, const char *from)
|
||||
{
|
||||
size_t length;
|
||||
char buff[FN_REFLEN];
|
||||
char buff[FN_REFLEN + 1];
|
||||
DBUG_ENTER("normalize_dirname");
|
||||
|
||||
/*
|
||||
@ -418,7 +419,7 @@ static char * expand_tilde(char **path)
|
||||
size_t unpack_filename(char * to, const char *from)
|
||||
{
|
||||
size_t length, n_length, buff_length;
|
||||
char buff[FN_REFLEN];
|
||||
char buff[FN_REFLEN + 1];
|
||||
DBUG_ENTER("unpack_filename");
|
||||
|
||||
length=dirname_part(buff, from, &buff_length);/* copy & convert dirname */
|
||||
@ -448,7 +449,7 @@ size_t system_filename(char *to, const char *from)
|
||||
char *intern_filename(char *to, const char *from)
|
||||
{
|
||||
size_t length, to_length;
|
||||
char buff[FN_REFLEN];
|
||||
char buff[FN_REFLEN + 1];
|
||||
if (from == to)
|
||||
{ /* Dirname may destroy from */
|
||||
strmov(buff,from);
|
||||
|
@ -206,7 +206,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
|
||||
(
|
||||
"movq %%rsp, (%[save])\n\t"
|
||||
"movq %[stack], %%rsp\n\t"
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
|
||||
/*
|
||||
This emits a DWARF DW_CFA_undefined directive to make the return address
|
||||
undefined. This indicates that this is the top of the stack frame, and
|
||||
@ -456,7 +456,7 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
|
||||
(
|
||||
"movl %%esp, (%[save])\n\t"
|
||||
"movl %[stack], %%esp\n\t"
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
|
||||
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 && !defined(__INTEL_COMPILER)
|
||||
/*
|
||||
This emits a DWARF DW_CFA_undefined directive to make the return address
|
||||
undefined. This indicates that this is the top of the stack frame, and
|
||||
|
@ -145,7 +145,7 @@ mysql_declare_plugin(audit_null)
|
||||
{
|
||||
MYSQL_AUDIT_PLUGIN, /* type */
|
||||
&audit_null_descriptor, /* descriptor */
|
||||
"NULL_AUDIT", /* name */
|
||||
"AUDIT_NULL", /* name */
|
||||
"Oracle Corp", /* author */
|
||||
"Simple NULL Audit", /* description */
|
||||
PLUGIN_LICENSE_GPL,
|
||||
|
@ -1,9 +1,11 @@
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex
|
||||
${CMAKE_SOURCE_DIR}/extra/yassl/include)
|
||||
${SSL_INCLUDE_DIRS})
|
||||
|
||||
SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc
|
||||
url_base.cc url_http.cc utils.cc)
|
||||
|
||||
ADD_DEFINITIONS(${SSL_DEFINES})
|
||||
|
||||
INCLUDE (CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES (netdb.h HAVE_NETDB_H)
|
||||
IF(HAVE_NETDB_H)
|
||||
@ -11,8 +13,10 @@ IF(HAVE_NETDB_H)
|
||||
ENDIF(HAVE_NETDB_H)
|
||||
|
||||
IF(WIN32)
|
||||
#SET(FEEDBACK_LIBS Ws2_32)
|
||||
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES} STATIC_ONLY DEFAULT)
|
||||
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}
|
||||
LINK_LIBRARIES ${SSL_LIBRARIES}
|
||||
STATIC_ONLY DEFAULT)
|
||||
ELSE(WIN32)
|
||||
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES})
|
||||
MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}
|
||||
LINK_LIBRARIES ${SSL_LIBRARIES})
|
||||
ENDIF(WIN32)
|
||||
|
@ -29,12 +29,6 @@ namespace feedback {
|
||||
static const uint FOR_READING= 0;
|
||||
static const uint FOR_WRITING= 1;
|
||||
|
||||
#ifdef MARIADB_BASE_VERSION
|
||||
#define ssl_connect(A,B,C,D) sslconnect(A,B,C,D)
|
||||
#else
|
||||
#define ssl_connect(A,B,C,D) sslconnect(A,B,C)
|
||||
#endif
|
||||
|
||||
/**
|
||||
implementation of the Url class that sends the data via HTTP POST request.
|
||||
|
||||
@ -199,12 +193,23 @@ int Url_http::send(const char* data, size_t data_length)
|
||||
struct st_VioSSLFd *UNINIT_VAR(ssl_fd);
|
||||
if (ssl)
|
||||
{
|
||||
buf[0]= 0;
|
||||
if (!(ssl_fd= new_VioSSLConnectorFd(0, 0, 0, 0, 0)) ||
|
||||
ssl_connect(ssl_fd, vio, send_timeout, buf))
|
||||
enum enum_ssl_init_error ssl_init_error= SSL_INITERR_NOERROR;
|
||||
ulong ssl_error= 0;
|
||||
if (!(ssl_fd= new_VioSSLConnectorFd(0, 0, 0, 0, 0, &ssl_init_error)) ||
|
||||
sslconnect(ssl_fd, vio, send_timeout, &ssl_error))
|
||||
{
|
||||
const char *err;
|
||||
if (ssl_init_error != SSL_INITERR_NOERROR)
|
||||
err= sslGetErrString(ssl_init_error);
|
||||
else
|
||||
{
|
||||
ERR_error_string_n(ssl_error, buf, sizeof(buf));
|
||||
buf[sizeof(buf)-1]= 0;
|
||||
err= buf;
|
||||
}
|
||||
|
||||
sql_print_error("feedback plugin: ssl failed for url '%s' %s",
|
||||
full_url.str, buf);
|
||||
full_url.str, err);
|
||||
if (ssl_fd)
|
||||
free_vio_ssl_acceptor_fd(ssl_fd);
|
||||
closesocket(fd);
|
||||
@ -256,18 +261,21 @@ int Url_http::send(const char* data, size_t data_length)
|
||||
Extract the first string between <h1>...</h1> tags
|
||||
and put it as a server reply into the error log.
|
||||
*/
|
||||
len= 0;
|
||||
for (;;)
|
||||
{
|
||||
size_t i= vio_read(vio, (uchar*)buf + len, sizeof(buf) - len - 1);
|
||||
size_t i= sizeof(buf) - len - 1;
|
||||
if (i)
|
||||
i= vio_read(vio, (uchar*)buf + len, i);
|
||||
if ((int)i <= 0)
|
||||
break;
|
||||
len+= i;
|
||||
}
|
||||
if (len && len < sizeof(buf))
|
||||
if (len)
|
||||
{
|
||||
char *from;
|
||||
|
||||
buf[len+1]= 0; // safety
|
||||
buf[len]= 0; // safety
|
||||
|
||||
if ((from= strstr(buf, "<h1>")))
|
||||
{
|
||||
@ -296,7 +304,7 @@ int Url_http::send(const char* data, size_t data_length)
|
||||
if (ssl)
|
||||
{
|
||||
SSL_CTX_free(ssl_fd->ssl_context);
|
||||
my_free(ssl_fd, MYF(0));
|
||||
my_free(ssl_fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -92,11 +92,7 @@ plugindir_rel=`echo $plugindir | sed -e "s;^$basedir/;;"`
|
||||
fix_path plugindir $plugindir_rel lib/mysql/plugin lib/plugin
|
||||
|
||||
pkgincludedir='@pkgincludedir@'
|
||||
if [ -f "$basedir/include/mysql/mysql.h" ]; then
|
||||
pkgincludedir="$basedir/include/mysql"
|
||||
elif [ -f "$basedir/include/mysql.h" ]; then
|
||||
pkgincludedir="$basedir/include"
|
||||
fi
|
||||
fix_path pkgincludedir include/mysql
|
||||
|
||||
version='@VERSION@'
|
||||
socket='@MYSQL_UNIX_ADDR@'
|
||||
@ -125,8 +121,11 @@ if [ -r "$pkglibdir/libmygcc.a" ]; then
|
||||
embedded_libs="$embedded_libs -lmygcc "
|
||||
fi
|
||||
|
||||
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
|
||||
include="-I$pkgincludedir"
|
||||
if [ "$basedir" != "/usr" ]; then
|
||||
include="$include -I$pkgincludedir/.."
|
||||
fi
|
||||
cflags="$include @CFLAGS@ " #note: end space!
|
||||
|
||||
# Remove some options that a client doesn't have to care about
|
||||
# FIXME until we have a --cxxflags, we need to remove -Xa
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
# -*- cperl -*-
|
||||
#
|
||||
# Copyright (c) 2007, 2012, Oracle and/or its affiliates
|
||||
# Copyright (c) 2007, 2012, Oracle and/or its affiliates.
|
||||
#
|
||||
# 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
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2002, 2012, Oracle and/or its affiliates
|
||||
# Copyright (c) 2002, 2012, Oracle and/or its affiliates.
|
||||
#
|
||||
# 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
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#!@PERL@
|
||||
# Test of table elimination feature
|
||||
|
||||
@ -93,7 +92,7 @@ $dbh->do("create view elim_current_facts as $select_current_full_facts");
|
||||
|
||||
if ($opt_lock_tables)
|
||||
{
|
||||
do_query($dbh,"LOCK TABLES elim_facts, elim_attr1, elim_attr2 WRITE");
|
||||
do_query($dbh,"LOCK TABLES elim_current_facts WRITE, elim_facts WRITE, elim_attr1 WRITE, elim_attr2 WRITE");
|
||||
}
|
||||
|
||||
if ($opt_fast && defined($server->{vacuum}))
|
||||
@ -200,12 +199,14 @@ if ($opt_lock_tables)
|
||||
|
||||
if ($opt_fast && defined($server->{vacuum}))
|
||||
{
|
||||
$server->vacuum(0,\$dbh,["elim_facts", "elim_attr1", "elim_attr2"]);
|
||||
$server->vacuum(1,\$dbh,"elim_facts");
|
||||
$server->vacuum(1,\$dbh,"elim_attr1");
|
||||
$server->vacuum(1,\$dbh,"elim_attr2");
|
||||
}
|
||||
|
||||
if ($opt_lock_tables)
|
||||
{
|
||||
do_query($dbh,"LOCK TABLES elim_facts, elim_attr1, elim_attr2 WRITE");
|
||||
do_query($dbh,"LOCK TABLES elim_current_facts READ, elim_facts READ, elim_attr1 READ, elim_attr2 READ");
|
||||
}
|
||||
|
||||
####
|
||||
|
@ -4651,8 +4651,8 @@ int ha_partition::common_index_read(uchar *buf, bool have_start_key)
|
||||
bool reverse_order= FALSE;
|
||||
DBUG_ENTER("ha_partition::common_index_read");
|
||||
|
||||
DBUG_PRINT("info", ("m_ordered %u m_ordered_scan_ong %u have_start_key %u",
|
||||
m_ordered, m_ordered_scan_ongoing, have_start_key));
|
||||
DBUG_PRINT("info", ("m_ordered: %u have_start_key: %u",
|
||||
m_ordered, have_start_key));
|
||||
|
||||
if (have_start_key)
|
||||
{
|
||||
|
@ -1569,6 +1569,15 @@ public:
|
||||
:Item_func(b), cached_result_type(INT_RESULT),
|
||||
entry(NULL), entry_thread_id(0), name(a)
|
||||
{}
|
||||
Item_func_set_user_var(Item_func_set_user_var *item)
|
||||
:Item_func(item), cached_result_type(item->cached_result_type),
|
||||
entry(item->entry), entry_thread_id(item->entry_thread_id),
|
||||
value(item->value), decimal_buff(item->decimal_buff),
|
||||
null_item(item->null_item), save_result(item->save_result),
|
||||
name(item->name)
|
||||
{
|
||||
//fixed= 1;
|
||||
}
|
||||
enum Functype functype() const { return SUSERVAR_FUNC; }
|
||||
double val_real();
|
||||
longlong val_int();
|
||||
|
@ -2521,9 +2521,8 @@ Item_sum_hybrid::min_max_update_int_field()
|
||||
void
|
||||
Item_sum_hybrid::min_max_update_decimal_field()
|
||||
{
|
||||
/* TODO: optimize: do not get result_field in case of args[0] is NULL */
|
||||
my_decimal old_val, nr_val;
|
||||
const my_decimal *old_nr= result_field->val_decimal(&old_val);
|
||||
const my_decimal *old_nr;
|
||||
const my_decimal *nr= args[0]->val_decimal(&nr_val);
|
||||
if (!args[0]->null_value)
|
||||
{
|
||||
@ -2531,16 +2530,17 @@ Item_sum_hybrid::min_max_update_decimal_field()
|
||||
old_nr=nr;
|
||||
else
|
||||
{
|
||||
old_nr= result_field->val_decimal(&old_val);
|
||||
bool res= my_decimal_cmp(old_nr, nr) > 0;
|
||||
/* (cmp_sign > 0 && res) || (!(cmp_sign > 0) && !res) */
|
||||
if ((cmp_sign > 0) ^ (!res))
|
||||
old_nr=nr;
|
||||
}
|
||||
result_field->set_notnull();
|
||||
result_field->store_decimal(old_nr);
|
||||
}
|
||||
else if (result_field->is_null(0))
|
||||
result_field->set_null();
|
||||
result_field->store_decimal(old_nr);
|
||||
}
|
||||
|
||||
|
||||
|
54
sql/log.cc
54
sql/log.cc
@ -1279,12 +1279,6 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
|
||||
|
||||
DBUG_ASSERT(thd);
|
||||
|
||||
lock_shared();
|
||||
if (!opt_log)
|
||||
{
|
||||
unlock();
|
||||
return 0;
|
||||
}
|
||||
user_host_len= make_user_name(thd, user_host_buff);
|
||||
|
||||
current_time= my_hrtime();
|
||||
@ -1295,15 +1289,19 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
|
||||
command_name[(uint) command].length,
|
||||
query, query_length);
|
||||
|
||||
while (*current_handler)
|
||||
error|= (*current_handler++)->
|
||||
log_general(thd, current_time, user_host_buff,
|
||||
user_host_len, thd->thread_id,
|
||||
command_name[(uint) command].str,
|
||||
command_name[(uint) command].length,
|
||||
query, query_length,
|
||||
thd->variables.character_set_client) || error;
|
||||
unlock();
|
||||
if (opt_log && log_command(thd, command))
|
||||
{
|
||||
lock_shared();
|
||||
while (*current_handler)
|
||||
error|= (*current_handler++)->
|
||||
log_general(thd, current_time, user_host_buff,
|
||||
user_host_len, thd->thread_id,
|
||||
command_name[(uint) command].str,
|
||||
command_name[(uint) command].length,
|
||||
query, query_length,
|
||||
thd->variables.character_set_client) || error;
|
||||
unlock();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -5333,7 +5331,7 @@ bool general_log_write(THD *thd, enum enum_server_command command,
|
||||
const char *query, uint query_length)
|
||||
{
|
||||
/* Write the message to the log if we want to log this king of commands */
|
||||
if (logger.log_command(thd, command))
|
||||
if (logger.log_command(thd, command) || mysql_audit_general_enabled())
|
||||
return logger.general_log_write(thd, command, query, query_length);
|
||||
|
||||
return FALSE;
|
||||
@ -6963,8 +6961,9 @@ int TC_LOG_MMAP::open(const char *opt_name)
|
||||
|
||||
syncing= 0;
|
||||
active=pages;
|
||||
DBUG_ASSERT(npages >= 2);
|
||||
pool=pages+1;
|
||||
pool_last=pages+npages-1;
|
||||
pool_last_ptr= &((pages+npages-1)->next);
|
||||
commit_ordered_queue= NULL;
|
||||
commit_ordered_queue_busy= false;
|
||||
|
||||
@ -6997,8 +6996,8 @@ void TC_LOG_MMAP::get_active_from_pool()
|
||||
do
|
||||
{
|
||||
best_p= p= &pool;
|
||||
if ((*p)->waiters == 0) // can the first page be used ?
|
||||
break; // yes - take it.
|
||||
if ((*p)->waiters == 0 && (*p)->free > 0) // can the first page be used ?
|
||||
break; // yes - take it.
|
||||
|
||||
best_free=0; // no - trying second strategy
|
||||
for (p=&(*p)->next; *p; p=&(*p)->next)
|
||||
@ -7015,10 +7014,10 @@ void TC_LOG_MMAP::get_active_from_pool()
|
||||
mysql_mutex_assert_owner(&LOCK_active);
|
||||
active=*best_p;
|
||||
|
||||
if ((*best_p)->next) // unlink the page from the pool
|
||||
*best_p=(*best_p)->next;
|
||||
else
|
||||
pool_last=*best_p;
|
||||
/* Unlink the page from the pool. */
|
||||
if (!(*best_p)->next)
|
||||
pool_last_ptr= best_p;
|
||||
*best_p=(*best_p)->next;
|
||||
mysql_mutex_unlock(&LOCK_pool);
|
||||
|
||||
mysql_mutex_lock(&active->lock);
|
||||
@ -7125,12 +7124,9 @@ int TC_LOG_MMAP::log_one_transaction(my_xid xid)
|
||||
mysql_mutex_unlock(&LOCK_active);
|
||||
mysql_mutex_lock(&p->lock);
|
||||
p->waiters++;
|
||||
for (;;)
|
||||
while (p->state == PS_DIRTY && syncing)
|
||||
{
|
||||
int not_dirty = p->state != PS_DIRTY;
|
||||
mysql_mutex_unlock(&p->lock);
|
||||
if (not_dirty || !syncing)
|
||||
break;
|
||||
mysql_cond_wait(&p->cond, &LOCK_sync);
|
||||
mysql_mutex_lock(&p->lock);
|
||||
}
|
||||
@ -7182,8 +7178,8 @@ int TC_LOG_MMAP::sync()
|
||||
|
||||
/* page is synced. let's move it to the pool */
|
||||
mysql_mutex_lock(&LOCK_pool);
|
||||
pool_last->next=syncing;
|
||||
pool_last=syncing;
|
||||
(*pool_last_ptr)=syncing;
|
||||
pool_last_ptr=&(syncing->next);
|
||||
syncing->next=0;
|
||||
syncing->state= err ? PS_ERROR : PS_POOL;
|
||||
mysql_cond_signal(&COND_pool); // in case somebody's waiting
|
||||
|
@ -134,7 +134,7 @@ class TC_LOG_MMAP: public TC_LOG
|
||||
my_off_t file_length;
|
||||
uint npages, inited;
|
||||
uchar *data;
|
||||
struct st_page *pages, *syncing, *active, *pool, *pool_last;
|
||||
struct st_page *pages, *syncing, *active, *pool, **pool_last_ptr;
|
||||
/*
|
||||
note that, e.g. LOCK_active is only used to protect
|
||||
'active' pointer, to protect the content of the active page
|
||||
|
@ -10943,6 +10943,13 @@ int QUICK_RANGE_SELECT::reset()
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::reset");
|
||||
last_range= NULL;
|
||||
cur_range= (QUICK_RANGE**) ranges.buffer;
|
||||
|
||||
if (file->inited == handler::RND)
|
||||
{
|
||||
/* Handler could be left in this state by MRR */
|
||||
if ((error= file->ha_rnd_end()))
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
if (file->inited == handler::NONE)
|
||||
{
|
||||
|
@ -3113,8 +3113,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
|
||||
(the order of query cache and subst_spvars calls is irrelevant because
|
||||
queries with SP vars can't be cached)
|
||||
*/
|
||||
if (unlikely((thd->variables.option_bits & OPTION_LOG_OFF)==0))
|
||||
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
|
||||
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
|
||||
|
||||
if (query_cache_send_result_to_client(thd, thd->query(),
|
||||
thd->query_length()) <= 0)
|
||||
|
@ -1633,14 +1633,20 @@ ulong acl_get(const char *host, const char *ip,
|
||||
acl_entry *entry;
|
||||
DBUG_ENTER("acl_get");
|
||||
|
||||
mysql_mutex_lock(&acl_cache->lock);
|
||||
end=strmov((tmp_db=strmov(strmov(key, ip ? ip : "")+1,user)+1),db);
|
||||
tmp_db= strmov(strmov(key, ip ? ip : "") + 1, user) + 1;
|
||||
end= strnmov(tmp_db, db, key + sizeof(key) - tmp_db);
|
||||
|
||||
if (end >= key + sizeof(key)) // db name was truncated
|
||||
DBUG_RETURN(0); // no privileges for an invalid db name
|
||||
|
||||
if (lower_case_table_names)
|
||||
{
|
||||
my_casedn_str(files_charset_info, tmp_db);
|
||||
db=tmp_db;
|
||||
}
|
||||
key_length= (size_t) (end-key);
|
||||
|
||||
mysql_mutex_lock(&acl_cache->lock);
|
||||
if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search((uchar*) key,
|
||||
key_length)))
|
||||
{
|
||||
@ -4954,11 +4960,17 @@ static bool check_grant_db_routine(THD *thd, const char *db, HASH *hash)
|
||||
bool check_grant_db(THD *thd,const char *db)
|
||||
{
|
||||
Security_context *sctx= thd->security_ctx;
|
||||
char helping [SAFE_NAME_LEN + USERNAME_LENGTH+2];
|
||||
char helping [SAFE_NAME_LEN + USERNAME_LENGTH+2], *end;
|
||||
uint len;
|
||||
bool error= TRUE;
|
||||
|
||||
len= (uint) (strmov(strmov(helping, sctx->priv_user) + 1, db) - helping) + 1;
|
||||
end= strmov(helping, sctx->priv_user) + 1;
|
||||
end= strnmov(end, db, helping + sizeof(helping) - end);
|
||||
|
||||
if (end >= helping + sizeof(helping)) // db name was truncated
|
||||
return 1; // no privileges for an invalid db name
|
||||
|
||||
len= (uint) (end - helping) + 1;
|
||||
|
||||
mysql_rwlock_rdlock(&LOCK_grant);
|
||||
|
||||
|
@ -37,8 +37,16 @@ extern void mysql_audit_acquire_plugins(THD *thd, uint event_class);
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
extern void mysql_audit_notify(THD *thd, uint event_class,
|
||||
uint event_subtype, ...);
|
||||
|
||||
static inline bool mysql_audit_general_enabled()
|
||||
{
|
||||
return mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK;
|
||||
}
|
||||
|
||||
#else
|
||||
#define mysql_audit_notify(...)
|
||||
static inline void mysql_audit_notify(THD *thd, uint event_class,
|
||||
uint event_subtype, ...) { }
|
||||
#define mysql_audit_general_enabled() 0
|
||||
#endif
|
||||
extern void mysql_audit_release(THD *thd);
|
||||
|
||||
@ -72,8 +80,7 @@ void mysql_audit_general_log(THD *thd, time_t time,
|
||||
const char *cmd, uint cmdlen,
|
||||
const char *query, uint querylen)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK)
|
||||
if (mysql_audit_general_enabled())
|
||||
{
|
||||
CHARSET_INFO *clientcs= thd ? thd->variables.character_set_client
|
||||
: global_system_variables.character_set_client;
|
||||
@ -82,7 +89,6 @@ void mysql_audit_general_log(THD *thd, time_t time,
|
||||
0, time, user, userlen, cmd, cmdlen,
|
||||
query, querylen, clientcs, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,8 +107,7 @@ static inline
|
||||
void mysql_audit_general(THD *thd, uint event_subtype,
|
||||
int error_code, const char *msg)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK)
|
||||
if (mysql_audit_general_enabled())
|
||||
{
|
||||
time_t time= my_time(0);
|
||||
uint msglen= msg ? strlen(msg) : 0;
|
||||
@ -130,7 +135,6 @@ void mysql_audit_general(THD *thd, uint event_subtype,
|
||||
error_code, time, user, userlen, msg, msglen,
|
||||
query.str(), query.length(), query.charset(), rows);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
|
||||
|
@ -8909,7 +8909,9 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
|
||||
/* Update virtual fields*/
|
||||
thd->abort_on_warning= FALSE;
|
||||
if (vcol_table && vcol_table->vfield &&
|
||||
update_virtual_fields(thd, vcol_table, TRUE))
|
||||
update_virtual_fields(thd, vcol_table,
|
||||
vcol_table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_WRITE))
|
||||
goto err;
|
||||
thd->abort_on_warning= save_abort_on_warning;
|
||||
thd->no_errors= save_no_errors;
|
||||
@ -8973,7 +8975,9 @@ fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields,
|
||||
if (item_field && item_field->field &&
|
||||
(table= item_field->field->table) &&
|
||||
table->vfield)
|
||||
result= update_virtual_fields(thd, table, TRUE);
|
||||
result= update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_WRITE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -9057,7 +9061,10 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors,
|
||||
}
|
||||
/* Update virtual fields*/
|
||||
thd->abort_on_warning= FALSE;
|
||||
if (table->vfield && update_virtual_fields(thd, table, TRUE))
|
||||
if (table->vfield &&
|
||||
update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_WRITE))
|
||||
goto err;
|
||||
thd->abort_on_warning= abort_on_warning_saved;
|
||||
DBUG_RETURN(thd->is_error());
|
||||
@ -9110,7 +9117,9 @@ fill_record_n_invoke_before_triggers(THD *thd, Field **ptr,
|
||||
{
|
||||
TABLE *table= (*ptr)->table;
|
||||
if (table->vfield)
|
||||
result= update_virtual_fields(thd, table, TRUE);
|
||||
result= update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_WRITE);
|
||||
}
|
||||
return result;
|
||||
|
||||
|
@ -306,7 +306,8 @@ TABLE *find_table_for_mdl_upgrade(THD *thd, const char *db,
|
||||
bool no_error);
|
||||
void mark_tmp_table_for_reuse(TABLE *table);
|
||||
bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists);
|
||||
int update_virtual_fields(THD *thd, TABLE *table, bool ignore_stored= FALSE);
|
||||
int update_virtual_fields(THD *thd, TABLE *table,
|
||||
enum enum_vcol_update_mode vcol_update_mode= VCOL_UPDATE_FOR_READ);
|
||||
int dynamic_column_error_message(enum_dyncol_func_result rc);
|
||||
|
||||
/* open_and_lock_tables with optional derived handling */
|
||||
|
@ -329,7 +329,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
! thd->is_error())
|
||||
{
|
||||
if (table->vfield)
|
||||
update_virtual_fields(thd, table);
|
||||
update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_READ);
|
||||
thd->examined_row_count++;
|
||||
// thd->is_error() is tested to disallow delete row on error
|
||||
if (!select || select->skip_record(thd) > 0)
|
||||
|
@ -1677,9 +1677,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
}
|
||||
}
|
||||
key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0);
|
||||
key_part_map keypart_map= (1 << table->key_info[key_nr].key_parts) - 1;
|
||||
if ((error= (table->file->ha_index_read_idx_map(table->record[1],
|
||||
key_nr, (uchar*) key,
|
||||
HA_WHOLE_KEY,
|
||||
keypart_map,
|
||||
HA_READ_KEY_EXACT))))
|
||||
goto err;
|
||||
}
|
||||
|
@ -6717,8 +6717,10 @@ void sql_kill(THD *thd, ulong id, killed_state state)
|
||||
uint error;
|
||||
if (!(error= kill_one_thread(thd, id, state)))
|
||||
{
|
||||
if (! thd->killed)
|
||||
if ((!thd->killed))
|
||||
my_ok(thd);
|
||||
else
|
||||
my_error(killed_errno(thd->killed), MYF(0), id);
|
||||
}
|
||||
else
|
||||
my_error(error, MYF(0), id);
|
||||
|
@ -2505,14 +2505,24 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
|
||||
*/
|
||||
if (sl->prep_where)
|
||||
{
|
||||
sl->where= sl->prep_where->copy_andor_structure(thd);
|
||||
/*
|
||||
We need this rollback because memory allocated in
|
||||
copy_andor_structure() will be freed
|
||||
*/
|
||||
thd->change_item_tree((Item**)&sl->where,
|
||||
sl->prep_where->copy_andor_structure(thd));
|
||||
sl->where->cleanup();
|
||||
}
|
||||
else
|
||||
sl->where= NULL;
|
||||
if (sl->prep_having)
|
||||
{
|
||||
sl->having= sl->prep_having->copy_andor_structure(thd);
|
||||
/*
|
||||
We need this rollback because memory allocated in
|
||||
copy_andor_structure() will be freed
|
||||
*/
|
||||
thd->change_item_tree((Item**)&sl->having,
|
||||
sl->prep_having->copy_andor_structure(thd));
|
||||
sl->having->cleanup();
|
||||
}
|
||||
else
|
||||
|
@ -1233,11 +1233,9 @@ JOIN::optimize()
|
||||
DBUG_RETURN(1); // error == -1
|
||||
}
|
||||
if (const_table_map != found_const_table_map &&
|
||||
!(select_options & SELECT_DESCRIBE) &&
|
||||
(!conds ||
|
||||
!(conds->used_tables() & RAND_TABLE_BIT) ||
|
||||
select_lex->master_unit() == &thd->lex->unit)) // upper level SELECT
|
||||
!(select_options & SELECT_DESCRIBE))
|
||||
{
|
||||
// There is at least one empty const table
|
||||
zero_result_cause= "no matching row in const table";
|
||||
DBUG_PRINT("error",("Error: %s", zero_result_cause));
|
||||
error= 0;
|
||||
@ -5380,7 +5378,8 @@ best_access_path(JOIN *join,
|
||||
!ref_or_null_part)
|
||||
{ /* use eq key */
|
||||
max_key_part= (uint) ~0;
|
||||
if ((key_flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME)
|
||||
if ((key_flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME ||
|
||||
test(key_flags & HA_EXT_NOSAME))
|
||||
{
|
||||
tmp = prev_record_reads(join->positions, idx, found_ref);
|
||||
records=1.0;
|
||||
@ -7969,18 +7968,23 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
|
||||
*ref_key=0; // end_marker
|
||||
if (j->type == JT_FT)
|
||||
DBUG_RETURN(0);
|
||||
ulong key_flags= j->table->actual_key_flags(keyinfo);
|
||||
if (j->type == JT_CONST)
|
||||
j->table->const_table= 1;
|
||||
else if (((j->table->actual_key_flags(keyinfo) &
|
||||
(HA_NOSAME | HA_NULL_PART_KEY))
|
||||
!= HA_NOSAME) ||
|
||||
else if (((key_flags & (HA_NOSAME | HA_NULL_PART_KEY))!= HA_NOSAME) ||
|
||||
keyparts != j->table->actual_n_key_parts(keyinfo) ||
|
||||
null_ref_key)
|
||||
{
|
||||
/* Must read with repeat */
|
||||
j->type= null_ref_key ? JT_REF_OR_NULL : JT_REF;
|
||||
j->ref.null_ref_key= null_ref_key;
|
||||
j->ref.null_ref_part= null_ref_part;
|
||||
if (test(key_flags & HA_EXT_NOSAME) && keyparts == keyinfo->ext_key_parts &&
|
||||
!null_ref_key)
|
||||
j->type= JT_EQ_REF;
|
||||
else
|
||||
{
|
||||
/* Must read with repeat */
|
||||
j->type= null_ref_key ? JT_REF_OR_NULL : JT_REF;
|
||||
j->ref.null_ref_key= null_ref_key;
|
||||
j->ref.null_ref_part= null_ref_part;
|
||||
}
|
||||
}
|
||||
else if (keyuse_uses_no_tables)
|
||||
{
|
||||
@ -9140,7 +9144,7 @@ void JOIN::drop_unused_derived_keys()
|
||||
JOIN_TAB *tab;
|
||||
for (tab= first_linear_tab(this, WITHOUT_CONST_TABLES);
|
||||
tab;
|
||||
tab= next_linear_tab(this, tab, WITHOUT_BUSH_ROOTS))
|
||||
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||
{
|
||||
|
||||
TABLE *table=tab->table;
|
||||
@ -10606,9 +10610,22 @@ void JOIN::cleanup(bool full)
|
||||
|
||||
if (full)
|
||||
{
|
||||
JOIN_TAB *sort_tab= first_linear_tab(this, WITHOUT_CONST_TABLES);
|
||||
if (pre_sort_join_tab)
|
||||
{
|
||||
if (sort_tab && sort_tab->select == pre_sort_join_tab->select)
|
||||
{
|
||||
pre_sort_join_tab->select= NULL;
|
||||
}
|
||||
else
|
||||
clean_pre_sort_join_tab();
|
||||
}
|
||||
|
||||
for (tab= first_linear_tab(this, WITH_CONST_TABLES); tab;
|
||||
tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||
{
|
||||
tab->cleanup();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -16488,6 +16505,17 @@ int safe_index_read(JOIN_TAB *tab)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reads content of constant table
|
||||
|
||||
@param tab table
|
||||
@param pos position of table in query plan
|
||||
|
||||
@retval 0 ok, one row was found or one NULL-complemented row was created
|
||||
@retval -1 ok, no row was found and no NULL-complemented row was created
|
||||
@retval 1 error
|
||||
*/
|
||||
|
||||
static int
|
||||
join_read_const_table(JOIN_TAB *tab, POSITION *pos)
|
||||
{
|
||||
@ -16606,6 +16634,16 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read a constant table when there is at most one matching row, using a table
|
||||
scan.
|
||||
|
||||
@param tab Table to read
|
||||
|
||||
@retval 0 Row was found
|
||||
@retval -1 Row was not found
|
||||
@retval 1 Got an error (other than row not found) during read
|
||||
*/
|
||||
static int
|
||||
join_read_system(JOIN_TAB *tab)
|
||||
{
|
||||
@ -16638,12 +16676,9 @@ join_read_system(JOIN_TAB *tab)
|
||||
|
||||
@param tab Table to read
|
||||
|
||||
@retval
|
||||
0 Row was found
|
||||
@retval
|
||||
-1 Row was not found
|
||||
@retval
|
||||
1 Got an error (other than row not found) during read
|
||||
@retval 0 Row was found
|
||||
@retval -1 Row was not found
|
||||
@retval 1 Got an error (other than row not found) during read
|
||||
*/
|
||||
|
||||
static int
|
||||
@ -18478,15 +18513,18 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
||||
*/
|
||||
|
||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
|
||||
quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT)
|
||||
goto use_filesort;
|
||||
ref_key= select->quick->index;
|
||||
ref_key_parts= select->quick->used_key_parts;
|
||||
ref_key= MAX_KEY;
|
||||
else
|
||||
{
|
||||
ref_key= select->quick->index;
|
||||
ref_key_parts= select->quick->used_key_parts;
|
||||
}
|
||||
}
|
||||
|
||||
if (ref_key >= 0)
|
||||
if (ref_key >= 0 && ref_key != MAX_KEY)
|
||||
{
|
||||
/*
|
||||
We come here when there is a REF key.
|
||||
@ -18858,6 +18896,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
TABLE *table;
|
||||
SQL_SELECT *select;
|
||||
JOIN_TAB *tab;
|
||||
int err= 0;
|
||||
bool quick_created= FALSE;
|
||||
DBUG_ENTER("create_sort_index");
|
||||
|
||||
if (join->table_count == join->const_tables)
|
||||
@ -18865,18 +18905,61 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
tab= join->join_tab + join->const_tables;
|
||||
table= tab->table;
|
||||
select= tab->select;
|
||||
|
||||
JOIN_TAB *save_pre_sort_join_tab= NULL;
|
||||
if (join->pre_sort_join_tab)
|
||||
{
|
||||
/*
|
||||
we've already been in this function, and stashed away the original access
|
||||
method in join->pre_sort_join_tab, restore it now.
|
||||
*/
|
||||
|
||||
/* First, restore state of the handler */
|
||||
if (join->pre_sort_index != MAX_KEY)
|
||||
{
|
||||
if (table->file->ha_index_or_rnd_end())
|
||||
goto err;
|
||||
if (join->pre_sort_idx_pushed_cond)
|
||||
{
|
||||
table->file->idx_cond_push(join->pre_sort_index,
|
||||
join->pre_sort_idx_pushed_cond);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (table->file->ha_index_or_rnd_end() ||
|
||||
table->file->ha_rnd_init(TRUE))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Second, restore access method parameters */
|
||||
tab->records= join->pre_sort_join_tab->records;
|
||||
tab->select= join->pre_sort_join_tab->select;
|
||||
tab->select_cond= join->pre_sort_join_tab->select_cond;
|
||||
tab->type= join->pre_sort_join_tab->type;
|
||||
tab->read_first_record= join->pre_sort_join_tab->read_first_record;
|
||||
|
||||
save_pre_sort_join_tab= join->pre_sort_join_tab;
|
||||
join->pre_sort_join_tab= NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Save index #, save index condition. Do it right now, because MRR may
|
||||
*/
|
||||
if (table->file->inited == handler::INDEX)
|
||||
{
|
||||
join->pre_sort_index= table->file->active_index;
|
||||
join->pre_sort_idx_pushed_cond= table->file->pushed_idx_cond;
|
||||
// no need to save key_read
|
||||
}
|
||||
else
|
||||
join->pre_sort_index= MAX_KEY;
|
||||
}
|
||||
|
||||
/* Currently ORDER BY ... LIMIT is not supported in subqueries. */
|
||||
DBUG_ASSERT(join->group_list || !join->is_in_subquery());
|
||||
|
||||
/*
|
||||
If we have a select->quick object that is created outside of
|
||||
create_sort_index() and this is part of a subquery that
|
||||
potentially can be executed multiple times then we should not
|
||||
delete the quick object on exit from this function.
|
||||
*/
|
||||
bool keep_quick= select && select->quick && join->join_tab_save;
|
||||
|
||||
/*
|
||||
When there is SQL_BIG_RESULT do not sort using index for GROUP BY,
|
||||
and thus force sorting on disk unless a group min-max optimization
|
||||
@ -18928,7 +19011,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
get_quick_select_for_ref(thd, table, &tab->ref,
|
||||
tab->found_records))))
|
||||
goto err;
|
||||
DBUG_ASSERT(!keep_quick);
|
||||
quick_created= TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18944,7 +19027,27 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
table->sort.found_records=filesort(thd, table,join->sortorder, length,
|
||||
select, filesort_limit, 0,
|
||||
&examined_rows);
|
||||
|
||||
if (quick_created)
|
||||
{
|
||||
/* This will delete the quick select. */
|
||||
select->cleanup();
|
||||
}
|
||||
|
||||
if (!join->pre_sort_join_tab)
|
||||
{
|
||||
if (save_pre_sort_join_tab)
|
||||
join->pre_sort_join_tab= save_pre_sort_join_tab;
|
||||
else if (!(join->pre_sort_join_tab= (JOIN_TAB*)thd->alloc(sizeof(JOIN_TAB))))
|
||||
goto err;
|
||||
}
|
||||
|
||||
*(join->pre_sort_join_tab)= *tab;
|
||||
|
||||
/*TODO: here, close the index scan, cancel index-only read. */
|
||||
tab->records= table->sort.found_records; // For SQL_CALC_ROWS
|
||||
#if 0
|
||||
/* MariaDB doesn't need the following: */
|
||||
if (select)
|
||||
{
|
||||
/*
|
||||
@ -18961,6 +19064,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
tablesort_result_cache= table->sort.io_cache;
|
||||
table->sort.io_cache= NULL;
|
||||
|
||||
// select->cleanup(); // filesort did select
|
||||
/*
|
||||
If a quick object was created outside of create_sort_index()
|
||||
that might be reused, then do not call select->cleanup() since
|
||||
@ -18983,18 +19087,61 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
// Restore the output resultset
|
||||
table->sort.io_cache= tablesort_result_cache;
|
||||
}
|
||||
#endif
|
||||
tab->select=NULL;
|
||||
tab->set_select_cond(NULL, __LINE__);
|
||||
tab->last_inner= 0;
|
||||
tab->first_unmatched= 0;
|
||||
tab->type=JT_ALL; // Read with normal read_record
|
||||
tab->read_first_record= join_init_read_record;
|
||||
tab->table->file->ha_index_or_rnd_end();
|
||||
|
||||
if (err)
|
||||
goto err;
|
||||
|
||||
tab->join->examined_rows+=examined_rows;
|
||||
table->disable_keyread(); // Restore if we used indexes
|
||||
DBUG_RETURN(table->sort.found_records == HA_POS_ERROR);
|
||||
err:
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
|
||||
void JOIN::clean_pre_sort_join_tab()
|
||||
{
|
||||
//TABLE *table= pre_sort_join_tab->table;
|
||||
/*
|
||||
Note: we can come here for fake_select_lex object. That object will have
|
||||
the table already deleted by st_select_lex_unit::cleanup().
|
||||
We rely on that fake_select_lex didn't have quick select.
|
||||
*/
|
||||
#if 0
|
||||
if (pre_sort_join_tab->select && pre_sort_join_tab->select->quick)
|
||||
{
|
||||
/*
|
||||
We need to preserve tablesort's output resultset here, because
|
||||
QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT (called by
|
||||
SQL_SELECT::cleanup()) may free it assuming it's the result of the quick
|
||||
select operation that we no longer need. Note that all the other parts of
|
||||
this data structure are cleaned up when
|
||||
QUICK_INDEX_MERGE_SELECT::get_next encounters end of data, so the next
|
||||
SQL_SELECT::cleanup() call changes sort.io_cache alone.
|
||||
*/
|
||||
IO_CACHE *tablesort_result_cache;
|
||||
|
||||
tablesort_result_cache= table->sort.io_cache;
|
||||
table->sort.io_cache= NULL;
|
||||
pre_sort_join_tab->select->cleanup();
|
||||
table->quick_keys.clear_all(); // as far as we cleanup select->quick
|
||||
table->intersect_keys.clear_all();
|
||||
table->sort.io_cache= tablesort_result_cache;
|
||||
}
|
||||
#endif
|
||||
//table->disable_keyread(); // Restore if we used indexes
|
||||
if (pre_sort_join_tab->select && pre_sort_join_tab->select->quick)
|
||||
{
|
||||
pre_sort_join_tab->select->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
Remove duplicates from tmp table
|
||||
This should be recoded to add a unique index to the table and remove
|
||||
@ -20474,40 +20621,66 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
|
||||
res_selected_fields.empty();
|
||||
res_all_fields.empty();
|
||||
|
||||
uint i, border= all_fields.elements - elements;
|
||||
for (i= 0; (item= it++); i++)
|
||||
uint border= all_fields.elements - elements;
|
||||
for (uint i= 0; (item= it++); i++)
|
||||
{
|
||||
Field *field;
|
||||
|
||||
if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM) ||
|
||||
(item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC))
|
||||
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
|
||||
item_field= item;
|
||||
else
|
||||
else if (item->type() == Item::FIELD_ITEM)
|
||||
item_field= item->get_tmp_table_item(thd);
|
||||
else if (item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC)
|
||||
{
|
||||
if (item->type() == Item::FIELD_ITEM)
|
||||
field= item->get_tmp_table_field();
|
||||
if (field != NULL)
|
||||
{
|
||||
item_field= item->get_tmp_table_item(thd);
|
||||
/*
|
||||
Replace "@:=<expression>" with "@:=<tmp table column>". Otherwise,
|
||||
we would re-evaluate <expression>, and if expression were
|
||||
a subquery, this would access already-unlocked tables.
|
||||
*/
|
||||
Item_func_set_user_var* suv=
|
||||
new Item_func_set_user_var((Item_func_set_user_var*) item);
|
||||
Item_field *new_field= new Item_field(field);
|
||||
if (!suv || !new_field || suv->fix_fields(thd, (Item**)&suv))
|
||||
DBUG_RETURN(true); // Fatal error
|
||||
((Item *)suv)->name= item->name;
|
||||
/*
|
||||
We are replacing the argument of Item_func_set_user_var after its
|
||||
value has been read. The argument's null_value should be set by
|
||||
now, so we must set it explicitly for the replacement argument
|
||||
since the null_value may be read without any preceeding call to
|
||||
val_*().
|
||||
*/
|
||||
new_field->update_null_value();
|
||||
List<Item> list;
|
||||
list.push_back(new_field);
|
||||
suv->set_arguments(list);
|
||||
item_field= suv;
|
||||
}
|
||||
else if ((field= item->get_tmp_table_field()))
|
||||
{
|
||||
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
|
||||
item_field= ((Item_sum*) item)->result_item(field);
|
||||
else
|
||||
item_field= (Item*) new Item_field(field);
|
||||
if (!item_field)
|
||||
DBUG_RETURN(TRUE); // Fatal error
|
||||
else
|
||||
item_field= item;
|
||||
}
|
||||
else if ((field= item->get_tmp_table_field()))
|
||||
{
|
||||
if (item->type() == Item::SUM_FUNC_ITEM && field->table->group)
|
||||
item_field= ((Item_sum*) item)->result_item(field);
|
||||
else
|
||||
item_field= (Item*) new Item_field(field);
|
||||
if (!item_field)
|
||||
DBUG_RETURN(true); // Fatal error
|
||||
|
||||
if (item->real_item()->type() != Item::FIELD_ITEM)
|
||||
field->orig_table= 0;
|
||||
item_field->name= item->name;
|
||||
if (item->type() == Item::REF_ITEM)
|
||||
{
|
||||
Item_field *ifield= (Item_field *) item_field;
|
||||
Item_ref *iref= (Item_ref *) item;
|
||||
ifield->table_name= iref->table_name;
|
||||
ifield->db_name= iref->db_name;
|
||||
}
|
||||
if (item->real_item()->type() != Item::FIELD_ITEM)
|
||||
field->orig_table= 0;
|
||||
item_field->name= item->name;
|
||||
if (item->type() == Item::REF_ITEM)
|
||||
{
|
||||
Item_field *ifield= (Item_field *) item_field;
|
||||
Item_ref *iref= (Item_ref *) item;
|
||||
ifield->table_name= iref->table_name;
|
||||
ifield->db_name= iref->db_name;
|
||||
}
|
||||
#ifndef DBUG_OFF
|
||||
if (!item_field->name)
|
||||
{
|
||||
@ -20519,20 +20692,20 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
|
||||
item_field->name= sql_strmake(str.ptr(),str.length());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
item_field= item;
|
||||
}
|
||||
else
|
||||
item_field= item;
|
||||
|
||||
res_all_fields.push_back(item_field);
|
||||
ref_pointer_array[((i < border)? all_fields.elements-i-1 : i-border)]=
|
||||
item_field;
|
||||
}
|
||||
|
||||
List_iterator_fast<Item> itr(res_all_fields);
|
||||
for (i= 0; i < border; i++)
|
||||
for (uint i= 0; i < border; i++)
|
||||
itr++;
|
||||
itr.sublist(res_selected_fields, elements);
|
||||
DBUG_RETURN(FALSE);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
||||
@ -22712,6 +22885,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
|
||||
ha_rows table_records= table->stat_records();
|
||||
bool group= join && join->group && order == join->group_list;
|
||||
ha_rows ref_key_quick_rows= HA_POS_ERROR;
|
||||
const bool has_limit= (select_limit_arg != HA_POS_ERROR);
|
||||
|
||||
/*
|
||||
If not used with LIMIT, only use keys if the whole query can be
|
||||
@ -22736,7 +22910,8 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
|
||||
else
|
||||
keys= usable_keys;
|
||||
|
||||
if (ref_key >= 0 && table->covering_keys.is_set(ref_key))
|
||||
if (ref_key >= 0 && ref_key != MAX_KEY &&
|
||||
table->covering_keys.is_set(ref_key))
|
||||
ref_key_quick_rows= table->quick_rows[ref_key];
|
||||
|
||||
if (join)
|
||||
@ -22843,7 +23018,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
|
||||
be included into the result set.
|
||||
*/
|
||||
if (select_limit > table_records/rec_per_key)
|
||||
select_limit= table_records;
|
||||
select_limit= table_records;
|
||||
else
|
||||
select_limit= (ha_rows) (select_limit*rec_per_key);
|
||||
} /* group */
|
||||
@ -22925,7 +23100,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
|
||||
|
||||
*new_key= best_key;
|
||||
*new_key_direction= best_key_direction;
|
||||
*new_select_limit= best_select_limit;
|
||||
*new_select_limit= has_limit ? best_select_limit : table_records;
|
||||
if (new_used_key_parts != NULL)
|
||||
*new_used_key_parts= best_key_parts;
|
||||
|
||||
|
@ -897,6 +897,14 @@ protected:
|
||||
|
||||
public:
|
||||
JOIN_TAB *join_tab, **best_ref;
|
||||
|
||||
/*
|
||||
Saved join_tab for pre_sorting. create_sort_index() will save here..
|
||||
*/
|
||||
JOIN_TAB *pre_sort_join_tab;
|
||||
uint pre_sort_index;
|
||||
Item *pre_sort_idx_pushed_cond;
|
||||
void clean_pre_sort_join_tab();
|
||||
|
||||
/*
|
||||
For "Using temporary+Using filesort" queries, JOIN::join_tab can point to
|
||||
@ -1279,6 +1287,8 @@ public:
|
||||
outer_ref_cond= pseudo_bits_cond= NULL;
|
||||
in_to_exists_where= NULL;
|
||||
in_to_exists_having= NULL;
|
||||
|
||||
pre_sort_join_tab= NULL;
|
||||
}
|
||||
|
||||
int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,
|
||||
|
@ -3880,8 +3880,9 @@ end:
|
||||
/* Restore original LEX value, statement's arena and THD arena values. */
|
||||
lex_end(thd->lex);
|
||||
|
||||
if (i_s_arena.free_list)
|
||||
i_s_arena.free_items();
|
||||
// Free items, before restoring backup_arena below.
|
||||
DBUG_ASSERT(i_s_arena.free_list == NULL);
|
||||
thd->free_items();
|
||||
|
||||
/*
|
||||
For safety reset list of open temporary tables before closing
|
||||
|
@ -7515,7 +7515,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
|
||||
}
|
||||
prev_insert_id= to->file->next_insert_id;
|
||||
if (to->vfield)
|
||||
update_virtual_fields(thd, to, TRUE);
|
||||
update_virtual_fields(thd, to, VCOL_UPDATE_FOR_WRITE);
|
||||
if (thd->is_error())
|
||||
{
|
||||
error= 1;
|
||||
|
@ -560,7 +560,9 @@ int mysql_update(THD *thd,
|
||||
while (!(error=info.read_record(&info)) && !thd->killed)
|
||||
{
|
||||
if (table->vfield)
|
||||
update_virtual_fields(thd, table);
|
||||
update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_READ);
|
||||
thd->examined_row_count++;
|
||||
if (!select || (error= select->skip_record(thd)) > 0)
|
||||
{
|
||||
@ -676,7 +678,9 @@ int mysql_update(THD *thd,
|
||||
while (!(error=info.read_record(&info)) && !thd->killed)
|
||||
{
|
||||
if (table->vfield)
|
||||
update_virtual_fields(thd, table);
|
||||
update_virtual_fields(thd, table,
|
||||
table->triggers ? VCOL_UPDATE_ALL :
|
||||
VCOL_UPDATE_FOR_READ);
|
||||
thd->examined_row_count++;
|
||||
if (!select || select->skip_record(thd) > 0)
|
||||
{
|
||||
|
26
sql/table.cc
26
sql/table.cc
@ -988,7 +988,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
|
||||
keyinfo->ext_key_part_map= 0;
|
||||
if (share->use_ext_keys && i)
|
||||
{
|
||||
keyinfo->ext_key_flags= keyinfo->flags | HA_NOSAME;
|
||||
keyinfo->ext_key_part_map= 0;
|
||||
for (j= 0;
|
||||
j < first_key_parts && keyinfo->ext_key_parts < MAX_REF_PARTS;
|
||||
@ -1009,7 +1008,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
|
||||
keyinfo->ext_key_parts++;
|
||||
keyinfo->ext_key_part_map|= 1 << j;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j == first_key_parts)
|
||||
keyinfo->ext_key_flags= keyinfo->flags | HA_NOSAME | HA_EXT_NOSAME;
|
||||
}
|
||||
share->ext_key_parts+= keyinfo->ext_key_parts;
|
||||
}
|
||||
@ -6425,22 +6426,25 @@ bool is_simple_order(ORDER *order)
|
||||
|
||||
@param thd Thread handle
|
||||
@param table The TABLE object
|
||||
@param for_write Requests to compute only fields needed for write
|
||||
@param vcol_update_mode Specifies what virtual column are computed
|
||||
|
||||
@details
|
||||
The function computes the values of the virtual columns of the table and
|
||||
stores them in the table record buffer.
|
||||
Only fields from vcol_set are computed, and, when the flag for_write is not
|
||||
set to TRUE, a virtual field is computed only if it's not stored.
|
||||
The flag for_write is set to TRUE for row insert/update operations.
|
||||
|
||||
If vcol_update_mode is set to VCOL_UPDATE_ALL then all virtual column are
|
||||
computed. Otherwise, only fields from vcol_set are computed: all of them,
|
||||
if vcol_update_mode is set to VCOL_UPDATE_FOR_WRITE, and, only those with
|
||||
the stored_in_db flag set to false, if vcol_update_mode is equal to
|
||||
VCOL_UPDATE_FOR_READ.
|
||||
|
||||
@retval
|
||||
0 Success
|
||||
@retval
|
||||
>0 Error occurred when storing a virtual field value
|
||||
*/
|
||||
|
||||
int update_virtual_fields(THD *thd, TABLE *table, bool for_write)
|
||||
int update_virtual_fields(THD *thd, TABLE *table,
|
||||
enum enum_vcol_update_mode vcol_update_mode)
|
||||
{
|
||||
DBUG_ENTER("update_virtual_fields");
|
||||
Field **vfield_ptr, *vfield;
|
||||
@ -6453,9 +6457,9 @@ int update_virtual_fields(THD *thd, TABLE *table, bool for_write)
|
||||
{
|
||||
vfield= (*vfield_ptr);
|
||||
DBUG_ASSERT(vfield->vcol_info && vfield->vcol_info->expr_item);
|
||||
/* Only update those fields that are marked in the vcol_set bitmap */
|
||||
if (bitmap_is_set(table->vcol_set, vfield->field_index) &&
|
||||
(for_write || !vfield->stored_in_db))
|
||||
if ((bitmap_is_set(table->vcol_set, vfield->field_index) &&
|
||||
(vcol_update_mode == VCOL_UPDATE_FOR_WRITE || !vfield->stored_in_db)) ||
|
||||
vcol_update_mode == VCOL_UPDATE_ALL)
|
||||
{
|
||||
/* Compute the actual value of the virtual fields */
|
||||
error= vfield->vcol_info->expr_item->save_in_field(vfield, 0);
|
||||
|
@ -300,6 +300,13 @@ enum tmp_table_type
|
||||
};
|
||||
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
|
||||
|
||||
enum enum_vcol_update_mode
|
||||
{
|
||||
VCOL_UPDATE_FOR_READ= 0,
|
||||
VCOL_UPDATE_FOR_WRITE,
|
||||
VCOL_UPDATE_ALL
|
||||
};
|
||||
|
||||
typedef struct st_filesort_info
|
||||
{
|
||||
IO_CACHE *io_cache; /* If sorted through filesort */
|
||||
|
@ -65,7 +65,7 @@ int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key,
|
||||
info->update= HA_STATE_NO_KEY;
|
||||
DBUG_RETURN(my_errno);
|
||||
}
|
||||
if (!(keyinfo->flag & HA_NOSAME))
|
||||
if ((keyinfo->flag & (HA_NOSAME | HA_NULL_PART_KEY)) != HA_NOSAME)
|
||||
memcpy(info->lastkey, key, (size_t) keyinfo->length);
|
||||
}
|
||||
memcpy(record, pos, (size_t) share->reclength);
|
||||
|
@ -3263,6 +3263,7 @@ btr_compress(
|
||||
|
||||
if (adjust) {
|
||||
nth_rec = page_rec_get_n_recs_before(btr_cur_get_rec(cursor));
|
||||
ut_ad(nth_rec > 0);
|
||||
}
|
||||
|
||||
/* Decide the page to which we try to merge and which will inherit
|
||||
@ -3498,6 +3499,7 @@ func_exit:
|
||||
mem_heap_free(heap);
|
||||
|
||||
if (adjust) {
|
||||
ut_ad(nth_rec > 0);
|
||||
btr_cur_position(
|
||||
index,
|
||||
page_rec_get_nth(merge_block->frame, nth_rec),
|
||||
@ -4011,8 +4013,22 @@ btr_index_page_validate(
|
||||
{
|
||||
page_cur_t cur;
|
||||
ibool ret = TRUE;
|
||||
#ifndef DBUG_OFF
|
||||
ulint nth = 1;
|
||||
#endif /* !DBUG_OFF */
|
||||
|
||||
page_cur_set_before_first(block, &cur);
|
||||
|
||||
/* Directory slot 0 should only contain the infimum record. */
|
||||
DBUG_EXECUTE_IF("check_table_rec_next",
|
||||
ut_a(page_rec_get_nth_const(
|
||||
page_cur_get_page(&cur), 0)
|
||||
== cur.rec);
|
||||
ut_a(page_dir_slot_get_n_owned(
|
||||
page_dir_get_nth_slot(
|
||||
page_cur_get_page(&cur), 0))
|
||||
== 1););
|
||||
|
||||
page_cur_move_to_next(&cur);
|
||||
|
||||
for (;;) {
|
||||
@ -4026,6 +4042,16 @@ btr_index_page_validate(
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Verify that page_rec_get_nth_const() is correctly
|
||||
retrieving each record. */
|
||||
DBUG_EXECUTE_IF("check_table_rec_next",
|
||||
ut_a(cur.rec == page_rec_get_nth_const(
|
||||
page_cur_get_page(&cur),
|
||||
page_rec_get_n_recs_before(
|
||||
cur.rec)));
|
||||
ut_a(nth++ == page_rec_get_n_recs_before(
|
||||
cur.rec)););
|
||||
|
||||
page_cur_move_to_next(&cur);
|
||||
}
|
||||
|
||||
|
@ -1902,6 +1902,7 @@ page_cur_delete_rec(
|
||||
|
||||
/* Save to local variables some data associated with current_rec */
|
||||
cur_slot_no = page_dir_find_owner_slot(current_rec);
|
||||
ut_ad(cur_slot_no > 0);
|
||||
cur_dir_slot = page_dir_get_nth_slot(page, cur_slot_no);
|
||||
cur_n_owned = page_dir_slot_get_n_owned(cur_dir_slot);
|
||||
|
||||
|
@ -796,8 +796,8 @@ zip_reorganize:
|
||||
/* Before copying, "ret" was the predecessor
|
||||
of the predefined supremum record. If it was
|
||||
the predefined infimum record, then it would
|
||||
still be the infimum. Thus, the assertion
|
||||
ut_a(ret_pos > 0) would fail here. */
|
||||
still be the infimum, and we would have
|
||||
ret_pos == 0. */
|
||||
|
||||
if (UNIV_UNLIKELY
|
||||
(!page_zip_reorganize(new_block, index, mtr))) {
|
||||
@ -1052,6 +1052,7 @@ page_delete_rec_list_end(
|
||||
|
||||
n_owned = rec_get_n_owned_new(rec2) - count;
|
||||
slot_index = page_dir_find_owner_slot(rec2);
|
||||
ut_ad(slot_index > 0);
|
||||
slot = page_dir_get_nth_slot(page, slot_index);
|
||||
} else {
|
||||
rec_t* rec2 = rec;
|
||||
@ -1067,6 +1068,7 @@ page_delete_rec_list_end(
|
||||
|
||||
n_owned = rec_get_n_owned_old(rec2) - count;
|
||||
slot_index = page_dir_find_owner_slot(rec2);
|
||||
ut_ad(slot_index > 0);
|
||||
slot = page_dir_get_nth_slot(page, slot_index);
|
||||
}
|
||||
|
||||
@ -1471,6 +1473,10 @@ page_rec_get_nth_const(
|
||||
ulint n_owned;
|
||||
const rec_t* rec;
|
||||
|
||||
if (nth == 0) {
|
||||
return(page_get_infimum_rec(page));
|
||||
}
|
||||
|
||||
ut_ad(nth < UNIV_PAGE_SIZE / (REC_N_NEW_EXTRA_BYTES + 1));
|
||||
|
||||
for (i = 0;; i++) {
|
||||
|
@ -2484,9 +2484,10 @@ int ha_maria::info(uint flag)
|
||||
errkey= maria_info.errkey;
|
||||
my_store_ptr(dup_ref, ref_length, maria_info.dup_key_pos);
|
||||
}
|
||||
/* Faster to always update, than to do it based on flag */
|
||||
stats.update_time= maria_info.update_time;
|
||||
stats.auto_increment_value= maria_info.auto_increment;
|
||||
if (flag & HA_STATUS_TIME)
|
||||
stats.update_time= maria_info.update_time;
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
stats.auto_increment_value= maria_info.auto_increment;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4669,7 +4669,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
|
||||
uchar *data, uchar *end_of_data)
|
||||
{
|
||||
MARIA_SHARE *share= info->s;
|
||||
uchar *UNINIT_VAR(field_length_data), *blob_buffer, *start_of_data;
|
||||
uchar *UNINIT_VAR(field_length_data), *UNINIT_VAR(blob_buffer), *start_of_data;
|
||||
uint flag, null_bytes, cur_null_bytes, row_extents, field_lengths;
|
||||
my_bool found_blob= 0;
|
||||
MARIA_EXTENT_CURSOR extent;
|
||||
@ -4677,8 +4677,6 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
|
||||
MARIA_ROW *cur_row= &info->cur_row;
|
||||
DBUG_ENTER("_ma_read_block_record2");
|
||||
|
||||
LINT_INIT(blob_buffer);
|
||||
|
||||
start_of_data= data;
|
||||
flag= (uint) (uchar) data[0];
|
||||
cur_null_bytes= share->base.original_null_bytes;
|
||||
@ -5106,6 +5104,7 @@ int _ma_read_block_record(MARIA_HA *info, uchar *record,
|
||||
uchar *data, *end_of_data, *buff;
|
||||
uint offset;
|
||||
uint block_size= share->block_size;
|
||||
int ret;
|
||||
DBUG_ENTER("_ma_read_block_record");
|
||||
DBUG_PRINT("enter", ("rowid: %lu page: %lu rownr: %u",
|
||||
(ulong) record_pos,
|
||||
@ -5127,7 +5126,8 @@ int _ma_read_block_record(MARIA_HA *info, uchar *record,
|
||||
my_errno= HA_ERR_RECORD_DELETED; /* File crashed */
|
||||
DBUG_RETURN(HA_ERR_RECORD_DELETED);
|
||||
}
|
||||
DBUG_RETURN(_ma_read_block_record2(info, record, data, end_of_data));
|
||||
ret= _ma_read_block_record2(info, record, data, end_of_data);
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
int maria_rrnd(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos)
|
||||
{
|
||||
int ret;
|
||||
DBUG_ENTER("maria_rrnd");
|
||||
|
||||
DBUG_ASSERT(filepos != HA_OFFSET_ERROR);
|
||||
@ -40,5 +41,6 @@ int maria_rrnd(MARIA_HA *info, uchar *buf, MARIA_RECORD_POS filepos)
|
||||
DBUG_RETURN(my_errno);
|
||||
|
||||
info->cur_row.lastpos= filepos; /* Remember for update */
|
||||
DBUG_RETURN((*info->s->read_record)(info, buf, filepos));
|
||||
ret= (*info->s->read_record)(info, buf, filepos);
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ static ulong pagecache_size=8192*32;
|
||||
static enum data_file_type record_type= DYNAMIC_RECORD;
|
||||
|
||||
static uint keys=MARIA_KEYS,recant=1000;
|
||||
static uint16 key1[1001],key3[5000];
|
||||
static uint16 key1[1001],key3[5001];
|
||||
static uchar record[300],record2[300],key[100],key2[100];
|
||||
static uchar read_record[300],read_record2[300],read_record3[300];
|
||||
static HA_KEYSEG glob_keyseg[MARIA_KEYS][MAX_PARTS];
|
||||
@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
blob_buffer=0;
|
||||
|
||||
for (i=1000 ; i>0 ; i--) key1[i]=0;
|
||||
for (i=4999 ; i>0 ; i--) key3[i]=0;
|
||||
for (i=5000 ; i>0 ; i--) key3[i]=0;
|
||||
|
||||
if (!silent)
|
||||
printf("- Creating maria-file\n");
|
||||
@ -280,7 +280,7 @@ int main(int argc, char *argv[])
|
||||
if (key3[n3] == 1 && first_key <3 && first_key+keys >= 3)
|
||||
{
|
||||
printf("Error: Didn't get error when writing second key: '%8d'\n",n3);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
write_count++; key1[n1]++; key3[n3]=1;
|
||||
}
|
||||
@ -341,7 +341,7 @@ int main(int argc, char *argv[])
|
||||
key, keyinfo[0].seg[0].length))
|
||||
{
|
||||
printf("Found wrong record when searching for key: \"%s\"\n",key);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (opt_delete == (uint) remove_count) /* While testing */
|
||||
goto end;
|
||||
@ -394,7 +394,7 @@ int main(int argc, char *argv[])
|
||||
printf("Found wrong record when searching for key: \"%s\"; Found \"%.*s\"\n",
|
||||
key, keyinfo[0].seg[0].length,
|
||||
read_record+keyinfo[0].seg[0].start);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (use_blob)
|
||||
{
|
||||
@ -455,7 +455,7 @@ int main(int argc, char *argv[])
|
||||
if (memcmp(read_record,read_record2,reclength) != 0)
|
||||
{
|
||||
printf("maria_rsame didn't find same record\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
info.recpos=maria_position(file);
|
||||
if (maria_rfirst(file,read_record2,0) ||
|
||||
@ -463,7 +463,7 @@ int main(int argc, char *argv[])
|
||||
memcmp(read_record,read_record2,reclength) != 0)
|
||||
{
|
||||
printf("maria_rsame_with_pos didn't find same record\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
{
|
||||
int skr;
|
||||
@ -484,7 +484,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys)
|
||||
{
|
||||
printf("next: Found: %d keys of %d\n",ant,dupp_keys);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
ant=0;
|
||||
while (maria_rprev(file,read_record3,0) == 0 &&
|
||||
@ -492,7 +492,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys)
|
||||
{
|
||||
printf("prev: Found: %d records of %d\n",ant,dupp_keys);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
/* Check of maria_rnext_same */
|
||||
@ -504,7 +504,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys || my_errno != HA_ERR_END_OF_FILE)
|
||||
{
|
||||
printf("maria_rnext_same: Found: %d records of %d\n",ant,dupp_keys);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ int main(int argc, char *argv[])
|
||||
printf("Can't find last record\n");
|
||||
DBUG_DUMP("record2", read_record2, reclength);
|
||||
DBUG_DUMP("record3", read_record3, reclength);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
ant=1;
|
||||
while (maria_rprev(file,read_record3,0) == 0 && ant < write_count+10)
|
||||
@ -539,12 +539,12 @@ int main(int argc, char *argv[])
|
||||
if (ant != write_count - opt_delete)
|
||||
{
|
||||
printf("prev: I found: %d records of %d\n",ant,write_count);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (bcmp(read_record,read_record3,reclength))
|
||||
{
|
||||
printf("Can't find first record\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
@ -585,7 +585,7 @@ int main(int argc, char *argv[])
|
||||
if (bcmp(read_record+start,key,(uint) i))
|
||||
{
|
||||
puts("Didn't find right record");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -605,7 +605,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys-1)
|
||||
{
|
||||
printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-1);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
if (dupp_keys>4)
|
||||
@ -623,7 +623,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys-2)
|
||||
{
|
||||
printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-2);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
if (dupp_keys > 6)
|
||||
@ -643,7 +643,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys-3)
|
||||
{
|
||||
printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-3);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
@ -658,7 +658,7 @@ int main(int argc, char *argv[])
|
||||
if (ant != dupp_keys-4)
|
||||
{
|
||||
printf("next: I can only find: %d keys of %d\n",ant,dupp_keys-4);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -687,7 +687,7 @@ int main(int argc, char *argv[])
|
||||
if (i != write_count && i != write_count - opt_delete)
|
||||
{
|
||||
printf("Found wrong number of rows while scanning table\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (maria_rsame_with_pos(file,read_record,0,info.recpos))
|
||||
@ -695,7 +695,7 @@ int main(int argc, char *argv[])
|
||||
if (bcmp(read_record,read_record2,reclength) != 0)
|
||||
{
|
||||
printf("maria_rsame_with_pos didn't find same record\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
for (i=min(2,keys) ; i-- > 0 ;)
|
||||
@ -704,7 +704,7 @@ int main(int argc, char *argv[])
|
||||
if (bcmp(read_record,read_record2,reclength) != 0)
|
||||
{
|
||||
printf("maria_rsame didn't find same record\n");
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
if (!silent)
|
||||
@ -731,7 +731,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("maria_records_range returned %ld; Should be about %ld\n",
|
||||
(long) range_records,(long) info.records);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
@ -768,7 +768,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("maria_records_range for key: %d returned %lu; Should be about %lu\n",
|
||||
i, (ulong) range_records, (ulong) records);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (verbose && records)
|
||||
{
|
||||
@ -783,13 +783,13 @@ int main(int argc, char *argv[])
|
||||
if (!silent)
|
||||
printf("- maria_info\n");
|
||||
maria_status(file,&info,HA_STATUS_VARIABLE | HA_STATUS_CONST);
|
||||
if (info.records != write_count-opt_delete || info.deleted > opt_delete + update
|
||||
|| info.keys != keys)
|
||||
if (info.records != write_count-opt_delete ||
|
||||
info.deleted > opt_delete + update || info.keys != keys)
|
||||
{
|
||||
puts("Wrong info from maria_info");
|
||||
printf("Got: records: %lu delete: %lu i_keys: %d\n",
|
||||
(ulong) info.records, (ulong) info.deleted, info.keys);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
@ -828,7 +828,7 @@ int main(int argc, char *argv[])
|
||||
printf("scan with cache: I can only find: %d records of %d\n",
|
||||
ant,write_count-opt_delete);
|
||||
maria_scan_end(file);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (maria_extra(file,HA_EXTRA_NO_CACHE,0))
|
||||
{
|
||||
@ -848,7 +848,7 @@ int main(int argc, char *argv[])
|
||||
printf("scan with cache: I can only find: %d records of %d\n",
|
||||
ant,write_count-opt_delete);
|
||||
maria_scan_end(file);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
maria_scan_end(file);
|
||||
|
||||
@ -872,7 +872,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
printf("maria_rrnd didn't advance filepointer; old: %ld, new: %ld\n",
|
||||
(long) lastpos, (long) info.recpos);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
lastpos=info.recpos;
|
||||
if (error == 0)
|
||||
@ -897,7 +897,7 @@ int main(int argc, char *argv[])
|
||||
printf("Found blob with wrong info at %ld\n",(long) lastpos);
|
||||
maria_scan_end(file);
|
||||
my_errno= 0;
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -920,7 +920,7 @@ int main(int argc, char *argv[])
|
||||
printf("Deleted only %d of %d records (%d parts)\n",opt_delete,write_count,
|
||||
found_parts);
|
||||
maria_scan_end(file);
|
||||
goto err;
|
||||
goto err2;
|
||||
}
|
||||
if (testflag == 6)
|
||||
goto end;
|
||||
@ -1021,10 +1021,11 @@ reads: %10lu\n",
|
||||
return(0);
|
||||
err:
|
||||
printf("got error: %d when using MARIA-database\n",my_errno);
|
||||
err2:
|
||||
if (file)
|
||||
{
|
||||
if (maria_commit(file))
|
||||
goto err;
|
||||
printf("got error: %d when using MARIA-database\n",my_errno);
|
||||
maria_close(file);
|
||||
}
|
||||
maria_end();
|
||||
|
16
storage/pbxt/mysql-test/main/r/rpl_mmap.result
Normal file
16
storage/pbxt/mysql-test/main/r/rpl_mmap.result
Normal file
@ -0,0 +1,16 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
create table t1 (a int) engine=InnoDB;
|
||||
create table t2 (a int) engine=pbxt;
|
||||
begin;
|
||||
insert into t1 values (1);
|
||||
insert into t2 values (2);
|
||||
commit;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
2
|
||||
drop table t1, t2;
|
||||
include/rpl_end.inc
|
21
storage/pbxt/mysql-test/main/t/rpl_mmap.test
Normal file
21
storage/pbxt/mysql-test/main/t/rpl_mmap.test
Normal file
@ -0,0 +1,21 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
create table t1 (a int) engine=InnoDB;
|
||||
create table t2 (a int) engine=pbxt;
|
||||
|
||||
begin;
|
||||
insert into t1 values (1);
|
||||
insert into t2 values (2);
|
||||
commit;
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
connection master;
|
||||
drop table t1, t2;
|
||||
|
||||
--source include/rpl_end.inc
|
@ -1891,6 +1891,7 @@ btr_root_raise_and_insert(
|
||||
root = btr_cur_get_page(cursor);
|
||||
root_block = btr_cur_get_block(cursor);
|
||||
root_page_zip = buf_block_get_page_zip(root_block);
|
||||
ut_ad(page_get_n_recs(root) > 0);
|
||||
#ifdef UNIV_ZIP_DEBUG
|
||||
ut_a(!root_page_zip || page_zip_validate(root_page_zip, root));
|
||||
#endif /* UNIV_ZIP_DEBUG */
|
||||
@ -2371,12 +2372,20 @@ btr_insert_on_non_leaf_level_func(
|
||||
BTR_CONT_MODIFY_TREE,
|
||||
&cursor, 0, file, line, mtr);
|
||||
|
||||
err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
|
||||
| BTR_KEEP_SYS_FLAG
|
||||
| BTR_NO_UNDO_LOG_FLAG,
|
||||
&cursor, tuple, &rec,
|
||||
&dummy_big_rec, 0, NULL, mtr);
|
||||
ut_a(err == DB_SUCCESS);
|
||||
ut_ad(cursor.flag == BTR_CUR_BINARY);
|
||||
|
||||
err = btr_cur_optimistic_insert(
|
||||
BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG
|
||||
| BTR_NO_UNDO_LOG_FLAG, &cursor, tuple, &rec,
|
||||
&dummy_big_rec, 0, NULL, mtr);
|
||||
|
||||
if (err == DB_FAIL) {
|
||||
err = btr_cur_pessimistic_insert(
|
||||
BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG
|
||||
| BTR_NO_UNDO_LOG_FLAG,
|
||||
&cursor, tuple, &rec, &dummy_big_rec, 0, NULL, mtr);
|
||||
ut_a(err == DB_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************//**
|
||||
|
@ -1412,7 +1412,12 @@ fail_err:
|
||||
|
||||
if (UNIV_UNLIKELY(reorg)) {
|
||||
ut_a(zip_size);
|
||||
ut_a(*rec);
|
||||
/* It's possible for rec to be NULL if the
|
||||
page is compressed. This is because a
|
||||
reorganized page may become incompressible. */
|
||||
if (!*rec) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1548,20 +1553,9 @@ btr_cur_pessimistic_insert(
|
||||
ut_ad((thr && thr_get_trx(thr)->fake_changes) || mtr_memo_contains(mtr, btr_cur_get_block(cursor),
|
||||
MTR_MEMO_PAGE_X_FIX));
|
||||
|
||||
/* Try first an optimistic insert; reset the cursor flag: we do not
|
||||
assume anything of how it was positioned */
|
||||
|
||||
cursor->flag = BTR_CUR_BINARY;
|
||||
|
||||
err = btr_cur_optimistic_insert(flags, cursor, entry, rec,
|
||||
big_rec, n_ext, thr, mtr);
|
||||
if (err != DB_FAIL) {
|
||||
|
||||
return(err);
|
||||
}
|
||||
|
||||
/* Retry with a pessimistic insert. Check locks and write to undo log,
|
||||
if specified */
|
||||
/* Check locks and write to undo log, if specified */
|
||||
|
||||
err = btr_cur_ins_lock_and_undo(flags, cursor, entry,
|
||||
thr, mtr, &dummy_inh);
|
||||
@ -2188,8 +2182,12 @@ any_extern:
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
max_size = old_rec_size
|
||||
+ page_get_max_insert_size_after_reorganize(page, 1);
|
||||
/* We do not attempt to reorganize if the page is compressed.
|
||||
This is because the page may fail to compress after reorganization. */
|
||||
max_size = page_zip
|
||||
? page_get_max_insert_size(page, 1)
|
||||
: (old_rec_size
|
||||
+ page_get_max_insert_size_after_reorganize(page, 1));
|
||||
|
||||
if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
|
||||
&& (max_size >= new_rec_size))
|
||||
@ -2559,7 +2557,12 @@ make_external:
|
||||
err = DB_SUCCESS;
|
||||
goto return_after_reservations;
|
||||
} else {
|
||||
ut_a(optim_err != DB_UNDERFLOW);
|
||||
/* If the page is compressed and it initially
|
||||
compresses very well, and there is a subsequent insert
|
||||
of a badly-compressing record, it is possible for
|
||||
btr_cur_optimistic_update() to return DB_UNDERFLOW and
|
||||
btr_cur_insert_if_possible() to return FALSE. */
|
||||
ut_a(page_zip || optim_err != DB_UNDERFLOW);
|
||||
|
||||
/* Out of space: reset the free bits. */
|
||||
if (!dict_index_is_clust(index)
|
||||
@ -2588,7 +2591,9 @@ make_external:
|
||||
was_first = page_cur_is_before_first(page_cursor);
|
||||
|
||||
/* Lock checks and undo logging were already performed by
|
||||
btr_cur_upd_lock_and_undo(). */
|
||||
btr_cur_upd_lock_and_undo(). We do not try
|
||||
btr_cur_optimistic_insert() because
|
||||
btr_cur_insert_if_possible() already failed above. */
|
||||
|
||||
err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG
|
||||
| BTR_NO_LOCKING_FLAG
|
||||
|
@ -354,44 +354,39 @@ btr_pcur_restore_position_func(
|
||||
/* Restore the old search mode */
|
||||
cursor->search_mode = old_mode;
|
||||
|
||||
if (btr_pcur_is_on_user_rec(cursor)) {
|
||||
switch (cursor->rel_pos) {
|
||||
case BTR_PCUR_ON:
|
||||
if (!cmp_dtuple_rec(
|
||||
tuple, btr_pcur_get_rec(cursor),
|
||||
rec_get_offsets(btr_pcur_get_rec(cursor),
|
||||
index, NULL,
|
||||
ULINT_UNDEFINED, &heap))) {
|
||||
switch (cursor->rel_pos) {
|
||||
case BTR_PCUR_ON:
|
||||
if (btr_pcur_is_on_user_rec(cursor)
|
||||
&& !cmp_dtuple_rec(
|
||||
tuple, btr_pcur_get_rec(cursor),
|
||||
rec_get_offsets(btr_pcur_get_rec(cursor),
|
||||
index, NULL,
|
||||
ULINT_UNDEFINED, &heap))) {
|
||||
|
||||
/* We have to store the NEW value for
|
||||
the modify clock, since the cursor can
|
||||
now be on a different page! But we can
|
||||
retain the value of old_rec */
|
||||
/* We have to store the NEW value for
|
||||
the modify clock, since the cursor can
|
||||
now be on a different page! But we can
|
||||
retain the value of old_rec */
|
||||
|
||||
cursor->block_when_stored =
|
||||
btr_pcur_get_block(cursor);
|
||||
cursor->modify_clock =
|
||||
buf_block_get_modify_clock(
|
||||
cursor->block_when_stored);
|
||||
cursor->old_stored = BTR_PCUR_OLD_STORED;
|
||||
cursor->block_when_stored =
|
||||
btr_pcur_get_block(cursor);
|
||||
cursor->modify_clock =
|
||||
buf_block_get_modify_clock(
|
||||
cursor->block_when_stored);
|
||||
cursor->old_stored = BTR_PCUR_OLD_STORED;
|
||||
|
||||
mem_heap_free(heap);
|
||||
mem_heap_free(heap);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
break;
|
||||
case BTR_PCUR_BEFORE:
|
||||
page_cur_move_to_next(btr_pcur_get_page_cur(cursor));
|
||||
break;
|
||||
case BTR_PCUR_AFTER:
|
||||
page_cur_move_to_prev(btr_pcur_get_page_cur(cursor));
|
||||
break;
|
||||
#ifdef UNIV_DEBUG
|
||||
default:
|
||||
ut_error;
|
||||
#endif /* UNIV_DEBUG */
|
||||
return(TRUE);
|
||||
}
|
||||
#ifdef UNIV_DEBUG
|
||||
/* fall through */
|
||||
case BTR_PCUR_BEFORE:
|
||||
case BTR_PCUR_AFTER:
|
||||
break;
|
||||
default:
|
||||
ut_error;
|
||||
#endif /* UNIV_DEBUG */
|
||||
}
|
||||
|
||||
mem_heap_free(heap);
|
||||
|
@ -336,15 +336,6 @@ be effective only if PFS_GROUP_BUFFER_SYNC is defined. */
|
||||
# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
|
||||
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
|
||||
|
||||
/** A chunk of buffers. The buffer pool is allocated in chunks. (moved to buf0buf.h)*/
|
||||
//struct buf_chunk_struct{
|
||||
// ulint mem_size; /*!< allocated size of the chunk */
|
||||
// ulint size; /*!< size of frames[] and blocks[] */
|
||||
// void* mem; /*!< pointer to the memory area which
|
||||
// was allocated for the frames */
|
||||
// buf_block_t* blocks; /*!< array of buffer control blocks */
|
||||
//};
|
||||
|
||||
/********************************************************************//**
|
||||
Gets the smallest oldest_modification lsn for any page in the pool. Returns
|
||||
zero if all modified pages have been flushed to disk.
|
||||
@ -1028,7 +1019,8 @@ buf_chunk_init(
|
||||
/*===========*/
|
||||
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
|
||||
buf_chunk_t* chunk, /*!< out: chunk of buffers */
|
||||
ulint mem_size) /*!< in: requested size in bytes */
|
||||
ulint mem_size, /*!< in: requested size in bytes */
|
||||
ibool populate) /*!< in: virtual page preallocation */
|
||||
{
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
@ -1044,7 +1036,7 @@ buf_chunk_init(
|
||||
+ (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE);
|
||||
|
||||
chunk->mem_size = mem_size;
|
||||
chunk->mem = os_mem_alloc_large(&chunk->mem_size);
|
||||
chunk->mem = os_mem_alloc_large(&chunk->mem_size, populate);
|
||||
|
||||
if (UNIV_UNLIKELY(chunk->mem == NULL)) {
|
||||
|
||||
@ -1254,6 +1246,7 @@ buf_pool_init_instance(
|
||||
/*===================*/
|
||||
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
|
||||
ulint buf_pool_size, /*!< in: size in bytes */
|
||||
ibool populate, /*!< in: virtual page preallocation */
|
||||
ulint instance_no) /*!< in: id of the instance */
|
||||
{
|
||||
ulint i;
|
||||
@ -1286,7 +1279,7 @@ buf_pool_init_instance(
|
||||
|
||||
UT_LIST_INIT(buf_pool->free);
|
||||
|
||||
if (!buf_chunk_init(buf_pool, chunk, buf_pool_size)) {
|
||||
if (!buf_chunk_init(buf_pool, chunk, buf_pool_size, populate)) {
|
||||
mem_free(chunk);
|
||||
mem_free(buf_pool);
|
||||
|
||||
@ -1381,6 +1374,7 @@ ulint
|
||||
buf_pool_init(
|
||||
/*==========*/
|
||||
ulint total_size, /*!< in: size of the total pool in bytes */
|
||||
ibool populate, /*!< in: virtual page preallocation */
|
||||
ulint n_instances) /*!< in: number of instances */
|
||||
{
|
||||
ulint i;
|
||||
@ -1398,7 +1392,7 @@ buf_pool_init(
|
||||
for (i = 0; i < n_instances; i++) {
|
||||
buf_pool_t* ptr = &buf_pool_ptr[i];
|
||||
|
||||
if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) {
|
||||
if (buf_pool_init_instance(ptr, size, populate, i) != DB_SUCCESS) {
|
||||
|
||||
/* Free all the instances created so far. */
|
||||
buf_pool_free(i);
|
||||
@ -4973,7 +4967,7 @@ buf_stats_aggregate_pool_info(
|
||||
Collect buffer pool stats information for a buffer pool. Also
|
||||
record aggregated stats if there are more than one buffer pool
|
||||
in the server */
|
||||
static
|
||||
UNIV_INTERN
|
||||
void
|
||||
buf_stats_get_pool_info(
|
||||
/*====================*/
|
||||
|
@ -2384,7 +2384,7 @@ buf_LRU_free_one_page(
|
||||
#endif
|
||||
mutex_t* block_mutex = buf_page_get_mutex(bpage);
|
||||
|
||||
ut_ad(buf_pool_mutex_own(buf_pool));
|
||||
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
|
||||
ut_ad(mutex_own(block_mutex));
|
||||
|
||||
if (buf_LRU_block_remove_hashed_page(bpage, TRUE)
|
||||
|
@ -64,7 +64,7 @@ buf_read_page_handle_error(
|
||||
== BUF_BLOCK_FILE_PAGE);
|
||||
|
||||
/* First unfix and release lock on the bpage */
|
||||
buf_pool_mutex_enter(buf_pool);
|
||||
mutex_enter(&buf_pool->LRU_list_mutex);
|
||||
mutex_enter(buf_page_get_mutex(bpage));
|
||||
ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_READ);
|
||||
ut_ad(bpage->buf_fix_count == 0);
|
||||
@ -85,7 +85,7 @@ buf_read_page_handle_error(
|
||||
buf_pool->n_pend_reads--;
|
||||
|
||||
mutex_exit(buf_page_get_mutex(bpage));
|
||||
buf_pool_mutex_exit(buf_pool);
|
||||
mutex_exit(&buf_pool->LRU_list_mutex);
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
|
@ -874,7 +874,7 @@ extern "C" UNIV_INTERN
|
||||
ibool
|
||||
thd_is_replication_slave_thread(
|
||||
/*============================*/
|
||||
void* thd) /*!< in: thread handle (THD*) */
|
||||
const void* thd) /*!< in: thread handle (THD*) */
|
||||
{
|
||||
return((ibool) thd_slave_thread((THD*) thd));
|
||||
}
|
||||
@ -2465,6 +2465,122 @@ ha_innobase::init_table_handle_for_HANDLER(void)
|
||||
reset_template();
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
/* The last read master log coordinates in the slave info file */
|
||||
static char master_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = "";
|
||||
static int master_log_pos;
|
||||
/* The slave relay log coordinates in the slave info file after startup */
|
||||
static char original_relay_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = "";
|
||||
static int original_relay_log_pos;
|
||||
/* The master log coordinates in the slave info file after startup */
|
||||
static char original_master_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = "";
|
||||
static int original_master_log_pos;
|
||||
#endif
|
||||
|
||||
/*****************************************************************//**
|
||||
Overwrites the MySQL relay log info file with the current master and relay log
|
||||
coordinates from InnoDB. Skips overwrite if the master log position did not
|
||||
change from the last overwrite. If the InnoDB master log position is equal
|
||||
to position that was read from the info file on startup before any overwrites,
|
||||
restores the original positions. */
|
||||
static
|
||||
void
|
||||
innobase_do_overwrite_relay_log_info(void)
|
||||
/*======================================*/
|
||||
{
|
||||
#ifdef HAVE_REPLICATION
|
||||
char info_fname[FN_REFLEN];
|
||||
File info_fd = -1;
|
||||
int error = 0;
|
||||
char buff[FN_REFLEN*2+22*2+4];
|
||||
char *relay_info_log_pos;
|
||||
size_t buf_len;
|
||||
|
||||
if (master_log_fname[0] == '\0') {
|
||||
fprintf(stderr,
|
||||
"InnoDB: something wrong with relay-log.info. "
|
||||
"InnoDB will not overwrite it.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(master_log_fname, trx_sys_mysql_master_log_name) == 0
|
||||
&& master_log_pos == trx_sys_mysql_master_log_pos) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: InnoDB and relay-log.info are synchronized. "
|
||||
"InnoDB will not overwrite it.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we overwrite the file back to the original master log position,
|
||||
restore the original relay log position too. This is required because
|
||||
we might have rolled back a prepared transaction and restored the
|
||||
original master log position from the InnoDB trx sys header, but the
|
||||
corresponding relay log position points to an already-purged file. */
|
||||
if (strcmp(original_master_log_fname, trx_sys_mysql_master_log_name)
|
||||
== 0
|
||||
&& (original_master_log_pos == trx_sys_mysql_master_log_pos)) {
|
||||
|
||||
strncpy(trx_sys_mysql_relay_log_name, original_relay_log_fname,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
trx_sys_mysql_relay_log_pos = original_relay_log_pos;
|
||||
}
|
||||
|
||||
fn_format(info_fname, relay_log_info_file, mysql_data_home, "",
|
||||
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH);
|
||||
|
||||
if (access(info_fname, F_OK)) {
|
||||
/* File does not exist */
|
||||
error = 1;
|
||||
goto skip_overwrite;
|
||||
}
|
||||
|
||||
/* File exists */
|
||||
info_fd = my_open(info_fname, O_RDWR|O_BINARY, MYF(MY_WME));
|
||||
if (info_fd < 0) {
|
||||
error = 1;
|
||||
goto skip_overwrite;
|
||||
}
|
||||
|
||||
relay_info_log_pos = strmov(buff, trx_sys_mysql_relay_log_name);
|
||||
*relay_info_log_pos ++= '\n';
|
||||
relay_info_log_pos = longlong2str(trx_sys_mysql_relay_log_pos,
|
||||
relay_info_log_pos, 10);
|
||||
*relay_info_log_pos ++= '\n';
|
||||
relay_info_log_pos = strmov(relay_info_log_pos,
|
||||
trx_sys_mysql_master_log_name);
|
||||
*relay_info_log_pos ++= '\n';
|
||||
relay_info_log_pos = longlong2str(trx_sys_mysql_master_log_pos,
|
||||
relay_info_log_pos, 10);
|
||||
*relay_info_log_pos = '\n';
|
||||
|
||||
buf_len = (relay_info_log_pos - buff) + 1;
|
||||
if (my_write(info_fd, (uchar *)buff, buf_len, MY_WME) != buf_len) {
|
||||
error = 1;
|
||||
} else if (my_sync(info_fd, MY_WME)) {
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (info_fd >= 0) {
|
||||
my_close(info_fd, MYF(0));
|
||||
}
|
||||
|
||||
strncpy(master_log_fname, trx_sys_mysql_relay_log_name,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
master_log_pos = trx_sys_mysql_master_log_pos;
|
||||
|
||||
skip_overwrite:
|
||||
if (error) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: ERROR: error occured during overwriting "
|
||||
"relay-log.info.\n");
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"InnoDB: relay-log.info was overwritten.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************//**
|
||||
Opens an InnoDB database.
|
||||
@return 0 on success, error code on failure */
|
||||
@ -2598,12 +2714,13 @@ innobase_init(
|
||||
#ifdef HAVE_REPLICATION
|
||||
#ifdef MYSQL_SERVER
|
||||
/* read master log position from relay-log.info if exists */
|
||||
char fname[FN_REFLEN+128];
|
||||
int pos;
|
||||
char info_fname[FN_REFLEN];
|
||||
char relay_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN];
|
||||
int relay_log_pos;
|
||||
int info_fd;
|
||||
IO_CACHE info_file;
|
||||
|
||||
fname[0] = '\0';
|
||||
info_fname[0] = '\0';
|
||||
|
||||
if(innobase_overwrite_relay_log_info) {
|
||||
|
||||
@ -2612,13 +2729,14 @@ innobase_init(
|
||||
" Updates by other storage engines may not be synchronized.\n");
|
||||
|
||||
bzero((char*) &info_file, sizeof(info_file));
|
||||
fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32);
|
||||
fn_format(info_fname, relay_log_info_file, mysql_data_home, "", 4+32);
|
||||
|
||||
int error=0;
|
||||
|
||||
if (!access(fname,F_OK)) {
|
||||
if (!access(info_fname,F_OK)) {
|
||||
/* exist */
|
||||
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) {
|
||||
if ((info_fd = my_open(info_fname, O_RDWR | O_BINARY,
|
||||
MYF(MY_WME))) < 0) {
|
||||
error=1;
|
||||
} else if (init_io_cache(&info_file, info_fd, IO_SIZE*2,
|
||||
READ_CACHE, 0L, 0, MYF(MY_WME))) {
|
||||
@ -2629,16 +2747,18 @@ innobase_init(
|
||||
relay_info_error:
|
||||
if (info_fd >= 0)
|
||||
my_close(info_fd, MYF(0));
|
||||
fname[0] = '\0';
|
||||
master_log_fname[0] = '\0';
|
||||
goto skip_relay;
|
||||
}
|
||||
} else {
|
||||
fname[0] = '\0';
|
||||
master_log_fname[0] = '\0';
|
||||
goto skip_relay;
|
||||
}
|
||||
|
||||
if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") || /* dummy (it is relay-log) */
|
||||
init_intvar_from_file(&pos, &info_file, BIN_LOG_HEADER_SIZE)) {
|
||||
if (init_strvar_from_file(relay_log_fname, sizeof(relay_log_fname),
|
||||
&info_file, "")
|
||||
|| /* dummy (it is relay-log) */ init_intvar_from_file(
|
||||
&relay_log_pos, &info_file, BIN_LOG_HEADER_SIZE)) {
|
||||
end_io_cache(&info_file);
|
||||
error=1;
|
||||
goto relay_info_error;
|
||||
@ -2647,13 +2767,19 @@ relay_info_error:
|
||||
fprintf(stderr,
|
||||
"InnoDB: relay-log.info is detected.\n"
|
||||
"InnoDB: relay log: position %u, file name %s\n",
|
||||
pos, fname);
|
||||
relay_log_pos, relay_log_fname);
|
||||
|
||||
strncpy(trx_sys_mysql_relay_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
trx_sys_mysql_relay_log_pos = (ib_int64_t) pos;
|
||||
strncpy(trx_sys_mysql_relay_log_name, relay_log_fname,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
trx_sys_mysql_relay_log_pos = (ib_int64_t) relay_log_pos;
|
||||
|
||||
if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") ||
|
||||
init_intvar_from_file(&pos, &info_file, 0)) {
|
||||
strncpy(original_relay_log_fname, relay_log_fname,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
original_relay_log_pos = relay_log_pos;
|
||||
|
||||
if (init_strvar_from_file(master_log_fname, sizeof(master_log_fname),
|
||||
&info_file, "")
|
||||
|| init_intvar_from_file(&master_log_pos, &info_file, 0)) {
|
||||
end_io_cache(&info_file);
|
||||
error=1;
|
||||
goto relay_info_error;
|
||||
@ -2661,10 +2787,15 @@ relay_info_error:
|
||||
|
||||
fprintf(stderr,
|
||||
"InnoDB: master log: position %u, file name %s\n",
|
||||
pos, fname);
|
||||
master_log_pos, master_log_fname);
|
||||
|
||||
strncpy(trx_sys_mysql_master_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
trx_sys_mysql_master_log_pos = (ib_int64_t) pos;
|
||||
strncpy(trx_sys_mysql_master_log_name, master_log_fname,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
trx_sys_mysql_master_log_pos = (ib_int64_t) master_log_pos;
|
||||
|
||||
strncpy(original_master_log_fname, master_log_fname,
|
||||
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
|
||||
original_master_log_pos = master_log_pos;
|
||||
|
||||
end_io_cache(&info_file);
|
||||
if (info_fd >= 0)
|
||||
@ -2999,75 +3130,9 @@ innobase_change_buffering_inited_ok:
|
||||
goto mem_free_and_error;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
#ifdef MYSQL_SERVER
|
||||
if(innobase_overwrite_relay_log_info) {
|
||||
/* If InnoDB progressed from relay-log.info, overwrite it */
|
||||
if (fname[0] == '\0') {
|
||||
fprintf(stderr,
|
||||
"InnoDB: Something is wrong with the file relay-info.log. InnoDB will not overwrite it.\n");
|
||||
} else if (0 != strcmp(fname, trx_sys_mysql_master_log_name)
|
||||
|| pos != trx_sys_mysql_master_log_pos) {
|
||||
/* Overwrite relay-log.info */
|
||||
bzero((char*) &info_file, sizeof(info_file));
|
||||
fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32);
|
||||
|
||||
int error = 0;
|
||||
|
||||
if (!access(fname,F_OK)) {
|
||||
/* exist */
|
||||
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) {
|
||||
error = 1;
|
||||
} else if (init_io_cache(&info_file, info_fd, IO_SIZE*2,
|
||||
WRITE_CACHE, 0L, 0, MYF(MY_WME))) {
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (info_fd >= 0)
|
||||
my_close(info_fd, MYF(0));
|
||||
goto skip_overwrite;
|
||||
}
|
||||
} else {
|
||||
error = 1;
|
||||
goto skip_overwrite;
|
||||
}
|
||||
|
||||
char buff[FN_REFLEN*2+22*2+4], *pos;
|
||||
|
||||
my_b_seek(&info_file, 0L);
|
||||
pos=strmov(buff, trx_sys_mysql_relay_log_name);
|
||||
*pos++='\n';
|
||||
pos=longlong10_to_str(trx_sys_mysql_relay_log_pos, pos, 10);
|
||||
*pos++='\n';
|
||||
pos=strmov(pos, trx_sys_mysql_master_log_name);
|
||||
*pos++='\n';
|
||||
pos=longlong10_to_str(trx_sys_mysql_master_log_pos, pos, 10);
|
||||
*pos='\n';
|
||||
|
||||
if (my_b_write(&info_file, (uchar*) buff, (size_t) (pos-buff)+1))
|
||||
error = 1;
|
||||
if (flush_io_cache(&info_file))
|
||||
error = 1;
|
||||
|
||||
end_io_cache(&info_file);
|
||||
if (info_fd >= 0)
|
||||
my_close(info_fd, MYF(0));
|
||||
skip_overwrite:
|
||||
if (error) {
|
||||
fprintf(stderr,
|
||||
"InnoDB: ERROR: An error occurred while overwriting relay-log.info.\n");
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"InnoDB: The file relay-log.info was successfully overwritten.\n");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"InnoDB: InnoDB and relay-log.info are synchronized. InnoDB will not overwrite it.\n");
|
||||
innobase_do_overwrite_relay_log_info();
|
||||
}
|
||||
}
|
||||
#endif /* MYSQL_SERVER */
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
innobase_old_blocks_pct = buf_LRU_old_ratio_update(
|
||||
innobase_old_blocks_pct, TRUE);
|
||||
@ -3170,6 +3235,32 @@ innobase_alter_table_flags(
|
||||
| HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);
|
||||
}
|
||||
|
||||
/****************************************************************//**
|
||||
Copy the current replication position from MySQL to a transaction. */
|
||||
static
|
||||
void
|
||||
innobase_copy_repl_coords_to_trx(
|
||||
/*=============================*/
|
||||
const THD* thd, /*!< in: thread handle */
|
||||
trx_t* trx) /*!< in/out: transaction */
|
||||
{
|
||||
if (thd && thd_is_replication_slave_thread(thd)) {
|
||||
/* Update the replication position info inside InnoDB.
|
||||
In embedded server, does nothing. */
|
||||
const char *log_file_name, *group_relay_log_name;
|
||||
ulonglong log_pos, relay_log_pos;
|
||||
bool res = rpl_get_position_info(&log_file_name, &log_pos,
|
||||
&group_relay_log_name,
|
||||
&relay_log_pos);
|
||||
if (res) {
|
||||
trx->mysql_master_log_file_name = log_file_name;
|
||||
trx->mysql_master_log_pos = (ib_int64_t)log_pos;
|
||||
trx->mysql_relay_log_file_name = group_relay_log_name;
|
||||
trx->mysql_relay_log_pos = (ib_int64_t)relay_log_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************//**
|
||||
Commits a transaction in an InnoDB database. */
|
||||
static
|
||||
@ -3179,27 +3270,12 @@ innobase_commit_low(
|
||||
trx_t* trx) /*!< in: transaction handle */
|
||||
{
|
||||
if (trx_is_started(trx)) {
|
||||
#ifdef HAVE_REPLICATION
|
||||
#ifdef MYSQL_SERVER
|
||||
THD *thd=current_thd;
|
||||
|
||||
if (thd && thd_is_replication_slave_thread(thd)) {
|
||||
/* Update the replication position info inside InnoDB.
|
||||
In embedded server, does nothing. */
|
||||
const char *log_file_name, *group_relay_log_name;
|
||||
ulonglong log_pos, relay_log_pos;
|
||||
bool res = rpl_get_position_info(&log_file_name, &log_pos,
|
||||
&group_relay_log_name,
|
||||
&relay_log_pos);
|
||||
if (res) {
|
||||
trx->mysql_master_log_file_name = log_file_name;
|
||||
trx->mysql_master_log_pos = (ib_int64_t)log_pos;
|
||||
trx->mysql_relay_log_file_name = group_relay_log_name;
|
||||
trx->mysql_relay_log_pos = (ib_int64_t)relay_log_pos;
|
||||
}
|
||||
}
|
||||
#endif /* MYSQL_SERVER */
|
||||
#endif /* HAVE_REPLICATION */
|
||||
/* Save the current replication position for write to trx sys
|
||||
header for undo purposes, see the comment at corresponding call
|
||||
at innobase_xa_prepare(). */
|
||||
|
||||
innobase_copy_repl_coords_to_trx(current_thd, trx);
|
||||
|
||||
trx_commit_for_mysql(trx);
|
||||
}
|
||||
@ -3399,6 +3475,9 @@ innobase_commit(
|
||||
if (all
|
||||
|| (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
|
||||
|
||||
DBUG_EXECUTE_IF("crash_innodb_before_commit",
|
||||
DBUG_SUICIDE(););
|
||||
|
||||
/* Run the fast part of commit if we did not already. */
|
||||
if (!trx_is_active_commit_ordered(trx)) {
|
||||
innobase_commit_ordered_2(trx, thd);
|
||||
@ -11559,7 +11638,27 @@ innobase_xa_prepare(
|
||||
|
||||
ut_ad(trx_is_registered_for_2pc(trx));
|
||||
|
||||
/* Update the replication position info in current trx. This
|
||||
is different from the binlog position update that happens
|
||||
during XA COMMIT. In contrast to that, the slave position is
|
||||
an actual part of the changes made by this transaction and thus
|
||||
must be updated in the XA PREPARE stage. Since the trx sys
|
||||
header page changes are not undo-logged, again store this
|
||||
position in a different field in the XA COMMIT stage, so that
|
||||
it might be used in case of rollbacks. */
|
||||
|
||||
/* Since currently there might be only one slave SQL thread, we
|
||||
don't need to take any precautions (e.g. prepare_commit_mutex)
|
||||
to ensure position ordering. Revisit this in 5.6 which has
|
||||
both the multi-threaded replication to cause us problems and
|
||||
the group commit to solve them. */
|
||||
|
||||
innobase_copy_repl_coords_to_trx(thd, trx);
|
||||
|
||||
error = (int) trx_prepare_for_mysql(trx);
|
||||
|
||||
DBUG_EXECUTE_IF("crash_innodb_after_prepare",
|
||||
DBUG_SUICIDE(););
|
||||
} else {
|
||||
/* We just mark the SQL statement ended and do not do a
|
||||
transaction prepare */
|
||||
@ -11652,6 +11751,22 @@ innobase_rollback_by_xid(
|
||||
if (trx) {
|
||||
int ret = innobase_rollback_trx(trx);
|
||||
trx_free_for_background(trx);
|
||||
|
||||
if (innobase_overwrite_relay_log_info) {
|
||||
|
||||
/* On rollback of a prepared transaction revert the
|
||||
current slave positions to the ones recorded by the
|
||||
last COMMITTed transaction. This has an effect of
|
||||
undoing the position change caused by the transaction
|
||||
being rolled back. Assumes single-threaded slave SQL
|
||||
thread. If the server has non-master write traffic
|
||||
with XA rollbacks, this will cause additional spurious
|
||||
slave info log overwrites, which should be harmless. */
|
||||
|
||||
trx_sys_print_committed_mysql_master_log_pos();
|
||||
innobase_do_overwrite_relay_log_info();
|
||||
}
|
||||
|
||||
return(ret);
|
||||
} else {
|
||||
return(XAER_NOTA);
|
||||
@ -12670,6 +12785,12 @@ static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
|
||||
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
|
||||
NULL, NULL, 128*1024*1024L, 5*1024*1024L, LONGLONG_MAX, 1024*1024L);
|
||||
|
||||
static MYSQL_SYSVAR_BOOL(buffer_pool_populate, srv_buf_pool_populate,
|
||||
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
|
||||
"Preallocate (pre-fault) the page frames required for the mapping "
|
||||
"established by the buffer pool memory region. Disabled by default.",
|
||||
NULL, NULL, FALSE);
|
||||
|
||||
static MYSQL_SYSVAR_LONG(buffer_pool_instances, innobase_buffer_pool_instances,
|
||||
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
|
||||
"Number of buffer pool instances, set to higher value on high-end machines to increase scalability",
|
||||
@ -13049,6 +13170,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
|
||||
MYSQL_SYSVAR(additional_mem_pool_size),
|
||||
MYSQL_SYSVAR(autoextend_increment),
|
||||
MYSQL_SYSVAR(buffer_pool_size),
|
||||
MYSQL_SYSVAR(buffer_pool_populate),
|
||||
MYSQL_SYSVAR(buffer_pool_instances),
|
||||
MYSQL_SYSVAR(buffer_pool_shm_key),
|
||||
MYSQL_SYSVAR(buffer_pool_shm_checksum),
|
||||
@ -13194,7 +13316,10 @@ i_s_innodb_buffer_pool_pages,
|
||||
i_s_innodb_buffer_pool_pages_index,
|
||||
i_s_innodb_buffer_pool_pages_blob,
|
||||
i_s_innodb_admin_command,
|
||||
i_s_innodb_changed_pages
|
||||
i_s_innodb_changed_pages,
|
||||
i_s_innodb_buffer_page,
|
||||
i_s_innodb_buffer_page_lru,
|
||||
i_s_innodb_buffer_stats
|
||||
maria_declare_plugin_end;
|
||||
|
||||
/** @brief Initialize the default value of innodb_commit_concurrency.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,5 +52,8 @@ extern struct st_maria_plugin i_s_innodb_buffer_pool_pages;
|
||||
extern struct st_maria_plugin i_s_innodb_buffer_pool_pages_index;
|
||||
extern struct st_maria_plugin i_s_innodb_buffer_pool_pages_blob;
|
||||
extern struct st_maria_plugin i_s_innodb_changed_pages;
|
||||
extern struct st_maria_plugin i_s_innodb_buffer_page;
|
||||
extern struct st_maria_plugin i_s_innodb_buffer_page_lru;
|
||||
extern struct st_maria_plugin i_s_innodb_buffer_stats;
|
||||
|
||||
#endif /* i_s_h */
|
||||
|
@ -3650,11 +3650,18 @@ bitmap_fail:
|
||||
|
||||
root = ibuf_tree_root_get(&mtr);
|
||||
|
||||
err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
|
||||
| BTR_NO_UNDO_LOG_FLAG,
|
||||
cursor,
|
||||
ibuf_entry, &ins_rec,
|
||||
&dummy_big_rec, 0, thr, &mtr);
|
||||
err = btr_cur_optimistic_insert(
|
||||
BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG,
|
||||
cursor, ibuf_entry, &ins_rec,
|
||||
&dummy_big_rec, 0, thr, &mtr);
|
||||
|
||||
if (err == DB_FAIL) {
|
||||
err = btr_cur_pessimistic_insert(
|
||||
BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG,
|
||||
cursor, ibuf_entry, &ins_rec,
|
||||
&dummy_big_rec, 0, thr, &mtr);
|
||||
}
|
||||
|
||||
mutex_exit(&ibuf_pessimistic_insert_mutex);
|
||||
ibuf_size_update(root, &mtr);
|
||||
mutex_exit(&ibuf_mutex);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user