~ubuntu-branches/ubuntu/gutsy/mysql-dfsg-5.0/gutsy

« back to all changes in this revision

Viewing changes to libmysqld/item_subselect.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-03 09:43:01 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070403094301-fnjhfr59hu72pvtg
Tags: 5.0.38-0ubuntu1
* Package the Enterprise version again (.37 was a community version), since
  Debian and we have always done so. This brings in a few more bug fixes and
  makes functional derivations less likely.
* debian/README.Maintainer: Add pointer to upstream download URL, since it
  is very hard to find the Enterprise versions.
* Disable 33_scripts__mysql_create_system_tables__no_test.dpatch, since that
  script was removed upstream.
* debian/patches/41_scripts__mysql_install_db.sh__no_test.dpatch: Adapted to
  changed formatting in new upstream version.
* Remove debian/patches/86_PATH_MAX.dpatch, fixed upstream.
* Add debian/patches/90_org_tables_definition.dpatch: Fix local variable
  declaration in libmysqld/sql_parse.cc to fix compilation with
  EMBEDDED_LIBRARY.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
void Item_subselect::init(st_select_lex *select_lex,
52
52
                          select_subselect *result)
53
53
{
 
54
  /*
 
55
    Please see Item_singlerow_subselect::invalidate_and_restore_select_lex(),
 
56
    which depends on alterations to the parse tree implemented here.
 
57
  */
54
58
 
55
59
  DBUG_ENTER("Item_subselect::init");
56
60
  DBUG_PRINT("enter", ("select_lex: 0x%lx", (long) select_lex));
91
95
  DBUG_VOID_RETURN;
92
96
}
93
97
 
 
98
st_select_lex *
 
99
Item_subselect::get_select_lex()
 
100
{
 
101
  return unit->first_select();
 
102
}
 
103
 
94
104
void Item_subselect::cleanup()
95
105
{
96
106
  DBUG_ENTER("Item_subselect::cleanup");
232
242
  return const_item_cache;
233
243
}
234
244
 
235
 
Item *Item_subselect::get_tmp_table_item(THD *thd)
 
245
Item *Item_subselect::get_tmp_table_item(THD *thd_arg)
236
246
{
237
247
  if (!with_sum_func && !const_item())
238
248
    return new Item_field(result_field);
239
 
  return copy_or_same(thd);
 
249
  return copy_or_same(thd_arg);
240
250
}
241
251
 
242
252
void Item_subselect::update_used_tables()
268
278
  DBUG_VOID_RETURN;
269
279
}
270
280
 
 
281
st_select_lex *
 
282
Item_singlerow_subselect::invalidate_and_restore_select_lex()
 
283
{
 
284
  DBUG_ENTER("Item_singlerow_subselect::invalidate_and_restore_select_lex");
 
285
  st_select_lex *result= get_select_lex();
 
286
 
 
287
  DBUG_ASSERT(result);
 
288
 
 
289
  /*
 
290
    This code restore the parse tree in it's state before the execution of
 
291
    Item_singlerow_subselect::Item_singlerow_subselect(),
 
292
    and in particular decouples this object from the SELECT_LEX,
 
293
    so that the SELECT_LEX can be used with a different flavor
 
294
    or Item_subselect instead, as part of query rewriting.
 
295
  */
 
296
  unit->item= NULL;
 
297
 
 
298
  DBUG_RETURN(result);
 
299
}
 
300
 
271
301
Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param,
272
302
                                             Item_subselect *parent,
273
303
                                             st_select_lex *select_lex,
551
581
}
552
582
 
553
583
 
554
 
bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit)
 
