~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to sql/item_subselect.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
123
123
}
124
124
 
125
125
 
126
 
/*
127
 
   We cannot use generic Item::safe_charset_converter() because
128
 
   Subselect transformation does not happen in view_prepare_mode
129
 
   and thus we can not evaluate val_...() for const items.
130
 
*/
131
 
 
132
 
Item *Item_subselect::safe_charset_converter(CHARSET_INFO *tocs)
133
 
{
134
 
  Item_func_conv_charset *conv=
135
 
    new Item_func_conv_charset(this, tocs, thd->lex->view_prepare_mode ? 0 : 1);
136
 
  return conv->safe ? conv : NULL;
137
 
}
138
 
 
139
 
 
140
126
void Item_singlerow_subselect::cleanup()
141
127
{
142
128
  DBUG_ENTER("Item_singlerow_subselect::cleanup");
271
257
  if (thd->is_error() || thd->killed)
272
258
    return 1;
273
259
 
 
260
  DBUG_ASSERT(!thd->lex->context_analysis_only);
274
261
  /*
275
262
    Simulate a failure in sub-query execution. Used to test e.g.
276
263
    out of memory or query being killed conditions.
307
294
 
308
295
bool Item_subselect::const_item() const
309
296
{
310
 
  return const_item_cache;
 
297
  return thd->lex->context_analysis_only ? FALSE : const_item_cache;
311
298
}
312
299
 
313
300
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
1029
1016
        it.replace(item);
1030
1017
      }
1031
1018
 
 
1019
      DBUG_EXECUTE("where",
 
1020
                   print_where(item, "rewrite with MIN/MAX", QT_ORDINARY););
 
1021
      if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
 
1022
      {
 
1023
        DBUG_ASSERT(select_lex->non_agg_field_used());
 
1024
        select_lex->set_non_agg_field_used(false);
 
1025
      }
 
1026
 
1032
1027
      save_allow_sum_func= thd->lex->allow_sum_func;
1033
1028
      thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
1034
1029
      /*
1638
1633
{
1639
1634
  bool result = 0;
1640
1635
  
1641
 
  if (thd_arg->lex->view_prepare_mode && left_expr && !left_expr->fixed)
 
1636
  if ((thd_arg->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) &&
 
1637
      left_expr && !left_expr->fixed)
1642
1638
    result = left_expr->fix_fields(thd_arg, &left_expr);
1643
1639
 
1644
1640
  return result || Item_subselect::fix_fields(thd_arg, ref);
1683
1679
                               select_subselect *result_arg,
1684
1680
                               Item_subselect *item_arg)
1685
1681
  :subselect_engine(item_arg, result_arg),
1686
 
   prepared(0), optimized(0), executed(0),
 
1682
   prepared(0), optimized(0), executed(0), optimize_error(0),
1687
1683
   select_lex(select), join(0)
1688
1684
{
1689
1685
  select_lex->master_unit()->item= item_arg;
1693
1689
void subselect_single_select_engine::cleanup()
1694
1690
{
1695
1691
  DBUG_ENTER("subselect_single_select_engine::cleanup");
1696
 
  prepared= optimized= executed= 0;
 
1692
  prepared= optimized= executed= optimize_error= 0;
1697
1693
  join= 0;
1698
1694
  result->cleanup();
1699
1695
  DBUG_VOID_RETURN;
1889
1885
int subselect_single_select_engine::exec()
1890
1886
{
1891
1887
  DBUG_ENTER("subselect_single_select_engine::exec");
 
1888
 
 
1889
  if (optimize_error)
 
1890
    DBUG_RETURN(1);
 
1891
 
1892
1892
  char const *save_where= thd->where;
1893
1893
  SELECT_LEX *save_select= thd->lex->current_select;
1894
1894
  thd->lex->current_select= select_lex;
1896
1896
  {
1897
1897
    SELECT_LEX_UNIT *unit= select_lex->master_unit();
1898
1898
 
 
1899
    DBUG_EXECUTE_IF("bug11747970_simulate_error",
 
1900
                    DBUG_SET("+d,bug11747970_raise_error"););
 
1901
 
1899
1902
    optimized= 1;
1900
1903
    unit->set_limit(unit->global_parameters);
1901
1904
    if (join->optimize())
1902
1905
    {
1903
1906
      thd->where= save_where;
1904
 
      executed= 1;
 
1907
      optimize_error= 1;
1905
1908
      thd->lex->current_select= save_select;
1906
1909
      DBUG_RETURN(join->error ? join->error : 1);
1907
1910
    }