~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/pars/pars0opt.c

  • Committer: Lee Bieber
  • Date: 2010-11-14 23:15:42 UTC
  • mfrom: (1929.1.42 warning-stack-frame)
  • Revision ID: kalebral@gmail.com-20101114231542-fnnu6ydd2p17n582
Merge Monty - fix bug 672372: some functions use > 32k stack

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
35
35
#include "dict0dict.h"
36
36
#include "dict0mem.h"
37
37
#include "que0que.h"
38
 
#include "pars0grm.hh"
 
38
#include "pars0grm.h"
39
39
#include "pars0pars.h"
40
40
#include "lock0lock.h"
41
41
 
96
96
        ut_ad(exp && sel_node);
97
97
 
98
98
        if (que_node_get_type(exp) == QUE_NODE_FUNC) {
99
 
                func_node = static_cast<func_node_t *>(exp);
 
99
                func_node = exp;
100
100
 
101
101
                arg = func_node->args;
102
102
 
114
114
 
115
115
        ut_a(que_node_get_type(exp) == QUE_NODE_SYMBOL);
116
116
 
117
 
        sym_node = static_cast<sym_node_t *>(exp);
 
117
        sym_node = exp;
118
118
 
119
119
        if (sym_node->token_type != SYM_COLUMN) {
120
120
 
185
185
        arg = search_cond->args;
186
186
 
187
187
        if (que_node_get_type(arg) == QUE_NODE_SYMBOL) {
188
 
                sym_node = static_cast<sym_node_t *>(arg);
 
188
                sym_node = arg;
189
189
 
190
190
                if ((sym_node->token_type == SYM_COLUMN)
191
191
                    && (sym_node->table == table)
211
211
        arg = que_node_get_next(arg);
212
212
 
213
213
        if (que_node_get_type(arg) == QUE_NODE_SYMBOL) {
214
 
                sym_node = static_cast<sym_node_t *>(arg);
 
214
                sym_node = arg;
215
215
 
216
216
                if ((sym_node->token_type == SYM_COLUMN)
217
217
                    && (sym_node->table == table)
262
262
        ut_a(search_cond->func != PARS_NOT_TOKEN);
263
263
 
264
264
        if (search_cond->func == PARS_AND_TOKEN) {
265
 
                new_cond = static_cast<func_node_t *>(search_cond->args);
 
265
                new_cond = search_cond->args;
266
266
 
267
267
                exp = opt_look_for_col_in_cond_before(cmp_type, col_no,
268
268
                                                      new_cond, sel_node,
272
272
                        return(exp);
273
273
                }
274
274
 
275
 
                new_cond = static_cast<func_node_t *>(que_node_get_next(new_cond));
 
275
                new_cond = que_node_get_next(new_cond);
276
276
 
277
277
                exp = opt_look_for_col_in_cond_before(cmp_type, col_no,
278
278
                                                      new_cond, sel_node,
329
329
        ulint           goodness;
330
330
        ulint           n_fields;
331
331
        ulint           col_no;
332
 
        ulint           op= 0;
 
332
        ulint           op;
333
333
        ulint           j;
334
334
 
335
335
        goodness = 0;
346
346
                col_no = dict_index_get_nth_col_no(index, j);
347
347
 
348
348
                exp = opt_look_for_col_in_cond_before(
349
 
                        OPT_EQUAL, col_no,
350
 
                        static_cast<func_node_t *>(sel_node->search_cond),
 
349
                        OPT_EQUAL, col_no, sel_node->search_cond,
351
350
                        sel_node, nth_table, &op);
352
351
                if (exp) {
353
352
                        /* The value for this column is exactly known already
360
359
                        /* Look for non-equality comparisons */
361
360
 
362
361
                        exp = opt_look_for_col_in_cond_before(
363
 
                                OPT_COMPARISON, col_no, static_cast<func_node_t *>(sel_node->search_cond),
 
362
                                OPT_COMPARISON, col_no, sel_node->search_cond,
364
363
                                sel_node, nth_table, &op);
365
364
                        if (exp) {
366
365
                                index_plan[j] = exp;
584
583
                                            n_fields);
585
584
                dict_index_copy_types(plan->tuple, plan->index, n_fields);
586
585
 
587
 
                plan->tuple_exps = static_cast<void **>(mem_heap_alloc(pars_sym_tab_global->heap,
588
 
                                                  n_fields * sizeof(void*)));
 
586
                plan->tuple_exps = mem_heap_alloc(pars_sym_tab_global->heap,
 
587
                                                  n_fields * sizeof(void*));
589
588
 
590
589
                ut_memcpy(plan->tuple_exps, best_index_plan,
591
590
                          n_fields * sizeof(void*));
718
717
                                        conditions or NULL */
719
718
{
720
719
        func_node_t*    new_cond;
721
 
        ulint           func_class;
 
720
        ulint           class;
722
721
        plan_t*         plan;
723
722
 
724
723
        if (cond == NULL) {
727
726
        }
728
727
 
729
728
        if (cond->func == PARS_AND_TOKEN) {
730
 
                new_cond = static_cast<func_node_t *>(cond->args);
 
729
                new_cond = cond->args;
731
730
 
732
731
                opt_find_test_conds(sel_node, i, new_cond);
733
732
 
734
 
                new_cond = static_cast<func_node_t *>(que_node_get_next(new_cond));
 
733
                new_cond = que_node_get_next(new_cond);
735
734
 
736
735
                opt_find_test_conds(sel_node, i, new_cond);
737
736
 
740
739
 
741
740
        plan = sel_node_get_nth_plan(sel_node, i);
742
741
 
743
 
        func_class = opt_classify_comparison(sel_node, i, cond);
 
742
        class = opt_classify_comparison(sel_node, i, cond);
744
743
 
745
 
        if (func_class == OPT_END_COND) {
 
744
        if (class == OPT_END_COND) {
746
745
                UT_LIST_ADD_LAST(cond_list, plan->end_conds, cond);
747
746
 
748
 
        } else if (func_class == OPT_TEST_COND) {
 
747
        } else if (class == OPT_TEST_COND) {
749
748
                UT_LIST_ADD_LAST(cond_list, plan->other_conds, cond);
750
749
 
751
750
        }
773
772
 
774
773
                if (que_node_get_type(arg2) == QUE_NODE_SYMBOL) {
775
774
 
776
 
                        sym_node = static_cast<sym_node_t *>(arg2);
 
775
                        sym_node = arg2;
777
776
 
778
777
                        if ((sym_node->token_type == SYM_COLUMN)
779
778
                            && (sym_node->table == table)) {
813
812
 
814
813
        /* Recursively go through the conjuncts and classify them */
815
814
 
816
 
        opt_find_test_conds(sel_node, i, static_cast<func_node_t *>(sel_node->search_cond));
 
815
        opt_find_test_conds(sel_node, i, sel_node->search_cond);
817
816
 
818
817
        opt_normalize_cmp_conds(UT_LIST_GET_FIRST(plan->end_conds),
819
818
                                plan->table);
853
852
        }
854
853
 
855
854
        if (que_node_get_type(exp) == QUE_NODE_FUNC) {
856
 
                func_node = static_cast<func_node_t *>(exp);
 
855
                func_node = exp;
857
856
 
858
857
                arg = func_node->args;
859
858
 
868
867
 
869
868
        ut_a(que_node_get_type(exp) == QUE_NODE_SYMBOL);
870
869
 
871
 
        sym_node = static_cast<sym_node_t *>(exp);
 
870
        sym_node = exp;
872
871
 
873
872
        if (sym_node->token_type != SYM_COLUMN) {
874
873
 
954
953
        ut_ad(que_node_get_type(search_cond) == QUE_NODE_FUNC);
955
954
 
956
955
        if (search_cond->func == PARS_AND_TOKEN) {
957
 
                new_cond = static_cast<func_node_t *>(search_cond->args);
 
956
                new_cond = search_cond->args;
958
957
 
959
958
                opt_find_copy_cols(sel_node, i, new_cond);
960
959
 
961
 
                new_cond = static_cast<func_node_t *>(que_node_get_next(new_cond));
 
960
                new_cond = que_node_get_next(new_cond);
962
961
 
963
962
                opt_find_copy_cols(sel_node, i, new_cond);
964
963
 
1013
1012
                exp = que_node_get_next(exp);
1014
1013
        }
1015
1014
 
1016
 
        opt_find_copy_cols(sel_node, i, static_cast<func_node_t *>(sel_node->search_cond));
 
1015
        opt_find_copy_cols(sel_node, i, sel_node->search_cond);
1017
1016
 
1018
1017
        /* All remaining columns in the search condition are temporary
1019
1018
        columns: therefore FALSE */
1069
1068
 
1070
1069
        dict_index_copy_types(plan->clust_ref, clust_index, n_fields);
1071
1070
 
1072
 
        plan->clust_map = static_cast<unsigned long *>(mem_heap_alloc(heap, n_fields * sizeof(ulint)));
 
1071
        plan->clust_map = mem_heap_alloc(heap, n_fields * sizeof(ulint));
1073
1072
 
1074
1073
        for (i = 0; i < n_fields; i++) {
1075
1074
                pos = dict_index_get_nth_field_pos(index, clust_index, i);
1109
1108
        order_node_t*   order_by;
1110
1109
        ulint           i;
1111
1110
 
1112
 
        sel_node->plans = static_cast<plan_t *>(mem_heap_alloc(pars_sym_tab_global->heap,
1113
 
                                         sel_node->n_tables * sizeof(plan_t)));
 
1111
        sel_node->plans = mem_heap_alloc(pars_sym_tab_global->heap,
 
1112
                                         sel_node->n_tables * sizeof(plan_t));
1114
1113
 
1115
1114
        /* Analyze the search condition to find out what we know at each
1116
1115
        join stage about the conditions that the columns of a table should
1139
1138
 
1140
1139
                opt_determine_and_normalize_test_conds(sel_node, i);
1141
1140
 
1142
 
                table_node = static_cast<sym_node_t *>(que_node_get_next(table_node));
 
1141
                table_node = que_node_get_next(table_node);
1143
1142
        }
1144
1143
 
1145
1144
        table_node = sel_node->table_list;
1156
1155
 
1157
1156
                opt_clust_access(sel_node, i);
1158
1157
 
1159
 
                table_node = static_cast<sym_node_t *>(que_node_get_next(table_node));
 
1158
                table_node = que_node_get_next(table_node);
1160
1159
        }
1161
1160
 
1162
1161
        /* Check that the plan obeys a possible order-by clause: if not,