~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2009-02-07 22:02:41 UTC
  • Revision ID: brian@tangent.org-20090207220241-ez3828o1246ab2sp
Removing on typedeffed class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
                                JOIN_TAB *join_tab,
70
70
                                uint32_t tables, COND *conds,
71
71
                                COND_EQUAL *cond_equal,
72
 
                                table_map table_map, SELECT_LEX *select_lex,
 
72
                                table_map table_map, Select_Lex *select_lex,
73
73
                                st_sargable_param **sargables);
74
74
static int sort_keyuse(KEYUSE *a,KEYUSE *b);
75
75
static void set_position(JOIN *join,uint32_t index,JOIN_TAB *table,KEYUSE *key);
268
268
                   ulong setup_tables_done_option)
269
269
{
270
270
  bool res;
271
 
  register SELECT_LEX *select_lex = &lex->select_lex;
 
271
  register Select_Lex *select_lex = &lex->select_lex;
272
272
  DRIZZLE_SELECT_START();
273
273
 
274
274
  if (select_lex->master_unit()->is_union() ||
276
276
    res= mysql_union(session, lex, result, &lex->unit, setup_tables_done_option);
277
277
  else
278
278
  {
279
 
    SELECT_LEX_UNIT *unit= &lex->unit;
 
279
    Select_Lex_UNIT *unit= &lex->unit;
280
280
    unit->set_limit(unit->global_parameters);
281
281
    session->session_marker= 0;
282
282
    /*
349
349
*/
350
350
 
351
351
bool
352
 
fix_inner_refs(Session *session, List<Item> &all_fields, SELECT_LEX *select,
 
352
fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
353
353
                 Item **ref_pointer_array)
354
354
{
355
355
  Item_outer_ref *ref;
468
468
              uint32_t wild_num, COND *conds_init, uint32_t og_num,
469
469
              order_st *order_init, order_st *group_init,
470
470
              Item *having_init,
471
 
              order_st *proc_param_init, SELECT_LEX *select_lex_arg,
472
 
              SELECT_LEX_UNIT *unit_arg)
 
471
              order_st *proc_param_init, Select_Lex *select_lex_arg,
 
472
              Select_Lex_UNIT *unit_arg)
473
473
{
474
474
  // to prevent double initialization on EXPLAIN
475
475
  if (optimized)
2612
2612
                              This object is responsible for send result
2613
2613
                              set rows to the client or inserting them
2614
2614
                              into a table.
2615
 
  @param select_lex           the only SELECT_LEX of this query
 
2615
  @param select_lex           the only Select_Lex of this query
2616
2616
  @param unit                 top-level UNIT of this query
2617
2617
                              UNIT is an artificial object created by the
2618
2618
                              parser for every SELECT clause.
2631
2631
             TableList *tables, uint32_t wild_num, List<Item> &fields,
2632
2632
             COND *conds, uint32_t og_num,  order_st *order, order_st *group,
2633
2633
             Item *having, order_st *proc_param, uint64_t select_options,
2634
 
             select_result *result, SELECT_LEX_UNIT *unit,
2635
 
             SELECT_LEX *select_lex)
 
2634
             select_result *result, Select_Lex_UNIT *unit,
 
2635
             Select_Lex *select_lex)
2636
2636
{
2637
2637
  bool err;
2638
2638
  bool free_join= 1;
2749
2749
}
2750
2750
 
2751
2751
 
2752
 
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TableList> *tlist)
 
