~stewart/drizzle/docs-improvements-1

« back to all changes in this revision

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

merged with up to date trunk

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.h"
 
38
#include "pars0grm.hh"
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 = exp;
 
99
                func_node = static_cast<func_node_t *>(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 = exp;
 
117
        sym_node = static_cast<sym_node_t *>(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 = arg;
 
188
                sym_node = static_cast<sym_node_t *>(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 = arg;
 
214
                sym_node = static_cast<sym_node_t *>(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 = search_cond->args;
 
265
                new_cond = static_cast<func_node_t *>(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 = que_node_get_next(new_cond);
 
275
                new_cond = static_cast<func_node_t *>(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;
 
332
        ulint           op= 0;
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, sel_node->search_cond,
 
349
                        OPT_EQUAL, col_no,
 
350
                        static_cast<func_node_t *>(sel_node->search_cond),
350
351
                        sel_node, nth_table, &op);
351
352
                if (exp) {
352
353
                        /* The value for this column is exactly known already
359
360
                        /* Look for non-equality comparisons */
360
361
 
361
362
                        exp = opt_look_for_col_in_cond_before(
362
 
                                OPT_COMPARISON, col_no, sel_node->search_cond,
 
363
                                OPT_COMPARISON, col_no, static_cast<func_node_t *>(sel_node->search_cond),
363
364
                                sel_node, nth_table, &op);
364
365
                        if (exp) {
365
366
                                index_plan[j] = exp;
583
584
                                            n_fields);
584
585
                dict_index_copy_types(plan->tuple, plan->index, n_fields);
585
586
 
586
 
                plan->tuple_exps = mem_heap_alloc(pars_sym_tab_global->heap,
587
 
                                                  n_fields * sizeof(void*));
 
587
                plan->tuple_exps = static_cast<void **>(mem_heap_alloc(pars_sym_tab_global->heap,
 
588
                                                  n_fields * sizeof(void*)));
588
589
 
589
590
                ut_memcpy(plan->tuple_exps, best_index_plan,
590
591
                          n_fields * sizeof(void*));
717
718
                                        conditions or NULL */
718
719
{
719
720
        func_node_t*    new_cond;
720
 
        ulint           class;
 
721
        ulint           func_class;
721
722
        plan_t*         plan;
722
723
 
723
724
        if (cond == NULL) {
726
727
        }
727
728
 
728
729
        if (cond->func == PARS_AND_TOKEN) {
729
 
                new_cond = cond->args;
 
730
                new_cond = static_cast<func_node_t *>(cond->args);
730
731
 
731
732
                opt_find_test_conds(sel_node, i, new_cond);
732
733
 
733
 
                new_cond = que_node_get_next(new_cond);
 
734
                new_cond = static_cast<func_node_t *>(que_node_get_next(new_cond));
734
735
 
735
736
                opt_find_test_conds(sel_node, i, new_cond);
736
737
 
739
740
 
740
741
        plan = sel_node_get_nth_plan(sel_node, i);
741
742
 
742
 
        class = opt_classify_comparison(sel_node, i, cond);
 
743
        func_class = opt_classify_comparison(sel_node, i, cond);
743
744
 
744
 
        if (class == OPT_END_COND) {
 
745
        if (func_class == OPT_END_COND) {
745
746
                UT_LIST_ADD_LAST(cond_list, plan->end_conds, cond);
746
747
 
747
 
        } else if (class == OPT_TEST_COND) {
 
748
        } else if (func_class == OPT_TEST_COND) {
748
749
                UT_LIST_ADD_LAST(cond_list, plan->other_conds, cond);
749
750
 
750
751
        }
772
773
 
773
774
                if (que_node_get_type(arg2) == QUE_NODE_SYMBOL) {
774
775
 
775
 
                        sym_node = arg2;
 
776
                        sym_node = static_cast<sym_node_t *>(arg2);
776
777
 
777
778
                        if ((sym_node->token_type == SYM_COLUMN)
778
779
                            && (sym_node->table == table)) {
812
813
 
813
814
        /* Recursively go through the conjuncts and classify them */
814
815
 
815
 
        opt_find_test_conds(sel_node, i, sel_node->search_cond);
 
816
        opt_find_test_conds(sel_node, i, static_cast<func_node_t *>(sel_node->search_cond));
816
817
 
817
818
        opt_normalize_cmp_conds(UT_LIST_GET_FIRST(plan->end_conds),
818
819
                                plan->table);
852
853
        }
853
854
 
854
855
        if (que_node_get_type(exp) == QUE_NODE_FUNC) {
855
 
                func_node = exp;
 
856
                func_node = static_cast<func_node_t *>(exp);
856
857
 
857
858
                arg = func_node->args;
858
859
 
867
868
 
868
869
        ut_a(que_node_get_type(exp) == QUE_NODE_SYMBOL);
869
870
 
870
 
        sym_node = exp;
 
871
        sym_node = static_cast<sym_node_t *>(exp);
871
872
 
872
873
        if (sym_node->token_type != SYM_COLUMN) {
873
874
 
953
954
        ut_ad(que_node_get_type(search_cond) == QUE_NODE_FUNC);
954
955
 
955
956
        if (search_cond->func == PARS_AND_TOKEN) {
956
 
                new_cond = search_cond->args;
 
957
                new_cond = static_cast<func_node_t *>(search_cond->args);
957
958
 
958
959
                opt_find_copy_cols(sel_node, i, new_cond);
959
960
 
960
 
                new_cond = que_node_get_next(new_cond);
 
961
                new_cond = static_cast<func_node_t *>(que_node_get_next(new_cond));
961
962
 
962
963
                opt_find_copy_cols(sel_node, i, new_cond);
963
964
 
1012
1013
                exp = que_node_get_next(exp);
1013
1014
        }
1014
1015
 
1015
 
        opt_find_copy_cols(sel_node, i, sel_node->search_cond);
 
1016
        opt_find_copy_cols(sel_node, i, static_cast<func_node_t *>(sel_node->search_cond));
1016
1017
 
1017
1018
        /* All remaining columns in the search condition are temporary
1018
1019
        columns: therefore FALSE */
1068
1069
 
1069
1070
        dict_index_copy_types(plan->clust_ref, clust_index, n_fields);
1070
1071
 
1071
 
        plan->clust_map = mem_heap_alloc(heap, n_fields * sizeof(ulint));
 
1072
        plan->clust_map = static_cast<unsigned long *>(mem_heap_alloc(heap, n_fields * sizeof(ulint)));
1072
1073
 
1073
1074
        for (i = 0; i < n_fields; i++) {
1074
1075
                pos = dict_index_get_nth_field_pos(index, clust_index, i);
1108
1109
        order_node_t*   order_by;
1109
1110
        ulint           i;
1110
1111
 
1111
 
        sel_node->plans = mem_heap_alloc(pars_sym_tab_global->heap,
1112
 
                                         sel_node->n_tables * sizeof(plan_t));
 
1112
        sel_node->plans = static_cast<plan_t *>(mem_heap_alloc(pars_sym_tab_global->heap,
 
1113
                                         sel_node->n_tables * sizeof(plan_t)));
1113
1114
 
1114
1115
        /* Analyze the search condition to find out what we know at each
1115
1116
        join stage about the conditions that the columns of a table should
1138
1139
 
1139
1140
                opt_determine_and_normalize_test_conds(sel_node, i);
1140
1141
 
1141
 
                table_node = que_node_get_next(table_node);
 
1142
                table_node = static_cast<sym_node_t *>(que_node_get_next(table_node));
1142
1143
        }
1143
1144
 
1144
1145
        table_node = sel_node->table_list;
1155
1156
 
1156
1157
                opt_clust_access(sel_node, i);
1157
1158
 
1158
 
                table_node = que_node_get_next(table_node);
 
1159
                table_node = static_cast<sym_node_t *>(que_node_get_next(table_node));
1159
1160
        }
1160
1161
 
1161
1162
        /* Check that the plan obeys a possible order-by clause: if not,