@@ -43,17 +43,19 @@ typedef struct query_specification {
43
43
{}
44
44
} query_specification_t ;
45
45
46
- typedef enum query_expression_type_t {
47
- QUERY_EXPRESSION_TYPE_NON_JOIN_QUERY_EXPRESSION,
48
- QUERY_EXPRESSION_TYPE_JOINED_TABLE
49
- } query_expression_type_t ;
46
+ // Query components are expressions, terms and primaries. Each of those
47
+ // components contains either a non-join query component or a joined table
48
+ typedef enum query_component_type_t {
49
+ QUERY_COMPONENT_TYPE_NON_JOIN,
50
+ QUERY_COMPONENT_TYPE_JOINED_TABLE
51
+ } query_component_type_t ;
50
52
51
53
// A query expression produces a table-like selection of rows.
52
54
53
55
typedef struct query_expression {
54
- query_expression_type_t query_expression_type ;
55
- query_expression (query_expression_type_t qe_type) :
56
- query_expression_type (qe_type)
56
+ query_component_type_t query_component_type ;
57
+ query_expression (query_component_type_t qe_type) :
58
+ query_component_type (qe_type)
57
59
{}
58
60
} query_expression_t ;
59
61
@@ -81,10 +83,18 @@ typedef struct query_specification_non_join_query_primary : non_join_query_prima
81
83
{}
82
84
} query_specification_non_join_query_primary_t ;
83
85
84
- typedef struct non_join_query_term {
86
+ typedef struct query_term {
87
+ query_component_type_t query_component_type;
88
+ query_term (query_component_type_t component_type) :
89
+ query_component_type (component_type)
90
+ {}
91
+ } query_term_t ;
92
+
93
+ typedef struct non_join_query_term : query_term_t {
85
94
std::unique_ptr<non_join_query_primary_t > primary;
86
95
non_join_query_term (
87
96
std::unique_ptr<non_join_query_primary_t >& primary) :
97
+ query_term_t (QUERY_COMPONENT_TYPE_NON_JOIN),
88
98
primary (std::move(primary))
89
99
{}
90
100
} non_join_query_term_t ;
@@ -93,17 +103,16 @@ typedef struct non_join_query_expression : query_expression_t {
93
103
std::unique_ptr<non_join_query_term_t > term;
94
104
non_join_query_expression (
95
105
std::unique_ptr<non_join_query_term_t >& term) :
96
- query_expression_t (QUERY_EXPRESSION_TYPE_NON_JOIN_QUERY_EXPRESSION ),
106
+ query_expression_t (QUERY_COMPONENT_TYPE_NON_JOIN ),
97
107
term (std::move(term))
98
108
{}
99
109
} non_join_query_expression_t ;
100
110
101
111
typedef struct joined_table_query_expression : query_expression_t {
102
- // Guaranteed to be static_castable to joined_table_t
103
112
std::unique_ptr<joined_table_t > joined_table;
104
113
joined_table_query_expression (
105
114
std::unique_ptr<joined_table_t >& joined_table) :
106
- query_expression_t (QUERY_EXPRESSION_TYPE_JOINED_TABLE ),
115
+ query_expression_t (QUERY_COMPONENT_TYPE_JOINED_TABLE ),
107
116
joined_table (std::move(joined_table))
108
117
{}
109
118
} joined_table_query_expression_t ;
0 commit comments