From 000f2403aaf918b9e78d592dcb1df69635f59689 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 18:25:58 +0200 Subject: Combining zlib security fixes for version 4.1.13a: Fix for CAN-2005-1849 from zlib-1.2.3 (originally: 2005/07/27 14:55:08+02:00 lenz@mysql.com ) Ensure static linking takes the bundled libraries (originally: 2005/07/27 16:42:13+02:00 lenz@mysql.com ) Version number change. configure.in: Update the version number. support-files/mysql.spec.sh: - build against the bundled zlib, when linking statically (originally: 2005/07/27 16:42:08+02:00 lenz@mysql.com +1 -0 ) zlib/inftrees.h: - applied another security fix to resolve CAN-2005-1849, taken from the 1.2.3 zlib sources (CAN-2005-1849) (originally: 2005/07/27 14:54:58+02:00 lenz@mysql.com +5 -5 ) --- configure.in | 2 +- support-files/mysql.spec.sh | 1 + zlib/inftrees.h | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index 0889e9a3257..e86baf9d0df 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 4.1.13) +AM_INIT_AUTOMAKE(mysql, 4.1.13a) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 7dc04c39225..e4cd3027b8a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -348,6 +348,7 @@ BuildMySQL "--disable-shared \ %if %{STATIC_BUILD} --with-mysqld-ldflags='-all-static' \ --with-client-ldflags='-all-static' \ + --with-zlib-dir=bundled \ $USE_OTHER_LIBC_DIR \ %endif --with-comment=\"MySQL Community Edition - Standard (GPL)\" \ diff --git a/zlib/inftrees.h b/zlib/inftrees.h index 82d365a7e90..b1104c87e76 100644 --- a/zlib/inftrees.h +++ b/zlib/inftrees.h @@ -1,5 +1,5 @@ /* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2003 Mark Adler + * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -36,12 +36,12 @@ typedef struct { */ /* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 code structures (850 for length/literals - and 154 for distances, the latter actually the result of an + exhaustive search was 1444 code structures (852 for length/literals + and 592 for distances, the latter actually the result of an exhaustive search). The true maximum is not known, but the value below is more than safe. */ -#define ENOUGH 1440 -#define MAXD 154 +#define ENOUGH 2048 +#define MAXD 592 /* Type of code to build for inftable() */ typedef enum { -- cgit v1.2.1 From 74e523d259552645067155e2acb87e30d6068d87 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 13:31:15 -0700 Subject: sql_select.cc: Fixed bug #12144. Added an optimization that avoids key access with null keys for the 'ref' method when used in outer joins. The regilar optimization with adding IS NOT NULL expressions is not applied for outer join on expressions as the predicates of these expressions are not pushed down in 4.1. null_key.result, null_key.test: Added a test case for bug #12144. mysql-test/t/null_key.test: Added a test case for bug #12144. mysql-test/r/null_key.result: Added a test case for bug #12144. sql/sql_select.cc: Fixed bug #12144. Added an optimization that avoids key access with null keys for the 'ref' method when used in outer joins. The regilar optimization with adding IS NOT NULL expressions is not applied for outer join on expressions as the predicates of these expressions are not pushed down in 4.1. --- mysql-test/r/null_key.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/null_key.test | 26 ++++++++++++++++++++++++++ sql/sql_select.cc | 9 ++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 4b7400e5e60..9f11a0129cd 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -364,3 +364,34 @@ select * from t1; id id2 1 1 drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES +(NULL), (NULL), (NULL), (NULL), (NULL), +(NULL), (NULL), (NULL), (NULL), (NULL), +(2); +ANALYZE table t1, t2, t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 +1 SIMPLE t2 ref idx idx 5 test.t1.a 1 +1 SIMPLE t3 ref idx idx 5 test.t2.b 1 Using index +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a +LEFT JOIN t3 ON t2.b=t3.b; +a a b b +1 1 1 NULL +2 NULL NULL NULL +3 3 1 NULL +4 NULL NULL NULL +SELECT FOUND_ROWS(); +FOUND_ROWS() +4 +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test index 9b346a181bf..0eff53ac371 100644 --- a/mysql-test/t/null_key.test +++ b/mysql-test/t/null_key.test @@ -191,3 +191,29 @@ select * from t1 where id2 is null or id2 > 0; delete from t1 where id <=> NULL; select * from t1; drop table t1; + +# +# Test for bug #12144: optimizations for key access with null keys +# used for outer joins +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES + (NULL), (NULL), (NULL), (NULL), (NULL), + (NULL), (NULL), (NULL), (NULL), (NULL), + (2); +ANALYZE table t1, t2, t3; + +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a + LEFT JOIN t3 ON t2.b=t3.b; + +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a + LEFT JOIN t3 ON t2.b=t3.b; + +SELECT FOUND_ROWS(); + +DROP TABLE t1,t2,t3; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 29560e8701b..6f95ca1390e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2255,7 +2255,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond, */ (*key_fields)->null_rejecting= (cond->functype() == Item_func::EQ_FUNC) && ((*value)->type() == Item::FIELD_ITEM) && - ((Item_field*)*value)->field->maybe_null(); + + (((Item_field*)*value)->field->maybe_null() || + ((Item_field *)*value)->field->table->maybe_null); (*key_fields)++; } @@ -6310,6 +6312,11 @@ join_read_always_key(JOIN_TAB *tab) int error; TABLE *table= tab->table; + for (uint i= 0 ; i < tab->ref.key_parts ; i++) + { + if ((tab->ref.null_rejecting & 1 << i) && tab->ref.items[i]->is_null()) + return -1; + } if (!table->file->inited) table->file->ha_index_init(tab->ref.key); if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) -- cgit v1.2.1 From a54ddda4c826a4142f9fb779a58577528f525d73 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 16:04:47 -0700 Subject: null_key.test, null_key.result: Modified the test case for patch of the bug #12144 to display status of Handler_read_next before and after the tested query. mysql-test/r/null_key.result: Modified the test case for patch of the bug #12144 to display status of Handler_read_next before and after the tested query. mysql-test/t/null_key.test: Modified the test case for patch of the bug #12144 to display status of Handler_read_next before and after the tested query. --- mysql-test/r/null_key.result | 42 +++++++++++++++++++++++++++++++++++++++--- mysql-test/t/null_key.test | 30 +++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 9f11a0129cd..89f9663f527 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -367,23 +367,51 @@ drop table t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int, b int, INDEX idx(a)); CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); INSERT INTO t1 VALUES (1), (2), (3), (4); INSERT INTO t2 VALUES (1, 1), (3, 1); INSERT INTO t3 VALUES (NULL), (NULL), (NULL), (NULL), (NULL), -(NULL), (NULL), (NULL), (NULL), (NULL), -(2); +(NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); ANALYZE table t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK test.t2 analyze status OK test.t3 analyze status OK +SELECT COUNT(*) FROM t3; +COUNT(*) +15972 EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 1 SIMPLE t2 ref idx idx 5 test.t1.a 1 1 SIMPLE t3 ref idx idx 5 test.t2.b 1 Using index +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 25 +Handler_read_key 63 +Handler_read_next 25979 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 147 SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; a a b b @@ -391,7 +419,15 @@ a a b b 2 NULL NULL NULL 3 3 1 NULL 4 NULL NULL NULL +SHOW STATUS LIKE "handler_read%"; +Variable_name Value +Handler_read_first 25 +Handler_read_key 69 +Handler_read_next 25981 +Handler_read_prev 0 +Handler_read_rnd 0 +Handler_read_rnd_next 152 SELECT FOUND_ROWS(); FOUND_ROWS() 4 -DROP TABLE t1,t2,t3; +DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test index 4952d6ac8e2..228b00d528a 100644 --- a/mysql-test/t/null_key.test +++ b/mysql-test/t/null_key.test @@ -200,21 +200,45 @@ drop table t1; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int, b int, INDEX idx(a)); CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); INSERT INTO t1 VALUES (1), (2), (3), (4); INSERT INTO t2 VALUES (1, 1), (3, 1); INSERT INTO t3 VALUES (NULL), (NULL), (NULL), (NULL), (NULL), - (NULL), (NULL), (NULL), (NULL), (NULL), - (2); + (NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); + ANALYZE table t1, t2, t3; +SELECT COUNT(*) FROM t3; + EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; +SHOW STATUS LIKE "handler_read%"; + SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; +SHOW STATUS LIKE "handler_read%"; + SELECT FOUND_ROWS(); -DROP TABLE t1,t2,t3; +DROP TABLE t1,t2,t3,t4; # End of 4.1 tests -- cgit v1.2.1 From 0ad1836d23d67e13c88b2c45d253844303503cc0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 17:53:51 -0700 Subject: null_key.test, null_key.result: Made the test case for bug #12144 independent on other tests. mysql-test/r/null_key.result: Made the test case for bug #12144 independent on other tests. mysql-test/t/null_key.test: Made the test case for bug #12144 independent on other tests. --- mysql-test/r/null_key.result | 17 +++++------------ mysql-test/t/null_key.test | 6 +----- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 89f9663f527..516894edb88 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -404,14 +404,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 1 SIMPLE t2 ref idx idx 5 test.t1.a 1 1 SIMPLE t3 ref idx idx 5 test.t2.b 1 Using index -SHOW STATUS LIKE "handler_read%"; -Variable_name Value -Handler_read_first 25 -Handler_read_key 63 -Handler_read_next 25979 -Handler_read_prev 0 -Handler_read_rnd 0 -Handler_read_rnd_next 147 +FLUSH STATUS ; SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; a a b b @@ -421,12 +414,12 @@ a a b b 4 NULL NULL NULL SHOW STATUS LIKE "handler_read%"; Variable_name Value -Handler_read_first 25 -Handler_read_key 69 -Handler_read_next 25981 +Handler_read_first 0 +Handler_read_key 6 +Handler_read_next 2 Handler_read_prev 0 Handler_read_rnd 0 -Handler_read_rnd_next 152 +Handler_read_rnd_next 5 SELECT FOUND_ROWS(); FOUND_ROWS() 4 diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test index 228b00d528a..bd37a031745 100644 --- a/mysql-test/t/null_key.test +++ b/mysql-test/t/null_key.test @@ -230,14 +230,10 @@ SELECT COUNT(*) FROM t3; EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; -SHOW STATUS LIKE "handler_read%"; - - +FLUSH STATUS ; SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; - SHOW STATUS LIKE "handler_read%"; - SELECT FOUND_ROWS(); DROP TABLE t1,t2,t3,t4; -- cgit v1.2.1 From 21d2fb6287347659dd6ce5835ddf16cd3be50279 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 19:11:29 -0700 Subject: func_gconcat.result, func_gconcat.test: Added a test case for bug #12095. sql_class.h: Fixed bug #12095: a join query with GROUP_CONCAT over a single row table. Added a flag to the TMP_TABLE_PARAM class forcing to put constant items generated after elimination of a single row table into temp table in some cases (e.g. when GROUP_CONCAT is calculated over a single row table). bk ci sql/item_sum.cc Fixed bug #12095: a join query with GROUP_CONCAT over a single row table. If GROUP_CONCAT is calculated we always put its argument into a temp table, even when the argument is a constant item. sql_select.cc: Fixed bug #12095: a join query with GROUP_CONCAT over one row table. If temp table is used to calculate GROUP_CONCAT the argument should be always put into this table, even when it is a constant item. sql/sql_select.cc: Fixed bug #12095: a join query with GROUP_CONCAT over one row table. If temp table is used to calculate GROUP_CONCAT the argument should be always put into this table, even when it is a constant item. sql/sql_class.h: Fixed bug #12095: a join query with GROUP_CONCAT over a single row table. Added a flag to the TMP_TABLE_PARAM class forcing to put constant items generated after elimination of a single row table into temp table in some cases (e.g. when GROUP_CONCAT is calculated over a single row table). bk ci sql/item_sum.cc Fixed bug #12095: a join query with GROUP_CONCAT over a single row table. If GROUP_CONCAT is calculated we always put its argument into a temp table, even when the argument is a constant item. mysql-test/t/func_gconcat.test: Added a test case for bug #12095. mysql-test/r/func_gconcat.result: Added a test case for bug #12095. --- mysql-test/r/func_gconcat.result | 31 +++++++++++++++++++++++++++++++ mysql-test/t/func_gconcat.test | 33 +++++++++++++++++++++++++++++++++ sql/sql_class.h | 4 +++- sql/sql_select.cc | 3 ++- 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 661793821a0..9faee3cbc01 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -517,3 +517,34 @@ a group_concat(distinct b order by b) 2 3,7 NULL 1,2,3,4,7 drop table t1; +CREATE TABLE t1 ( +aID smallint(5) unsigned NOT NULL auto_increment, +sometitle varchar(255) NOT NULL default '', +bID smallint(5) unsigned NOT NULL, +PRIMARY KEY (aID), +UNIQUE KEY sometitle (sometitle) +); +INSERT INTO t1 SET sometitle = 'title1', bID = 1; +INSERT INTO t1 SET sometitle = 'title2', bID = 1; +CREATE TABLE t2 ( +bID smallint(5) unsigned NOT NULL auto_increment, +somename varchar(255) NOT NULL default '', +PRIMARY KEY (bID), +UNIQUE KEY somename (somename) +); +INSERT INTO t2 SET somename = 'test'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +FROM t1 JOIN t2 ON t1.bID = t2.bID; +COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +2 test +INSERT INTO t2 SET somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +FROM t1 JOIN t2 ON t1.bID = t2.bID; +COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +2 test +DELETE FROM t2 WHERE somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +FROM t1 JOIN t2 ON t1.bID = t2.bID; +COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') +2 test +DROP TABLE t1,t2; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e93ffcb17b3..9793d0d0a2c 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -310,4 +310,37 @@ select a, group_concat(b order by b) from t1 group by a with rollup; select a, group_concat(distinct b order by b) from t1 group by a with rollup; drop table t1; +# +# Bug #12095: GROUP_CONCAT for one row table +# + +CREATE TABLE t1 ( + aID smallint(5) unsigned NOT NULL auto_increment, + sometitle varchar(255) NOT NULL default '', + bID smallint(5) unsigned NOT NULL, + PRIMARY KEY (aID), + UNIQUE KEY sometitle (sometitle) +); +INSERT INTO t1 SET sometitle = 'title1', bID = 1; +INSERT INTO t1 SET sometitle = 'title2', bID = 1; + +CREATE TABLE t2 ( + bID smallint(5) unsigned NOT NULL auto_increment, + somename varchar(255) NOT NULL default '', + PRIMARY KEY (bID), + UNIQUE KEY somename (somename) +); +INSERT INTO t2 SET somename = 'test'; + +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; +INSERT INTO t2 SET somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; +DELETE FROM t2 WHERE somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; + +DROP TABLE t1,t2; + # End of 4.1 tests diff --git a/sql/sql_class.h b/sql/sql_class.h index b6bf0dcdc45..85ff901fe72 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1325,10 +1325,12 @@ public: bool using_indirect_summary_function; /* If >0 convert all blob fields to varchar(convert_blob_length) */ uint convert_blob_length; + bool need_const; /* <=> const items are saved in tmp table */ TMP_TABLE_PARAM() :copy_field(0), group_parts(0), - group_length(0), group_null_parts(0), convert_blob_length(0) + group_length(0), group_null_parts(0), convert_blob_length(0), + need_const(0) {} ~TMP_TABLE_PARAM() { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1bde62276b8..fc85f49093d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5201,7 +5201,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, param->using_indirect_summary_function=1; continue; } - if (item->const_item() && (int) hidden_field_count <= 0) + if (item->const_item() && (int) hidden_field_count <= 0 && + !param->need_const) continue; // We don't have to store this } if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields) -- cgit v1.2.1