584
bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit_arg)
555
585
{
556
 
  if (unit->fake_select_lex &&
557
 
      unit->fake_select_lex->test_limit())
 
586
  if (unit_arg->fake_select_lex &&
 
587
      unit_arg->fake_select_lex->test_limit())
558
588
    return(1);
559
589
 
560
 
  SELECT_LEX *sl= unit->first_select();
 
590
  SELECT_LEX *sl= unit_arg->first_select();
561
591
  for (; sl; sl= sl->next_select())
562
592
  {
563
593
    if (sl->test_limit())
829
859
Item_in_subselect::single_value_transformer(JOIN *join,
830
860
                                            Comp_creator *func)
831
861
{
832
 
  Item_subselect::trans_res result= RES_ERROR;
833
862
  SELECT_LEX *select_lex= join->select_lex;
834
863
  DBUG_ENTER("Item_in_subselect::single_value_transformer");
835
864
 
927
956
  if (!substitution)
928
957
  {
929
958
    /* We're invoked for the 1st (or the only) SELECT in the subquery UNION */
930
 
    SELECT_LEX_UNIT *unit= select_lex->master_unit();
 
959
    SELECT_LEX_UNIT *master_unit= select_lex->master_unit();
931
960
    substitution= optimizer;
932
961
 
933
962
    SELECT_LEX *current= thd->lex->current_select, *up;
950
979
                              (char *)"<no matter>",
951
980
                              (char *)in_left_expr_name);
952
981
 
953
 
    unit->uncacheable|= UNCACHEABLE_DEPENDENT;
 
982
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
954
983
  }
955
984
  if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
956
985
  {
1149
1178
  if (!substitution)
1150
1179
  {
1151
1180
    //first call for this unit
1152
 
    SELECT_LEX_UNIT *unit= select_lex->master_unit();
 
1181
    SELECT_LEX_UNIT *master_unit= select_lex->master_unit();
1153
1182
    substitution= optimizer;
1154
1183
 
1155
1184
    SELECT_LEX *current= thd->lex->current_select, *up;
1165
1194
    optimizer->keep_top_level_cache();
1166
1195
 
1167
1196
    thd->lex->current_select= current;
1168
 
    unit->uncacheable|= UNCACHEABLE_DEPENDENT;
 
1197
    master_unit->uncacheable|= UNCACHEABLE_DEPENDENT;
1169
1198
 
1170
1199
    if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
1171
1200
    {
1198
1227
    {
1199
1228
      DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
1200
1229
      if (select_lex->ref_pointer_array[i]->
1201
 
          check_cols(left_expr->el(i)->cols()))
 
1230
          check_cols(left_expr->element_index(i)->cols()))
1202
1231
        DBUG_RETURN(RES_ERROR);
1203
1232
      Item *item_eq=
1204
1233
        new Item_func_eq(new
1221
1250
                                      (char *)"<list ref>")
1222
1251
                            );
1223
1252
      Item *col_item= new Item_cond_or(item_eq, item_isnull);
1224
 
      if (!abort_on_null && left_expr->el(i)->maybe_null)
 
1253
      if (!abort_on_null && left_expr->element_index(i)->maybe_null)
1225
1254
      {
1226
1255
        if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i))))
1227
1256
          DBUG_RETURN(RES_ERROR);
1235
1264
                                                ref_pointer_array + i,
1236
1265
                                                (char *)"<no matter>",
1237
1266
                                                (char *)"<list ref>"));
1238
 
      if (!abort_on_null && left_expr->el(i)->maybe_null)
 
1267
      if (!abort_on_null && left_expr->element_index(i)->maybe_null)
1239
1268
      {
1240
1269
        if (!(item_nnull_test= 
1241
1270
              new Item_func_trig_cond(item_nnull_test, get_cond_guard(i))))
1272
1301
      Item *item, *item_isnull;
1273
1302
      DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
1274
1303
      if (select_lex->ref_pointer_array[i]->
1275
 
          check_cols(left_expr->el(i)->cols()))
 
1304
          check_cols(left_expr->element_index(i)->cols()))
1276
1305
        DBUG_RETURN(RES_ERROR);
1277
1306
      item=
1278
1307
        new Item_func_eq(new
1312
1341
          TODO: why we create the above for cases where the right part
1313
1342
                cant be NULL?
1314
1343
        */
1315
 
        if (left_expr->el(i)->maybe_null)
 
1344
        if (left_expr->element_index(i)->maybe_null)
1316
1345
        {
1317
1346
          if (!(item= new Item_func_trig_cond(item, get_cond_guard(i))))
1318
1347
            DBUG_RETURN(RES_ERROR);
1474
1503
}
1475
1504
 
1476
1505
 
1477
 
bool Item_in_subselect::fix_fields(THD *thd, Item **ref)
 
1506
bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
1478
1507
{
1479
1508
  bool result = 0;
1480
1509
  
1481
 
  if(thd->lex->view_prepare_mode && left_expr && !left_expr->fixed)
1482
 
    result = left_expr->fix_fields(thd, &left_expr);
 
1510
  if (thd_arg->lex->view_prepare_mode && left_expr && !left_expr->fixed)
 
1511
    result = left_expr->fix_fields(thd_arg, &left_expr);
1483
1512
 
1484
 
  return result || Item_subselect::fix_fields(thd, ref);
 
1513
  return result || Item_subselect::fix_fields(thd_arg, ref);
1485
1514
}
1486
1515
 
1487
1516
 
1520
1549
 
1521
1550
subselect_single_select_engine::
1522
1551
subselect_single_select_engine(st_select_lex *select,
1523
 
                               select_subselect *result,
1524
 
                               Item_subselect *item)
1525
 
  :subselect_engine(item, result),
 
1552
                               select_subselect *result_arg,
 
1553
                               Item_subselect *item_arg)
 
1554
  :subselect_engine(item_arg, result_arg),
1526
1555
   prepared(0), optimized(0), executed(0),
1527
1556
   select_lex(select), join(0)
1528
1557
{
1529
 
  select_lex->master_unit()->item= item;
 
1558
  select_lex->master_unit()->item= item_arg;
1530
1559
}
1531
1560
 
1532
1561
 
1763
1792
  if (!executed)
1764
1793
  {
1765
1794
    item->reset_value_registration();
1766
 
    bool have_changed_access= FALSE;
1767
1795
    JOIN_TAB *changed_tabs[MAX_TABLES];
1768
1796
    JOIN_TAB **last_changed_tab= changed_tabs;
1769
1797
    if (item->have_guarded_conds())