~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_derived.cc

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    true   Error
34
34
*/
35
35
bool
36
 
mysql_handle_derived(LEX *lex, bool (*processor)(THD*, LEX*, TABLE_LIST*))
 
36
mysql_handle_derived(LEX *lex, bool (*processor)(THD*, LEX*, TableList*))
37
37
{
38
38
  bool res= false;
39
39
  if (lex->derived_tables)
43
43
         sl;
44
44
         sl= sl->next_select_in_list())
45
45
    {
46
 
      for (TABLE_LIST *cursor= sl->get_table_list();
 
46
      for (TableList *cursor= sl->get_table_list();
47
47
           cursor;
48
48
           cursor= cursor->next_local)
49
49
      {
74
74
    mysql_derived_prepare()
75
75
    thd                 Thread handle
76
76
    lex                 LEX for this thread
77
 
    orig_table_list     TABLE_LIST for the upper SELECT
 
77
    orig_table_list     TableList for the upper SELECT
78
78
 
79
79
  IMPLEMENTATION
80
80
    Derived table is resolved with temporary table.
81
81
 
82
 
    After table creation, the above TABLE_LIST is updated with a new table.
 
82
    After table creation, the above TableList is updated with a new table.
83
83
 
84
84
    This function is called before any command containing derived table
85
85
    is executed.
93
93
*/
94
94
 
95
95
bool mysql_derived_prepare(THD *thd, LEX *lex __attribute__((unused)),
96
 
                           TABLE_LIST *orig_table_list)
 
96
                           TableList *orig_table_list)
97
97
{
98
98
  SELECT_LEX_UNIT *unit= orig_table_list->derived;
99
99
  uint64_t create_options;
101
101
  if (unit)
102
102
  {
103
103
    SELECT_LEX *first_select= unit->first_select();
104
 
    TABLE *table= 0;
 
104
    Table *table= 0;
105
105
    select_union *derived_result;
106
106
 
107
107
    /* prevent name resolving out of derived table */
144
144
    if (res)
145
145
    {
146
146
      if (table)
147
 
        free_tmp_table(thd, table);
 
147
          table->free_tmp_table(thd);
148
148
      delete derived_result;
149
149
    }
150
150
    else
182
182
    thd                 Thread handle
183
183
    lex                 LEX for this thread
184
184
    unit                node that contains all SELECT's for derived tables
185
 
    orig_table_list     TABLE_LIST for the upper SELECT
 
185
    orig_table_list     TableList for the upper SELECT
186
186
 
187
187
  IMPLEMENTATION
188
188
    Derived table is resolved with temporary table. It is created based on the
197
197
    true   Error
198
198
*/
199
199
 
200
 
bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
 
200
bool mysql_derived_filling(THD *thd, LEX *lex, TableList *orig_table_list)
201
201
{
202
 
  TABLE *table= orig_table_list->table;
 
202
  Table *table= orig_table_list->table;
203
203
  SELECT_LEX_UNIT *unit= orig_table_list->derived;
204
204
  bool res= false;
205
205
 
222
222
 
223
223
      lex->current_select= first_select;
224
224
      res= mysql_select(thd, &first_select->ref_pointer_array,
225
 
                        (TABLE_LIST*) first_select->table_list.first,
 
225
                        (TableList*) first_select->table_list.first,
226
226
                        first_select->with_wild,
227
227
                        first_select->item_list, first_select->where,
228
228
                        (first_select->order_list.elements+
229
229
                         first_select->group_list.elements),
230
 
                        (ORDER *) first_select->order_list.first,
231
 
                        (ORDER *) first_select->group_list.first,
232
 
                        first_select->having, (ORDER*) NULL,
 
230
                        (order_st *) first_select->order_list.first,
 
231
                        (order_st *) first_select->group_list.first,
 
232
                        first_select->having, (order_st*) NULL,
233
233
                        (first_select->options | thd->options |
234
234
                         SELECT_NO_UNLOCK),
235
235
                        derived_result, unit, first_select);
238
238
    if (!res)
239
239
    {
240
240
      /*
241
 
        Here we entirely fix both TABLE_LIST and list of SELECT's as
 
241
        Here we entirely fix both TableList and list of SELECT's as
242
242
        there were no derived tables
243
243
      */
244
244
      if (derived_result->flush())