~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_derived.cc

  • Committer: Brian Aker
  • Date: 2010-08-09 18:04:12 UTC
  • mfrom: (1689.3.7 staging)
  • Revision ID: brian@gaz-20100809180412-olurwh51ojllev6p
Merge in heap conversion, and case insensitive patch, and remove need for
M_HASH in session.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
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);