summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-04-08 23:28:47 +0300
committerunknown <bell@sanja.is.com.ua>2004-04-08 23:28:47 +0300
commit52a62ce0b08832401741a1340b983620194d9fe6 (patch)
tree9006de30fe78a7e93d470cdd8ffeef4a0137f767 /sql/sql_derived.cc
parentd57ffe071a7ba174c076052fe89279a30c067bab (diff)
downloadmariadb-git-52a62ce0b08832401741a1340b983620194d9fe6.tar.gz
fixed subquery in the FROM clause with parameter (BUG#3020)
sql/sql_derived.cc: do not execute subqueries in the FROM clause in PS preparation tests/client_test.c: test of subquery in FROM clause with parameter
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc64
1 files changed, 35 insertions, 29 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 81269a8cbcf..2e2ad6786fc 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -148,36 +148,42 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
}
derived_result->set_table(table);
-
- if (is_union)
- {
- // execute union without clean up
- if (!(res= unit->prepare(thd, derived_result, SELECT_NO_UNLOCK)))
- res= unit->exec();
- }
- else
+ /*
+ if it is preparation PS only then we do not need real data and we
+ can skip execution (and parameters is not defined, too)
+ */
+ if (!thd->current_statement)
{
- unit->offset_limit_cnt= first_select->offset_limit;
- unit->select_limit_cnt= first_select->select_limit+
- first_select->offset_limit;
- if (unit->select_limit_cnt < first_select->select_limit)
- unit->select_limit_cnt= HA_POS_ERROR;
- if (unit->select_limit_cnt == HA_POS_ERROR)
- first_select->options&= ~OPTION_FOUND_ROWS;
-
- lex->current_select= first_select;
- res= mysql_select(thd, &first_select->ref_pointer_array,
- (TABLE_LIST*) first_select->table_list.first,
- first_select->with_wild,
- first_select->item_list, first_select->where,
- (first_select->order_list.elements+
- first_select->group_list.elements),
- (ORDER *) first_select->order_list.first,
- (ORDER *) first_select->group_list.first,
- first_select->having, (ORDER*) NULL,
- (first_select->options | thd->options |
- SELECT_NO_UNLOCK),
- derived_result, unit, first_select);
+ if (is_union)
+ {
+ // execute union without clean up
+ if (!(res= unit->prepare(thd, derived_result, SELECT_NO_UNLOCK)))
+ res= unit->exec();
+ }
+ else
+ {
+ unit->offset_limit_cnt= first_select->offset_limit;
+ unit->select_limit_cnt= first_select->select_limit+
+ first_select->offset_limit;
+ if (unit->select_limit_cnt < first_select->select_limit)
+ unit->select_limit_cnt= HA_POS_ERROR;
+ if (unit->select_limit_cnt == HA_POS_ERROR)
+ first_select->options&= ~OPTION_FOUND_ROWS;
+
+ lex->current_select= first_select;
+ res= mysql_select(thd, &first_select->ref_pointer_array,
+ (TABLE_LIST*) first_select->table_list.first,
+ first_select->with_wild,
+ first_select->item_list, first_select->where,
+ (first_select->order_list.elements+
+ first_select->group_list.elements),
+ (ORDER *) first_select->order_list.first,
+ (ORDER *) first_select->group_list.first,
+ first_select->having, (ORDER*) NULL,
+ (first_select->options | thd->options |
+ SELECT_NO_UNLOCK),
+ derived_result, unit, first_select);
+ }
}
if (!res)