~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_derived.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/*
17
17
  Derived tables
27
27
  Call given derived table processor (preparing or filling tables)
28
28
 
29
29
  SYNOPSIS
30
 
    mysql_handle_derived()
 
30
    handle_derived()
31
31
    lex                 LEX for this thread
32
32
    processor           procedure of derived table processing
33
33
 
35
35
    false  OK
36
36
    true   Error
37
37
*/
38
 
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session*, LEX*, TableList*))
 
38
bool handle_derived(LEX *lex, bool (*processor)(Session*, LEX*, TableList*))
39
39
{
40
40
  bool res= false;
41
41
  if (lex->derived_tables)
54
54
          Force join->join_tmp creation, because we will use this JOIN
55
55
          twice for EXPLAIN and we have to have unchanged join for EXPLAINing
56
56
        */
57
 
        sl->uncacheable|= UNCACHEABLE_EXPLAIN;
58
 
        sl->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
 
57
        sl->uncacheable.set(UNCACHEABLE_EXPLAIN);
 
58
        sl->master_unit()->uncacheable.set(UNCACHEABLE_EXPLAIN);
59
59
      }
60
60
    }
61
61
  }
68
68
  Create temporary table structure (but do not fill it)
69
69
 
70
70
  SYNOPSIS
71
 
    mysql_derived_prepare()
 
71
    derived_prepare()
72
72
    session                     Thread handle
73
73
    lex                 LEX for this thread
74
74
    orig_table_list     TableList for the upper SELECT
88
88
    false  OK
89
89
    true   Error
90
90
*/
91
 
bool mysql_derived_prepare(Session *session, LEX *, TableList *orig_table_list)
 
91
bool derived_prepare(Session *session, LEX *, TableList *orig_table_list)
92
92
{
93
93
  Select_Lex_Unit *unit= orig_table_list->derived;
94
94
  uint64_t create_options;
144
144
    }
145
145
    else
146
146
    {
147
 
      if (! session->fill_derived_tables())
148
 
      {
149
 
        delete derived_result;
150
 
        derived_result= NULL;
151
 
      }
152
147
      orig_table_list->derived_result= derived_result;
153
148
      orig_table_list->table= table;
154
 
      orig_table_list->table_name=        const_cast<char *>(table->getShare()->getTableName());
 
149
      orig_table_list->setTableName(const_cast<char *>(table->getShare()->getTableName()));
155
150
      orig_table_list->table_name_length= table->getShare()->getTableNameSize();
156
151
      table->derived_select_number= first_select->select_number;
157
 
      orig_table_list->db= (char *)"";
 
152
      orig_table_list->setSchemaName((char *)"");
158
153
      orig_table_list->db_length= 0;
159
154
      /* Force read of table stats in the optimizer */
160
155
      table->cursor->info(HA_STATUS_VARIABLE);
161
156
      /* Add new temporary table to list of open derived tables */
162
 
      table->setNext(session->derived_tables);
163
 
      session->derived_tables= table;
 
157
      table->setNext(session->getDerivedTables());
 
158
      session->setDerivedTables(table);
164
159
    }
165
160
  }
166
161
 
171
166
  fill derived table
172
167
 
173
168
  SYNOPSIS
174
 
    mysql_derived_filling()
 
169
    derived_filling()
175
170
    session                     Thread handle
176
171
    lex                 LEX for this thread
177
172
    unit                node that contains all SELECT's for derived tables
189
184
    false  OK
190
185
    true   Error
191
186
*/
192
 
bool mysql_derived_filling(Session *session, LEX *lex, TableList *orig_table_list)
 
187
bool derived_filling(Session *session, LEX *lex, TableList *orig_table_list)
193
188
{
194
189
  Table *table= orig_table_list->table;
195
190
  Select_Lex_Unit *unit= orig_table_list->derived;
213
208
              first_select->options&= ~OPTION_FOUND_ROWS;
214
209
 
215
210
      lex->current_select= first_select;
216
 
      res= mysql_select(session, &first_select->ref_pointer_array,
 
211
      res= select_query(session, &first_select->ref_pointer_array,
217
212
                        (TableList*) first_select->table_list.first,
218
213
                        first_select->with_wild,
219
214
                        first_select->item_list, first_select->where,
220
215
                        (first_select->order_list.elements+
221
216
                        first_select->group_list.elements),
222
 
                        (order_st *) first_select->order_list.first,
223
 
                        (order_st *) first_select->group_list.first,
 
217
                        (Order *) first_select->order_list.first,
 
218
                        (Order *) first_select->group_list.first,
224
219
                        first_select->having,
225
220
                        (first_select->options | session->options | SELECT_NO_UNLOCK),
226
221
                        derived_result, unit, first_select);