Skip to content

Commit

Permalink
Mistakes corrected, test file corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
Galina Shalygina committed Jun 30, 2017
1 parent 615da8f commit 7ba19ba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
8 changes: 7 additions & 1 deletion mysql-test/t/table_value_const.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
create table t1 (a int, b int);

insert into t1 values (1,2),(4,6),(9,7),(1,1),(2,5),(7,8);

values (1,2);

select 1,2 union values (1,2);

values (1,2) union select (1,2);

values (1,2), (3,4) union select 1,2;

select * from t1 where (t1.a,t1.b) in (select 5,7 union values (1,2),(2,3));

select * from t1 where (t1.a,t1.b) in (values (1,2),(2,3) union select 5,7);
Expand All @@ -26,5 +32,5 @@ create view v1 as select 1,2 union values (3,4),(5,6);

eval $drop_view;


drop table t1;

1 change: 1 addition & 0 deletions sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,7 @@ void st_select_lex::init_select()
with_dep= 0;
join= 0;
lock_type= TL_READ_DEFAULT;
tvc= 0;
}

/*
Expand Down
4 changes: 4 additions & 0 deletions sql/sql_tvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class table_value_constr : public Sql_alloc
List<List_item> lists_of_values;
select_result *result;

table_value_constr(List<List_item> tvc_values) :
lists_of_values(tvc_values), result(0)
{ }

bool prepare(THD *thd_arg, SELECT_LEX *sl,
select_result *tmp_result);
bool exec();
Expand Down
17 changes: 11 additions & 6 deletions sql/sql_union.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1357,17 +1357,21 @@ bool st_select_lex_unit::exec()
we don't calculate found_rows() per union part.
Otherwise, SQL_CALC_FOUND_ROWS should be done on all sub parts.
*/
sl->join->select_options=
(select_limit_cnt == HA_POS_ERROR || sl->braces) ?
sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
saved_error= sl->join->optimize();
if (!sl->tvc)
{
sl->join->select_options=
(select_limit_cnt == HA_POS_ERROR || sl->braces) ?
sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
saved_error= sl->join->optimize();
}
}
if (!saved_error)
{
records_at_start= table->file->stats.records;
if (sl->tvc)
sl->tvc->exec();
sl->join->exec();
else
sl->join->exec();
if (sl == union_distinct && !(with_element && with_element->is_recursive))
{
// This is UNION DISTINCT, so there should be a fake_select_lex
Expand All @@ -1376,7 +1380,8 @@ bool st_select_lex_unit::exec()
DBUG_RETURN(TRUE);
table->no_keyread=1;
}
saved_error= sl->join->error;
if (!sl->tvc)
saved_error= sl->join->error;
offset_limit_cnt= (ha_rows)(sl->offset_limit ?
sl->offset_limit->val_uint() :
0);
Expand Down
4 changes: 3 additions & 1 deletion sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "lex_token.h"
#include "sql_lex.h"
#include "sql_sequence.h"
#include "sql_tvc.h"

/* this is to get the bison compilation windows warnings out */
#ifdef _MSC_VER
Expand Down Expand Up @@ -16277,7 +16278,8 @@ table_value_constructor:
LEX *lex=Lex;
$$= Lex->current_select;
mysql_init_select(Lex);
$$->tvc->lists_of_values= lex->many_values;
table_value_constr tvc(lex->many_values);
$$->tvc= &tvc;
}
;

Expand Down

0 comments on commit 7ba19ba

Please sign in to comment.