MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / SQE_select

Function SQE_select

src/gpre/sqe.cpp:1089–1166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087//
1088
1089gpre_rse* SQE_select(gpre_req* request, bool view_flag)
1090{
1091 gpre_lls* context_stack = NULL;
1092 gpre_ctx* context = 0;
1093 bool have_union = false;
1094
1095 assert_IS_REQ(request);
1096
1097 map* const old_map = request->req_map;
1098
1099 // Get components of union. Most likely there isn't one, so this is
1100 // probably wasted work.
1101
1102 gpre_rse* select = NULL;
1103 gpre_rse* rse1 = NULL;
1104 select = rse1 = par_select(request, NULL);
1105
1106 // "Look for ... the UNION label ... "
1107 while (MSC_match(KW_UNION))
1108 {
1109 have_union = true;
1110 const bool union_all = MSC_match(KW_ALL);
1111 if (!MSC_match(KW_SELECT))
1112 CPR_s_error("SELECT");
1113
1114 MSC_push((gpre_nod*) request->req_contexts, &context_stack);
1115 request->req_contexts = NULL;
1116 request->req_map = NULL;
1117 gpre_rse* rse2 = par_select(request, rse1);
1118
1119 // We've got a bona fide union. Make a union node to hold sub-rse
1120 // and then a new rse to point to it.
1121
1122 select = (gpre_rse*) MSC_alloc(RSE_LEN(1));
1123 select->rse_context[0] = context = MSC_context(request);
1124 gpre_nod* node = MSC_node(nod_union, 2);
1125 select->rse_union = node;
1126 node->nod_arg[0] = (gpre_nod*) rse1;
1127 node->nod_arg[1] = (gpre_nod*) rse2;
1128
1129 map* new_map = (map*) MSC_alloc(sizeof(map));
1130 rse1->rse_map = new_map;
1131 new_map->map_context = context;
1132 select->rse_fields = post_select_list(rse1->rse_fields, new_map);
1133
1134 rse2->rse_map = new_map = (map*) MSC_alloc(sizeof(map));
1135 new_map->map_context = context;
1136 post_select_list(rse2->rse_fields, new_map);
1137
1138 select->rse_into = rse1->rse_into;
1139 if (!union_all)
1140 select->rse_reduced = select->rse_fields;
1141
1142 // Result of this UNION might be the left side of the NEXT UNION
1143 rse1 = select;
1144 }
1145
1146 // Restore the context lists that were forgotten

Callers 4

act_create_viewFunction · 0.85
act_declareFunction · 0.85
act_insertFunction · 0.85
act_selectFunction · 0.85

Calls 12

par_selectFunction · 0.85
MSC_matchFunction · 0.85
CPR_s_errorFunction · 0.85
MSC_pushFunction · 0.85
MSC_allocFunction · 0.85
RSE_LENFunction · 0.85
MSC_contextFunction · 0.85
MSC_nodeFunction · 0.85
post_select_listFunction · 0.85
MSC_popFunction · 0.85
par_orderFunction · 0.85
par_updateFunction · 0.85

Tested by

no test coverage detected