CUBRID Engine  latest
query_graph.c File Reference
#include "config.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <assert.h>
#include <values.h>
#include "parser.h"
#include "error_code.h"
#include "error_manager.h"
#include "object_primitive.h"
#include "object_representation.h"
#include "optimizer.h"
#include "query_graph.h"
#include "query_planner.h"
#include "schema_manager.h"
#include "statistics.h"
#include "system_parameter.h"
#include "environment_variable.h"
#include "xasl_generation.h"
#include "query_list.h"
#include "db.h"
#include "memory_alloc.h"
#include "util_func.h"
#include "locator_cl.h"
#include "object_domain.h"
#include "network_interface_cl.h"
#include "dbtype.h"
#include "xasl.h"

Go to the source code of this file.

Classes

struct  walk_info
 

Macros

#define SIZEOF_USING_INDEX(n)   (sizeof(QO_USING_INDEX) + (((n)-1) * sizeof(QO_USING_INDEX_ENTRY)))
 
#define PREDICATE_TERM   -2
 
#define RANK_DEFAULT   0 /* default */
 
#define RANK_NAME   RANK_DEFAULT /* name -- use default */
 
#define RANK_VALUE   RANK_DEFAULT /* value -- use default */
 
#define RANK_EXPR_LIGHT   1 /* Group 1 */
 
#define RANK_EXPR_MEDIUM   2 /* Group 2 */
 
#define RANK_EXPR_HEAVY   3 /* Group 3 */
 
#define RANK_EXPR_FUNCTION   4 /* agg function, set */
 
#define RANK_QUERY   8 /* subquery */
 
#define LOG2_SIZEOF_POINTER   2
 
#define SIZEOF_INDEX(n)   (sizeof(QO_INDEX) + (((n)-1)* sizeof(QO_INDEX_ENTRY)))
 
#define SIZEOF_CLASS_INFO(n)   (sizeof(QO_CLASS_INFO) + (((n)-1) * sizeof(QO_CLASS_INFO_ENTRY)))
 
#define SIZEOF_ATTR_CUM_STATS_PKEYS(n)   ((n) * sizeof(int))
 
#define NOMINAL_HEAP_SIZE(class)   200 /* pages */
 
#define NOMINAL_OBJECT_SIZE(class)   64 /* bytes */
 
#define SIZEOF_NODE_INDEX(n)   (sizeof(QO_NODE_INDEX) + (((n)-1)* sizeof(QO_NODE_INDEX_ENTRY)))
 
#define EXCHANGE_BUILDER(type, e0, e1)   do { type _tmp = e0; e0 = e1; e1 = _tmp; } while (0)
 
#define TERMCLASS_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(QO_TERMCLASS,e0,e1)
 
#define DOUBLE_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(double,e0,e1)
 
#define PT_NODE_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(PT_NODE *,e0,e1)
 
#define INT_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(int,e0,e1)
 
#define SEGMENTPTR_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(QO_SEGMENT *,e0,e1)
 
#define NODEPTR_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(QO_NODE *,e0,e1)
 
#define EQCLASSPTR_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(QO_EQCLASS *,e0,e1)
 
#define BOOL_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(bool,e0,e1)
 
#define JOIN_TYPE_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(JOIN_TYPE,e0,e1)
 
#define FLAG_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(int,e0,e1)
 
#define INT_PTR_EXCHANGE(e0, e1)   EXCHANGE_BUILDER(int *,e0,e1)
 
#define BISET_EXCHANGE(s0, s1)
 
#define PUT_FLAG(cond, flag)
 
#define OPTIMIZATION_LIMIT   64
 

Typedefs

typedef struct walk_info WALK_INFO
 

Enumerations

enum  QO_BUILD_STATUS { QO_BUILD_ENTITY = 0x01, QO_BUILD_PATH = 0x02 }
 

Functions

static QO_PLANqo_optimize_helper (QO_ENV *env)
 
static QO_NODEqo_add_node (PT_NODE *entity, QO_ENV *env)
 
static QO_SEGMENTqo_insert_segment (QO_NODE *head, QO_NODE *tail, PT_NODE *node, QO_ENV *env, const char *expr_str)
 
static QO_SEGMENTqo_join_segment (QO_NODE *head, QO_NODE *tail, PT_NODE *name, QO_ENV *env)
 
