mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
5.3 merge
This commit is contained in:
commit
44cf9ee5f7
52 changed files with 850 additions and 135 deletions
|
@ -24,7 +24,6 @@ extern "C" {
|
|||
#include <my_base.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_ctype.h>
|
||||
#include "../storage/maria/ma_pagecache.h"
|
||||
#include "my_compare.h"
|
||||
#include "ft_global.h"
|
||||
#include <myisamchk.h>
|
||||
|
@ -268,7 +267,6 @@ extern my_bool maria_flush, maria_single_user, maria_page_checksums;
|
|||
extern my_bool maria_delay_key_write;
|
||||
extern my_off_t maria_max_temp_length;
|
||||
extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size;
|
||||
extern PAGECACHE maria_pagecache_var, *maria_pagecache;
|
||||
extern MY_TMPDIR *maria_tmpdir;
|
||||
/*
|
||||
This is used to check if a symlink points into the mysql data home,
|
||||
|
@ -353,69 +351,6 @@ typedef struct st_maria_bit_buff
|
|||
uint error;
|
||||
} MARIA_BIT_BUFF;
|
||||
|
||||
|
||||
typedef struct st_maria_sort_info
|
||||
{
|
||||
/* sync things */
|
||||
mysql_mutex_t mutex;
|
||||
mysql_cond_t cond;
|
||||
MARIA_HA *info, *new_info;
|
||||
HA_CHECK *param;
|
||||
char *buff;
|
||||
SORT_KEY_BLOCKS *key_block, *key_block_end;
|
||||
SORT_FT_BUF *ft_buf;
|
||||
my_off_t filelength, dupp, buff_length;
|
||||
pgcache_page_no_t page;
|
||||
ha_rows max_records;
|
||||
uint current_key, total_keys;
|
||||
uint got_error, threads_running;
|
||||
myf myf_rw;
|
||||
enum data_file_type new_data_file_type, org_data_file_type;
|
||||
} MARIA_SORT_INFO;
|
||||
|
||||
typedef struct st_maria_sort_param
|
||||
{
|
||||
pthread_t thr;
|
||||
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
|
||||
DYNAMIC_ARRAY buffpek;
|
||||
MARIA_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
|
||||
|
||||
MARIA_KEYDEF *keyinfo;
|
||||
MARIA_SORT_INFO *sort_info;
|
||||
HA_KEYSEG *seg;
|
||||
uchar **sort_keys;
|
||||
uchar *rec_buff;
|
||||
void *wordlist, *wordptr;
|
||||
MEM_ROOT wordroot;
|
||||
uchar *record;
|
||||
MY_TMPDIR *tmpdir;
|
||||
|
||||
/*
|
||||
The next two are used to collect statistics, see maria_update_key_parts for
|
||||
description.
|
||||
*/
|
||||
ulonglong unique[HA_MAX_KEY_SEG+1];
|
||||
ulonglong notnull[HA_MAX_KEY_SEG+1];
|
||||
|
||||
MARIA_RECORD_POS pos,max_pos,filepos,start_recpos, current_filepos;
|
||||
uint key, key_length,real_key_length,sortbuff_size;
|
||||
uint maxbuffers, keys, find_length, sort_keys_length;
|
||||
my_bool fix_datafile, master;
|
||||
my_bool calc_checksum; /* calculate table checksum */
|
||||
size_t rec_buff_size;
|
||||
|
||||
int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *);
|
||||
int (*key_read)(struct st_maria_sort_param *, uchar *);
|
||||
int (*key_write)(struct st_maria_sort_param *, const uchar *);
|
||||
void (*lock_in_memory)(HA_CHECK *);
|
||||
int (*write_keys)(struct st_maria_sort_param *, register uchar **,
|
||||
uint , struct st_buffpek *, IO_CACHE *);
|
||||
uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
|
||||
int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,uchar *,
|
||||
uint, uint);
|
||||
} MARIA_SORT_PARAM;
|
||||
|
||||
|
||||
/* functions in maria_check */
|
||||
void maria_chk_init(HA_CHECK *param);
|
||||
void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info);
|
||||
|
@ -443,7 +378,6 @@ int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start,
|
|||
my_off_t length, const char *type);
|
||||
int maria_movepoint(MARIA_HA *info, uchar *record, my_off_t oldpos,
|
||||
my_off_t newpos, uint prot_key);
|
||||
int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile);
|
||||
int maria_test_if_almost_full(MARIA_HA *info);
|
||||
int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
|
||||
int maria_disable_indexes(MARIA_HA *info);
|
||||
|
@ -456,10 +390,6 @@ my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
|
|||
int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows);
|
||||
void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
|
||||
void maria_end_bulk_insert(MARIA_HA *info);
|
||||
int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map,
|
||||
PAGECACHE *key_cache);
|
||||
void maria_change_pagecache(PAGECACHE *old_key_cache,
|
||||
PAGECACHE *new_key_cache);
|
||||
int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves);
|
||||
void maria_versioning(MARIA_HA *info, my_bool versioning);
|
||||
void maria_ignore_trids(MARIA_HA *info);
|
||||
|
|
|
@ -2044,6 +2044,59 @@ a
|
|||
drop table t1,t2;
|
||||
set optimizer_switch=@save968720_optimizer_switch;
|
||||
#
|
||||
# LP BUG#978847 Server crashes in Item_ref::real_item on
|
||||
# INSERT .. SELECT with FROM subquery and derived_merge=ON
|
||||
SET @save978847_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch = 'derived_merge=on';
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
INSERT INTO t1 VALUES (2,1),(3,2);
|
||||
select * from t1;
|
||||
a b
|
||||
2 1
|
||||
3 2
|
||||
INSERT INTO t1 SELECT * FROM
|
||||
( SELECT * FROM t1 ) AS alias;
|
||||
select * from t1;
|
||||
a b
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
prepare stmt1 from 'INSERT INTO t1 SELECT SQL_BIG_RESULT * FROM
|
||||
( SELECT * FROM t1 ) AS alias';
|
||||
execute stmt1;
|
||||
select * from t1;
|
||||
a b
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
execute stmt1;
|
||||
select * from t1;
|
||||
a b
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
2 1
|
||||
3 2
|
||||
drop table t1;
|
||||
set optimizer_switch=@save978847_optimizer_switch;
|
||||
#
|
||||
# end of 5.3 tests
|
||||
#
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1976,6 +1976,53 @@ Warning 1292 Truncated incorrect DOUBLE value: 'g'
|
|||
Warning 1292 Truncated incorrect DOUBLE value: 'v'
|
||||
SET SESSION SQL_MODE=default;
|
||||
drop table t1;
|
||||
#
|
||||
# LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('x');
|
||||
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES
|
||||
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
|
||||
(0, 'p'),(3, 'j'),(8, 'c');
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
rand() + 1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
zzz
|
||||
0
|
||||
3
|
||||
4
|
||||
8
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
zzz
|
||||
0
|
||||
3
|
||||
4
|
||||
8
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
t2_1.b + 1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
zzz
|
||||
0
|
||||
3
|
||||
4
|
||||
8
|
||||
#TODO: in merge with 5.3 add original test suite
|
||||
drop table t1, t2;
|
||||
# End of 5.2 tests
|
||||
#
|
||||
# lp:872702: Crash in add_ref_to_table_cond() when grouping by a PK
|
||||
|
|
5
mysql-test/r/in_datetime_241.result
Normal file
5
mysql-test/r/in_datetime_241.result
Normal file
|
@ -0,0 +1,5 @@
|
|||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 ( a DATE );
|
||||
SELECT * FROM t1 WHERE ( SELECT a FROM t1 ) IN ('2012-04-25','2012-04-26');
|
||||
a
|
||||
DROP TABLE t1;
|
|
@ -4585,7 +4585,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
|||
FROM t1
|
||||
WHERE a = 230;
|
||||
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
NULL 0
|
||||
NULL NULL
|
||||
DROP TABLE t1, st1, st2;
|
||||
#
|
||||
# Bug #48709: Assertion failed in sql_select.cc:11782:
|
||||
|
@ -6521,5 +6521,46 @@ INSERT INTO t1 VALUES (1);
|
|||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
# main query and implicit grouping
|
||||
#
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 1
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
|
|
@ -4587,7 +4587,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
|||
FROM t1
|
||||
WHERE a = 230;
|
||||
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
NULL 0
|
||||
NULL NULL
|
||||
DROP TABLE t1, st1, st2;
|
||||
#
|
||||
# Bug #48709: Assertion failed in sql_select.cc:11782:
|
||||
|
@ -6520,6 +6520,47 @@ INSERT INTO t1 VALUES (1);
|
|||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
# main query and implicit grouping
|
||||
#
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 1
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -4583,7 +4583,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
|||
FROM t1
|
||||
WHERE a = 230;
|
||||
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
NULL 0
|
||||
NULL NULL
|
||||
DROP TABLE t1, st1, st2;
|
||||
#
|
||||
# Bug #48709: Assertion failed in sql_select.cc:11782:
|
||||
|
@ -6516,6 +6516,47 @@ INSERT INTO t1 VALUES (1);
|
|||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
# main query and implicit grouping
|
||||
#
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 1
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -4591,7 +4591,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
|||
FROM t1
|
||||
WHERE a = 230;
|
||||
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
NULL 0
|
||||
NULL NULL
|
||||
DROP TABLE t1, st1, st2;
|
||||
#
|
||||
# Bug #48709: Assertion failed in sql_select.cc:11782:
|
||||
|
@ -6527,6 +6527,47 @@ INSERT INTO t1 VALUES (1);
|
|||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
# main query and implicit grouping
|
||||
#
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 1
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -4583,7 +4583,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
|||
FROM t1
|
||||
WHERE a = 230;
|
||||
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
NULL 0
|
||||
NULL NULL
|
||||
DROP TABLE t1, st1, st2;
|
||||
#
|
||||
# Bug #48709: Assertion failed in sql_select.cc:11782:
|
||||
|
@ -6516,6 +6516,47 @@ INSERT INTO t1 VALUES (1);
|
|||
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
||||
a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
# main query and implicit grouping
|
||||
#
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 1
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
drop table t1,t2;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -2671,4 +2671,44 @@ a
|
|||
DEALLOCATE PREPARE pstmt;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#978479: Wrong result (extra rows) with derived_with_keys+loosescan+semijoin=ON, materialization=OFF
|
||||
#
|
||||
set @tmp_jcl_978479= @@join_cache_level;
|
||||
set join_cache_level=0;
|
||||
set @tmp_os_978479= @@optimizer_switch;
|
||||
set optimizer_switch = 'derived_with_keys=on,loosescan=on,semijoin=on,materialization=off';
|
||||
# Part#1: make sure EXPLAIN is using LooseScan:
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
INSERT INTO t1 VALUES
|
||||
(4,0),(6,8),(3,1),(5,8),(3,9),(2,4),
|
||||
(2,6),(9,1),(5,4),(7,7),(5,4);
|
||||
CREATE ALGORITHM=TEMPTABLE
|
||||
VIEW v1 AS SELECT * FROM t1;
|
||||
# This will use LooseScan:
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
|
||||
1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 11
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
a b a b
|
||||
3 1 9 1
|
||||
5 8 4 0
|
||||
3 9 9 1
|
||||
2 4 6 8
|
||||
2 4 4 0
|
||||
2 6 6 8
|
||||
2 6 4 0
|
||||
5 4 4 0
|
||||
7 7 7 7
|
||||
5 4 4 0
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
set @@join_cache_level= @tmp_jcl_978479;
|
||||
set @@optimizer_switch= @tmp_os_978479;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
|
|
@ -2685,6 +2685,46 @@ a
|
|||
DEALLOCATE PREPARE pstmt;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#978479: Wrong result (extra rows) with derived_with_keys+loosescan+semijoin=ON, materialization=OFF
|
||||
#
|
||||
set @tmp_jcl_978479= @@join_cache_level;
|
||||
set join_cache_level=0;
|
||||
set @tmp_os_978479= @@optimizer_switch;
|
||||
set optimizer_switch = 'derived_with_keys=on,loosescan=on,semijoin=on,materialization=off';
|
||||
# Part#1: make sure EXPLAIN is using LooseScan:
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
INSERT INTO t1 VALUES
|
||||
(4,0),(6,8),(3,1),(5,8),(3,9),(2,4),
|
||||
(2,6),(9,1),(5,4),(7,7),(5,4);
|
||||
CREATE ALGORITHM=TEMPTABLE
|
||||
VIEW v1 AS SELECT * FROM t1;
|
||||
# This will use LooseScan:
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
|
||||
1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
|
||||
1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
|
||||
3 DERIVED t1 ALL NULL NULL NULL NULL 11
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
a b a b
|
||||
3 1 9 1
|
||||
5 8 4 0
|
||||
3 9 9 1
|
||||
2 4 6 8
|
||||
2 4 4 0
|
||||
2 6 6 8
|
||||
2 6 4 0
|
||||
5 4 4 0
|
||||
7 7 7 7
|
||||
5 4 4 0
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
set @@join_cache_level= @tmp_jcl_978479;
|
||||
set @@optimizer_switch= @tmp_os_978479;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
|
|
@ -21,6 +21,12 @@ name cdate note
|
|||
name1 1998-01-01 note01
|
||||
name2 1998-01-01 note01
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL;
|
||||
a
|
||||
1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 ( datum DATE );
|
||||
INSERT INTO t1 VALUES ( "2000-1-1" );
|
||||
INSERT INTO t1 VALUES ( "2000-1-2" );
|
||||
|
|
9
mysql-test/r/update_ignore_216.result
Normal file
9
mysql-test/r/update_ignore_216.result
Normal file
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE t1 ( a INT, b CHAR(3) );
|
||||
INSERT INTO t1 VALUES ( 1, 'foo' );
|
||||
CREATE TABLE t2 ( c CHAR(3), d INT );
|
||||
INSERT INTO t2 VALUES ( 'foo', 1 );
|
||||
UPDATE IGNORE t1, t2 SET b = 'bar', c = 'bar'
|
||||
WHERE a != ( SELECT 1 UNION SELECT 2 );
|
||||
Warnings:
|
||||
Warning 1242 Subquery returns more than 1 row
|
||||
DROP TABLE t1, t2;
|
|
@ -1413,6 +1413,30 @@ SELECT * FROM t1;
|
|||
drop table t1,t2;
|
||||
set optimizer_switch=@save968720_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#978847 Server crashes in Item_ref::real_item on
|
||||
--echo # INSERT .. SELECT with FROM subquery and derived_merge=ON
|
||||
SET @save978847_optimizer_switch=@@optimizer_switch;
|
||||
SET optimizer_switch = 'derived_merge=on';
|
||||
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
INSERT INTO t1 VALUES (2,1),(3,2);
|
||||
|
||||
select * from t1;
|
||||
INSERT INTO t1 SELECT * FROM
|
||||
( SELECT * FROM t1 ) AS alias;
|
||||
select * from t1;
|
||||
prepare stmt1 from 'INSERT INTO t1 SELECT SQL_BIG_RESULT * FROM
|
||||
( SELECT * FROM t1 ) AS alias';
|
||||
execute stmt1;
|
||||
select * from t1;
|
||||
execute stmt1;
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
set optimizer_switch=@save978847_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # end of 5.3 tests
|
||||
--echo #
|
||||
|
|
|
@ -317,10 +317,11 @@ SELECT ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3
|
|||
select ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3));
|
||||
|
||||
#bug 986977 Assertion `!cur_p->event' failed in Gcalc_scan_iterator::arrange_event(int, int)
|
||||
SELECT ASTEXT(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
|
||||
SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
|
||||
-2.910427500435995 0.727606875108998,
|
||||
-0.910427500435995 8.727606875108998,
|
||||
7.664100588675687 1.503849116986468,
|
||||
1.664100588675687 -2.496150883013531,
|
||||
0.0 -3.0
|
||||
))' ), 3 ));
|
||||
))' ), 3 )));
|
||||
|
||||
|
|
|
@ -1339,6 +1339,45 @@ SELECT alias2.f3 AS field1 , alias2.f1 AS field2 FROM t1 AS alias1 JOIN t1 AS al
|
|||
SET SESSION SQL_MODE=default;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('x');
|
||||
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES
|
||||
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
|
||||
(0, 'p'),(3, 'j'),(8, 'c');
|
||||
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
rand() + 1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
|
||||
SELECT t2_1.b as zzz
|
||||
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
|
||||
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
|
||||
WHERE
|
||||
t2_1.b + 1 > 0 OR
|
||||
a = t2_1.c
|
||||
GROUP BY zzz;
|
||||
|
||||
--echo #TODO: in merge with 5.3 add original test suite
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo # End of 5.2 tests
|
||||
|
||||
--echo #
|
||||
|
|
9
mysql-test/t/in_datetime_241.test
Normal file
9
mysql-test/t/in_datetime_241.test
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# MDEV-241 lp:992722 - Server crashes in get_datetime_value
|
||||
#
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1;
|
||||
--enable_warnings
|
||||
CREATE TABLE t1 ( a DATE );
|
||||
SELECT * FROM t1 WHERE ( SELECT a FROM t1 ) IN ('2012-04-25','2012-04-26');
|
||||
DROP TABLE t1;
|
|
@ -5499,6 +5499,35 @@ SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
|
|||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
|
||||
--echo # main query and implicit grouping
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 int) engine=MyISAM;
|
||||
INSERT INTO t1 VALUES (7),(8);
|
||||
|
||||
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
|
||||
INSERT INTO t2 VALUES (3,'f');
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
|
||||
EXPLAIN
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
|
||||
--echo # return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
|
|
@ -2366,5 +2366,38 @@ DEALLOCATE PREPARE pstmt;
|
|||
DROP VIEW v1;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#978479: Wrong result (extra rows) with derived_with_keys+loosescan+semijoin=ON, materialization=OFF
|
||||
--echo #
|
||||
|
||||
set @tmp_jcl_978479= @@join_cache_level;
|
||||
set join_cache_level=0;
|
||||
|
||||
set @tmp_os_978479= @@optimizer_switch;
|
||||
set optimizer_switch = 'derived_with_keys=on,loosescan=on,semijoin=on,materialization=off';
|
||||
|
||||
--echo # Part#1: make sure EXPLAIN is using LooseScan:
|
||||
CREATE TABLE t1 ( a INT, b INT );
|
||||
INSERT INTO t1 VALUES
|
||||
(4,0),(6,8),(3,1),(5,8),(3,9),(2,4),
|
||||
(2,6),(9,1),(5,4),(7,7),(5,4);
|
||||
|
||||
CREATE ALGORITHM=TEMPTABLE
|
||||
VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
--echo # This will use LooseScan:
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
|
||||
SELECT * FROM t1 AS t1_1, t1 AS t1_2
|
||||
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
set @@join_cache_level= @tmp_jcl_978479;
|
||||
set @@optimizer_switch= @tmp_os_978479;
|
||||
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
|
|
@ -26,6 +26,13 @@ INSERT INTO t2 VALUES ('1998-01-02','note02');
|
|||
select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
|
||||
drop table t1,t2;
|
||||
|
||||
# MariaDB lp:993103. WHERE LAST_DAY(zero_date) IS NULL does not evaluate to TRUE.
|
||||
|
||||
CREATE TABLE t1(a INT);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Date and BETWEEN
|
||||
#
|
||||
|
|
13
mysql-test/t/update_ignore_216.test
Normal file
13
mysql-test/t/update_ignore_216.test
Normal file
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# MDEV-216 lp:976104 - Assertion `0' failed in my_message_sql on UPDATE IGNORE, or unknown error on release build
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( a INT, b CHAR(3) );
|
||||
INSERT INTO t1 VALUES ( 1, 'foo' );
|
||||
CREATE TABLE t2 ( c CHAR(3), d INT );
|
||||
INSERT INTO t2 VALUES ( 'foo', 1 );
|
||||
|
||||
UPDATE IGNORE t1, t2 SET b = 'bar', c = 'bar'
|
||||
WHERE a != ( SELECT 1 UNION SELECT 2 );
|
||||
|
||||
DROP TABLE t1, t2;
|
|
@ -8787,7 +8787,7 @@ bool Item_cache_temporal::cache_value()
|
|||
value_cached= true;
|
||||
|
||||
MYSQL_TIME ltime;
|
||||
if (example->get_date(<ime, TIME_FUZZY_DATE))
|
||||
if (example->get_date_result(<ime, TIME_FUZZY_DATE))
|
||||
value=0;
|
||||
else
|
||||
value= pack_time(<ime);
|
||||
|
|
|
@ -1560,6 +1560,7 @@ public:
|
|||
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
||||
COND **conds);
|
||||
void top_level_item() { abort_on_null=1; }
|
||||
bool top_level() { return abort_on_null; }
|
||||
void copy_andor_arguments(THD *thd, Item_cond *item);
|
||||
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
|
||||
Item *transform(Item_transformer transformer, uchar *arg);
|
||||
|
|
|
@ -769,7 +769,8 @@ void Item_subselect::fix_length_and_dec()
|
|||
|
||||
table_map Item_subselect::used_tables() const
|
||||
{
|
||||
return (table_map) (engine->uncacheable() ? used_tables_cache : 0L);
|
||||
return (table_map) ((engine->uncacheable() & ~UNCACHEABLE_EXPLAIN)?
|
||||
used_tables_cache : 0L);
|
||||
}
|
||||
|
||||
|
||||
|
@ -900,6 +901,15 @@ void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
|
|||
}
|
||||
|
||||
|
||||
void Item_maxmin_subselect::no_rows_in_result()
|
||||
{
|
||||
value= 0;
|
||||
null_value= 0;
|
||||
was_values= 0;
|
||||
make_const();
|
||||
}
|
||||
|
||||
|
||||
void Item_singlerow_subselect::reset()
|
||||
{
|
||||
Item_subselect::reset();
|
||||
|
@ -1095,6 +1105,8 @@ void Item_singlerow_subselect::bring_value()
|
|||
double Item_singlerow_subselect::val_real()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->val_real();
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
|
@ -1110,6 +1122,8 @@ double Item_singlerow_subselect::val_real()
|
|||
longlong Item_singlerow_subselect::val_int()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->val_int();
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
|
@ -1124,6 +1138,9 @@ longlong Item_singlerow_subselect::val_int()
|
|||
|
||||
String *Item_singlerow_subselect::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->val_str(str);
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
|
@ -1139,6 +1156,9 @@ String *Item_singlerow_subselect::val_str(String *str)
|
|||
|
||||
my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->val_decimal(decimal_value);
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
|
@ -1154,6 +1174,9 @@ my_decimal *Item_singlerow_subselect::val_decimal(my_decimal *decimal_value)
|
|||
|
||||
bool Item_singlerow_subselect::val_bool()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->val_bool();
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
|
@ -1167,6 +1190,24 @@ bool Item_singlerow_subselect::val_bool()
|
|||
}
|
||||
|
||||
|
||||
bool Item_singlerow_subselect::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (forced_const)
|
||||
return value->get_date(ltime, fuzzydate);
|
||||
if (!exec() && !value->null_value)
|
||||
{
|
||||
null_value= FALSE;
|
||||
return value->get_date(ltime, fuzzydate);
|
||||
}
|
||||
else
|
||||
{
|
||||
reset();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex):
|
||||
Item_subselect()
|
||||
{
|
||||
|
@ -1323,10 +1364,17 @@ Item* Item_exists_subselect::expr_cache_insert_transformer(uchar *thd_arg)
|
|||
}
|
||||
|
||||
|
||||
void Item_exists_subselect::no_rows_in_result()
|
||||
{
|
||||
value= 0;
|
||||
null_value= 0;
|
||||
make_const();
|
||||
}
|
||||
|
||||
double Item_exists_subselect::val_real()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (exec())
|
||||
if (!forced_const && exec())
|
||||
{
|
||||
reset();
|
||||
return 0;
|
||||
|
@ -1337,7 +1385,7 @@ double Item_exists_subselect::val_real()
|
|||
longlong Item_exists_subselect::val_int()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (exec())
|
||||
if (!forced_const && exec())
|
||||
{
|
||||
reset();
|
||||
return 0;
|
||||
|
@ -1362,7 +1410,7 @@ longlong Item_exists_subselect::val_int()
|
|||
String *Item_exists_subselect::val_str(String *str)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (exec())
|
||||
if (!forced_const && exec())
|
||||
reset();
|
||||
str->set((ulonglong)value,&my_charset_bin);
|
||||
return str;
|
||||
|
@ -1385,7 +1433,7 @@ String *Item_exists_subselect::val_str(String *str)
|
|||
my_decimal *Item_exists_subselect::val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (exec())
|
||||
if (!forced_const && exec())
|
||||
reset();
|
||||
int2my_decimal(E_DEC_FATAL_ERROR, value, 0, decimal_value);
|
||||
return decimal_value;
|
||||
|
@ -1395,7 +1443,7 @@ my_decimal *Item_exists_subselect::val_decimal(my_decimal *decimal_value)
|
|||
bool Item_exists_subselect::val_bool()
|
||||
{
|
||||
DBUG_ASSERT(fixed == 1);
|
||||
if (exec())
|
||||
if (!forced_const && exec())
|
||||
{
|
||||
reset();
|
||||
return 0;
|
||||
|
@ -2660,6 +2708,15 @@ void Item_allany_subselect::print(String *str, enum_query_type query_type)
|
|||
}
|
||||
|
||||
|
||||
void Item_allany_subselect::no_rows_in_result()
|
||||
{
|
||||
value= 0;
|
||||
null_value= 0;
|
||||
was_null= 0;
|
||||
make_const();
|
||||
}
|
||||
|
||||
|
||||
void subselect_engine::set_thd(THD *thd_arg)
|
||||
{
|
||||
thd= thd_arg;
|
||||
|
@ -2869,7 +2926,7 @@ void subselect_engine::set_row(List<Item> &item_list, Item_cache **row)
|
|||
item->decimals= sel_item->decimals;
|
||||
item->unsigned_flag= sel_item->unsigned_flag;
|
||||
maybe_null= sel_item->maybe_null;
|
||||
if (!(row[i]= Item_cache::get_cache(sel_item)))
|
||||
if (!(row[i]= Item_cache::get_cache(sel_item, sel_item->cmp_type())))
|
||||
return;
|
||||
row[i]->setup(sel_item);
|
||||
//psergey-backport-timours: row[i]->store(sel_item);
|
||||
|
|
|
@ -158,6 +158,11 @@ public:
|
|||
eliminated= FALSE;
|
||||
null_value= 1;
|
||||
}
|
||||
/**
|
||||
Set the subquery result to the default value for the predicate when the
|
||||
subquery is known to produce an empty result.
|
||||
*/
|
||||
void no_rows_in_result()= 0;
|
||||
virtual bool select_transformer(JOIN *join);
|
||||
bool assigned() { return value_assigned; }
|
||||
void assigned(bool a) { value_assigned= a; }
|
||||
|
@ -274,6 +279,7 @@ public:
|
|||
subs_type substype() { return SINGLEROW_SUBS; }
|
||||
|
||||
void reset();
|
||||
void no_rows_in_result() { reset(); make_const(); }
|
||||
bool select_transformer(JOIN *join);
|
||||
void store(uint i, Item* item);
|
||||
double val_real();
|
||||
|
@ -281,6 +287,7 @@ public:
|
|||
String *val_str (String *);
|
||||
my_decimal *val_decimal(my_decimal *);
|
||||
bool val_bool();
|
||||
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
|
||||
enum Item_result result_type() const;
|
||||
enum_field_types field_type() const;
|
||||
void fix_length_and_dec();
|
||||
|
@ -326,6 +333,7 @@ public:
|
|||
bool any_value() { return was_values; }
|
||||
void register_value() { was_values= TRUE; }
|
||||
void reset_value_registration() { was_values= FALSE; }
|
||||
void no_rows_in_result();
|
||||
};
|
||||
|
||||
/* exists subselect */
|
||||
|
@ -347,6 +355,7 @@ public:
|
|||
eliminated= FALSE;
|
||||
value= 0;
|
||||
}
|
||||
void no_rows_in_result();
|
||||
|
||||
enum Item_result result_type() const { return INT_RESULT;}
|
||||
longlong val_int();
|
||||
|
@ -676,6 +685,7 @@ public:
|
|||
virtual void print(String *str, enum_query_type query_type);
|
||||
bool is_maxmin_applicable(JOIN *join);
|
||||
bool transform_into_max_min(JOIN *join);
|
||||
void no_rows_in_result();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -5467,8 +5467,8 @@ bool JOIN::choose_tableless_subquery_plan()
|
|||
/*
|
||||
If the optimizer determined that his query has an empty result,
|
||||
in most cases the subquery predicate is a known constant value -
|
||||
either FALSE or NULL. The implementation of Item_subselect::reset()
|
||||
determines which one.
|
||||
either of TRUE, FALSE or NULL. The implementation of
|
||||
Item_subselect::no_rows_in_result() determines which one.
|
||||
*/
|
||||
if (zero_result_cause)
|
||||
{
|
||||
|
@ -5476,14 +5476,13 @@ bool JOIN::choose_tableless_subquery_plan()
|
|||
{
|
||||
/*
|
||||
Both group by queries and non-group by queries without aggregate
|
||||
functions produce empty subquery result.
|
||||
functions produce empty subquery result. There is no need to further
|
||||
rewrite the subquery because it will not be executed at all.
|
||||
*/
|
||||
subs_predicate->reset();
|
||||
subs_predicate->make_const();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
/* @todo
|
||||
A further optimization is possible when a non-group query with
|
||||
MIN/MAX/COUNT is optimized by opt_sum_query. Then, if there are
|
||||
only MIN/MAX functions over an empty result set, the subquery
|
||||
|
|
|
@ -146,7 +146,9 @@ public:
|
|||
|
||||
void add_keyuse(table_map remaining_tables, KEYUSE *keyuse)
|
||||
{
|
||||
if (try_loosescan && keyuse->sj_pred_no != UINT_MAX)
|
||||
if (try_loosescan && keyuse->sj_pred_no != UINT_MAX &&
|
||||
(keyuse->table->file->index_flags(keyuse->key, 0, 1 ) & HA_READ_ORDER))
|
||||
|
||||
{
|
||||
if (!(remaining_tables & keyuse->used_tables))
|
||||
{
|
||||
|
|
|
@ -86,6 +86,40 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static ulonglong view_algo_to_frm(ulonglong val)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case VIEW_ALGORITHM_UNDEFINED:
|
||||
return VIEW_ALGORITHM_UNDEFINED_FRM;
|
||||
case VIEW_ALGORITHM_MERGE:
|
||||
return VIEW_ALGORITHM_MERGE_FRM;
|
||||
case VIEW_ALGORITHM_TMPTABLE:
|
||||
return VIEW_ALGORITHM_TMPTABLE_FRM;
|
||||
}
|
||||
DBUG_ASSERT(0); /* Should never happen */
|
||||
return VIEW_ALGORITHM_UNDEFINED;
|
||||
}
|
||||
|
||||
static ulonglong view_algo_from_frm(ulonglong val)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case VIEW_ALGORITHM_UNDEFINED_FRM:
|
||||
return VIEW_ALGORITHM_UNDEFINED;
|
||||
case VIEW_ALGORITHM_MERGE_FRM:
|
||||
return VIEW_ALGORITHM_MERGE;
|
||||
case VIEW_ALGORITHM_TMPTABLE_FRM:
|
||||
return VIEW_ALGORITHM_TMPTABLE;
|
||||
}
|
||||
|
||||
/*
|
||||
Early versions of MariaDB 5.2/5.3 had identical in-memory and frm values
|
||||
Return input value.
|
||||
*/
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write parameter value to IO_CACHE.
|
||||
|
@ -124,8 +158,14 @@ write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
|
|||
break;
|
||||
}
|
||||
case FILE_OPTIONS_ULONGLONG:
|
||||
case FILE_OPTIONS_VIEW_ALGO:
|
||||
{
|
||||
num.set(*((ulonglong *)(base + parameter->offset)), &my_charset_bin);
|
||||
ulonglong val= *(ulonglong *)(base + parameter->offset);
|
||||
|
||||
if (parameter->type == FILE_OPTIONS_VIEW_ALGO)
|
||||
val= view_algo_to_frm(val);
|
||||
|
||||
num.set(val, &my_charset_bin);
|
||||
if (my_b_append(file, (const uchar *)num.ptr(), num.length()))
|
||||
DBUG_RETURN(TRUE);
|
||||
break;
|
||||
|
@ -769,6 +809,7 @@ File_parser::parse(uchar* base, MEM_ROOT *mem_root,
|
|||
break;
|
||||
}
|
||||
case FILE_OPTIONS_ULONGLONG:
|
||||
case FILE_OPTIONS_VIEW_ALGO:
|
||||
if (!(eol= strchr(ptr, '\n')))
|
||||
{
|
||||
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
||||
|
@ -777,8 +818,12 @@ File_parser::parse(uchar* base, MEM_ROOT *mem_root,
|
|||
}
|
||||
{
|
||||
int not_used;
|
||||
*((ulonglong*)(base + parameter->offset))=
|
||||
my_strtoll10(ptr, 0, ¬_used);
|
||||
ulonglong val= (ulonglong)my_strtoll10(ptr, 0, ¬_used);
|
||||
|
||||
if (parameter->type == FILE_OPTIONS_VIEW_ALGO)
|
||||
val= view_algo_from_frm(val);
|
||||
|
||||
*((ulonglong*)(base + parameter->offset))= val;
|
||||
}
|
||||
ptr= eol+1;
|
||||
break;
|
||||
|
|
|
@ -31,6 +31,7 @@ enum file_opt_type {
|
|||
FILE_OPTIONS_STRING, /**< String (LEX_STRING) */
|
||||
FILE_OPTIONS_ESTRING, /**< Escaped string (LEX_STRING) */
|
||||
FILE_OPTIONS_ULONGLONG, /**< ulonglong parameter (ulonglong) */
|
||||
FILE_OPTIONS_VIEW_ALGO, /**< Similar to longlong, but needs conversion */
|
||||
FILE_OPTIONS_TIMESTAMP, /**< timestamp (LEX_STRING have to be
|
||||
allocated with length 20 (19+1) */
|
||||
FILE_OPTIONS_STRLIST, /**< list of escaped strings
|
||||
|
|
|
@ -4431,10 +4431,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
|
|||
(event_pos= uint4korr(buf+LOG_POS_OFFSET)) > mi->master_log_pos + inc_pos)
|
||||
{
|
||||
inc_pos= event_pos - mi->master_log_pos;
|
||||
DBUG_PRINT("info", ("Adjust master_log_pos %lu->%lu to account for "
|
||||
DBUG_PRINT("info", ("Adjust master_log_pos %llu->%llu to account for "
|
||||
"master-side filtering",
|
||||
(unsigned long)(mi->master_log_pos + inc_pos),
|
||||
event_pos));
|
||||
mi->master_log_pos + inc_pos, event_pos));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -8559,14 +8559,16 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
|
|||
if (find_mpvio_user(mpvio))
|
||||
return packet_error;
|
||||
|
||||
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH)
|
||||
if ((thd->client_capabilities & CLIENT_PLUGIN_AUTH) &&
|
||||
(client_plugin < (char *)net->read_pos + pkt_len))
|
||||
{
|
||||
if (client_plugin >= (char *)net->read_pos + pkt_len)
|
||||
return packet_error;
|
||||
client_plugin= fix_plugin_ptr(client_plugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Some clients lie. Sad, but true */
|
||||
thd->client_capabilities &= ~CLIENT_PLUGIN_AUTH;
|
||||
|
||||
if (thd->client_capabilities & CLIENT_SECURE_CONNECTION)
|
||||
client_plugin= native_password_plugin_name.str;
|
||||
else
|
||||
|
|
|
@ -8499,6 +8499,11 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
field_iterator.create_item() builds used_items which we
|
||||
have to save because changes made once and they are persistent
|
||||
*/
|
||||
tables->persistent_used_items= tables->used_items;
|
||||
|
||||
if ((field= field_iterator.field()))
|
||||
{
|
||||
|
|
|
@ -3420,6 +3420,11 @@ bool st_select_lex::optimize_unflattened_subqueries()
|
|||
continue;
|
||||
}
|
||||
|
||||
bool empty_union_result= true;
|
||||
/*
|
||||
If the subquery is a UNION, optimize all the subqueries in the UNION. If
|
||||
there is no UNION, then the loop will execute once for the subquery.
|
||||
*/
|
||||
for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
|
||||
{
|
||||
JOIN *inner_join= sl->join;
|
||||
|
@ -3442,9 +3447,19 @@ bool st_select_lex::optimize_unflattened_subqueries()
|
|||
res= inner_join->optimize();
|
||||
inner_join->select_options= save_options;
|
||||
un->thd->lex->current_select= save_select;
|
||||
if (empty_union_result)
|
||||
{
|
||||
/*
|
||||
If at least one subquery in a union is non-empty, the UNION result
|
||||
is non-empty. If there is no UNION, the only subquery is non-empy.
|
||||
*/
|
||||
empty_union_result= inner_join->empty_result();
|
||||
}
|
||||
if (res)
|
||||
return TRUE;
|
||||
}
|
||||
if (empty_union_result)
|
||||
subquery_predicate->no_rows_in_result();
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -12178,9 +12178,10 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab,
|
|||
|
||||
@param cond condition whose multiple equalities are to be checked
|
||||
@param table constant table that has been read
|
||||
@param const_key mark key parts as constant
|
||||
*/
|
||||
|
||||
static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
|
||||
static void update_const_equal_items(COND *cond, JOIN_TAB *tab, bool const_key)
|
||||
{
|
||||
if (!(cond->used_tables() & tab->table->map))
|
||||
return;
|
||||
|
@ -12191,7 +12192,10 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
|
|||
List_iterator_fast<Item> li(*cond_list);
|
||||
Item *item;
|
||||
while ((item= li++))
|
||||
update_const_equal_items(item, tab);
|
||||
update_const_equal_items(item, tab,
|
||||
(((Item_cond*) cond)->top_level() &&
|
||||
((Item_cond*) cond)->functype() ==
|
||||
Item_func::COND_AND_FUNC));
|
||||
}
|
||||
else if (cond->type() == Item::FUNC_ITEM &&
|
||||
((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
|
||||
|
@ -12221,7 +12225,8 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
|
|||
TABLE *tab= field->table;
|
||||
KEYUSE *use;
|
||||
for (use= stat->keyuse; use && use->table == tab; use++)
|
||||
if (!use->is_for_hash_join() && possible_keys.is_set(use->key) &&
|
||||
if (const_key &&
|
||||
!use->is_for_hash_join() && possible_keys.is_set(use->key) &&
|
||||
tab->key_info[use->key].key_part[use->keypart].field ==
|
||||
field)
|
||||
tab->const_key_parts[use->key]|= use->keypart_map;
|
||||
|
@ -16428,7 +16433,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
|
|||
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
|
||||
/* Check appearance of new constant items in Item_equal objects */
|
||||
if (join->conds)
|
||||
update_const_equal_items(join->conds, tab);
|
||||
update_const_equal_items(join->conds, tab, TRUE);
|
||||
while ((tbl= ti++))
|
||||
{
|
||||
TABLE_LIST *embedded;
|
||||
|
@ -16437,7 +16442,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
|
|||
{
|
||||
embedded= embedding;
|
||||
if (embedded->on_expr)
|
||||
update_const_equal_items(embedded->on_expr, tab);
|
||||
update_const_equal_items(embedded->on_expr, tab, TRUE);
|
||||
embedding= embedded->embedding;
|
||||
}
|
||||
while (embedding &&
|
||||
|
@ -18265,7 +18270,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||
int ref_key;
|
||||
uint UNINIT_VAR(ref_key_parts);
|
||||
int order_direction= 0;
|
||||
uint used_key_parts;
|
||||
uint used_key_parts= 0;
|
||||
TABLE *table=tab->table;
|
||||
SQL_SELECT *select=tab->select;
|
||||
key_map usable_keys;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
|
||||
#if defined(WITH_ARIA_STORAGE_ENGINE)
|
||||
#include "../storage/maria/ha_maria.h"
|
||||
#include <maria.h>
|
||||
#endif
|
||||
#if defined(USE_ARIA_FOR_TMP_TABLES)
|
||||
#define TMP_ENGINE_HTON maria_hton
|
||||
|
@ -1319,6 +1319,7 @@ public:
|
|||
return (do_send_rows && implicit_grouping && !group_optimized_away &&
|
||||
having_value != Item::COND_FALSE);
|
||||
}
|
||||
bool empty_result() { return (zero_result_cause && !implicit_grouping); }
|
||||
bool change_result(select_result *result);
|
||||
bool is_top_level_join() const
|
||||
{
|
||||
|
|
|
@ -1406,11 +1406,7 @@ bool mysql_multi_update(THD *thd,
|
|||
DBUG_PRINT("info",("res: %d report_error: %d", res, (int) thd->is_error()));
|
||||
res|= thd->is_error();
|
||||
if (unlikely(res))
|
||||
{
|
||||
/* If we had a another error reported earlier then this will be ignored */
|
||||
(*result)->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR));
|
||||
(*result)->abort_result_set();
|
||||
}
|
||||
thd->abort_on_warning= 0;
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
|
|
@ -752,7 +752,7 @@ static File_option view_parameters[]=
|
|||
FILE_OPTIONS_ULONGLONG},
|
||||
{{ C_STRING_WITH_LEN("algorithm")},
|
||||
my_offsetof(TABLE_LIST, algorithm),
|
||||
FILE_OPTIONS_ULONGLONG},
|
||||
FILE_OPTIONS_VIEW_ALGO},
|
||||
{{ C_STRING_WITH_LEN("definer_user")},
|
||||
my_offsetof(TABLE_LIST, definer.user),
|
||||
FILE_OPTIONS_STRING},
|
||||
|
|
|
@ -6696,7 +6696,8 @@ bool TABLE_LIST::change_refs_to_fields()
|
|||
We need to restore the pointers after the execution of the
|
||||
prepared statement.
|
||||
*/
|
||||
thd->change_item_tree((Item **)&ref->ref, (Item*)materialized_items + idx);
|
||||
thd->change_item_tree((Item **)&ref->ref,
|
||||
(Item*)(materialized_items + idx));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
17
sql/table.h
17
sql/table.h
|
@ -1363,12 +1363,6 @@ typedef struct st_schema_table
|
|||
/*
|
||||
Types of derived tables. The ending part is a bitmap of phases that are
|
||||
applicable to a derived table of the type.
|
||||
* /
|
||||
#define VIEW_ALGORITHM_UNDEFINED 0
|
||||
#define VIEW_ALGORITHM_MERGE 1 + DT_COMMON + DT_MERGE
|
||||
#define DERIVED_ALGORITHM_MERGE 2 + DT_COMMON + DT_MERGE
|
||||
#define VIEW_ALGORITHM_TMPTABLE 3 + DT_COMMON + DT_MATERIALIZE
|
||||
#define DERIVED_ALGORITHM_MATERIALIZE 4 + DT_COMMON + DT_MATERIALIZE
|
||||
*/
|
||||
#define DTYPE_ALGORITHM_UNDEFINED 0
|
||||
#define DTYPE_VIEW 1
|
||||
|
@ -1401,7 +1395,16 @@ typedef struct st_schema_table
|
|||
|
||||
#define VIEW_ALGORITHM_UNDEFINED 0
|
||||
#define VIEW_ALGORITHM_MERGE (DTYPE_VIEW | DTYPE_MERGE)
|
||||
#define VIEW_ALGORITHM_TMPTABLE (DTYPE_VIEW + DTYPE_MATERIALIZE )
|
||||
#define VIEW_ALGORITHM_TMPTABLE (DTYPE_VIEW | DTYPE_MATERIALIZE)
|
||||
|
||||
/*
|
||||
View algorithm values as stored in the FRM. Values differ from in-memory
|
||||
representation for backward compatibility.
|
||||
*/
|
||||
|
||||
#define VIEW_ALGORITHM_UNDEFINED_FRM 0
|
||||
#define VIEW_ALGORITHM_MERGE_FRM 1
|
||||
#define VIEW_ALGORITHM_TMPTABLE_FRM 2
|
||||
|
||||
#define JOIN_TYPE_LEFT 1
|
||||
#define JOIN_TYPE_RIGHT 2
|
||||
|
|
|
@ -49,7 +49,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <m_ctype.h>
|
||||
#include <mysys_err.h>
|
||||
#include <mysql/plugin.h>
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
#include <mysql/psi/psi.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ Smart ALTER TABLE
|
|||
#include <unireg.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <sql_lex.h> // SQLCOM_CREATE_INDEX
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
|
||||
extern "C" {
|
||||
#include "log0log.h"
|
||||
|
|
|
@ -33,7 +33,7 @@ Created July 18, 2007 Vasil Dimov
|
|||
#include <my_sys.h>
|
||||
#include "i_s.h"
|
||||
#include <sql_plugin.h>
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
|
||||
extern "C" {
|
||||
#include "btr0types.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#ifndef _WIN32 /*no fork() in Windows*/
|
||||
|
||||
#include "maria.h"
|
||||
#include "maria_def.h"
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
/* This file is included by all internal maria files */
|
||||
|
||||
#include "maria.h" /* Structs & some defines */
|
||||
#include "ma_pagecache.h"
|
||||
#include <myisampack.h> /* packing of keys */
|
||||
#include <my_tree.h>
|
||||
#include <my_bitmap.h>
|
||||
|
@ -45,6 +46,75 @@
|
|||
/* maria_open() flag, specific for maria_pack */
|
||||
#define HA_OPEN_IGNORE_MOVED_STATE (1U << 30)
|
||||
|
||||
extern PAGECACHE maria_pagecache_var, *maria_pagecache;
|
||||
int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map,
|
||||
PAGECACHE *key_cache);
|
||||
void maria_change_pagecache(PAGECACHE *old_key_cache,
|
||||
PAGECACHE *new_key_cache);
|
||||
|
||||
typedef struct st_maria_sort_info
|
||||
{
|
||||
/* sync things */
|
||||
mysql_mutex_t mutex;
|
||||
mysql_cond_t cond;
|
||||
MARIA_HA *info, *new_info;
|
||||
HA_CHECK *param;
|
||||
char *buff;
|
||||
SORT_KEY_BLOCKS *key_block, *key_block_end;
|
||||
SORT_FT_BUF *ft_buf;
|
||||
my_off_t filelength, dupp, buff_length;
|
||||
pgcache_page_no_t page;
|
||||
ha_rows max_records;
|
||||
uint current_key, total_keys;
|
||||
uint got_error, threads_running;
|
||||
myf myf_rw;
|
||||
enum data_file_type new_data_file_type, org_data_file_type;
|
||||
} MARIA_SORT_INFO;
|
||||
|
||||
typedef struct st_maria_sort_param
|
||||
{
|
||||
pthread_t thr;
|
||||
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
|
||||
DYNAMIC_ARRAY buffpek;
|
||||
MARIA_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
|
||||
|
||||
MARIA_KEYDEF *keyinfo;
|
||||
MARIA_SORT_INFO *sort_info;
|
||||
HA_KEYSEG *seg;
|
||||
uchar **sort_keys;
|
||||
uchar *rec_buff;
|
||||
void *wordlist, *wordptr;
|
||||
MEM_ROOT wordroot;
|
||||
uchar *record;
|
||||
MY_TMPDIR *tmpdir;
|
||||
|
||||
/*
|
||||
The next two are used to collect statistics, see maria_update_key_parts for
|
||||
description.
|
||||
*/
|
||||
ulonglong unique[HA_MAX_KEY_SEG+1];
|
||||
ulonglong notnull[HA_MAX_KEY_SEG+1];
|
||||
|
||||
MARIA_RECORD_POS pos,max_pos,filepos,start_recpos, current_filepos;
|
||||
uint key, key_length,real_key_length,sortbuff_size;
|
||||
uint maxbuffers, keys, find_length, sort_keys_length;
|
||||
my_bool fix_datafile, master;
|
||||
my_bool calc_checksum; /* calculate table checksum */
|
||||
size_t rec_buff_size;
|
||||
|
||||
int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *);
|
||||
int (*key_read)(struct st_maria_sort_param *, uchar *);
|
||||
int (*key_write)(struct st_maria_sort_param *, const uchar *);
|
||||
void (*lock_in_memory)(HA_CHECK *);
|
||||
int (*write_keys)(struct st_maria_sort_param *, register uchar **,
|
||||
uint , struct st_buffpek *, IO_CACHE *);
|
||||
uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
|
||||
int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,uchar *,
|
||||
uint, uint);
|
||||
} MARIA_SORT_PARAM;
|
||||
|
||||
int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile);
|
||||
|
||||
struct st_transaction;
|
||||
|
||||
/* undef map from my_nosys; We need test-if-disk full */
|
||||
|
|
|
@ -51,7 +51,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
#include <m_ctype.h>
|
||||
#include <mysys_err.h>
|
||||
#include <mysql/plugin.h>
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
#include <mysql/psi/psi.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Smart ALTER TABLE
|
|||
#include <mysqld_error.h>
|
||||
#include <sql_class.h>
|
||||
#include <sql_lex.h> // SQLCOM_CREATE_INDEX
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
|
||||
extern "C" {
|
||||
#include "log0log.h"
|
||||
|
|
|
@ -34,7 +34,7 @@ Created July 18, 2007 Vasil Dimov
|
|||
#include <my_sys.h>
|
||||
#include "i_s.h"
|
||||
#include <sql_plugin.h>
|
||||
#include <mysql/innodb_priv.h>
|
||||
#include <innodb_priv.h>
|
||||
|
||||
extern "C" {
|
||||
#include "btr0pcur.h" /* for file sys_tables related info. */
|
||||
|
|
|
@ -24,6 +24,7 @@ FIND_PATH(WIX_DIR heat.exe
|
|||
"$ENV{ProgramFiles}/Windows Installer XML v3/bin"
|
||||
"$ENV{ProgramFiles}/Windows Installer XML v3.5/bin"
|
||||
"$ENV{ProgramFiles}/Windows Installer XML v3.6/bin"
|
||||
"$ENV{WIX}/bin"
|
||||
)
|
||||
|
||||
SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB")
|
||||
|
|
|
@ -22,28 +22,40 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
|
|||
|
||||
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
SET(WIX_ARCH_SUFFIX "_x64")
|
||||
SET(WIX36_ARCH_SUFFIX "x64")
|
||||
ELSE()
|
||||
SET(WIX_ARCH_SUFFIX)
|
||||
SET(WIX36_ARCH_SUFFIX "x86")
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC_VERSION EQUAL 1400)
|
||||
SET(WIX35_MSVC_SUFFIX "_2005")
|
||||
ELSEIF(MSVC_VERSION EQUAL 1500)
|
||||
SET(WIX35_MSVC_SUFFIX "_2008")
|
||||
SET(WIX36_MSVC_SUFFIX "VS2008")
|
||||
ELSEIF(MSVC_VERSION EQUAL 1600)
|
||||
SET(WIX35_MSVC_SUFFIX "_2010")
|
||||
SET(WIX36_MSVC_SUFFIX "VS2010")
|
||||
ELSE()
|
||||
# When next VS is out, add the correct version here
|
||||
MESSAGE(FATAL_ERROR "Unknown VS version")
|
||||
ENDIF()
|
||||
INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/${WIX36_MSVC_SUFFIX}/inc)
|
||||
|
||||
FIND_LIBRARY(WIX_WCAUTIL_LIBRARY
|
||||
NAMES wcautil${WIX_ARCH_SUFFIX} wcautil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
|
||||
HINTS ${WIX_DIR}/../SDK/lib)
|
||||
wcautil
|
||||
PATHS
|
||||
${WIX_DIR}/../SDK/lib
|
||||
${WIX_DIR}/../SDK/${WIX36_MSVC_SUFFIX}/lib/${WIX36_ARCH_SUFFIX})
|
||||
|
||||
FIND_LIBRARY(WIX_DUTIL_LIBRARY
|
||||
NAMES dutil${WIX_ARCH_SUFFIX} dutil${WIX35_MSVC_SUFFIX}${WIX_ARCH_SUFFIX}
|
||||
PATHS ${WIX_DIR}/../SDK/lib)
|
||||
dutil
|
||||
PATHS
|
||||
${WIX_DIR}/../SDK/lib
|
||||
${WIX_DIR}/../SDK/${WIX36_MSVC_SUFFIX}/lib/${WIX36_ARCH_SUFFIX}
|
||||
)
|
||||
|
||||
ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES)
|
||||
ADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES})
|
||||
|
|
Loading…
Reference in a new issue