2752
void fix_list_after_tbl_changes(Select_Lex *new_parent, List<TableList> *tlist)
2753
2753
{
2754
2754
  List_iterator<TableList> it(*tlist);
2755
2755
  TableList *table;
2793
2793
 
2794
2794
bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
2795
2795
{
2796
 
  SELECT_LEX *parent_lex= parent_join->select_lex;
 
2796
  Select_Lex *parent_lex= parent_join->select_lex;
2797
2797
  TableList *emb_tbl_nest= NULL;
2798
2798
  List<TableList> *emb_join_list= &parent_lex->top_join_list;
2799
2799
  Session *session= parent_join->session;
2920
2920
    2. Walk through subquery's top list and set 'embedding' to point to the
2921
2921
       sj-nest.
2922
2922
  */
2923
 
  st_select_lex *subq_lex= subq_pred->unit->first_select();
 
2923
  Select_Lex *subq_lex= subq_pred->unit->first_select();
2924
2924
  nested_join->join_list.empty();
2925
2925
  List_iterator_fast<TableList> li(subq_lex->top_join_list);
2926
2926
  TableList *tl, *last_leaf;
2965
2965
  {
2966
2966
    tl->table->tablenr= table_no;
2967
2967
    tl->table->map= ((table_map)1) << table_no;
2968
 
    SELECT_LEX *old_sl= tl->select_lex;
 
2968
    Select_Lex *old_sl= tl->select_lex;
2969
2969
    tl->select_lex= parent_join->select_lex;
2970
2970
    for(TableList *emb= tl->embedding; emb && emb->select_lex == old_sl; emb= emb->embedding)
2971
2971
      emb->select_lex= parent_join->select_lex;
2976
2976
    Put the subquery's WHERE into semi-join's sj_on_expr
2977
2977
    Add the subquery-induced equalities too.
2978
2978
  */
2979
 
  SELECT_LEX *save_lex= session->lex->current_select;
 
2979
  Select_Lex *save_lex= session->lex->current_select;
2980
2980
  session->lex->current_select=subq_lex;
2981
2981
  if (!subq_pred->left_expr->fixed &&
2982
2982
       subq_pred->left_expr->fix_fields(session, &subq_pred->left_expr))
3195
3195
 
3196
3196
bool JOIN::setup_subquery_materialization()
3197
3197
{
3198
 
  for (SELECT_LEX_UNIT *un= select_lex->first_inner_unit(); un;
 
3198
  for (Select_Lex_UNIT *un= select_lex->first_inner_unit(); un;
3199
3199
       un= un->next_unit())
3200
3200
  {
3201
 
    for (SELECT_LEX *sl= un->first_select(); sl; sl= sl->next_select())
 
3201
    for (Select_Lex *sl= un->first_select(); sl; sl= sl->next_select())
3202
3202
    {
3203
3203
      Item_subselect *subquery_predicate= sl->master_unit()->item;
3204
3204
      if (subquery_predicate &&
4610
4610
static bool
4611
4611
update_ref_and_keys(Session *session, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
4612
4612
                    uint32_t tables, COND *cond, COND_EQUAL *,
4613
 
                    table_map normal_tables, SELECT_LEX *select_lex,
 
4613
                    table_map normal_tables, Select_Lex *select_lex,
4614
4614
                    SARGABLE_PARAM **sargables)
4615
4615
{
4616
4616
  uint  and_level,i,found_eq_constant;
7991
7991
 
7992
7992
void JOIN::join_free()
7993
7993
{
7994
 
  SELECT_LEX_UNIT *tmp_unit;
7995
 
  SELECT_LEX *sl;
 
7994
  Select_Lex_UNIT *tmp_unit;
 
7995
  Select_Lex *sl;
7996
7996
  /*
7997
7997
    Optimization: if not EXPLAIN and we are done with the JOIN,
7998
7998
    free all tables.
14455
14455
*/
14456
14456
 
14457
14457
void
14458
 
count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
 
14458
count_field_types(Select_Lex *select_lex, TMP_TABLE_PARAM *param,
14459
14459
                  List<Item> &fields, bool reset_with_sum_func)
14460
14460
{
14461
14461
  List_iterator<Item> li(fields);
15268
15268
  Free joins of subselect of this select.
15269
15269
 
15270
15270
  @param session      Session pointer
15271
 
  @param select   pointer to st_select_lex which subselects joins we will free
 
15271
  @param select   pointer to Select_Lex which subselects joins we will free
15272
15272
*/
15273
15273
 
15274
 
void free_underlaid_joins(Session *, SELECT_LEX *select)
 
15274
void free_underlaid_joins(Session *, Select_Lex *select)
15275
15275
{
15276
 
  for (SELECT_LEX_UNIT *unit= select->first_inner_unit();
 
15276
  for (Select_Lex_UNIT *unit= select->first_inner_unit();
15277
15277
       unit;
15278
15278
       unit= unit->next_unit())
15279
15279
    unit->cleanup();
15772
15772
                                        cs));
15773
15773
    /* table */
15774
15774
    {
15775
 
      SELECT_LEX *sl= join->unit->first_select();
 
15775
      Select_Lex *sl= join->unit->first_select();
15776
15776
      uint32_t len= 6, lastop= 0;
15777
15777
      memcpy(table_name_buffer, STRING_WITH_LEN("<union"));
15778
15778
      for (; sl && len + lastop + 5 < NAME_LEN; sl= sl->next_select())
16187
16187
        join->error= 1;
16188
16188
    }
16189
16189
  }
16190
 
  for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit();
 
16190
  for (Select_Lex_UNIT *unit= join->select_lex->first_inner_unit();
16191
16191
       unit;
16192
16192
       unit= unit->next_unit())
16193
16193
  {
16198
16198
}
16199
16199
 
16200
16200
 
16201
 
bool mysql_explain_union(Session *session, SELECT_LEX_UNIT *unit, select_result *result)
 
16201
bool mysql_explain_union(Session *session, Select_Lex_UNIT *unit, select_result *result)
16202
16202
{
16203
16203
  bool res= 0;
16204
 
  SELECT_LEX *first= unit->first_select();
 
16204
  Select_Lex *first= unit->first_select();
16205
16205
 
16206
 
  for (SELECT_LEX *sl= first;
 
16206
  for (Select_Lex *sl= first;
16207
16207
       sl;
16208
16208
       sl= sl->next_select())
16209
16209
  {
16440
16440
}
16441
16441
 
16442
16442
 
16443
 
void st_select_lex::print(Session *session, String *str, enum_query_type query_type)
 
16443
void Select_Lex::print(Session *session, String *str, enum_query_type query_type)
16444
16444
{
16445
16445
  /* QQ: session may not be set for sub queries, but this should be fixed */
16446
16446
  if (!session)