~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_olap.cc

  • Committer: Brian Aker
  • Date: 2009-04-17 01:45:33 UTC
  • Revision ID: brian@gaz-20090417014533-exdrtriab9zecqs2
Refactor get_variable to session

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
****************************************************************************/
37
37
 
38
38
 
39
 
static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new_fields)
 
39
static int make_new_olap_select(LEX *lex, Select_Lex *select_lex, List<Item> new_fields)
40
40
{
41
 
  THD   *thd=current_thd;
 
41
  Session       *session=current_session;
42
42
  Item *item, *new_item;
43
43
  Item_null *constant= new Item_null("ALL");
44
44
 
45
 
  SELECT_LEX *new_select = (SELECT_LEX *) thd->memdup((char*) select_lex, sizeof(*select_lex));
 
45
  Select_Lex *new_select = (Select_Lex *) session->memdup((char*) select_lex, sizeof(*select_lex));
46
46
  if (!new_select)
47
47
    return 1;
48
48
  lex->last_selects->next=new_select;
49
49
  new_select->linkage=OLAP_TYPE;
50
50
  new_select->olap=NON_EXISTING_ONE;
51
51
  new_select->group_list.elements=0;
52
 
  new_select->group_list.first=(uchar *)0;
53
 
  new_select->group_list.next=(uchar **)&new_select->group_list.first;
 
52
  new_select->group_list.first=(unsigned char *)0;
 
53
  new_select->group_list.next=(unsigned char **)&new_select->group_list.first;
54
54
  List<Item> privlist;
55
 
  
 
55
 
56
56
  List_iterator<Item> list_it(select_lex->item_list);
57
57
  List_iterator<Item> new_it(new_fields);
58
 
    
 
58
 
59
59
  while ((item=list_it++))
60
60
  {
61
61
    bool not_found= true;
65
65
      new_it.rewind();
66
66
      while ((new_item=new_it++))
67
67
      {
68
 
        if (new_item->type()==Item::FIELD_ITEM && 
 
68
        if (new_item->type()==Item::FIELD_ITEM &&
69
69
            !strcmp(((Item_field*)new_item)->table_name,iif->table_name) &&
70
70
            !strcmp(((Item_field*)new_item)->field_name,iif->field_name))
71
71
        {
85
85
      if (item->type() == Item::FIELD_ITEM)
86
86
        privlist.push_back(constant);
87
87
      else
88
 
        privlist.push_back((Item*)thd->memdup((char *)item,item->size_of()));
 
88
        privlist.push_back((Item*)session->memdup((char *)item,item->size_of()));
89
89
    }
90
90
  }
91
91
  new_select->item_list=privlist;
99
99
  Returns 0 if OK, 1 if error, -1 if error already printed to client
100
100
****************************************************************************/
101
101
 
102
 
static int  olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex, 
103
 
                              SELECT_LEX *select_lex, int position, int selection, int num_fields, 
 
102
static int  olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex,
 
103
                              Select_Lex *select_lex, int position, int selection, int num_fields,
104
104
                              int num_new_fields)
105
105
{
106
106
  int sl_return = 0;
126
126
 
127
127
/****************************************************************************
128
128
  Top level function for converting OLAP clauses to multiple selects
129
 
  This is also a place where clauses treatment depends on OLAP type 
 
129
  This is also a place where clauses treatment depends on OLAP type
130
130
  Returns 0 if OK, 1 if error, -1 if error already printed to client
131
131
****************************************************************************/
132
132
 
133
 
int handle_olaps(LEX *lex, SELECT_LEX *select_lex)
 
133
int handle_olaps(LEX *lex, Select_Lex *select_lex)
134
134
{
135
135
  List<Item> item_list_copy, new_item_list;
136
136
  item_list_copy.empty();
147
147
  List<Item>    all_fields(select_lex->item_list);
148
148
 
149
149
 
150
 
  if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list,
151
 
                   (TABLE_LIST *)select_lex->table_list.first
 
150
  if (setup_tables(lex->session, &select_lex->context, &select_lex->top_join_list,
 
151
                   (TableList *)select_lex->table_list.first
152
152
                   &select_lex->leaf_tables, false) ||
153
 
      setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ,
 
153
      setup_fields(lex->session, 0, select_lex->item_list, MARK_COLUMNS_READ,
154
154
                   &all_fields,1) ||
155
 
      setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ,
 
155
      setup_fields(lex->session, 0, item_list_copy, MARK_COLUMNS_READ,
156
156
                   &all_fields, 1))
157
157
    return -1;
158
158