CUBRID Engine  latest
access_spec.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 //
20 // access_spec - defines access on tables, lists, indexes
21 //
22 
23 #ifndef _ACCESS_SPEC_HPP_
24 #define _ACCESS_SPEC_HPP_
25 
26 #include "dbtype_def.h"
27 #include "storage_common.h"
28 
29 // forward definitions
30 class regu_variable_node;
31 
32 typedef enum /* range search option */
33 {
34  NA_NA, /* v1 and v2 are N/A, so that no range is defined */
35  GE_LE, /* v1 <= key <= v2 */
36  GE_LT, /* v1 <= key < v2 */
37  GT_LE, /* v1 < key <= v2 */
38  GT_LT, /* v1 < key < v2 */
39  GE_INF, /* v1 <= key (<= the end) */
40  GT_INF, /* v1 < key (<= the end) */
41  INF_LE, /* (the beginning <=) key <= v2 */
42  INF_LT, /* (the beginning <=) key < v2 */
43  INF_INF, /* the beginning <= key <= the end */
44  EQ_NA, /* key = v1, v2 is N/A */
45 
46  /* following options are reserved for the future use */
47  LE_GE, /* key <= v1 || key >= v2 or NOT (v1 < key < v2) */
48  LE_GT, /* key <= v1 || key > v2 or NOT (v1 < key <= v2) */
49  LT_GE, /* key < v1 || key >= v2 or NOT (v1 <= key < v2) */
50  LT_GT, /* key < v1 || key > v2 or NOT (v1 <= key <= v2) */
51  NEQ_NA /* key != v1 */
52 } RANGE;
53 
56 {
61  int num_index_term; /* #terms associated with index key range */
62 };
63 
64 typedef struct key_range KEY_RANGE;
65 struct key_range
66 {
67  regu_variable_node *key1; /* pointer to first key value */
68  regu_variable_node *key2; /* pointer to second key value */
69  RANGE range; /* range spec; GE_LE, GT_LE, GE_LT, GT_LT, GE_INF, GT_INF, INF_LT, INF_LE, INF_INF */
70 }; /* key range structure */
71 
72 typedef struct key_info KEY_INFO;
73 struct key_info
74 {
75  key_range *key_ranges; /* a list of key ranges */
76  int key_cnt; /* key count */
77  bool is_constant; /* every key value is a constant */
78  bool key_limit_reset; /* should key limit reset at each range */
79  bool is_user_given_keylimit; /* true if user specifies key limit */
80  regu_variable_node *key_limit_l; /* lower key limit */
81  regu_variable_node *key_limit_u; /* upper key limit */
82 }; /* key information structure */
83 
84 typedef struct indx_info INDX_INFO;
85 struct indx_info
86 {
87  BTID btid; /* index identifier */
88  int coverage; /* index coverage state */
90  RANGE_TYPE range_type; /* range type */
91  KEY_INFO key_info; /* key information */
92  int orderby_desc; /* first column of the order by is desc */
93  int groupby_desc; /* first column of the group by is desc */
94  int use_desc_index; /* using descending index */
95  int orderby_skip; /* order by skip information */
96  int groupby_skip; /* group by skip information */
97  int use_iss; /* flag set if using index skip scan */
98  int func_idx_col_id; /* function expression column position, if the index is a function index */
99  KEY_RANGE iss_range; /* placeholder range used for ISS; must be created on the broker */
100  int ils_prefix_len; /* index loose scan prefix length */
101 }; /* index information structure */
102 
103 // TODO - move access specification code here; note - this is supposed to be common to both client and server.
104 // access spec structures are now partly common and partly server/SA only. this requires some redesign &
105 // refactoring
106 
108 // inline/template implementation
110 
111 inline void
113 {
114  switch (range)
115  {
116  case GT_LE:
117  range = GE_LT;
118  break;
119  case GE_LT:
120  range = GT_LE;
121  break;
122  case GE_INF:
123  range = INF_LE;
124  break;
125  case GT_INF:
126  range = INF_LT;
127  break;
128  case INF_LE:
129  range = GE_INF;
130  break;
131  case INF_LT:
132  range = GT_INF;
133  break;
134  case NA_NA:
135  case GE_LE:
136  case GT_LT:
137  case INF_INF:
138  case EQ_NA:
139  default:
140  /* No change. */
141  break;
142  }
143 }
144 #endif // _ACCESS_SPEC_HPP_
regu_variable_node * key1
Definition: access_spec.hpp:67
key_range * key_ranges
Definition: access_spec.hpp:75
regu_variable_node * key_limit_u
Definition: access_spec.hpp:81
RANGE_TYPE
int ils_prefix_len
int orderby_desc
Definition: access_spec.hpp:92
int groupby_desc
Definition: access_spec.hpp:93
RANGE range
Definition: access_spec.hpp:69
KEY_INFO key_info
Definition: access_spec.hpp:91
KEY_RANGE iss_range
Definition: access_spec.hpp:99
int use_desc_index
Definition: access_spec.hpp:94
int orderby_skip
Definition: access_spec.hpp:95
int groupby_skip
Definition: access_spec.hpp:96
int func_idx_col_id
Definition: access_spec.hpp:98
void range_reverse(RANGE &range)
regu_variable_node * key2
Definition: access_spec.hpp:68
bool key_limit_reset
Definition: access_spec.hpp:78
RANGE_TYPE range_type
Definition: access_spec.hpp:90
bool is_user_given_keylimit
Definition: access_spec.hpp:79
DB_VALUE key1
Definition: access_spec.hpp:58
RANGE
Definition: access_spec.hpp:32
DB_VALUE key2
Definition: access_spec.hpp:59
bool is_constant
Definition: access_spec.hpp:77
regu_variable_node * key_limit_l
Definition: access_spec.hpp:80