summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-05-05 14:59:44 +0200
committerSergei Golubchik <sergii@pisem.net>2012-05-05 14:59:44 +0200
commit867ce618cbf4880b92a98022c7de813a0e5d8b28 (patch)
tree1d17e95b3c4f4373fbc575dfd9010dc5805c4d7a
parentaa8f0606e809f19c23f918286cbfefc5a4172072 (diff)
parent91527014c2f8cbc63e1588beb84d27b7780dbd85 (diff)
downloadmariadb-git-867ce618cbf4880b92a98022c7de813a0e5d8b28.tar.gz
merge
-rw-r--r--.bzrignore1
-rw-r--r--debian/libmariadbclient-dev.files3
-rw-r--r--include/CMakeLists.txt23
-rw-r--r--include/maria.h70
-rw-r--r--include/thread_pool_priv.h (renamed from include/mysql/thread_pool_priv.h)0
-rw-r--r--mysql-test/r/derived_view.result53
-rw-r--r--mysql-test/r/gis-precise.result10
-rw-r--r--mysql-test/r/group_by.result47
-rw-r--r--mysql-test/r/in_datetime_241.result5
-rw-r--r--mysql-test/r/subselect.result43
-rw-r--r--mysql-test/r/subselect_no_mat.result43
-rw-r--r--mysql-test/r/subselect_no_opts.result43
-rw-r--r--mysql-test/r/subselect_no_scache.result43
-rw-r--r--mysql-test/r/subselect_no_semijoin.result43
-rw-r--r--mysql-test/r/subselect_sj.result40
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result40
-rw-r--r--mysql-test/r/type_date.result6
-rw-r--r--mysql-test/r/update_ignore_216.result9
-rw-r--r--mysql-test/t/derived_view.test24
-rw-r--r--mysql-test/t/gis-precise.test5
-rw-r--r--mysql-test/t/group_by.test39
-rw-r--r--mysql-test/t/in_datetime_241.test9
-rw-r--r--mysql-test/t/subselect.test29
-rw-r--r--mysql-test/t/subselect_sj.test33
-rw-r--r--mysql-test/t/type_date.test7
-rw-r--r--mysql-test/t/update_ignore_216.test13
-rw-r--r--regex/CMakeLists.txt2
-rw-r--r--sql/CMakeLists.txt6
-rw-r--r--sql/innodb_priv.h (renamed from include/mysql/innodb_priv.h)0
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item_cmpfunc.h1
-rw-r--r--sql/item_subselect.cc71
-rw-r--r--sql/item_subselect.h10
-rw-r--r--sql/opt_subselect.cc11
-rw-r--r--sql/opt_subselect.h4
-rw-r--r--sql/parse_file.cc51
-rw-r--r--sql/parse_file.h1
-rw-r--r--sql/slave.cc5
-rw-r--r--sql/sql_acl.cc8
-rw-r--r--sql/sql_base.cc5
-rw-r--r--sql/sql_lex.cc15
-rw-r--r--sql/sql_select.cc17
-rw-r--r--sql/sql_select.h3
-rw-r--r--sql/sql_update.cc4
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/table.cc3
-rw-r--r--sql/table.h17
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/handler/handler0alter.cc2
-rw-r--r--storage/innobase/handler/i_s.cc2
-rw-r--r--storage/maria/ma_test3.c2
-rw-r--r--storage/maria/maria_def.h70
-rw-r--r--storage/xtradb/handler/ha_innodb.cc2
-rw-r--r--storage/xtradb/handler/handler0alter.cc2
-rw-r--r--storage/xtradb/handler/i_s.cc2
-rw-r--r--win/packaging/CMakeLists.txt1
-rw-r--r--win/packaging/ca/CMakeLists.txt16
57 files changed, 877 insertions, 143 deletions
diff --git a/.bzrignore b/.bzrignore
index f757e602563..f2b28d74d64 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1140,3 +1140,4 @@ libmysqld/gcalc_tools.cc
sql/share/errmsg.sys
sql/share/mysql
install_manifest.txt
+sql/db.opt
diff --git a/debian/libmariadbclient-dev.files b/debian/libmariadbclient-dev.files
index f75f049ec00..8f56a3065d5 100644
--- a/debian/libmariadbclient-dev.files
+++ b/debian/libmariadbclient-dev.files
@@ -1,6 +1,5 @@
usr/bin/mysql_config
-usr/include/mysql/*.h
-usr/include/mysql/psi/*.h
+usr/include/mysql
usr/lib/libmysqlclient.a
usr/lib/libmysqlclient_r.a
usr/lib/libmysqlservices.a
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 3046c3f7614..6404074c8c9 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -14,11 +14,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
SET(HEADERS_GEN_CONFIGURE
-${CMAKE_CURRENT_BINARY_DIR}/mysql_version.h
-${CMAKE_CURRENT_BINARY_DIR}/my_config.h
-${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h
-${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
-${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
+ mysql_version.h
+ my_config.h
+ mysqld_ername.h
+ mysqld_error.h
+ sql_state.h
)
SET(HEADERS
@@ -49,8 +49,19 @@ SET(HEADERS
m_ctype.h
my_attribute.h
my_compiler.h
- ${HEADERS_GEN_CONFIGURE}
)
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
+FOREACH(f ${HEADERS_GEN_CONFIGURE})
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
+ENDFOREACH(f)
INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h")
+
+STRING(REPLACE "." "\\." EXCL_RE "${HEADERS};${HEADERS_GEN_CONFIGURE}")
+STRING(REPLACE ";" "|" EXCL_RE "${EXCL_RE}")
+
+INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN CMakeFiles EXCLUDE
+ PATTERN mysql EXCLUDE
+ REGEX "\\./(${EXCL_RE}$)" EXCLUDE)
diff --git a/include/maria.h b/include/maria.h
index 404ce98dafd..cb2f92e8a35 100644
--- a/include/maria.h
+++ b/include/maria.h
@@ -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);
diff --git a/include/mysql/thread_pool_priv.h b/include/thread_pool_priv.h
index 4060cf51733..4060cf51733 100644
--- a/include/mysql/thread_pool_priv.h
+++ b/include/thread_pool_priv.h
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 32081c13376..176d39c50a9 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -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;
diff --git a/mysql-test/r/gis-precise.result b/mysql-test/r/gis-precise.result
index b8d52ddaa43..3b07be3930a 100644
--- a/mysql-test/r/gis-precise.result
+++ b/mysql-test/r/gis-precise.result
@@ -437,18 +437,18 @@ ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 383
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));
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))
POLYGON((3.999999999999999 6.999999999999998,4 7,3.999999999999999 6.999999999999998))
-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 ));
-ASTEXT(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
+))' ), 3 )));
+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 ))
-POLYGON((-0.07293649627016707 -5.999113246863451,-0.22000815313430944 -5.991921859366389,-0.36654979108711294 -5.9775226700487085,-0.5122083784872182 -5.955950367818698,-0.6566330110393919 -5.927256922241938,-0.7994757571537123 -5.891511458342072,-0.9403924961432446 -5.848800090072569,-1.0790437472409127 -5.799225712860663,-1.2150954874384077 -5.742907755723261,-1.3482199561768686 -5.679981893551977,-1.4780964449507783 -5.610599720260437,-1.604412069922844 -5.534928383581259,-1.7268625256885657 -5.453150182392531,-1.8451528183746095 -5.365462127543841,-1.95899797630489 -5.272075467239885,-2.068123736522295 -5.173215178125043,-2.172267205512173 -5.069119423294928,-2.2711774925358363 -4.96003897854064,-2.364616314048327 -4.846236628207907,-5.275043814484322 -1.1186297530989093,-5.319230881155628 -1.060595091401963,-5.4040722837148305 -0.9402467440153693,-5.482906277573628 -0.8158803911735814,-5.555542944735771 -0.6877956423138013,-5.621807297107846 -0.5563010648149315,-5.681539698060918 -0.421713440631731,-5.734596247009149 -0.28435700313934065,-5.78084912607892 -0.14456265602668295,-5.820186908033274 -0.002667176120491166,-5.852514824709904 0.14098759793956495,-5.877754995325945 0.28605558922010244,-5.895846614099603 0.43218731622367124,-5.906746096736613 0.5790307348202924,-5.910427185428624 0.7262320863526014,-5.906881012110549 0.873436749871442,-5.896116119824521 1.0202900964487915,-5.878158442138949 1.166438343509911,-5.853051240672284 1.3115294071265557,-5.82085500087199 1.455213750217997,-3.8208550008719904 9.455213750217997,-3.810890509428993 9.493971235882178,-3.7697930578388252 9.635367090770822,-3.7218071441700307 9.774576071789534,-3.667048370691708 9.91126281230977,-3.6056486560854664 10.045098022001275,-3.537755917641774 10.175759280121321,-3.4635337149142433 10.302931812254522,-3.38316085569034 10.426309248631974,-3.296830965227768 10.54559436220285,-3.204752019794256 10.660499784680422,-3.1071458456345153 10.770748698837412,-3.00424758457139 10.876075505382953,-2.8963051275286036 10.976226462814537,-2.783578517339813 11.070960298703525,-2.666339322282651 11.160048790941556,-2.544869981846949 11.243277317547594,-2.419463126313273 11.320445373711095,-2.2904208717809498 11.391367054825631,-2.158054092343913 11.455871504349394,-2.0226816711677866 11.513803325413559,-1.8846297322724088 11.565022955186954,-1.7442308548704988 11.609407001095144,-1.6018232721552075 11.646848538083955,-1.4577500564667278 11.67725736621129,-1.312358292800976 11.700560227946688,-1.1659982426514375 11.71670098465514,-1.0190225001985485 11.725640751839975,-0.8717851428794332 11.72735799281901,-0.7246408783843428 11.721848570608318,-0.5779441901347602 11.709125757888568,-0.4320484833017919 11.689220205029992,-0.28730523342215375 11.662179866252945,-0.1440631396628158 11.628069884101997,-0.002667284774170997 11.586972432511828,0.13654169624454027 11.538986518843034,0.2732284367647777 11.484227745364711,0.40706364645628224 11.42282803075847,0.5377249045763282 11.354935292314778,0.6648974367095297 11.280713089587247,0.7882748730869795 11.200340230363343,0.9075599866578576 11.114010339900771,1.022465409135429 11.02193139446726,9.59699349824711 3.798173636344729,9.681101497474424 3.7245938870816415,9.787638712688917 3.622949359037885,9.889060138562687 3.516199732899768,9.985121441997343 3.4046021778668174,10.075591202898927 3.2884255422239015,10.160251471689218 3.167949705662155,10.238898294365335 3.043464905024292,10.3113422038428 2.9152710350986295,10.37740867639835 2.783676926146276,10.436938552112853 2.6489995999019795,10.489788418301517 2.5115635058410044,10.535830955007588 2.371699739551923,10.574955241727293 2.2297452450983433,10.607067024627042 2.0860420032911513,10.632088943609169 1.940936207826777,10.649960718679184 1.7947774312762605,10.660639295165561 1.6479177829343097,10.664098947442213 1.5007110605571654,10.660331340903774 1.3535118980328205,10.649345552044398 1.2066749110369206,10.63116804659169 1.0605538427325394,10.605842615748447 0.9155007115719156,10.573430270695816 0.7718649632531696,10.534009095612015 0.6299926288750068,10.487674059560707 0.49022549131749327,10.43453678770221 0.3529002618571597,10.37472529237871 0.2183477690000466,10.308383664721301 0.08689216148685275,10.235671727521858 -0.0411498726097721,10.156764650205906 -0.16546986881453063,10.07185252683414 -0.2857683293674196,9.98113991814919 -0.40175544474006797,9.88484535877086 -0.5131517918122694,9.783200830727104 -0.6196890070267613,9.676451204588986 -0.7211104329005329,9.564853649556037 -0.8171717363351869,9.448677013913121 -0.9076414972367728,9.328201177351374 -0.9923017660270632,3.328201177351374 -4.992301766027062,3.205062809741012 -5.070143002902289,3.076906846199522 -5.1426539490804295,2.9453473086364443 -5.208789237566124,2.8107011355010223 -5.268389542656644,2.673292701217952 -5.321311281996655,2.533453034740978 -5.367426962480689,0.8693524460652908 -5.871276079467158,0.8008007456874348 -5.891144784632282,0.6579743953925739 -5.92695570431255,0.5135629271474615 -5.9557153313300875,0.3679142408280516 -5.977354381224364,0.22137921687700501 -5.991820723628828,0.07431087100197242 -5.999079507857523,-0.07293649627016707 -5.999113246863451))
+))' ),
+136
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index cffed9529d6..74e9cd3caaa 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -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
diff --git a/mysql-test/r/in_datetime_241.result b/mysql-test/r/in_datetime_241.result
new file mode 100644
index 00000000000..2c5b4bd8db1
--- /dev/null
+++ b/mysql-test/r/in_datetime_241.result
@@ -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;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 29b8c41e515..dca872f0bbd 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -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;
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index e8086b53ead..d5c7084c48d 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -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;
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 12b1e45c92c..7b44b1a1f5d 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -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;
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index b9a4f9b23a9..9b24af0dc3a 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -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;
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index ad6d61e9ec9..ba42ff881fc 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -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;
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index ca834b21df5..f8ebe0d07a9 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -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;
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index 19f3baac5f2..c0a9287483d 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -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
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 8d069477f3e..fbac1752c37 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -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" );
diff --git a/mysql-test/r/update_ignore_216.result b/mysql-test/r/update_ignore_216.result
new file mode 100644
index 00000000000..4abc1eae06e
--- /dev/null
+++ b/mysql-test/r/update_ignore_216.result
@@ -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;
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test
index 03d308b6c45..3320ca25136 100644
--- a/mysql-test/t/derived_view.test
+++ b/mysql-test/t/derived_view.test
@@ -1414,6 +1414,30 @@ 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 #
diff --git a/mysql-test/t/gis-precise.test b/mysql-test/t/gis-precise.test
index 8a10f6dd467..d021bb0b53d 100644
--- a/mysql-test/t/gis-precise.test
+++ b/mysql-test/t/gis-precise.test
@@ -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 )));
+
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index db8bfce2320..a6054e0a28a 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -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 #
diff --git a/mysql-test/t/in_datetime_241.test b/mysql-test/t/in_datetime_241.test
new file mode 100644
index 00000000000..f95a456f5e2
--- /dev/null
+++ b/mysql-test/t/in_datetime_241.test
@@ -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;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index f369f10a5e4..6e98c064d94 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -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;
diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test
index 2fb6f6b53b8..7f1181bb562 100644
--- a/mysql-test/t/subselect_sj.test
+++ b/mysql-test/t/subselect_sj.test
@@ -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;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 22b1eb97dad..52895951787 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -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
#
diff --git a/mysql-test/t/update_ignore_216.test b/mysql-test/t/update_ignore_216.test
new file mode 100644
index 00000000000..bae3930e1a7
--- /dev/null
+++ b/mysql-test/t/update_ignore_216.test
@@ -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;
diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt
index 83c13015671..b4a72620ac5 100644
--- a/regex/CMakeLists.txt
+++ b/regex/CMakeLists.txt
@@ -17,3 +17,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
ADD_CONVENIENCE_LIBRARY(regex ${REGEX_SOURCES})
+
+INSTALL(FILES "my_regex.h" DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development)
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 0e64487e24f..f57addbc117 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -353,3 +353,9 @@ IF(WIN32)
COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade_service mysys winservice)
ENDIF(WIN32)
+
+INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN examples EXCLUDE
+ PATTERN share EXCLUDE
+ PATTERN CMakeFiles EXCLUDE)
diff --git a/include/mysql/innodb_priv.h b/sql/innodb_priv.h
index 5406c292b18..5406c292b18 100644
--- a/include/mysql/innodb_priv.h
+++ b/sql/innodb_priv.h
diff --git a/sql/item.cc b/sql/item.cc
index f9032c79c12..9400af0f79f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -8787,7 +8787,7 @@ bool Item_cache_temporal::cache_value()
value_cached= true;
MYSQL_TIME ltime;
- if (example->get_date(&ltime, TIME_FUZZY_DATE))
+ if (example->get_date_result(&ltime, TIME_FUZZY_DATE))
value=0;
else
value= pack_time(&ltime);
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 5558b77d67d..b9740c7af03 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index b1829c1892a..276f35fe301 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -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);
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 57f413f1ccd..1a4c8a25a01 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -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();
};
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 56b76f5982e..9bf1aaf4039 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -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
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index a12e0c11620..7b8f3142851 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -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))
{
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 699aa7e2b95..a6e3aa7ed66 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -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, &not_used);
+ ulonglong val= (ulonglong)my_strtoll10(ptr, 0, &not_used);
+
+ if (parameter->type == FILE_OPTIONS_VIEW_ALGO)
+ val= view_algo_from_frm(val);
+
+ *((ulonglong*)(base + parameter->offset))= val;
}
ptr= eol+1;
break;
diff --git a/sql/parse_file.h b/sql/parse_file.h
index 20e3051e671..2a0266e98b7 100644
--- a/sql/parse_file.h
+++ b/sql/parse_file.h
@@ -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
diff --git a/sql/slave.cc b/sql/slave.cc
index 941a275cd84..94af12472c1 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -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));
}
/*
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 15c3999be54..41c04b9c413 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -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
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 624fc87815c..7a29bea8049 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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()))
{
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 246f03a7754..6fd6e53424f 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -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;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8f8ecd1725d..916e521d3b9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 53f2356853e..08ddc27e204 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -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
{
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index f9502589beb..7d5fe875d64 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -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);
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index b6a7cf010ed..bbc5c324573 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -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},
diff --git a/sql/table.cc b/sql/table.cc
index dc8ab3c6b42..40304dc6fdc 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -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;
diff --git a/sql/table.h b/sql/table.h
index 7b50caae536..f3f9d5ac036 100644
--- a/sql/table.h
+++ b/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
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 2d38dfadeb3..4fb8ee84952 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -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>
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index e76bed387d3..7bb370a8dc4 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -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"
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index af168c3f848..abbb8b10ce7 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -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"
diff --git a/storage/maria/ma_test3.c b/storage/maria/ma_test3.c
index d2ce68fc063..c11de6f8242 100644
--- a/storage/maria/ma_test3.c
+++ b/storage/maria/ma_test3.c
@@ -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>
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index a2a19924a73..1eb720c9607 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.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 */
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 4cb21d46804..1f004fe72c1 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -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>
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 2fd05901393..97bb8ac59de 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -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"
diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc
index 3b87b860a4a..1c40b87bbbd 100644
--- a/storage/xtradb/handler/i_s.cc
+++ b/storage/xtradb/handler/i_s.cc
@@ -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. */
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt
index 795732e946b..0b5e2f98f16 100644
--- a/win/packaging/CMakeLists.txt
+++ b/win/packaging/CMakeLists.txt
@@ -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")
diff --git a/win/packaging/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt
index 7dd30123587..940e9e3a7d1 100644
--- a/win/packaging/ca/CMakeLists.txt
+++ b/win/packaging/ca/CMakeLists.txt
@@ -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})