~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Brian Aker
  • Date: 2010-10-23 22:28:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1875.
  • Revision ID: brian@tangent.org-20101023222830-em4idhbau96l37zt
Encapsulate schema_name it table_list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
  }
339
339
 
340
340
  if (error)
341
 
    goto err;
 
341
    return(-1);
342
342
 
343
343
  /* 
344
344
   * The below will create the new table for
347
347
   * @see create_table_from_items() in drizzled/sql_insert.cc
348
348
   */
349
349
  if (result && result->prepare(fields_list, unit_arg))
350
 
    goto err;
 
350
    return(-1);
351
351
 
352
352
  /* Init join struct */
353
353
  count_field_types(select_lex, &tmp_table_param, all_fields, 0);
359
359
  if (sum_func_count && !group_list && (func_count || field_count))
360
360
  {
361
361
    my_message(ER_WRONG_SUM_SELECT,ER(ER_WRONG_SUM_SELECT),MYF(0));
362
 
    goto err;
 
362
    return(-1);
363
363
  }
364
364
#endif
365
365
  if (select_lex->olap == ROLLUP_TYPE && rollup_init())
366
 
    goto err;
 
366
    return(-1);
 
367
 
367
368
  if (alloc_func_list())
368
 
    goto err;
369
 
 
370
 
  return(0); // All OK
371
 
 
372
 
err:
373
 
  return(-1);
 
369
    return(-1);
 
370
 
 
371
  return 0; // All OK
374
372
}
375
373
 
376
374
/*
867
865
        save_index_subquery_explain_info(join_tab, where);
868
866
        join_tab[0].type= AM_UNIQUE_SUBQUERY;
869
867
        error= 0;
870
 
        return(unit->item->
871
 
                    change_engine(new
872
 
                                  subselect_uniquesubquery_engine(session,
873
 
                                                                  join_tab,
874
 
                                                                  unit->item,
875
 
                                                                  where)));
 
868
        return(unit->item->change_engine(new subselect_uniquesubquery_engine(session, join_tab, unit->item, where)));
876
869
      }
877
870
      else if (join_tab[0].type == AM_REF &&
878
871
         join_tab[0].ref.items[0]->name == in_left_expr_name)
881
874
        save_index_subquery_explain_info(join_tab, where);
882
875
        join_tab[0].type= AM_INDEX_SUBQUERY;
883
876
        error= 0;
884
 
        return(unit->item->
885
 
                    change_engine(new
886
 
                                  subselect_indexsubquery_engine(session,
887
 
                                                                 join_tab,
888
 
                                                                 unit->item,
889
 
                                                                 where,
890
 
                                                                 NULL,
891
 
                                                                 0)));
 
877
        return(unit->item->change_engine(new subselect_indexsubquery_engine(session, join_tab, unit->item, where, NULL, 0)));
892
878
      }
893
879
    } 
894
880
    else if (join_tab[0].type == AM_REF_OR_NULL &&
899
885
      error= 0;
900
886
      conds= remove_additional_cond(conds);
901
887
      save_index_subquery_explain_info(join_tab, conds);
902
 
      return(unit->item->
903
 
      change_engine(new subselect_indexsubquery_engine(session,
904
 
                   join_tab,
905
 
                   unit->item,
906
 
                   conds,
907
 
                                                                   having,
908
 
                   1)));
 
888
      return(unit->item->change_engine(new subselect_indexsubquery_engine(session, join_tab, unit->item, conds, having, 1)));
909
889
    }
910
890
 
911
891
  }
1106
1086
      If this join belongs to an uncacheable subquery save
1107
1087
      the original join
1108
1088
    */
1109
 
    if (select_lex->uncacheable && !is_top_level_join() &&
 
1089
    if (select_lex->uncacheable.any() && 
 
1090
        ! is_top_level_join() &&
1110
1091
        init_save_join_tab())
1111
 
      return(-1);
 
1092
    {
 
1093
      return -1;
 
1094
    }
1112
1095
  }
1113
1096
 
1114
1097
  error= 0;
1115
 
  return(0);
 
1098
  return 0;
1116
1099
 
1117
1100
setup_subq_exit:
1118
1101
  /* Even with zero matching rows, subqueries in the HAVING clause
1188
1171
{
1189
1172
  if (!(tmp_join= (Join*)session->alloc(sizeof(Join))))
1190
1173
    return 1;
 
1174
 
1191
1175
  error= 0;              // Ensure that tmp_join.error= 0
1192
1176
  restore_tmp();
 
1177
 
1193
1178
  return 0;
1194
1179
}
1195
1180
 
1196
1181
bool Join::save_join_tab()
1197
1182
{
1198
 
  if (!join_tab_save && select_lex->master_unit()->uncacheable)
 
1183
  if (! join_tab_save && select_lex->master_unit()->uncacheable.any())
1199
1184
  {
1200
1185
    if (!(join_tab_save= (JoinTable*)session->memdup((unsigned char*) join_tab,
1201
1186
            sizeof(JoinTable) * tables)))
1835
1820
    Optimization: if not EXPLAIN and we are done with the Join,
1836
1821
    free all tables.
1837
1822
  */
1838
 
  bool full= (!select_lex->uncacheable && !session->lex->describe);
 
1823
  bool full= (select_lex->uncacheable.none() && ! session->lex->describe);
1839
1824
  bool can_unlock= full;
1840
1825
 
1841
1826
  cleanup(full);
2837
2822
      if ((error=table->cursor->insertRecord(table->getInsertRecord())))
2838
2823
      {
2839
2824
        if (!table->cursor->is_fatal_error(error, HA_CHECK_DUP))
2840
 
          goto end;
 
2825
        {
 
2826
          return NESTED_LOOP_OK;
 
2827
        }
2841
2828
 
2842
2829
        my_error(ER_USE_SQL_BIG_RESULT, MYF(0));
2843
2830
        return NESTED_LOOP_ERROR;        // Table is_full error
2852
2839
      }
2853
2840
    }
2854
2841
  }
2855
 
end:
 
2842
 
2856
2843
  return NESTED_LOOP_OK;
2857
2844
}
2858
2845