static PT_NODEqo_add_final_segment (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static QO_TERMqo_add_term (PT_NODE *conjunct, int term_type, QO_ENV *env)
 
static void qo_add_dep_term (QO_NODE *derived_node, BITSET *depend_nodes, BITSET *depend_segs, QO_ENV *env)
 
static QO_TERMqo_add_dummy_join_term (QO_ENV *env, QO_NODE *p_node, QO_NODE *on_node)
 
static void qo_analyze_term (QO_TERM *term, int term_type)
 
static PT_NODEset_seg_expr (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static void set_seg_node (PT_NODE *attr, QO_ENV *env, BITSET *bitset)
 
static QO_ENVqo_env_init (PARSER_CONTEXT *parser, PT_NODE *query)
 
static bool qo_validate (QO_ENV *env)
 
static PT_NODEbuild_query_graph (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static PT_NODEbuild_query_graph_post (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static PT_NODEbuild_query_graph_function_index (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static QO_NODEbuild_graph_for_entity (QO_ENV *env, PT_NODE *entity, QO_BUILD_STATUS status)
 
static PT_NODEgraph_size_select (PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
 
static void graph_size_for_entity (QO_ENV *env, PT_NODE *entity)
 
static bool is_dependent_table (PT_NODE *entity)
 
static void get_term_subqueries (QO_ENV *env, QO_TERM *term)
 
static void get_term_rank (QO_ENV *env, QO_TERM *term)
 
static PT_NODEcheck_subquery_pre (PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *continue_walk)
 
static bool is_local_name (QO_ENV *env, PT_NODE *expr)
 
static void get_local_subqueries (QO_ENV *env, PT_NODE *tree)
 
static void get_rank (QO_ENV *env)
 
static PT_NODEget_referenced_attrs (PT_NODE *entity)
 
static bool expr_is_mergable (PT_NODE *pt_expr)
 
static bool qo_is_equi_join_term (QO_TERM *term)
 
static void add_hint (QO_ENV *env, PT_NODE *tree)
 
static void add_using_index (QO_ENV *env, PT_NODE *using_index)
 
static int get_opcode_rank (PT_OP_TYPE opcode)
 
static int get_expr_fcode_rank (FUNC_TYPE fcode)
 
static int get_operand_rank (PT_NODE *node)
 
static int count_classes (PT_NODE *p)
 
static QO_CLASS_INFO_ENTRYgrok_classes (QO_ENV *env, PT_NODE *dom_set, QO_CLASS_INFO_ENTRY *info)
 
static int qo_data_compare (DB_DATA *data1, DB_DATA *data2, DB_TYPE type)
 
static void qo_estimate_statistics (MOP class_mop, CLASS_STATS *)
 
static void qo_node_free (QO_NODE *)
 
static void qo_node_dump (QO_NODE *, FILE *)
 
static void qo_node_add_sarg (QO_NODE *, QO_TERM *)
 
static void qo_seg_free (QO_SEGMENT *)
 
static QO_EQCLASSqo_eqclass_new (QO_ENV *)
 
static void qo_eqclass_free (QO_EQCLASS *)
 
static void qo_eqclass_add (QO_EQCLASS *, QO_SEGMENT *)
 
static void qo_eqclass_dump (QO_EQCLASS *, FILE *)
 
static void qo_term_free (QO_TERM *)
 
static void qo_term_dump (QO_TERM *, FILE *)
 
static void qo_subquery_dump (QO_ENV *, QO_SUBQUERY *, FILE *)
 
static void qo_subquery_free (QO_SUBQUERY *)
 
static void qo_partition_init (QO_ENV *, QO_PARTITION *, int)
 
static void qo_partition_free (QO_PARTITION *)
 
static void qo_partition_dump (QO_PARTITION *, FILE *)
 
static void qo_find_index_terms (QO_ENV *env, BITSET *segsp, QO_INDEX_ENTRY *index_entry)
 
static void qo_find_index_seg_terms (QO_ENV *env, QO_INDEX_ENTRY *index_entry, int idx, BITSET *index_segsp)
 
static bool qo_find_index_segs (QO_ENV *, SM_CLASS_CONSTRAINT *, QO_NODE *, int *, int, int *, BITSET *)
 
static bool qo_is_coverage_index (QO_ENV *env, QO_NODE *nodep, QO_INDEX_ENTRY *index_entry)
 
static void qo_find_node_indexes (QO_ENV *, QO_NODE *)
 
static int is_equivalent_indexes (QO_INDEX_ENTRY *index1, QO_INDEX_ENTRY *index2)
 
static int qo_find_matching_index (QO_INDEX_ENTRY *index_entry, QO_INDEX *class_indexes)
 
static QO_INDEX_ENTRYis_index_compatible (QO_CLASS_INFO *class_info, int n, QO_INDEX_ENTRY *index_entry)
 
static void qo_discover_sort_limit_nodes (QO_ENV *env)
 
static void qo_equivalence (QO_SEGMENT *, QO_SEGMENT *)
 
static void qo_seg_nodes (QO_ENV *, BITSET *, BITSET *)
 
static QO_ENVqo_env_new (PARSER_CONTEXT *, PT_NODE *)
 
static void qo_discover_partitions (QO_ENV *)
 
static void qo_discover_indexes (QO_ENV *)
 
static void qo_assign_eq_classes (QO_ENV *)
 
static void qo_discover_edges (QO_ENV *)
 
static void qo_classify_outerjoin_terms (QO_ENV *)
 
static void qo_term_clear (QO_ENV *, int)
 
static void qo_seg_clear (QO_ENV *, int)
 
static void qo_node_clear (QO_ENV *, int)
 
static void qo_get_index_info (QO_ENV *env, QO_NODE *node)
 
static void qo_free_index (QO_ENV *env, QO_INDEX *)
 
static QO_INDEXqo_alloc_index (QO_ENV *env, int)
 
static void qo_free_node_index_info (QO_ENV *env, QO_NODE_INDEX *node_indexp)
 
static void qo_free_attr_info (QO_ENV *env, QO_ATTR_INFO *info)
 
static QO_ATTR_INFOqo_get_attr_info (QO_ENV *env, QO_SEGMENT *seg)
 
static QO_ATTR_INFOqo_get_attr_info_func_index (QO_ENV *env, QO_SEGMENT *seg, const char *expr_str)
 
static void qo_free_class_info (QO_ENV *env, QO_CLASS_INFO *)
 
static QO_CLASS_INFOqo_get_class_info (QO_ENV *env, QO_NODE *node)
 
static QO_SEGMENTqo_eqclass_wrt (QO_EQCLASS *, BITSET *)
 
static void qo_env_dump (QO_ENV *, FILE *)
 
static int qo_get_ils_prefix_length (QO_ENV *env, QO_NODE *nodep, QO_INDEX_ENTRY *index_entry)
 
static bool qo_is_iss_index (QO_ENV *env, QO_NODE *nodep, QO_INDEX_ENTRY *index_entry)
 
static void qo_discover_sort_limit_join_nodes (QO_ENV *env, QO_NODE *nodep, BITSET *order_nodes, BITSET *dep_nodes)
 
static bool qo_is_pk_fk_full_join (QO_ENV *env, QO_NODE *fk_node, QO_NODE *pk_node)
 
static bool qo_is_non_mvcc_class_with_index (QO_CLASS_INFO_ENTRY *class_entry_p)
 
void qo_get_optimization_param (void *retval, QO_PARAM param,...)
 
bool qo_need_skip_execution (void)
 
void qo_set_optimization_param (void *retval, QO_PARAM param,...)
 
QO_PLANqo_optimize_query (PARSER_CONTEXT *parser, PT_NODE *tree)
 
QO_NODElookup_node (PT_NODE *attr, QO_ENV *env, PT_NODE **entity)
 
QO_SEGMENTlookup_seg (QO_NODE *head, PT_NODE *name, QO_ENV *env)
 
void qo_expr_segs (QO_ENV *env, PT_NODE *pt_expr, BITSET *result)
 
bool pt_is_pseudo_const (PT_NODE *expr)
 
static void add_local_subquery (QO_ENV *env, PT_NODE *node)
 
static PT_NODEget_local_subqueries_pre (PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *continue_walk)
 
static PT_NODEget_local_subqueries_post (PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *continue_walk)
 
static void add_hint_args (QO_ENV *env, PT_NODE *arg_list, PT_HINT_ENUM hint)
 
void qo_abort (QO_ENV *env, const char *file, int line)
 
void qo_env_free (QO_ENV *env)
 
static void qo_exchange (QO_TERM *t0, QO_TERM *t1)
 
static bool qo_is_usable_index (SM_CLASS_CONSTRAINT *constraint, QO_NODE *nodep)
 
void qo_node_fprint (QO_NODE *node, FILE *f)
 
int qo_seg_width (QO_SEGMENT *seg)
 
void qo_seg_fprint (QO_SEGMENT *seg, FILE *f)
 
void qo_eqclass_fprint_wrt (QO_EQCLASS *eqclass, BITSET *nodeset, FILE *f)
 
void qo_term_fprint (QO_TERM *term, FILE *f)
 
void qo_termset_fprint (QO_ENV *env, BITSET *terms, FILE *f)
 
void qo_print_stats (FILE *f)
 
bool qo_is_prefix_index (QO_INDEX_ENTRY *ent)
 
bool qo_is_filter_index (QO_INDEX_ENTRY *ent)
 
void qo_check_coll_optimization (QO_INDEX_ENTRY *ent, COLL_OPT *collation_opt)
 
bool qo_check_type_index_covering (QO_INDEX_ENTRY *ent)
 

Variables

double QO_INFINITY = 0.0
 

Macro Definition Documentation

#define BISET_EXCHANGE (   s0,
  s1 
)
Value:
do { \
BITSET tmp; \
BITSET_MOVE(tmp, s0); \
BITSET_MOVE(s0, s1); \
BITSET_MOVE(s1, tmp); \
} while (0)
unsigned int BITSET
Definition: esql_misc.h:94
#define BITSET_MOVE(dst, src)
Definition: query_bitset.h:80

Definition at line 128 of file query_graph.c.

Referenced by qo_exchange().

#define BOOL_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(bool,e0,e1)

Definition at line 123 of file query_graph.c.

#define DOUBLE_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(double,e0,e1)

Definition at line 117 of file query_graph.c.

Referenced by qo_exchange().

#define EQCLASSPTR_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(QO_EQCLASS *,e0,e1)

Definition at line 122 of file query_graph.c.

Referenced by qo_exchange().

#define EXCHANGE_BUILDER (   type,
  e0,
  e1 
)    do { type _tmp = e0; e0 = e1; e1 = _tmp; } while (0)

Definition at line 113 of file query_graph.c.

#define FLAG_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(int,e0,e1)

Definition at line 125 of file query_graph.c.

Referenced by qo_exchange().

#define INT_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(int,e0,e1)

Definition at line 119 of file query_graph.c.

Referenced by qo_exchange().

#define INT_PTR_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(int *,e0,e1)

Definition at line 126 of file query_graph.c.

Referenced by qo_exchange().

#define JOIN_TYPE_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(JOIN_TYPE,e0,e1)

Definition at line 124 of file query_graph.c.

Referenced by qo_exchange().

#define LOG2_SIZEOF_POINTER   2

Definition at line 85 of file query_graph.c.

Referenced by qo_discover_partitions().

#define NODEPTR_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(QO_NODE *,e0,e1)

Definition at line 121 of file query_graph.c.

Referenced by qo_exchange().

#define NOMINAL_HEAP_SIZE (   class)    200 /* pages */

Definition at line 106 of file query_graph.c.

Referenced by qo_estimate_statistics().

#define NOMINAL_OBJECT_SIZE (   class)    64 /* bytes */

Definition at line 107 of file query_graph.c.

Referenced by qo_estimate_statistics().

#define OPTIMIZATION_LIMIT   64

Referenced by qo_validate().

#define PREDICATE_TERM   -2

Definition at line 68 of file query_graph.c.

Referenced by qo_analyze_term(), and qo_optimize_helper().

#define PT_NODE_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(PT_NODE *,e0,e1)

Definition at line 118 of file query_graph.c.

Referenced by qo_exchange().

#define PUT_FLAG (   cond,
  flag 
)
Value:
do { \
if (cond) { \
if (extra_info++) { \
fputs(flag, f); \
} else { \
fputs(" (", f); \
fputs(flag, f); \
} \
} \
} while (0)
if(extra_options)
Definition: dynamic_load.c:958

Definition at line 136 of file query_graph.c.

Referenced by qo_env_dump().

#define RANK_DEFAULT   0 /* default */

Definition at line 70 of file query_graph.c.

Referenced by get_operand_rank().

#define RANK_EXPR_FUNCTION   4 /* agg function, set */

Definition at line 76 of file query_graph.c.

Referenced by get_expr_fcode_rank(), and get_operand_rank().

#define RANK_EXPR_HEAVY   3 /* Group 3 */

Definition at line 75 of file query_graph.c.

Referenced by get_opcode_rank().

#define RANK_EXPR_LIGHT   1 /* Group 1 */

Definition at line 73 of file query_graph.c.

Referenced by get_expr_fcode_rank(), and get_opcode_rank().

#define RANK_EXPR_MEDIUM   2 /* Group 2 */

Definition at line 74 of file query_graph.c.

Referenced by get_expr_fcode_rank(), get_opcode_rank(), and get_operand_rank().

#define RANK_NAME   RANK_DEFAULT /* name -- use default */

Definition at line 71 of file query_graph.c.

Referenced by get_operand_rank().

#define RANK_QUERY   8 /* subquery */

Definition at line 77 of file query_graph.c.

Referenced by get_term_rank().

#define RANK_VALUE   RANK_DEFAULT /* value -- use default */

Definition at line 72 of file query_graph.c.

Referenced by get_operand_rank().

#define SEGMENTPTR_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(QO_SEGMENT *,e0,e1)

Definition at line 120 of file query_graph.c.

Referenced by qo_exchange().

#define SIZEOF_ATTR_CUM_STATS_PKEYS (   n)    ((n) * sizeof(int))

Definition at line 103 of file query_graph.c.

Referenced by qo_get_attr_info(), qo_get_attr_info_func_index(), and qo_get_index_info().

#define SIZEOF_CLASS_INFO (   n)    (sizeof(QO_CLASS_INFO) + (((n)-1) * sizeof(QO_CLASS_INFO_ENTRY)))

Definition at line 97 of file query_graph.c.

Referenced by qo_get_class_info().

#define SIZEOF_INDEX (   n)    (sizeof(QO_INDEX) + (((n)-1)* sizeof(QO_INDEX_ENTRY)))

Definition at line 91 of file query_graph.c.

Referenced by qo_alloc_index().

#define SIZEOF_NODE_INDEX (   n)    (sizeof(QO_NODE_INDEX) + (((n)-1)* sizeof(QO_NODE_INDEX_ENTRY)))

Definition at line 110 of file query_graph.c.

Referenced by qo_find_node_indexes().

#define SIZEOF_USING_INDEX (   n)    (sizeof(QO_USING_INDEX) + (((n)-1) * sizeof(QO_USING_INDEX_ENTRY)))

Definition at line 64 of file query_graph.c.

Referenced by add_using_index().

#define TERMCLASS_EXCHANGE (   e0,
  e1 
)    EXCHANGE_BUILDER(QO_TERMCLASS,e0,e1)

Definition at line 116 of file query_graph.c.

Referenced by qo_exchange().

Typedef Documentation

typedef struct walk_info WALK_INFO

Definition at line 153 of file query_graph.c.

Enumeration Type Documentation

Enumerator
QO_BUILD_ENTITY 
QO_BUILD_PATH 

Definition at line 147 of file query_graph.c.

Function Documentation

static void add_hint_args ( QO_ENV env,
PT_NODE arg_list,
PT_HINT_ENUM  hint 
)
static
static PT_NODE * build_query_graph ( PARSER_CONTEXT parser,
PT_NODE tree,
void *  arg,
int *  continue_walk 
)
static

Definition at line 938 of file query_graph.c.

References build_graph_for_entity(), walk_info::env, parser_node::node_type, PT_CONTINUE_WALK, PT_LIST_WALK, PT_SELECT, PT_SPEC, qo_env::pt_tree, and QO_BUILD_ENTITY.

Referenced by qo_optimize_helper().

Here is the caller graph for this function:

static PT_NODE * build_query_graph_post ( PARSER_CONTEXT parser,
PT_NODE tree,
void *  arg,
int *  continue_walk 
)
static

Definition at line 978 of file query_graph.c.

References build_graph_for_entity(), walk_info::env, parser_node::node_type, PT_CONTINUE_WALK, PT_SPEC, and QO_BUILD_PATH.

Referenced by qo_optimize_helper().

Here is the caller graph for this function:

static int count_classes ( PT_NODE p)
static

Definition at line 4792 of file query_graph.c.

References parser_node::next, and p.

Referenced by qo_get_class_info().

Here is the caller graph for this function:

static bool expr_is_mergable ( PT_NODE pt_expr)
static

Definition at line 2863 of file query_graph.c.

References pt_expr_info::arg1, pt_expr_info::arg2, pt_statement_info::expr, parser_node::info, NULL, pt_expr_info::op, parser_node::or_next, PT_BETWEEN_EQ_NA, PT_EQ, pt_is_query, and PT_RANGE.

Referenced by qo_analyze_term().

Here is the caller graph for this function:

static PT_NODE* get_local_subqueries_post ( PARSER_CONTEXT parser,
PT_NODE node,
void *  arg,
int *  continue_walk 
)
static
static PT_NODE* get_local_subqueries_pre ( PARSER_CONTEXT parser,
PT_NODE node,
void *  arg,
int *  continue_walk 
)
static
static int get_opcode_rank ( PT_OP_TYPE  opcode)
static

Definition at line 3026 of file query_graph.c.

References assert, PT_ABS, PT_ACOS, PT_ADD_MONTHS, PT_ADDDATE, PT_ADDTIME, PT_AES_DECRYPT, PT_AES_ENCRYPT, PT_AND, PT_ASCII, PT_ASIN, PT_ASSIGN, PT_ATAN, PT_ATAN2, PT_BETWEEN, PT_BETWEEN_AND, PT_BETWEEN_EQ_NA, PT_BETWEEN_GE_INF, PT_BETWEEN_GE_LE, PT_BETWEEN_GE_LT, PT_BETWEEN_GT_INF, PT_BETWEEN_GT_LE, PT_BETWEEN_GT_LT, PT_BETWEEN_INF_LE, PT_BETWEEN_INF_LT, PT_BIN, PT_BIT_AND, PT_BIT_COUNT, PT_BIT_LENGTH, PT_BIT_NOT, PT_BIT_OR, PT_BIT_XOR, PT_BITSHIFT_LEFT, PT_BITSHIFT_RIGHT, PT_CASE, PT_CAST, PT_CEIL, PT_CHAR_LENGTH, PT_CHARSET, PT_CHR, PT_COALESCE, PT_COERCIBILITY, PT_COLLATION, PT_CONCAT, PT_CONCAT_WS, PT_CONNECT_BY_ISCYCLE, PT_CONNECT_BY_ISLEAF, PT_CONV, PT_CONV_TZ, PT_COS, PT_COT, PT_CRC32, PT_CURRENT_DATE, PT_CURRENT_DATETIME, PT_CURRENT_TIME, PT_CURRENT_TIMESTAMP, PT_CURRENT_USER, PT_CURRENT_VALUE, PT_DATABASE, PT_DATE_ADD, PT_DATE_FORMAT, PT_DATE_SUB, PT_DATEDIFF, PT_DATEF, PT_DAYF, PT_DAYOFMONTH, PT_DAYOFWEEK, PT_DAYOFYEAR, PT_DBTIMEZONE, PT_DECODE, PT_DECRYPT, PT_DEFAULTF, PT_DEFINE_VARIABLE, PT_DEGREES, PT_DISK_SIZE, PT_DIV, PT_DIVIDE, PT_DRAND, PT_DRANDOM, PT_ENCRYPT, PT_EQ, PT_EQ_ALL, PT_EQ_SOME, PT_EVALUATE_VARIABLE, PT_EXISTS, PT_EXP, PT_EXTRACT, PT_FIELD, PT_FINDINSET, PT_FLOOR, PT_FORMAT, PT_FROM_BASE64, PT_FROM_TZ, PT_FROM_UNIXTIME, PT_FROMDAYS, PT_FUNCTION_HOLDER, PT_GE, PT_GE_ALL, PT_GE_SOME, PT_GREATEST, PT_GT, PT_GT_ALL, PT_GT_INF, PT_GT_SOME, PT_HEX, PT_HOURF, PT_IF, PT_IFNULL, PT_INDEX_CARDINALITY, PT_INDEX_PREFIX, PT_INET_ATON, PT_INET_NTOA, PT_INST_NUM, PT_INSTR, PT_IS, PT_IS_IN, PT_IS_NOT, PT_IS_NOT_IN, PT_IS_NOT_NULL, PT_IS_NULL, PT_ISNULL, PT_LAST_DAY, PT_LAST_INSERT_ID, PT_LE, PT_LE_ALL, PT_LE_SOME, PT_LEAST, PT_LEFT, PT_LEVEL, PT_LIKE, PT_LIKE_ESCAPE, PT_LIKE_LOWER_BOUND, PT_LIKE_UPPER_BOUND, PT_LIST_DBS, PT_LN, PT_LOCAL_TRANSACTION_ID, PT_LOCATE, PT_LOG, PT_LOG10, PT_LOG2, PT_LOWER, PT_LPAD, PT_LT, PT_LT_ALL, PT_LT_INF, PT_LT_SOME, PT_LTRIM, PT_MAKEDATE, PT_MAKETIME, PT_MD5, PT_MID, PT_MINUS, PT_MINUTEF, PT_MOD, PT_MODULUS, PT_MONTHF, PT_MONTHS_BETWEEN, PT_NE, PT_NE_ALL, PT_NE_SOME, PT_NEW_TIME, PT_NEXT_VALUE, PT_NOT, PT_NOT_BETWEEN, PT_NOT_LIKE, PT_NOT_RLIKE, PT_NOT_RLIKE_BINARY, PT_NULLIF, PT_NULLSAFE_EQ, PT_NVL, PT_NVL2, PT_OCTET_LENGTH, PT_OID_OF_DUPLICATE_KEY, PT_OR, PT_ORDERBY_NUM, PT_PATH_EXPR_SET, PT_PI, PT_PLUS, PT_POSITION, PT_POWER, PT_QUARTERF, PT_RADIANS, PT_RAND, PT_RANDOM, PT_RANGE, PT_REPEAT, PT_REPLACE, PT_REVERSE, PT_RIGHT, PT_RLIKE, PT_RLIKE_BINARY, PT_ROUND, PT_ROW_COUNT, PT_ROWNUM, PT_RPAD, PT_RTRIM, PT_SCHEMA, PT_SCHEMA_DEF, PT_SECONDF, PT_SECTOTIME, PT_SESSIONTIMEZONE, PT_SETEQ, PT_SETNEQ, PT_SHA_ONE, PT_SHA_TWO, PT_SIGN, PT_SIN, PT_SLEEP, PT_SPACE, PT_SQRT, PT_STR_TO_DATE, PT_STRCAT, PT_STRCMP, PT_SUBDATE, PT_SUBSET, PT_SUBSETEQ, PT_SUBSTRING, PT_SUBSTRING_INDEX, PT_SUPERSET, PT_SUPERSETEQ, PT_SYS_DATE, PT_SYS_DATETIME, PT_SYS_GUID, PT_SYS_TIME, PT_SYS_TIMESTAMP, PT_TAN, PT_TIME_FORMAT, PT_TIMEDIFF, PT_TIMEF, PT_TIMES, PT_TIMESTAMP, PT_TIMETOSEC, PT_TO_BASE64, PT_TO_CHAR, PT_TO_DATE, PT_TO_DATETIME, PT_TO_DATETIME_TZ, PT_TO_ENUMERATION_VALUE, PT_TO_NUMBER, PT_TO_TIME, PT_TO_TIMESTAMP, PT_TO_TIMESTAMP_TZ, PT_TODAYS, PT_TRANSLATE, PT_TRIM, PT_TRUNC, PT_TYPEOF, PT_TZ_OFFSET, PT_UNARY_MINUS, PT_UNIX_TIMESTAMP, PT_UPPER, PT_USER, PT_UTC_DATE, PT_UTC_TIME, PT_UTC_TIMESTAMP, PT_VERSION, PT_WEEKDAY, PT_WEEKF, PT_XOR, PT_YEARF, RANK_EXPR_HEAVY, RANK_EXPR_LIGHT, and RANK_EXPR_MEDIUM.

Referenced by get_operand_rank(), and get_term_rank().

Here is the caller graph for this function:

static void get_rank ( QO_ENV env)
static

Definition at line 4191 of file query_graph.c.

References get_term_rank(), i, qo_env::nterms, and QO_ENV_TERM.

Referenced by qo_optimize_helper().

Here is the caller graph for this function:

static PT_NODE * get_referenced_attrs ( PT_NODE entity)
static
static void get_term_subqueries ( QO_ENV env,
QO_TERM term 
)
static
static PT_NODE * graph_size_select ( PARSER_CONTEXT parser,
PT_NODE tree,
void *  arg,
int *  continue_walk 
)
static

Definition at line 815 of file query_graph.c.

References walk_info::env, graph_size_for_entity(), parser_node::node_type, PT_CONTINUE_WALK, PT_LIST_WALK, PT_SELECT, PT_SPEC, and qo_env::pt_tree.

Referenced by qo_validate().

Here is the caller graph for this function:

static int is_equivalent_indexes ( QO_INDEX_ENTRY index1,
QO_INDEX_ENTRY index2 
)
static

Definition at line 6488 of file query_graph.c.

References i, qo_index_entry::nsegs, and qo_index_entry::seg_idxs.

Referenced by qo_find_matching_index().

Here is the caller graph for this function:

static QO_INDEX_ENTRY * is_index_compatible ( QO_CLASS_INFO class_info,
int  n,
QO_INDEX_ENTRY index_entry 
)
static

Definition at line 6581 of file query_graph.c.

References i, qo_class_info_entry::index, qo_class_info::info, qo_class_info::n, qo_index_entry::next, NULL, qo_find_matching_index(), and QO_INDEX_INDEX.

Referenced by qo_find_node_indexes().

Here is the caller graph for this function:

bool pt_is_pseudo_const ( PT_NODE expr)

Definition at line 3655 of file query_graph.c.

References pt_expr_info::arg1, pt_expr_info::arg2, pt_expr_info::arg3, pt_function_info::arg_list, assert, pt_query_info::correlation_level, pt_statement_info::expr, F_MULTISET, F_SEQUENCE, F_SET, pt_statement_info::function, pt_function_info::function_type, parser_node::info, parser_node::next, parser_node::node_type, NULL, pt_expr_info::op, p, PT_ABS, PT_ACOS, PT_ADD_MONTHS, PT_ADDDATE, PT_ADDTIME, PT_AES_DECRYPT, PT_AES_ENCRYPT, PT_ASCII, PT_ASIN, PT_ATAN, PT_ATAN2, PT_BETWEEN_AND, PT_BETWEEN_EQ_NA, PT_BETWEEN_GE_INF, PT_BETWEEN_GE_LE, PT_BETWEEN_GE_LT, PT_BETWEEN_GT_INF, PT_BETWEEN_GT_LE, PT_BETWEEN_GT_LT, PT_BETWEEN_INF_LE, PT_BETWEEN_INF_LT, PT_BIN, PT_BIT_AND, PT_BIT_COUNT, PT_BIT_LENGTH, PT_BIT_NOT, PT_BIT_OR, PT_BIT_XOR, PT_BITSHIFT_LEFT, PT_BITSHIFT_RIGHT, PT_CASE, PT_CAST, PT_CEIL, PT_CHAR_LENGTH, PT_CHARSET, PT_CHR, PT_COALESCE, PT_COERCIBILITY, PT_COLLATION, PT_CONCAT, PT_CONCAT_WS, PT_CONV, PT_CONV_TZ, PT_COS, PT_COT, PT_CRC32, PT_CURRENT_DATE, PT_CURRENT_DATETIME, PT_CURRENT_TIME, PT_CURRENT_TIMESTAMP, PT_CURRENT_USER, PT_CURRENT_VALUE, PT_DATABASE, PT_DATE_ADD, PT_DATE_FORMAT, PT_DATE_SUB, PT_DATEDIFF, PT_DATEF, PT_DAYF, PT_DAYOFMONTH, PT_DAYOFWEEK, PT_DAYOFYEAR, PT_DBTIMEZONE, PT_DECODE, PT_DEFAULTF, PT_DEGREES, PT_DIFFERENCE, PT_DISK_SIZE, PT_DIV, PT_DIVIDE, PT_DOT_, PT_EVALUATE_VARIABLE, PT_EXP, PT_EXPR, PT_EXTRACT, PT_FIELD, PT_FINDINSET, PT_FLOOR, PT_FORMAT, PT_FROM_BASE64, PT_FROM_TZ, PT_FROM_UNIXTIME, PT_FROMDAYS, PT_FUNCTION, PT_FUNCTION_HOLDER, PT_GREATEST, PT_HEX, PT_HOST_VAR, PT_HOURF, PT_IF, PT_IFNULL, PT_INDEX_PREFIX, PT_INET_ATON, PT_INET_NTOA, PT_INSTR, PT_INTERSECTION, pt_is_pseudo_const(), PT_ISNULL, PT_LAST_DAY, PT_LAST_INSERT_ID, PT_LEAST, PT_LEFT, PT_LIKE_LOWER_BOUND, PT_LIKE_UPPER_BOUND, PT_LIST_DBS, PT_LN, PT_LOCAL_TRANSACTION_ID, PT_LOCATE, PT_LOG, PT_LOG10, PT_LOG2, PT_LOWER, PT_LPAD, PT_LTRIM, PT_MAKEDATE, PT_MAKETIME, PT_MD5, PT_MID, PT_MINUS, PT_MINUTEF, PT_MOD, PT_MODULUS, PT_MONTHF, PT_MONTHS_BETWEEN, PT_NAME, PT_NEW_TIME, PT_NEXT_VALUE, PT_NULLIF, PT_NVL, PT_NVL2, PT_OCTET_LENGTH, PT_OID_OF_DUPLICATE_KEY, PT_PI, PT_PLUS, PT_POSITION, PT_POWER, PT_PRIOR, PT_QPRIOR, PT_QUARTERF, PT_RADIANS, PT_REPEAT, PT_REPLACE, PT_REVERSE, PT_RIGHT, PT_ROUND, PT_ROW_COUNT, PT_RPAD, PT_RTRIM, PT_SCHEMA, PT_SCHEMA_DEF, PT_SECONDF, PT_SECTOTIME, PT_SELECT, PT_SHA_ONE, PT_SHA_TWO, PT_SIGN, PT_SIN, PT_SPACE, PT_SQRT, PT_STR_TO_DATE, PT_STRCAT, PT_STRCMP, PT_SUBDATE, PT_SUBSTRING, PT_SUBSTRING_INDEX, PT_SYS_DATE, PT_SYS_DATETIME, PT_SYS_TIME, PT_SYS_TIMESTAMP, PT_TAN, PT_TIME_FORMAT, PT_TIMEDIFF, PT_TIMEF, PT_TIMES, PT_TIMESTAMP, PT_TIMETOSEC, PT_TO_BASE64, PT_TO_CHAR, PT_TO_DATE, PT_TO_DATETIME, PT_TO_DATETIME_TZ, PT_TO_ENUMERATION_VALUE, PT_TO_NUMBER, PT_TO_TIME, PT_TO_TIMESTAMP, PT_TO_TIMESTAMP_TZ, PT_TODAYS, PT_TRANSLATE, PT_TRIM, PT_TRUNC, PT_TZ_OFFSET, PT_UNARY_MINUS, PT_UNION, PT_UNIX_TIMESTAMP, PT_UPPER, PT_USER, PT_UTC_DATE, PT_UTC_TIME, PT_UTC_TIMESTAMP, PT_VALUE, PT_VERSION, PT_WEEKDAY, PT_WEEKF, PT_YEARF, and pt_statement_info::query.

Referenced by pt_is_pseudo_const(), qo_analyze_term(), and qo_rewrite_like_terms().

Here is the caller graph for this function:

void qo_abort ( QO_ENV env,
const char *  file,
int  line 
)

Definition at line 5796 of file query_graph.c.

References qo_env::catch_, ER_FAILED_ASSERTION, er_set(), and ER_WARNING_SEVERITY.

static PT_NODE * qo_add_final_segment ( PARSER_CONTEXT parser,
PT_NODE tree,
void *  arg,
int *  continue_walk 
)
static
static void qo_analyze_term ( QO_TERM term,
int  term_type 
)
static

Definition at line 1915 of file query_graph.c.

References pt_expr_info::arg1, pt_expr_info::arg2, assert, bitset_add(), bitset_assign(), bitset_cardinality(), bitset_delset(), bitset_first_member(), bitset_init(), bitset_intersects(), bitset_is_empty(), bitset_iterate(), BITSET_MEMBER, bitset_next_member(), bitset_union(), db_col_size(), db_get_collection, db_value_type_is_collection(), walk_info::env, qo_term::env, pt_statement_info::expr, expr_is_mergable(), i, qo_term::index_seg, parser_node::info, is_local_name(), JOIN_INNER, JOIN_LEFT, JOIN_OUTER, JOIN_RIGHT, qo_term::multi_col_segs, parser_node::next, NO_JOIN, parser_node::node_type, qo_env::nterms, NULL, pt_expr_info::op, parser_node::or_next, parser, qo_env::parser, parser_walk_tree(), PREDICATE_TERM, PT_AND, PT_BETWEEN, PT_BETWEEN_EQ_NA, pt_check_instnum_post(), pt_check_instnum_pre(), pt_converse_op(), PT_DIFFERENCE, PT_DOT_, PT_EQ, PT_EQ_ALL, PT_EQ_SOME, PT_EXISTS, PT_EXPR, PT_EXPR_INFO_IS_FLAGED, PT_EXPR_INFO_TRANSITIVE, PT_GE, PT_GE_ALL, PT_GE_SOME, PT_GT, PT_GT_ALL, PT_GT_SOME, pt_has_non_idx_sarg_coll_pre(), PT_INTERSECTION, PT_IS, pt_is_const, PT_IS_CONST, pt_is_function_index_expr(), pt_is_function_index_expression(), PT_IS_IN, pt_is_multi_col_term, PT_IS_NOT, PT_IS_NOT_IN, PT_IS_NOT_NULL, PT_IS_NULL, pt_is_pseudo_const(), pt_is_set_type, PT_JOIN_FULL_OUTER, PT_JOIN_INNER, PT_JOIN_LEFT_OUTER, PT_JOIN_RIGHT_OUTER, PT_LE, PT_LE_ALL, PT_LE_SOME, PT_LIKE, PT_LT, PT_LT_ALL, PT_LT_SOME, PT_NAME, PT_NE, PT_NE_ALL, PT_NE_SOME, PT_NOT, PT_NOT_BETWEEN, PT_NOT_LIKE, PT_NOT_RLIKE, PT_NOT_RLIKE_BINARY, PT_NULLSAFE_EQ, PT_OR, PT_PARAMETER, PT_PATH_INNER, PT_PATH_OUTER, PT_PATH_OUTER_WEASEL, PT_PRIOR, PT_RANGE, PT_RLIKE, PT_RLIKE_BINARY, PT_SELECT, PT_SETEQ, PT_SETNEQ, PT_SUBSET, PT_SUBSETEQ, PT_SUPERSET, PT_SUPERSETEQ, PT_TYPE_ENUMERATION, PT_UNION, PT_VALUE, PT_XOR, QO_ABORT, QO_ADD_OUTER_DEP_SET, QO_ADD_RIGHT_DEP_SET, QO_ADD_RIGHT_TO_OUTER, QO_ASSERT, QO_ENV_NODE, QO_ENV_PARSER, QO_ENV_SEG, QO_ENV_TERM, qo_equivalence(), qo_expr_segs(), qo_expr_selectivity(), qo_is_equi_join_term(), QO_NODE_DEP_SET, QO_NODE_IDX, QO_NODE_LOCATION, QO_NODE_NCARD, QO_NODE_OUTER_DEP_SET, QO_NODE_PT_JOIN_TYPE, QO_ON_COND_TERM, QO_SEG_FUNC_INDEX, QO_SEG_HEAD, qo_seg_nodes(), QO_TC_JOIN, QO_TC_OTHER, QO_TC_PATH, QO_TC_SARG, QO_TC_TOTALLY_AFTER_JOIN, QO_TERM_CAN_USE_INDEX, QO_TERM_CLASS, QO_TERM_CLEAR_FLAG, QO_TERM_ENV, QO_TERM_EQUAL_OP, QO_TERM_HEAD, QO_TERM_IS_FLAGED, QO_TERM_JOIN_TYPE, QO_TERM_LOCATION, QO_TERM_MERGEABLE_EDGE, QO_TERM_MULTI_COL_CNT, QO_TERM_MULTI_COL_SEGS, QO_TERM_MULTI_COLL_CONST, QO_TERM_MULTI_COLL_PRED, QO_TERM_NODES, QO_TERM_NOMINAL_SEG, QO_TERM_NON_IDX_SARG_COLL, QO_TERM_OID_SEG, QO_TERM_OR_PRED, QO_TERM_PT_EXPR, QO_TERM_RANGELIST, QO_TERM_SEG, QO_TERM_SEGS, QO_TERM_SELECTIVITY, QO_TERM_SET_FLAG, QO_TERM_SINGLE_PRED, QO_TERM_TAIL, and swap_node().

Referenced by qo_add_term().

Here is the caller graph for this function:

static void qo_discover_sort_limit_join_nodes ( QO_ENV env,
QO_NODE nodep,
BITSET order_nodes,
BITSET dep_nodes 
)
static
static void qo_eqclass_add ( QO_EQCLASS eqclass,
QO_SEGMENT seg 
)
static

Definition at line 8408 of file query_graph.c.

References bitset_add(), QO_EQCLASS_IDX, QO_EQCLASS_SEGS, QO_NODE_EQCLASSES, QO_SEG_EQCLASS, QO_SEG_HEAD, and QO_SEG_IDX.

Referenced by qo_assign_eq_classes().

Here is the caller graph for this function:

static void qo_eqclass_dump ( QO_EQCLASS eqclass,
FILE *  f 
)
static

Definition at line 8422 of file query_graph.c.

References bitset_iterate(), bitset_next_member(), QO_ENV_SEG, QO_EQCLASS_ENV, QO_EQCLASS_SEGS, QO_EQCLASS_TERM, qo_seg_fprint(), and qo_term_fprint().

Referenced by qo_env_dump().

Here is the caller graph for this function:

void qo_eqclass_fprint_wrt ( QO_EQCLASS eqclass,
BITSET nodeset,
FILE *  f 
)

Definition at line 8740 of file query_graph.c.

References bitset_is_empty(), QO_EQCLASS_SEGS, QO_EQCLASS_TERM, qo_eqclass_wrt(), qo_seg_fprint(), QO_TERM_IDX, and QO_UNORDERED.

Referenced by qo_sort_fprint(), and qo_sort_info().

Here is the caller graph for this function:

static void qo_eqclass_free ( QO_EQCLASS eqclass)
static

Definition at line 8396 of file query_graph.c.

References bitset_delset(), and QO_EQCLASS_SEGS.

Referenced by qo_env_free().

Here is the caller graph for this function:

static QO_EQCLASS * qo_eqclass_new ( QO_ENV env)
static

Definition at line 8372 of file query_graph.c.

References bitset_init(), walk_info::env, qo_env::neqclasses, qo_env::Neqclasses, NULL, QO_ASSERT, QO_ENV_EQCLASS, QO_EQCLASS_ENV, QO_EQCLASS_IDX, QO_EQCLASS_SEGS, and QO_EQCLASS_TERM.

Referenced by qo_assign_eq_classes().

Here is the caller graph for this function:

static QO_SEGMENT * qo_eqclass_wrt ( QO_EQCLASS eqclass,
BITSET nodeset 
)
static

Definition at line 8712 of file query_graph.c.

References bitset_iterate(), BITSET_MEMBER, bitset_next_member(), qo_eqclass::env, NULL, QO_ASSERT, QO_ENV_SEG, QO_EQCLASS_ENV, QO_EQCLASS_SEGS, QO_NODE_IDX, and QO_SEG_HEAD.

Referenced by qo_eqclass_fprint_wrt().

Here is the caller graph for this function:

static void qo_equivalence ( QO_SEGMENT sega,
QO_SEGMENT segb 
)
static

Definition at line 8687 of file query_graph.c.

References QO_SEG_EQ_ROOT.

Referenced by qo_analyze_term().

Here is the caller graph for this function:

static void qo_estimate_statistics ( MOP  class_mop,
CLASS_STATS statblock 
)
static

Definition at line 5687 of file query_graph.c.

References DB_PAGESIZE, class_stats::heap_num_objects, class_stats::heap_num_pages, NOMINAL_HEAP_SIZE, and NOMINAL_OBJECT_SIZE.

Referenced by grok_classes().

Here is the caller graph for this function:

static bool qo_find_index_segs ( QO_ENV env,
SM_CLASS_CONSTRAINT consp,
QO_NODE nodep,
int *  seg_idx,
int  seg_idx_num,
int *  nseg_idxp,
BITSET segs 
)
static
static void qo_find_index_terms ( QO_ENV env,
BITSET segsp,
QO_INDEX_ENTRY index_entry 
)
static
static int qo_find_matching_index ( QO_INDEX_ENTRY index_entry,
QO_INDEX class_indexes 
)
static

Definition at line 6533 of file query_graph.c.

References i, is_equivalent_indexes(), qo_index::n, NULL, and QO_INDEX_INDEX.

Referenced by is_index_compatible().

Here is the caller graph for this function:

static void qo_find_node_indexes ( QO_ENV env,
QO_NODE nodep 
)
static

Definition at line 7125 of file query_graph.c.

References ARG_FILE_LINE, assert, sm_function_info::attr_index_start, sm_class_constraint::attributes, bitset_delset(), bitset_init(), qo_index_entry::class_, sm_function_info::col_id, qo_index_entry::col_num, qo_index_entry::constraints, qo_index_entry::cover_segments, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), sm_class_constraint::filter_predicate, qo_index_entry::force, free_and_init, sm_class_constraint::func_index_info, sm_attribute::header, i, qo_index_entry::ils_prefix_len, qo_class_info_entry::index, qo_class_info::info, intl_identifier_casecmp(), qo_index_entry::is_func_index, is_index_compatible(), qo_index_entry::is_iss_candidate, qo_index_entry::key_limit, qo_index_entry::key_type, qo_class_info_entry::mop, qo_class_info::n, qo_index::n, sm_component::name, sm_class_constraint::name, NELEMENTS, qo_index_entry::next, sm_class_constraint::next, qo_index_entry::nsegs, NULL, PT_IDX_HINT_ALL_EXCEPT, PT_IDX_HINT_FORCE, PT_IDX_HINT_IGNORE, PT_IDX_HINT_USE, PT_SPEC_SPECIAL_INDEX_SCAN, qo_alloc_index(), qo_find_index_seg_terms(), qo_find_index_segs(), qo_find_index_terms(), qo_get_ils_prefix_length(), QO_INDEX_INDEX, qo_is_coverage_index(), qo_is_iss_index(), qo_is_non_mvcc_class_with_index(), qo_is_usable_index(), QO_NI_ENTRY, QO_NI_N, QO_NODE_ENTITY_SPEC, QO_NODE_INDEXES, QO_NODE_INFO, QO_NODE_USING_INDEX, QO_UI_FORCE, QO_UI_INDEX, QO_UI_KEYLIMIT, QO_UI_N, qo_index_entry::rangelist_seg_idx, qo_index_entry::seg_equal_terms, qo_index_entry::seg_idxs, qo_index_entry::seg_other_terms, SIZEOF_NODE_INDEX, sm_class_constraints(), qo_index_entry::statistics_attribute_name, and strlen.

Referenced by qo_discover_indexes().

Here is the caller graph for this function:

static void qo_free_attr_info ( QO_ENV env,
QO_ATTR_INFO info 
)
static

Definition at line 5308 of file query_graph.c.

References qo_attr_info::cum_stats, free_and_init, and QO_ATTR_CUM_STATS::pkeys.

Referenced by qo_get_attr_info(), qo_get_attr_info_func_index(), and qo_seg_free().

Here is the caller graph for this function:

static void qo_free_class_info ( QO_ENV env,
QO_CLASS_INFO info 
)
static
static void qo_free_node_index_info ( QO_ENV env,
QO_NODE_INDEX node_indexp 
)
static

Definition at line 5548 of file query_graph.c.

References free_and_init, i, QO_ATTR_CUM_STATS::pkeys, QO_NI_ENTRY, and QO_NI_N.

Referenced by qo_node_free().

Here is the caller graph for this function:

static QO_ATTR_INFO * qo_get_attr_info ( QO_ENV env,
QO_SEGMENT seg 
)
static
static QO_ATTR_INFO * qo_get_attr_info_func_index ( QO_ENV env,
QO_SEGMENT seg,
const char *  expr_str 
)
static
static bool qo_is_non_mvcc_class_with_index ( QO_CLASS_INFO_ENTRY class_entry_p)
static

Definition at line 9598 of file query_graph.c.

References qo_class_info_entry::oid, OID_CACHE_HA_APPLY_INFO_CLASS_ID, OID_CACHE_SERIAL_CLASS_ID, and oid_check_cached_class_oid().

Referenced by qo_find_node_indexes().

Here is the caller graph for this function:

static bool qo_is_usable_index ( SM_CLASS_CONSTRAINT constraint,
QO_NODE nodep 
)
static
static QO_SEGMENT * qo_join_segment ( QO_NODE head,
QO_NODE tail,
PT_NODE name,
QO_ENV env 
)
static

Definition at line 1537 of file query_graph.c.

References lookup_seg(), NULL, QO_ASSERT, and QO_SEG_TAIL.

Referenced by build_graph_for_entity().

Here is the caller graph for this function:

bool qo_need_skip_execution ( void  )
static void qo_node_add_sarg ( QO_NODE node,
QO_TERM sarg 
)
static

Definition at line 8142 of file query_graph.c.

References bitset_add(), QO_NODE_NCARD, QO_NODE_SARGS, QO_NODE_SELECTIVITY, QO_TERM_IDX, and QO_TERM_SELECTIVITY.

Referenced by qo_discover_edges().

Here is the caller graph for this function:

void qo_node_fprint ( QO_NODE node,
FILE *  f 
)

Definition at line 8162 of file query_graph.c.

References QO_NODE_IDX, and QO_NODE_NAME.

Referenced by qo_scan_fprint(), qo_term_dump(), and qo_term_fprint().

Here is the caller graph for this function:

static QO_PLAN * qo_optimize_helper ( QO_ENV env)
static

Definition at line 429 of file query_graph.c.

References add_hint(), add_using_index(), pt_select_info::after_cb_filter, bitset_add(), BITSET_CLEAR, bitset_delset(), bitset_init(), bitset_is_empty(), BITSET_MEMBER, build_query_graph(), build_query_graph_function_index(), build_query_graph_post(), pt_select_info::connect_by, pt_spec_info::derived_table, DETAILED_DUMP, walk_info::env, pt_select_info::from, get_local_subqueries(), get_rank(), pt_select_info::group_by, pt_select_info::having, parser_node::info, is_dependent_table(), pt_select_info::list, parser_node::next, qo_env::nnodes, parser_node::node_type, NULL, pt_spec_info::on_cond, parser, parser_walk_tree(), PLAN_DUMP_ENABLED, qo_env::plan_dump_enabled, PREDICATE_TERM, pt_continue_walk(), PT_JOIN_CROSS, PT_JOIN_NONE, PT_SPEC, pt_query_info::q, qo_add_dep_term(), qo_add_dummy_join_term(), qo_add_final_segment(), qo_add_term(), QO_ASSERT, qo_assign_eq_classes(), qo_classify_outerjoin_terms(), qo_discover_edges(), qo_discover_indexes(), qo_discover_partitions(), qo_discover_sort_limit_nodes(), qo_env_dump(), qo_env_free(), QO_ENV_NODE, QO_ENV_PARSER, QO_ENV_PT_TREE, qo_expr_segs(), qo_get_optimization_param(), QO_NODE_ENTITY_SPEC, QO_NODE_IDX, QO_NODE_LOCATION, QO_NODE_PT_JOIN_TYPE, QO_ON_COND_TERM, QO_PARAM_LEVEL, qo_planner_search(), qo_seg_nodes(), QO_TC_JOIN, QO_TERM_CLASS, QO_TERM_HEAD, QO_TERM_LOCATION, QO_TERM_TAIL, pt_statement_info::query, query_Plan_dump_fp, pt_query_info::select, pt_select_info::single_table_opt, pt_statement_info::spec, pt_select_info::start_with, walk_info::term, pt_select_info::using_index, and pt_select_info::where.

Referenced by qo_optimize_query().

Here is the caller graph for this function:

static void qo_partition_dump ( QO_PARTITION part,
FILE *  f 
)
static

Definition at line 9149 of file query_graph.c.

References bitset_print(), QO_PARTITION_DEPENDENCIES, QO_PARTITION_EDGES, and QO_PARTITION_NODES.

Referenced by qo_env_dump().

Here is the caller graph for this function:

static void qo_partition_free ( QO_PARTITION part)
static

Definition at line 9122 of file query_graph.c.

References bitset_delset(), NULL, QO_PARTITION_DEPENDENCIES, QO_PARTITION_EDGES, QO_PARTITION_NODES, QO_PARTITION_PLAN, and qo_plan_del_ref.

Referenced by qo_env_free().

Here is the caller graph for this function:

static void qo_partition_init ( QO_ENV env,
QO_PARTITION part,
int  n 
)
static

Definition at line 9106 of file query_graph.c.

References bitset_init(), NULL, QO_PARTITION_DEPENDENCIES, QO_PARTITION_EDGES, QO_PARTITION_IDX, QO_PARTITION_M_OFFSET, QO_PARTITION_NODES, and QO_PARTITION_PLAN.

Referenced by qo_discover_partitions().

Here is the caller graph for this function:

void qo_print_stats ( FILE *  f)

Definition at line 9166 of file query_graph.c.

References qo_info_stats(), and qo_plans_stats().

Referenced by qo_plan_discard().

Here is the caller graph for this function:

static void qo_seg_clear ( QO_ENV env,
int  idx 
)
static
void qo_seg_fprint ( QO_SEGMENT seg,
FILE *  f 
)

Definition at line 8361 of file query_graph.c.

References QO_NODE_IDX, QO_SEG_HEAD, and QO_SEG_NAME.

Referenced by qo_env_dump(), qo_eqclass_dump(), qo_eqclass_fprint_wrt(), qo_plan_print_projected_segs(), qo_subquery_dump(), and qo_term_dump().

Here is the caller graph for this function:

static void qo_seg_free ( QO_SEGMENT seg)
static

Definition at line 8286 of file query_graph.c.

References bitset_delset(), free_and_init, NULL, qo_free_attr_info(), QO_SEG_ENV, QO_SEG_FUNC_INDEX, QO_SEG_INDEX_TERMS, QO_SEG_INFO, and QO_SEG_NAME.

Referenced by qo_env_free().

Here is the caller graph for this function:

static void qo_seg_nodes ( QO_ENV env,
BITSET segset,
BITSET result 
)
static

Definition at line 9185 of file query_graph.c.

References bitset_add(), BITSET_CLEAR, bitset_iterate(), bitset_next_member(), i, QO_ENV_SEG, QO_NODE_IDX, and QO_SEG_HEAD.

Referenced by add_local_subquery(), qo_analyze_term(), qo_discover_sort_limit_nodes(), and qo_optimize_helper().

Here is the caller graph for this function:

int qo_seg_width ( QO_SEGMENT seg)
void qo_set_optimization_param ( void *  retval,
QO_PARAM  param,
  ... 
)
static void qo_subquery_dump ( QO_ENV env,
QO_SUBQUERY subq,
FILE *  f 
)
static

Definition at line 9047 of file query_graph.c.

References bitset_iterate(), bitset_next_member(), i, qo_subquery::node, qo_subquery::nodes, NULL, QO_ENV_SEG, qo_seg_fprint(), qo_subquery::segs, and qo_subquery::terms.

Referenced by qo_env_dump().

Here is the caller graph for this function:

static void qo_subquery_free ( QO_SUBQUERY subq)
static

Definition at line 9091 of file query_graph.c.

References bitset_delset(), qo_subquery::nodes, qo_subquery::segs, and qo_subquery::terms.

Referenced by qo_env_free().

Here is the caller graph for this function:

void qo_term_fprint ( QO_TERM term,
FILE *  f 
)
static void qo_term_free ( QO_TERM term)
static
void qo_termset_fprint ( QO_ENV env,
BITSET terms,
FILE *  f 
)

Definition at line 8845 of file query_graph.c.

References bitset_iterate(), bitset_next_member(), QO_ENV_TERM, and qo_term_fprint().

Referenced by qo_join_fprint(), qo_plan_print_outer_join_terms(), qo_plan_print_sarged_terms(), and qo_scan_fprint().

Here is the caller graph for this function:

static void set_seg_node ( PT_NODE attr,
QO_ENV env,
BITSET bitset 
)
static

Definition at line 2836 of file query_graph.c.

References bitset_add(), lookup_node(), lookup_seg(), NULL, and QO_SEG_IDX.

Referenced by qo_add_final_segment(), and set_seg_expr().

Here is the caller graph for this function:

Variable Documentation

double QO_INFINITY = 0.0