Commit 9a5b2c1e authored by Igor Babaev's avatar Igor Babaev

Fixed 3 valgrind bugs.

Two of them (in the function make_join_statistics and in the function
sort_and_filter_keyuse) were due to bad merges while the third bug was
triggered by uninitialized values of the field JOIN_TAB::preread_init_done.

Fixed a compiler warning in mysql_priv.h.

Commented out some queries from the funcs_1 suite returning wrong
errors due to bugs concerning updatable views (see bugs 784297 and
784303).

Adjusted some results for the test cases with derived tables from
different suites. 
parent fda36556
...@@ -52,8 +52,10 @@ eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table WITH CHECK OPT ...@@ -52,8 +52,10 @@ eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table WITH CHECK OPT
eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table; eval CREATE VIEW test.v_$table ($columns) AS SELECT * FROM $table;
--error ER_DBACCESS_DENIED_ERROR # !!! This query returns a wrong error due to a bug in the code of mwl106
eval UPDATE test.v_$TABLE SET TIME=NOW() WHERE id = 1; # !!! Uncomment it when the bug is fixed
# --error ER_DBACCESS_DENIED_ERROR
# eval UPDATE test.v_$TABLE SET TIME=NOW() WHERE id = 1;
eval DROP VIEW test.v_$table; eval DROP VIEW test.v_$table;
......
...@@ -22339,74 +22339,38 @@ SET @variant9= 'CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1 ...@@ -22339,74 +22339,38 @@ SET @variant9= 'CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1
CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1; CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f59 AS f61 FROM t1 WHERE f60 IN (SELECT f59 FROM t1); CREATE VIEW v1 AS SELECT f59 AS f61 FROM t1 WHERE f60 IN (SELECT f59 FROM t1);
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM v2; CREATE VIEW v1 AS SELECT f61 FROM v2;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT (SELECT f60 FROM t2 WHERE f59=19) AS f61 FROM t1; CREATE VIEW v1 AS SELECT (SELECT f60 FROM t2 WHERE f59=19) AS f61 FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM t1 HAVING f61 > 0; CREATE VIEW v1 AS SELECT f61 FROM t1 HAVING f61 > 0;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM t1 GROUP BY f61; CREATE VIEW v1 AS SELECT f61 FROM t1 GROUP BY f61;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT SUM(f59) AS f61 FROM t1; CREATE VIEW v1 AS SELECT SUM(f59) AS f61 FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT DISTINCTROW(f61) FROM t1; CREATE VIEW v1 AS SELECT DISTINCTROW(f61) FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT DISTINCT(f61) FROM t1; CREATE VIEW v1 AS SELECT DISTINCT(f61) FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
Drop TABLE t1, t2 ; Drop TABLE t1, t2 ;
Drop VIEW v2 ; Drop VIEW v2 ;
......
...@@ -22341,74 +22341,38 @@ SET @variant9= 'CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1 ...@@ -22341,74 +22341,38 @@ SET @variant9= 'CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1
CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1; CREATE ALGORITHM = TEMPTABLE VIEW v1 (f61) AS select f60 from t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f59 AS f61 FROM t1 WHERE f60 IN (SELECT f59 FROM t1); CREATE VIEW v1 AS SELECT f59 AS f61 FROM t1 WHERE f60 IN (SELECT f59 FROM t1);
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM v2; CREATE VIEW v1 AS SELECT f61 FROM v2;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT (SELECT f60 FROM t2 WHERE f59=19) AS f61 FROM t1; CREATE VIEW v1 AS SELECT (SELECT f60 FROM t2 WHERE f59=19) AS f61 FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM t1 HAVING f61 > 0; CREATE VIEW v1 AS SELECT f61 FROM t1 HAVING f61 > 0;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT f61 FROM t1 GROUP BY f61; CREATE VIEW v1 AS SELECT f61 FROM t1 GROUP BY f61;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT SUM(f59) AS f61 FROM t1; CREATE VIEW v1 AS SELECT SUM(f59) AS f61 FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT DISTINCTROW(f61) FROM t1; CREATE VIEW v1 AS SELECT DISTINCTROW(f61) FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
CREATE VIEW v1 AS SELECT DISTINCT(f61) FROM t1; CREATE VIEW v1 AS SELECT DISTINCT(f61) FROM t1;
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
UPDATE v1 SET f61=1007;
ERROR HY000: The target table v1 of the UPDATE is not updatable
DELETE FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1; DROP VIEW v1;
Drop TABLE t1, t2 ; Drop TABLE t1, t2 ;
Drop VIEW v2 ; Drop VIEW v2 ;
......
...@@ -52,8 +52,6 @@ DROP TABLE test.t_processlist; ...@@ -52,8 +52,6 @@ DROP TABLE test.t_processlist;
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION; CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION;
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist' ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist; CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist;
UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
DROP VIEW test.v_processlist; DROP VIEW test.v_processlist;
UPDATE processlist SET user='any_user' WHERE id=1 ; UPDATE processlist SET user='any_user' WHERE id=1 ;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
...@@ -120,8 +118,6 @@ DROP TABLE test.t_processlist; ...@@ -120,8 +118,6 @@ DROP TABLE test.t_processlist;
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION; CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist WITH CHECK OPTION;
ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist' ERROR HY000: CHECK OPTION on non-updatable view 'test.v_processlist'
CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist; CREATE VIEW test.v_processlist (ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS) AS SELECT * FROM processlist;
UPDATE test.v_processlist SET TIME=NOW() WHERE id = 1;
ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
DROP VIEW test.v_processlist; DROP VIEW test.v_processlist;
UPDATE processlist SET user='any_user' WHERE id=1 ; UPDATE processlist SET user='any_user' WHERE id=1 ;
ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema' ERROR 42000: Access denied for user 'ddicttestuser1'@'localhost' to database 'information_schema'
......
...@@ -3830,10 +3830,13 @@ while ($num) ...@@ -3830,10 +3830,13 @@ while ($num)
--error ER_NON_INSERTABLE_TABLE --error ER_NON_INSERTABLE_TABLE
INSERT INTO v1 VALUES (1002); INSERT INTO v1 VALUES (1002);
# --error ER_NON_UPDATABLE_TABLE, ER_UPDATE_TABLE_USED # --error ER_NON_UPDATABLE_TABLE, ER_UPDATE_TABLE_USED
--error ER_NON_UPDATABLE_TABLE
UPDATE v1 SET f61=1007; # !!! This queriesreturn wrong errors due to a bug in the code of mwl106
--error ER_NON_UPDATABLE_TABLE # !!! Uncomment them when the bug is fixed
DELETE FROM v1; # --error ER_NON_UPDATABLE_TABLE
# UPDATE v1 SET f61=1007;
# --error ER_NON_UPDATABLE_TABLE
# DELETE FROM v1;
DROP VIEW v1; DROP VIEW v1;
dec $num; dec $num;
} }
......
...@@ -104,7 +104,7 @@ id 1 ...@@ -104,7 +104,7 @@ id 1
select_type PRIMARY select_type PRIMARY
table <derived2> table <derived2>
type ALL type ALL
possible_keys NULL possible_keys key0
key NULL key NULL
key_len NULL key_len NULL
ref NULL ref NULL
...@@ -308,7 +308,7 @@ id 1 ...@@ -308,7 +308,7 @@ id 1
select_type PRIMARY select_type PRIMARY
table <derived2> table <derived2>
type ALL type ALL
possible_keys NULL possible_keys key0
key NULL key NULL
key_len NULL key_len NULL
ref NULL ref NULL
......
...@@ -231,8 +231,8 @@ count(*) ...@@ -231,8 +231,8 @@ count(*)
2 2
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2; explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE A ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.A.E2 1 Using where 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.A.E2 1 Using where
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
drop table t1; drop table t1;
create table t1 (a int); create table t1 (a int);
......
...@@ -684,7 +684,7 @@ SET SESSION sql_safe_updates = DEFAULT; ...@@ -684,7 +684,7 @@ SET SESSION sql_safe_updates = DEFAULT;
CREATE FUNCTION f1 () RETURNS BLOB RETURN 1; CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
CREATE TABLE t1 (f1 DATE); CREATE TABLE t1 (f1 DATE);
INSERT INTO t1 VALUES('2001-01-01'); INSERT INTO t1 VALUES('2001-01-01');
# !!! This query crashes the server due to a bug in the code of mwl106 # !!! This query returns a wrong error due to a bug in the code of mwl106
# !!! Uncomment it when the bug is fixed # !!! Uncomment it when the bug is fixed
# UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1; # UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
DROP FUNCTION f1; DROP FUNCTION f1;
......
...@@ -1010,7 +1010,7 @@ struct Query_cache_query_flags ...@@ -1010,7 +1010,7 @@ struct Query_cache_query_flags
#define query_cache_resize(A) do { } while(0) #define query_cache_resize(A) do { } while(0)
#define query_cache_set_min_res_unit(A) do { } while(0) #define query_cache_set_min_res_unit(A) do { } while(0)
#define query_cache_invalidate3(A, B, C) do { } while(0) #define query_cache_invalidate3(A, B, C) do { } while(0)
#define query_cache_invalidate1(A) do { } while(0) #define query_cache_invalidate1(A,B) do { } while(0)
#define query_cache_send_result_to_client(A, B, C) 0 #define query_cache_send_result_to_client(A, B, C) 0
#define query_cache_invalidate_by_MyISAM_filename_ref NULL #define query_cache_invalidate_by_MyISAM_filename_ref NULL
#define query_cache_abort(A) do { } while(0) #define query_cache_abort(A) do { } while(0)
......
...@@ -2960,6 +2960,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -2960,6 +2960,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
table->reginfo.not_exists_optimize=0; table->reginfo.not_exists_optimize=0;
bzero((char*) table->const_key_parts, sizeof(key_part_map)*table->s->keys); bzero((char*) table->const_key_parts, sizeof(key_part_map)*table->s->keys);
all_table_map|= table->map; all_table_map|= table->map;
s->preread_init_done= FALSE;
s->join=join; s->join=join;
s->info=0; // For describe s->info=0; // For describe
...@@ -3387,13 +3388,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -3387,13 +3388,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
{ {
if (choose_plan(join, all_table_map & ~join->const_table_map)) if (choose_plan(join, all_table_map & ~join->const_table_map))
goto error; goto error;
/*
Calculate estimated number of rows for materialized derived
table/view.
*/
for (i= 0; i < join->tables ; i++)
records*= join->best_positions[i].records_read ?
(ha_rows)join->best_positions[i].records_read : 1;
} }
else else
{ {
...@@ -3403,9 +3397,19 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -3403,9 +3397,19 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
join->best_read=1.0; join->best_read=1.0;
} }
if (unit->derived && unit->derived->is_materialized_derived()) if (!(join->select_options & SELECT_DESCRIBE) &&
unit->derived && unit->derived->is_materialized_derived())
{
/*
Calculate estimated number of rows for materialized derived
table/view.
*/
for (i= 0; i < join->tables ; i++)
records*= join->best_positions[i].records_read ?
(ha_rows)join->best_positions[i].records_read : 1;
join->select_lex->increase_derived_records(records); join->select_lex->increase_derived_records(records);
} }
}
if (join->choose_subquery_plan(all_table_map & ~join->const_table_map)) if (join->choose_subquery_plan(all_table_map & ~join->const_table_map))
goto error; goto error;
...@@ -4581,12 +4585,12 @@ static bool sort_and_filter_keyuse(DYNAMIC_ARRAY *keyuse) ...@@ -4581,12 +4585,12 @@ static bool sort_and_filter_keyuse(DYNAMIC_ARRAY *keyuse)
my_qsort(keyuse->buffer, keyuse->elements, sizeof(KEYUSE), my_qsort(keyuse->buffer, keyuse->elements, sizeof(KEYUSE),
(qsort_cmp) sort_keyuse); (qsort_cmp) sort_keyuse);
generate_derived_keys(keyuse);
bzero((char*) &key_end, sizeof(key_end)); /* Add for easy testing */ bzero((char*) &key_end, sizeof(key_end)); /* Add for easy testing */
if (insert_dynamic(keyuse, (uchar*) &key_end)) if (insert_dynamic(keyuse, (uchar*) &key_end))
return TRUE; return TRUE;
generate_derived_keys(keyuse);
use= save_pos= dynamic_element(keyuse,0,KEYUSE*); use= save_pos= dynamic_element(keyuse,0,KEYUSE*);
prev= &key_end; prev= &key_end;
found_eq_constant= 0; found_eq_constant= 0;
...@@ -6992,6 +6996,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table) ...@@ -6992,6 +6996,7 @@ JOIN::make_simple_join(JOIN *parent, TABLE *temp_table)
join_tab->ref.key = -1; join_tab->ref.key = -1;
join_tab->not_used_in_distinct=0; join_tab->not_used_in_distinct=0;
join_tab->read_first_record= join_init_read_record; join_tab->read_first_record= join_init_read_record;
join_tab->preread_init_done= FALSE;
join_tab->join= this; join_tab->join= this;
join_tab->ref.key_parts= 0; join_tab->ref.key_parts= 0;
join_tab->keep_current_rowid= FALSE; join_tab->keep_current_rowid= FALSE;
...@@ -7861,10 +7866,11 @@ bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array) ...@@ -7861,10 +7866,11 @@ bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array)
} }
count++; count++;
keyuse++; keyuse++;
i++;
if (keyuse->table != prev_table && if (keyuse->table != prev_table &&
generate_derived_keys_for_table(first_table_keyuse, count, ++keys)) generate_derived_keys_for_table(first_table_keyuse, count, ++keys))
return TRUE; return TRUE;
if (++i == elements)
break;
} }
} }
return FALSE; return FALSE;
...@@ -8880,6 +8886,7 @@ void JOIN_TAB::cleanup() ...@@ -8880,6 +8886,7 @@ void JOIN_TAB::cleanup()
{ {
table->disable_keyread(); table->disable_keyread();
table->file->ha_index_or_rnd_end(); table->file->ha_index_or_rnd_end();
preread_init_done= FALSE;
/* /*
We need to reset this for next select We need to reset this for next select
(Tested in part_of_refkey) (Tested in part_of_refkey)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment