~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_derived.cc

[patch 125/129] Merge patch for revision 1943 from InnoDB SVN:
revno: 1943
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6207
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6202
committer: vasil
timestamp: Fri 2009-11-20 08:19:14 +0000
message:
  branches/zip: Merge r6198:6206 from branches/5.1:
  
  (r6203 was skipped as it is already in branches/zip)
  
    ------------------------------------------------------------------------
    r6200 | vasil | 2009-11-19 12:14:23 +0200 (Thu, 19 Nov 2009) | 4 lines
    Changed paths:
       M /branches/5.1/btr/btr0btr.c
    
    branches/5.1:
    
    White space fixup - indent under the opening (
    
    ------------------------------------------------------------------------
    r6203 | jyang | 2009-11-19 15:12:22 +0200 (Thu, 19 Nov 2009) | 8 lines
    Changed paths:
       M /branches/5.1/btr/btr0btr.c
    
    branches/5.1: Use btr_free_root() instead of fseg_free() for
    the fix of bug #48469, because fseg_free() is not defined
    in the zip branch. And we could save one mini-trasaction started
    by fseg_free().
    
    Approved by Marko.
    
    
    ------------------------------------------------------------------------
    r6205 | jyang | 2009-11-20 07:55:48 +0200 (Fri, 20 Nov 2009) | 11 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1: Add a special case to handle the Duplicated Key error
    and return DB_ERROR instead. This is to avoid a possible SIGSEGV
    by mysql error handling re-entering the storage layer for dup key
    info without proper table handle.
    This is to prevent a server crash when error situation in bug
    #45961 "DDL on partitioned innodb tables leaves data dictionary
    in an inconsistent state" happens.
    
    rb://157 approved by Sunny Bains.
    
    
    ------------------------------------------------------------------------
    r6206 | jyang | 2009-11-20 09:38:43 +0200 (Fri, 20 Nov 2009) | 5 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
    
    branches/5.1: Fix a minor code formating issue for 
    the parenthesis iplacement of the if condition in
    rename_table().
    
    
    ------------------------------------------------------------------------
modified:
  handler/ha_innodb.cc           2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fhandler%2Fha_innodb.cc
diff:
=== modified file 'handler/ha_innodb.cc'

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  Derived tables
18
18
  These were introduced by Sinisa <sinisa@mysql.com>
19
19
*/
20
 
#include <config.h>
21
 
 
22
 
#include <drizzled/sql_lex.h>
23
 
#include <drizzled/select_union.h>
24
 
#include <drizzled/sql_select.h>
25
 
#include <drizzled/session.h>
 
20
#include "config.h"
 
21
#include "drizzled/sql_select.h"
26
22
 
27
23
namespace drizzled
28
24
{
31
27
  Call given derived table processor (preparing or filling tables)
32
28
 
33
29
  SYNOPSIS
34
 
    handle_derived()
 
30
    mysql_handle_derived()
35
31
    lex                 LEX for this thread
36
32
    processor           procedure of derived table processing
37
33
 
39
35
    false  OK
40
36
    true   Error
41
37
*/
42
 
bool handle_derived(LEX *lex, bool (*processor)(Session*, LEX*, TableList*))
 
38
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session*, LEX*, TableList*))
43
39
{
44
40
  bool res= false;
45
41
  if (lex->derived_tables)
58
54
          Force join->join_tmp creation, because we will use this JOIN
59
55
          twice for EXPLAIN and we have to have unchanged join for EXPLAINing
60
56
        */
61
 
        sl->uncacheable.set(UNCACHEABLE_EXPLAIN);
62
 
        sl->master_unit()->uncacheable.set(UNCACHEABLE_EXPLAIN);
 
57
        sl->uncacheable|= UNCACHEABLE_EXPLAIN;
 
58
        sl->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
63
59
      }
64
60
    }
65
61
  }
72
68
  Create temporary table structure (but do not fill it)
73
69
 
74
70
  SYNOPSIS
75
 
    derived_prepare()
 
71
    mysql_derived_prepare()
76
72
    session                     Thread handle
77
73
    lex                 LEX for this thread
78
74
    orig_table_list     TableList for the upper SELECT
92
88
    false  OK
93
89
    true   Error
94
90
*/
95
 
bool derived_prepare(Session *session, LEX *, TableList *orig_table_list)
 
91
bool mysql_derived_prepare(Session *session, LEX *, TableList *orig_table_list)
96
92
{
97
93
  Select_Lex_Unit *unit= orig_table_list->derived;
98
94
  uint64_t create_options;
148
144
    }
149
145
    else
150
146
    {
 
147
      if (! session->fill_derived_tables())
 
148
      {
 
149
        delete derived_result;
 
150
        derived_result= NULL;
 
151
      }
151
152
      orig_table_list->derived_result= derived_result;
152
153
      orig_table_list->table= table;
153
 
      orig_table_list->setTableName(const_cast<char *>(table->getShare()->getTableName()));
 
154
      orig_table_list->table_name=        const_cast<char *>(table->getShare()->getTableName());
154
155
      orig_table_list->table_name_length= table->getShare()->getTableNameSize();
155
156
      table->derived_select_number= first_select->select_number;
156
 
      orig_table_list->setSchemaName((char *)"");
 
157
      orig_table_list->db= (char *)"";
157
158
      orig_table_list->db_length= 0;
158
159
      /* Force read of table stats in the optimizer */
159
160
      table->cursor->info(HA_STATUS_VARIABLE);
160
161
      /* Add new temporary table to list of open derived tables */
161
 
      table->setNext(session->getDerivedTables());
162
 
      session->setDerivedTables(table);
 
162
      table->setNext(session->derived_tables);
 
163
      session->derived_tables= table;
163
164
    }
164
165
  }
165
166
 
170
171
  fill derived table
171
172
 
172
173
  SYNOPSIS
173
 
    derived_filling()
 
174
    mysql_derived_filling()
174
175
    session                     Thread handle
175
176
    lex                 LEX for this thread
176
177
    unit                node that contains all SELECT's for derived tables
188
189
    false  OK
189
190
    true   Error
190
191
*/
191
 
bool derived_filling(Session *session, LEX *lex, TableList *orig_table_list)
 
192
bool mysql_derived_filling(Session *session, LEX *lex, TableList *orig_table_list)
192
193
{
193
194
  Table *table= orig_table_list->table;
194
195
  Select_Lex_Unit *unit= orig_table_list->derived;
212
213
              first_select->options&= ~OPTION_FOUND_ROWS;
213
214
 
214
215
      lex->current_select= first_select;
215
 
      res= select_query(session, &first_select->ref_pointer_array,
 
216
      res= mysql_select(session, &first_select->ref_pointer_array,
216
217
                        (TableList*) first_select->table_list.first,
217
218
                        first_select->with_wild,
218
219
                        first_select->item_list, first_select->where,
219
220
                        (first_select->order_list.elements+
220
221
                        first_select->group_list.elements),
221
 
                        (Order *) first_select->order_list.first,
222
 
                        (Order *) first_select->group_list.first,
 
222
                        (order_st *) first_select->order_list.first,
 
223
                        (order_st *) first_select->group_list.first,
223
224
                        first_select->having,
224
225
                        (first_select->options | session->options | SELECT_NO_UNLOCK),
225
226
                        derived_result, unit, first_select);