summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2004-04-08 23:28:47 +0300
committerbell@sanja.is.com.ua <>2004-04-08 23:28:47 +0300
commitef5f15c351119bd402a200bc59958092116aa5f8 (patch)
tree9006de30fe78a7e93d470cdd8ffeef4a0137f767 /sql/sql_derived.cc
parentd4f5f1b7aca00712d51587603853233090dc525c (diff)
downloadmariadb-git-ef5f15c351119bd402a200bc59958092116aa5f8.tar.gz
fixed subquery in the FROM clause with parameter (BUG#3020)
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)