← Back to Overview

src/backend/rewrite/rewriteGraphTable.c

Coverage: 453/479 lines (94.6%)
Total Lines
479
modified
Covered
453
94.6%
Uncovered
26
5.4%
키보드 네비게이션
element() lines 72-89
Modified Lines Coverage: 0/0 lines (0.0%)
LineHitsSourceCommit
72 - * Represents one property graph element (vertex or edge) in the path. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
73 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
74 - * Label expression in an element pattern resolves into a set of elements. We 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
75 - * create one path_element object for each of those elements. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
76 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
77 - struct path_element 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
78 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
79 - /* Path factor from which this element is derived. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
80 - struct path_factor *path_factor; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
81 - Oid elemoid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
82 - Oid reloid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
83 - /* Source and destination vertex elements for an edge element. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
84 - Oid srcvertexid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
85 - Oid destvertexid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
86 - /* Source and destination conditions for an edge element. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
87 - List *src_quals; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
88 - List *dest_quals; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
89 - }; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
rewriteGraphTable() lines 110-144
Modified Lines Coverage: 17/18 lines (94.4%)
LineHitsSourceCommit
110 349 rewriteGraphTable(Query *parsetree, int rt_index) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
111 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
112 349 RangeTblEntry *rte; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
113 349 Query *graph_table_query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
114 349 List *path_pattern; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
115 349 List *pathqueries = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
116 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
117 349 rte = rt_fetch(rt_index, parsetree->rtable); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
118 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
119 349 if (list_length(rte->graph_pattern->path_pattern_list) != 1) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
120 0 elog(ERROR, "unsupported path pattern list length"); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
121 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
122 349 path_pattern = linitial(rte->graph_pattern->path_pattern_list); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
123 349 pathqueries = generate_queries_for_path_pattern(rte, path_pattern); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
124 319 graph_table_query = generate_union_from_pathqueries(&pathqueries); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
125 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
126 319 AcquireRewriteLocks(graph_table_query, true, false); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
127 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
128 319 rte->rtekind = RTE_SUBQUERY; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
129 319 rte->subquery = graph_table_query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
130 319 rte->lateral = true; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
131 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
132 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
133 - * Reset no longer applicable fields, to appease 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
134 - * WRITE_READ_PARSE_PLAN_TREES. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
135 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
136 319 rte->graph_pattern = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
137 319 rte->graph_table_columns = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
138 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
139 - #if 0 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
140 - elog(INFO, "rewritten:\n%s", pg_get_querydef(copyObject(parsetree), false)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
141 - #endif 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
142 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
143 319 return parsetree; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
144 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_queries_for_path_pattern() lines 180-341
Modified Lines Coverage: 59/64 lines (92.2%)
LineHitsSourceCommit
180 349 generate_queries_for_path_pattern(RangeTblEntry *rte, List *path_pattern) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
181 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
182 349 List *pathqueries = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
183 349 List *path_elem_lists = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
184 349 int factorpos = 0; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
185 349 List *path_factors = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
186 349 struct path_factor *prev_pf = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
187 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
188 349 Assert(list_length(path_pattern) > 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
189 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
190 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
191 - * Create a list of path factors representing the given path pattern 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
192 - * linking edge path factors to their adjacent vertex path factors. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
193 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
194 - * While doing that merge element patterns with the same variable name 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
195 - * into a single path_factor. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
196 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
197 1761 foreach_node(GraphElementPattern, gep, path_pattern) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
198 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
199 1081 struct path_factor *pf = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
200 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
201 1081 if (gep->kind != VERTEX_PATTERN && !IS_EDGE_PATTERN(gep->kind)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
202 0 elog(ERROR, "unsupported element pattern kind: \"%s\"", get_gep_kind_name(gep->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
203 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
204 1081 if (gep->quantifier) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
205 0 ereport(ERROR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
206 - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
207 - errmsg("element pattern quantifier not supported yet"))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
208 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
209 2155 foreach_ptr(struct path_factor, other, path_factors) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
210 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
211 1188 if (gep->variable && other->variable && 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
212 798 strcmp(gep->variable, other->variable) == 0) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
213 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
214 114 if (other->kind != gep->kind) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
215 3 ereport(ERROR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
216 - (errcode(ERRCODE_WRONG_OBJECT_TYPE), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
217 - errmsg("element patterns with same variable name \"%s\" but different element pattern types", 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
218 - gep->variable))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
219 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
220 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
221 - * If both the element patterns have label expressions, they 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
222 - * need to be conjuncted, which is not supported right now. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
223 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
224 - * However, an empty label expression means all labels. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
225 - * Conjunction of any label expression with all labels is the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
226 - * expression itself. Hence if only one of the two element 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
227 - * patterns has a label expression use that expression. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
228 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
229 111 if (!other->labelexpr) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
230 102 other->labelexpr = gep->labelexpr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
231 9 else if (gep->labelexpr && !equal(other->labelexpr, gep->labelexpr)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
232 3 ereport(ERROR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
233 - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
234 - errmsg("element patterns with same variable name \"%s\" but different label expressions are not supported", 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
235 - gep->variable))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
236 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
237 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
238 - * If two element patterns have the same variable name, they 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
239 - * represent the same set of graph elements and hence are 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
240 - * constrained by conditions from both the element patterns. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
241 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
242 108 if (!other->whereClause) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
243 96 other->whereClause = gep->whereClause; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
244 12 else if (gep->whereClause) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
245 6 other->whereClause = (Node *) makeBoolExpr(AND_EXPR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
246 6 list_make2(other->whereClause, gep->whereClause), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
247 - -1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
248 - pf = other; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
249 - break; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
250 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
251 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
252 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
253 1075 if (!pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
254 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
255 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
256 967 pf = palloc0_object(struct path_factor); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
257 967 pf->factorpos = factorpos++; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
258 967 pf->kind = gep->kind; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
259 967 pf->labelexpr = gep->labelexpr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
260 967 pf->variable = gep->variable; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
261 967 pf->whereClause = gep->whereClause; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
262 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
263 967 path_factors = lappend(path_factors, pf); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
264 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
265 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
266 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
267 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
268 - * Setup links to the previous path factor in the path. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
269 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
270 - * If the previous path factor represents an edge, this path factor 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
271 - * represents an adjacent vertex; the source vertex for an edge 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
272 - * pointing left or the destination vertex for an edge pointing right. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
273 - * If this path factor represents an edge, the previous path factor 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
274 - * represents an adjacent vertex; source vertex for an edge pointing 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
275 - * right or the destination vertex for an edge pointing left. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
276 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
277 - * Edge pointing in any direction is treated similar to that pointing 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
278 - * in right direction here. When constructing a query in 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
279 - * generate_query_for_graph_path(), we will try links in both the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
280 - * directions. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
281 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
282 - * If multiple edge patterns share the same variable name, they 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
283 - * constrain the adjacent vertex patterns since an edge can connect 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
284 - * only one pair of vertexes. These adjacent vertex patterns need to 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
285 - * be merged even though they have different variables. Such element 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
286 - * patterns form a walk of graph where vertex and edges are repeated. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
287 - * For example, in (a)-[b]->(c)<-[b]-(d), (a) and (d) represent the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
288 - * same vertex element. This is slighly harder to implement and 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
289 - * probably less useful. Hence not supported for now. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
290 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
291 1075 if (prev_pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
292 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
293 726 if (prev_pf->kind == EDGE_PATTERN_RIGHT || prev_pf->kind == EDGE_PATTERN_ANY) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
294 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
295 354 Assert(!IS_EDGE_PATTERN(pf->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
296 354 if (prev_pf->dest_pf && prev_pf->dest_pf != pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
297 0 elog(ERROR, "An edge can not connect more than two vertexes even in a cyclic pattern."); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
298 354 prev_pf->dest_pf = pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
299 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
300 372 else if (prev_pf->kind == EDGE_PATTERN_LEFT) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
301 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
302 6 Assert(!IS_EDGE_PATTERN(pf->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
303 6 if (prev_pf->src_pf && prev_pf->src_pf != pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
304 0 elog(ERROR, "An edge can not connect more than two vertexes even in a cyclic pattern."); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
305 6 prev_pf->src_pf = pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
306 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
307 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
308 726 if (pf->kind == EDGE_PATTERN_RIGHT || pf->kind == EDGE_PATTERN_ANY) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
309 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
310 360 Assert(!IS_EDGE_PATTERN(prev_pf->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
311 360 if (pf->src_pf && pf->src_pf != prev_pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
312 3 elog(ERROR, "An edge can not connect more than two vertexes even in a cyclic pattern."); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
313 357 pf->src_pf = prev_pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
314 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
315 366 else if (pf->kind == EDGE_PATTERN_LEFT) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
316 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
317 6 Assert(!IS_EDGE_PATTERN(prev_pf->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
318 6 if (pf->dest_pf && pf->dest_pf != prev_pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
319 0 elog(ERROR, "An edge can not connect more than two vertexes even in a cyclic pattern."); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
320 6 pf->dest_pf = prev_pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
321 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
322 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
323 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
324 1072 prev_pf = pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
325 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
326 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
327 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
328 - * Collect list of elements for each path factor. Do this after all the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
329 - * edge links are setup correctly. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
330 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
331 1265 foreach_ptr(struct path_factor, pf, path_factors) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
332 925 path_elem_lists = lappend(path_elem_lists, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
333 931 get_path_elements_for_path_factor(rte->relid, pf)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
334 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
335 334 pathqueries = generate_queries_for_path_pattern_recurse(rte, pathqueries, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
336 - NIL, path_elem_lists, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
337 319 if (!pathqueries) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
338 3 pathqueries = list_make1(generate_query_for_empty_path_pattern(rte)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
339 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
340 319 return pathqueries; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
341 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_queries_for_path_pattern_recurse() lines 350-381
Modified Lines Coverage: 12/12 lines (100.0%)
LineHitsSourceCommit
350 7018 generate_queries_for_path_pattern_recurse(RangeTblEntry *rte, List *pathqueries, List *cur_path, List *path_elem_lists, int elempos) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
351 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
352 7018 List *path_elems = list_nth_node(List, path_elem_lists, elempos); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
353 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
354 36598 foreach_ptr(struct path_element, pe, path_elems) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
355 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
356 - /* Update current path being built with current element. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
357 22658 cur_path = lappend(cur_path, pe); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
358 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
359 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
360 - * If this is the last element in the path, generate query for the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
361 - * completed path. Else recurse processing the next element. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
362 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
363 67974 if (list_length(path_elem_lists) == list_length(cur_path)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
364 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
365 15974 Query *pathquery = generate_query_for_graph_path(rte, cur_path); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
366 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
367 15959 Assert(elempos == list_length(path_elem_lists) - 1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
368 15959 if (pathquery) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
369 584 pathqueries = lappend(pathqueries, pathquery); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
370 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
371 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
372 6684 pathqueries = generate_queries_for_path_pattern_recurse(rte, pathqueries, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
373 - cur_path, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
374 - path_elem_lists, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
375 - elempos + 1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
376 - /* Make way for the next element at the same position. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
377 22610 cur_path = list_delete_last(cur_path); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
378 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
379 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
380 6970 return pathqueries; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
381 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_query_for_graph_path() lines 405-560
Modified Lines Coverage: 68/68 lines (100.0%)
LineHitsSourceCommit
405 15974 generate_query_for_graph_path(RangeTblEntry *rte, List *graph_path) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
406 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
407 15974 Query *path_query = makeNode(Query); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
408 15974 List *fromlist = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
409 15974 List *qual_exprs = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
410 15974 List *vars; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
411 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
412 15974 path_query->commandType = CMD_SELECT; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
413 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
414 36684 foreach_ptr(struct path_element, pe, graph_path) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
415 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
416 35486 struct path_factor *pf = pe->path_factor; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
417 35486 RangeTblRef *rtr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
418 35486 Relation rel; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
419 35486 ParseNamespaceItem *pni; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
420 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
421 35486 Assert(pf->kind == VERTEX_PATTERN || IS_EDGE_PATTERN(pf->kind)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
422 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
423 - /* Add conditions representing edge connnections. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
424 35486 if (IS_EDGE_PATTERN(pf->kind)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
425 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
426 17490 struct path_element *src_pe; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
427 17490 struct path_element *dest_pe; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
428 17490 Expr *edge_qual = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
429 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
430 17490 Assert(pf->src_pf && pf->dest_pf); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
431 17490 src_pe = list_nth(graph_path, pf->src_pf->factorpos); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
432 17490 dest_pe = list_nth(graph_path, pf->dest_pf->factorpos); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
433 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
434 - /* Make sure that the links of adjacent vertices are correct. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
435 17490 Assert(pf->src_pf == src_pe->path_factor && 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
436 - pf->dest_pf == dest_pe->path_factor); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
437 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
438 17490 if (src_pe->elemoid == pe->srcvertexid && 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
439 6030 dest_pe->elemoid == pe->destvertexid) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
440 2109 edge_qual = makeBoolExpr(AND_EXPR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
441 2109 list_concat(copyObject(pe->src_quals), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
442 2109 copyObject(pe->dest_quals)), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
443 - -1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
444 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
445 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
446 - * An edge pattern in any direction matches edges in both 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
447 - * directions, try swapping source and destination. When the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
448 - * source and destination is the same vertex table, quals 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
449 - * corresponding to either direction may get satisfied. Hence OR 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
450 - * the quals corresponding to both the directions. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
451 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
452 17490 if (pf->kind == EDGE_PATTERN_ANY && 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
453 168 dest_pe->elemoid == pe->srcvertexid && 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
454 60 src_pe->elemoid == pe->destvertexid) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
455 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
456 18 List *src_quals = copyObject(pe->dest_quals); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
457 18 List *dest_quals = copyObject(pe->src_quals); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
458 18 Expr *rev_edge_qual; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
459 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
460 - /* Swap the source and destination varnos in the quals. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
461 18 ChangeVarNodes((Node *) dest_quals, pe->path_factor->src_pf->factorpos + 1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
462 18 pe->path_factor->dest_pf->factorpos + 1, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
463 18 ChangeVarNodes((Node *) src_quals, pe->path_factor->dest_pf->factorpos + 1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
464 18 pe->path_factor->src_pf->factorpos + 1, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
465 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
466 18 rev_edge_qual = makeBoolExpr(AND_EXPR, list_concat(src_quals, dest_quals), -1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
467 18 if (edge_qual) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
468 12 edge_qual = makeBoolExpr(OR_EXPR, list_make2(edge_qual, rev_edge_qual), -1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
469 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
470 - edge_qual = rev_edge_qual; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
471 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
472 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
473 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
474 - * If the given edge element does not connect the adjacent vertex 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
475 - * elements in this path, the path is broken. Abandon this path as 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
476 - * it won't return any rows. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
477 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
478 17490 if (edge_qual == NULL) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
479 15375 return NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
480 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
481 2115 qual_exprs = lappend(qual_exprs, edge_qual); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
482 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
483 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
484 20111 Assert(!pe->src_quals && !pe->dest_quals); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
485 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
486 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
487 - * Create RangeTblEntry for this element table. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
488 - * 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
489 - * SQL/PGQ standard (Ref. Section 11.19, Access rule 2 and General 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
490 - * rule 4) does not specify whose access privileges to use when 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
491 - * accessing the element tables: property graph owner's or current 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
492 - * user's. It is safer to use current user's privileges so as not to 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
493 - * make property graphs as a hole for unpriviledged data access. This 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
494 - * is inline with the views being security_invoker by default. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
495 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
496 20111 rel = table_open(pe->reloid, AccessShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
497 20111 pni = addRangeTableEntryForRelation(make_parsestate(NULL), rel, AccessShareLock, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
498 - NULL, true, false); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
499 20111 table_close(rel, NoLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
500 20111 path_query->rtable = lappend(path_query->rtable, pni->p_rte); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
501 20111 path_query->rteperminfos = lappend(path_query->rteperminfos, pni->p_perminfo); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
502 20111 pni->p_rte->perminfoindex = list_length(path_query->rteperminfos); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
503 20111 rtr = makeNode(RangeTblRef); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
504 20111 rtr->rtindex = list_length(path_query->rtable); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
505 20111 fromlist = lappend(fromlist, rtr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
506 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
507 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
508 - * Make sure that the assumption mentioned in create_pe_for_element() 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
509 - * holds true; that the elements' RangeTblEntrys are added in the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
510 - * order in which their respective path factors appear in the list of 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
511 - * path factors representing the path pattern. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
512 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
513 20111 Assert(pf->factorpos + 1 == rtr->rtindex); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
514 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
515 20111 if (pf->whereClause) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
516 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
517 2775 Node *tr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
518 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
519 2775 tr = replace_property_refs(rte->relid, pf->whereClause, list_make1(pe)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
520 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
521 2775 qual_exprs = lappend(qual_exprs, tr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
522 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
523 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
524 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
525 599 if (rte->graph_pattern->whereClause) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
526 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
527 239 Node *path_quals = replace_property_refs(rte->relid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
528 - (Node *) rte->graph_pattern->whereClause, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
529 - graph_path); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
530 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
531 239 qual_exprs = lappend(qual_exprs, path_quals); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
532 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
533 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
534 1126 path_query->jointree = makeFromExpr(fromlist, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
535 527 qual_exprs ? (Node *) makeBoolExpr(AND_EXPR, qual_exprs, -1) : NULL); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
536 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
537 - /* Construct query targetlist from COLUMNS specification of GRAPH_TABLE. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
538 599 path_query->targetList = castNode(List, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
539 - replace_property_refs(rte->relid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
540 - (Node *) rte->graph_table_columns, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
541 - graph_path)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
542 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
543 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
544 - * Mark the columns being accessed in the path query as requiring SELECT 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
545 - * privilege. Any lateral columns should have been handled when the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
546 - * corresponding ColumnRefs were transformed. Ignore those here. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
547 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
548 584 vars = pull_vars_of_level((Node *) list_make2(qual_exprs, path_query->targetList), 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
549 6285 foreach_node(Var, var, vars) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
550 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
551 11402 RTEPermissionInfo *perminfo = getRTEPermissionInfo(path_query->rteperminfos, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
552 5701 rt_fetch(var->varno, path_query->rtable)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
553 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
554 - /* Must offset the attnum to fit in a bitmapset */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
555 5701 perminfo->selectedCols = bms_add_member(perminfo->selectedCols, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
556 5701 var->varattno - FirstLowInvalidHeapAttributeNumber); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
557 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
558 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
559 - return path_query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
560 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_query_for_empty_path_pattern() lines 568-591
Modified Lines Coverage: 11/11 lines (100.0%)
LineHitsSourceCommit
568 3 generate_query_for_empty_path_pattern(RangeTblEntry *rte) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
569 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
570 3 Query *query = makeNode(Query); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
571 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
572 3 query->commandType = CMD_SELECT; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
573 3 query->rtable = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
574 3 query->rteperminfos = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
575 3 query->jointree = makeFromExpr(NIL, (Node *) makeBoolConst(false, false)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
576 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
577 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
578 - * Even though no rows are returned, the result still projects the same 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
579 - * columns as projected by GRAPH_TABLE clause. Do this by constructing a 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
580 - * target list full of NULL values. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
581 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
582 9 foreach_node(TargetEntry, te, rte->graph_table_columns) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
583 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
584 6 Node *nte = (Node *) te->expr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
585 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
586 6 te->expr = (Expr *) makeNullConst(exprType(nte), exprTypmod(nte), exprCollation(nte)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
587 6 query->targetList = lappend(query->targetList, te); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
588 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
589 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
590 3 return query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
591 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_union_from_pathqueries() lines 606-673
Modified Lines Coverage: 37/37 lines (100.0%)
LineHitsSourceCommit
606 319 generate_union_from_pathqueries(List **pathqueries) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
607 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
608 319 List *rtable = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
609 319 Query *sampleQuery = linitial_node(Query, *pathqueries); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
610 319 SetOperationStmt *sostmt; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
611 319 Query *union_query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
612 319 int resno; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
613 319 ListCell *lctl, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
614 - *lct, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
615 - *lcm, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
616 - *lcc; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
617 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
618 319 Assert(list_length(*pathqueries) > 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
619 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
620 - /* If there's only one pathquery, no need to construct a UNION query. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
621 319 if (list_length(*pathqueries) == 1) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
622 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
623 228 *pathqueries = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
624 228 return sampleQuery; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
625 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
626 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
627 91 sostmt = castNode(SetOperationStmt, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
628 - generate_setop_from_pathqueries(*pathqueries, &rtable, NULL)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
629 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
630 - /* Encapsulate the set operation statement into a Query. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
631 91 union_query = makeNode(Query); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
632 91 union_query->commandType = CMD_SELECT; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
633 91 union_query->rtable = rtable; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
634 91 union_query->setOperations = (Node *) sostmt; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
635 91 union_query->rteperminfos = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
636 91 union_query->jointree = makeFromExpr(NIL, NULL); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
637 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
638 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
639 - * Generate dummy targetlist for outer query using column names from one 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
640 - * of the queries and common datatypes/collations of topmost set 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
641 - * operation. It shouldn't matter which query. Also it shouldn't matter 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
642 - * which RT index is used as varno in the target list entries, as long as 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
643 - * it corresponds to a real RT entry; else funny things may happen when 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
644 - * the tree is mashed by rule rewriting. So we use 1 since there's always 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
645 - * one RT entry at least. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
646 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
647 91 Assert(rt_fetch(1, rtable)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
648 91 union_query->targetList = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
649 91 resno = 1; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
650 335 forfour(lct, sostmt->colTypes, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
651 - lcm, sostmt->colTypmods, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
652 - lcc, sostmt->colCollations, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
653 - lctl, sampleQuery->targetList) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
654 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
655 244 Oid colType = lfirst_oid(lct); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
656 244 int32 colTypmod = lfirst_int(lcm); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
657 244 Oid colCollation = lfirst_oid(lcc); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
658 244 TargetEntry *sample_tle = (TargetEntry *) lfirst(lctl); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
659 244 char *colName; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
660 244 TargetEntry *tle; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
661 244 Var *var; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
662 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
663 244 Assert(!sample_tle->resjunk); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
664 244 colName = pstrdup(sample_tle->resname); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
665 244 var = makeVar(1, sample_tle->resno, colType, colTypmod, colCollation, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
666 244 var->location = exprLocation((Node *) sample_tle->expr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
667 244 tle = makeTargetEntry((Expr *) var, (AttrNumber) resno++, colName, false); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
668 244 union_query->targetList = lappend(union_query->targetList, tle); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
669 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
670 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
671 91 *pathqueries = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
672 91 return union_query; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
673 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
generate_setop_from_pathqueries() lines 682-732
Modified Lines Coverage: 29/29 lines (100.0%)
LineHitsSourceCommit
682 450 generate_setop_from_pathqueries(List *pathqueries, List **rtable, List **targetlist) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
683 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
684 450 SetOperationStmt *sostmt; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
685 450 Query *lquery; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
686 450 Node *rarg; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
687 450 RangeTblRef *lrtr = makeNode(RangeTblRef); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
688 450 List *rtargetlist; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
689 450 ParseNamespaceItem *pni; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
690 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
691 - /* Recursion termination condition. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
692 450 if (list_length(pathqueries) == 0) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
693 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
694 91 *targetlist = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
695 91 return NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
696 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
697 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
698 359 lquery = linitial_node(Query, pathqueries); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
699 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
700 359 pni = addRangeTableEntryForSubquery(make_parsestate(NULL), lquery, NULL, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
701 - false, false); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
702 359 *rtable = lappend(*rtable, pni->p_rte); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
703 359 lrtr->rtindex = list_length(*rtable); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
704 359 rarg = generate_setop_from_pathqueries(list_delete_first(pathqueries), rtable, &rtargetlist); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
705 359 if (rarg == NULL) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
706 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
707 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
708 - * No further path queries in the list. Convert the last query into a 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
709 - * RangeTblRef as expected by SetOperationStmt. Extract a list of the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
710 - * non-junk TLEs for upper-level processing. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
711 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
712 91 if (targetlist) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
713 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
714 91 *targetlist = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
715 335 foreach_node(TargetEntry, tle, lquery->targetList) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
716 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
717 244 if (!tle->resjunk) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
718 244 *targetlist = lappend(*targetlist, tle); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
719 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
720 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
721 91 return (Node *) lrtr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
722 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
723 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
724 268 sostmt = makeNode(SetOperationStmt); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
725 268 sostmt->op = SETOP_UNION; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
726 268 sostmt->all = true; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
727 268 sostmt->larg = (Node *) lrtr; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
728 268 sostmt->rarg = rarg; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
729 268 constructSetOpTargetlist(sostmt, lquery->targetList, rtargetlist, targetlist, "UNION", NULL, false); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
730 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
731 268 return (Node *) sostmt; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
732 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
create_pe_for_element() lines 742-798
Modified Lines Coverage: 22/23 lines (95.7%)
LineHitsSourceCommit
742 3326 create_pe_for_element(struct path_factor *pf, Oid elemoid) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
743 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
744 3326 HeapTuple eletup = SearchSysCache1(PROPGRAPHELOID, ObjectIdGetDatum(elemoid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
745 3326 Form_pg_propgraph_element pgeform; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
746 3326 struct path_element *pe; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
747 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
748 3326 if (!eletup) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
749 0 elog(ERROR, "cache lookup failed for property graph element %u", elemoid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
750 3326 pgeform = ((Form_pg_propgraph_element) GETSTRUCT(eletup)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
751 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
752 3326 if ((pgeform->pgekind == PGEKIND_VERTEX && pf->kind != VERTEX_PATTERN) || 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
753 1845 (pgeform->pgekind == PGEKIND_EDGE && !IS_EDGE_PATTERN(pf->kind))) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
754 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
755 1407 ReleaseSysCache(eletup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
756 1407 return NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
757 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
758 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
759 1919 pe = palloc0_object(struct path_element); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
760 1919 pe->path_factor = pf; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
761 1919 pe->elemoid = elemoid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
762 1919 pe->reloid = pgeform->pgerelid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
763 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
764 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
765 - * When a path is converted into a query 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
766 - * (generate_query_for_graph_path()), a RangeTblEntry will be created for 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
767 - * every element in the path. Fixing rtindexes of RangeTblEntrys here 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
768 - * makes it possible to craft elements' qual expressions only once while 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
769 - * we have access to the catalog entry. Otherwise they need to be crafted 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
770 - * as many times as the number of paths a given element appears in, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
771 - * fetching catalog entry again each time. Hence we simply assume 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
772 - * RangeTblEntrys will be created in the same order in which the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
773 - * corresponding path factors appear in the list of path factors 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
774 - * representing a path pattern. That way their rtindexes will be same as 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
775 - * path_factor::factorpos + 1. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
776 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
777 1919 if (IS_EDGE_PATTERN(pf->kind)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
778 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
779 891 pe->srcvertexid = pgeform->pgesrcvertexid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
780 891 pe->destvertexid = pgeform->pgedestvertexid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
781 891 Assert(pf->src_pf && pf->dest_pf); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
782 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
783 891 pe->src_quals = build_edge_vertex_link_quals(eletup, pf->factorpos + 1, pf->src_pf->factorpos + 1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
784 - pe->srcvertexid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
785 - Anum_pg_propgraph_element_pgesrckey, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
786 - Anum_pg_propgraph_element_pgesrcref, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
787 - Anum_pg_propgraph_element_pgesrceqop); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
788 891 pe->dest_quals = build_edge_vertex_link_quals(eletup, pf->factorpos + 1, pf->dest_pf->factorpos + 1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
789 - pe->destvertexid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
790 - Anum_pg_propgraph_element_pgedestkey, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
791 - Anum_pg_propgraph_element_pgedestref, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
792 - Anum_pg_propgraph_element_pgedesteqop); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
793 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
794 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
795 1919 ReleaseSysCache(eletup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
796 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
797 1919 return pe; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
798 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
get_gep_kind_name() lines 801-818
Modified Lines Coverage: 0/11 lines (0.0%)
LineHitsSourceCommit
801 0 get_gep_kind_name(GraphElementPatternKind gepkind) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
802 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
803 0 switch (gepkind) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
804 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
805 - case VERTEX_PATTERN: 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
806 - return "vertex"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
807 0 case EDGE_PATTERN_LEFT: 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
808 0 return "edge pointing left"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
809 0 case EDGE_PATTERN_RIGHT: 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
810 0 return "edge pointing right"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
811 0 case EDGE_PATTERN_ANY: 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
812 0 return "edge pointing any direction"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
813 0 case PAREN_EXPR: 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
814 0 return "nested path pattern"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
815 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
816 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
817 0 pg_unreachable(); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
818 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
get_labels_for_expr() lines 825-878
Modified Lines Coverage: 26/27 lines (96.3%)
LineHitsSourceCommit
825 931 get_labels_for_expr(Oid propgraphid, Node *labelexpr) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
826 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
827 931 List *label_oids; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
828 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
829 931 if (!labelexpr) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
830 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
831 303 Relation rel; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
832 303 SysScanDesc scan; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
833 303 ScanKeyData key[1]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
834 303 HeapTuple tup; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
835 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
836 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
837 - * According to section 9.2 "Contextual inference of a set of labels" 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
838 - * subclause 2.a.ii of SQL/PGQ standard, element pattern which does 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
839 - * not have a label expression is considered to have label expression 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
840 - * equivalent to '%|!%' which is set of all labels. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
841 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
842 303 label_oids = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
843 303 rel = table_open(PropgraphLabelRelationId, AccessShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
844 303 ScanKeyInit(&key[0], 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
845 - Anum_pg_propgraph_label_pglpgid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
846 - BTEqualStrategyNumber, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
847 - F_OIDEQ, ObjectIdGetDatum(propgraphid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
848 303 scan = systable_beginscan(rel, PropgraphLabelGraphNameIndexId, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
849 - true, NULL, 1, key); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
850 2025 while (HeapTupleIsValid(tup = systable_getnext(scan))) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
851 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
852 1722 Form_pg_propgraph_label label = (Form_pg_propgraph_label) GETSTRUCT(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
853 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
854 1722 label_oids = lappend_oid(label_oids, label->oid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
855 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
856 303 systable_endscan(scan); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
857 303 table_close(rel, AccessShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
858 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
859 628 else if (IsA(labelexpr, GraphLabelRef)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
860 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
861 601 GraphLabelRef *glr = castNode(GraphLabelRef, labelexpr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
862 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
863 601 label_oids = list_make1_oid(glr->labelid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
864 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
865 27 else if (IsA(labelexpr, BoolExpr)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
866 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
867 27 BoolExpr *be = castNode(BoolExpr, labelexpr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
868 27 List *label_exprs = be->args; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
869 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
870 27 label_oids = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
871 84 foreach_node(GraphLabelRef, glr, label_exprs) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
872 57 label_oids = lappend_oid(label_oids, glr->labelid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
873 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
874 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
875 0 elog(ERROR, "unsupported label expression type: %d", (int) nodeTag(labelexpr)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
876 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
877 931 return label_oids; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
878 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
get_path_elements_for_path_factor() lines 897-992
Modified Lines Coverage: 35/35 lines (100.0%)
LineHitsSourceCommit
897 931 get_path_elements_for_path_factor(Oid propgraphid, struct path_factor *pf) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
898 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
899 931 List *label_oids = get_labels_for_expr(propgraphid, pf->labelexpr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
900 931 List *elem_oids_seen = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
901 931 List *pf_elem_oids = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
902 931 List *path_elements = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
903 931 List *unresolved_labels = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
904 931 Relation rel; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
905 931 SysScanDesc scan; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
906 931 ScanKeyData key[1]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
907 931 HeapTuple tup; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
908 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
909 931 rel = table_open(PropgraphElementLabelRelationId, AccessShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
910 4227 foreach_oid(labeloid, label_oids) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
911 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
912 2377 bool found = false; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
913 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
914 2377 ScanKeyInit(&key[0], 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
915 - Anum_pg_propgraph_element_label_pgellabelid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
916 - BTEqualStrategyNumber, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
917 - F_OIDEQ, ObjectIdGetDatum(labeloid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
918 2377 scan = systable_beginscan(rel, PropgraphElementLabelLabelIndexId, true, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
919 - NULL, 1, key); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
920 7980 while (HeapTupleIsValid(tup = systable_getnext(scan))) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
921 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
922 5603 Form_pg_propgraph_element_label label_elem = (Form_pg_propgraph_element_label) GETSTRUCT(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
923 5603 Oid elem_oid = label_elem->pgelelid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
924 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
925 5603 if (!list_member_oid(elem_oids_seen, elem_oid)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
926 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
927 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
928 - * Create path_element object if the new element qualifies the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
929 - * element pattern kind. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
930 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
931 3326 struct path_element *pe = create_pe_for_element(pf, elem_oid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
932 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
933 3326 if (pe) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
934 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
935 1919 path_elements = lappend(path_elements, pe); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
936 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
937 - /* Remember qualified elements. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
938 1919 pf_elem_oids = lappend_oid(pf_elem_oids, elem_oid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
939 1919 found = true; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
940 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
941 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
942 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
943 - * Rememeber qualified and unqualified elements processed so 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
944 - * far to avoid processing already processed elements again. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
945 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
946 3326 elem_oids_seen = lappend_oid(elem_oids_seen, label_elem->pgelelid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
947 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
948 2277 else if (list_member_oid(pf_elem_oids, elem_oid)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
949 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
950 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
951 - * The graph element is known to qualify the given element 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
952 - * pattern. Flag that the current label has at least one 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
953 - * qualified element associated with it. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
954 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
955 1167 found = true; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
956 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
957 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
958 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
959 2377 if (!found) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
960 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
961 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
962 - * We did not find any qualified element associated with this 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
963 - * label. The label or its properties can not be associated with 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
964 - * the given element pattern. Throw an error if the label was 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
965 - * explicitly specified in the element pattern. Otherwise remember 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
966 - * it for later use. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
967 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
968 729 if (!pf->labelexpr) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
969 723 unresolved_labels = lappend_oid(unresolved_labels, labeloid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
970 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
971 6 ereport(ERROR, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
972 - (errcode(ERRCODE_UNDEFINED_OBJECT), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
973 - errmsg("can not find label \"%s\" in property graph \"%s\" for element type \"%s\"", 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
974 - get_propgraph_label_name(labeloid), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
975 - get_rel_name(propgraphid), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
976 - get_graph_elem_kind_name(pf->kind)))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
977 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
978 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
979 2371 systable_endscan(scan); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
980 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
981 925 table_close(rel, AccessShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
982 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
983 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
984 - * Remove the labels which were not explicitly mentioned in the label 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
985 - * expression but do not have any qualified elements associated with them. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
986 - * Properties associated with such labels may not be referenced. See 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
987 - * replace_property_refs_mutator() for more details. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
988 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
989 925 pf->labeloids = list_difference_oid(label_oids, unresolved_labels); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
990 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
991 925 return path_elements; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
992 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
get_graph_elem_kind_name() lines 995-1005
Modified Lines Coverage: 2/5 lines (40.0%)
LineHitsSourceCommit
995 6 get_graph_elem_kind_name(GraphElementPatternKind gepkind) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
996 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
997 6 if (gepkind == VERTEX_PATTERN) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
998 - return "vertex"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
999 0 else if (IS_EDGE_PATTERN(gepkind)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1000 - return "edge"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1001 0 else if (gepkind == PAREN_EXPR) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1002 0 return "nested path pattern"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1003 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1004 - return "unknown"; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1005 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
replace_property_refs_mutator() lines 1018-1140
Modified Lines Coverage: 37/38 lines (97.4%)
LineHitsSourceCommit
1018 33631 replace_property_refs_mutator(Node *node, struct replace_property_refs_context *context) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1019 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1020 33631 if (node == NULL) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1021 - return NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1022 33631 if (IsA(node, Var)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1023 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1024 6 Var *var = (Var *) node; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1025 6 Var *newvar = copyObject(var); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1026 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1027 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1028 - * If it's already a Var, then it was a lateral reference. Since we 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1029 - * are in a subquery after the rewrite, we have to increase the level 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1030 - * by one. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1031 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1032 6 newvar->varlevelsup++; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1033 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1034 6 return (Node *) newvar; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1035 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1036 33625 else if (IsA(node, GraphPropertyRef)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1037 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1038 - GraphPropertyRef *gpr = (GraphPropertyRef *) node; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1039 16100 Node *n = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1040 - struct path_element *found_mapping = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1041 16100 struct path_factor *mapping_factor = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1042 16100 List *unrelated_labels = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1043 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1044 10342 foreach_ptr(struct path_element, m, context->mappings) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1045 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1046 10342 if (m->path_factor->variable && strcmp(gpr->elvarname, m->path_factor->variable) == 0) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1047 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1048 - found_mapping = m; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1049 - break; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1050 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1051 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1052 8050 if (!found_mapping) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1053 0 elog(ERROR, "undefined element variable \"%s\"", gpr->elvarname); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1054 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1055 8050 mapping_factor = found_mapping->path_factor; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1056 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1057 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1058 - * Find property definition for given element through any of the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1059 - * associated labels qualifying the given element pattern. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1060 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1061 44421 foreach_oid(labeloid, mapping_factor->labeloids) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1062 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1063 28321 Oid elem_labelid = GetSysCacheOid2(PROPGRAPHELEMENTLABELELEMENTLABEL, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1064 - Anum_pg_propgraph_element_label_oid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1065 - ObjectIdGetDatum(found_mapping->elemoid), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1066 - ObjectIdGetDatum(labeloid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1067 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1068 28321 if (OidIsValid(elem_labelid)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1069 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1070 17092 HeapTuple tup = SearchSysCache2(PROPGRAPHLABELPROP, ObjectIdGetDatum(elem_labelid), 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1071 - ObjectIdGetDatum(gpr->propid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1072 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1073 17092 if (!tup) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1074 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1075 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1076 - * The label is associated with the given element but it 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1077 - * is not associated with the required property. Check 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1078 - * next label. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1079 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1080 8790 continue; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1081 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1082 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1083 8302 n = stringToNode(TextDatumGetCString(SysCacheGetAttrNotNull(PROPGRAPHLABELPROP, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1084 - tup, Anum_pg_propgraph_label_property_plpexpr))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1085 8302 ChangeVarNodes(n, 1, mapping_factor->factorpos + 1, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1086 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1087 8302 ReleaseSysCache(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1088 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1089 - else 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1090 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1091 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1092 - * Label is not associated with the element but it may be 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1093 - * associated with the property through some other element. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1094 - * Save it for later use. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1095 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1096 11229 unrelated_labels = lappend_oid(unrelated_labels, labeloid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1097 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1098 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1099 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1100 - /* See if we can resolve the property in some other way. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1101 8050 if (!n) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1102 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1103 - bool prop_associated = false; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1104 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1105 72 foreach_oid(loid, unrelated_labels) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1106 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1107 57 if (is_property_associated_with_label(loid, gpr->propid)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1108 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1109 - prop_associated = true; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1110 - break; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1111 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1112 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1113 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1114 54 if (prop_associated) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1115 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1116 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1117 - * The property is associated with at least one of the labels 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1118 - * that satisfy given element pattern. If it's associated with 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1119 - * the given element (through some other label), use 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1120 - * correspondig value expression. Otherwise NULL. Ref. SQL/PGQ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1121 - * standard section 6.5 Property Reference, General Rule 2.b. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1122 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1123 78 n = get_element_property_expr(found_mapping->elemoid, gpr->propid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1124 39 mapping_factor->factorpos + 1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1125 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1126 39 if (!n) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1127 36 n = (Node *) makeNullConst(gpr->typeId, gpr->typmod, gpr->collation); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1128 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1129 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1130 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1131 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1132 51 if (!n) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1133 15 elog(ERROR, "property \"%s\" of element variable \"%s\" not found", 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1134 - get_propgraph_property_name(gpr->propid), mapping_factor->variable); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1135 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1136 8035 return n; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1137 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1138 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1139 25575 return expression_tree_mutator(node, replace_property_refs_mutator, context); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1140 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
replace_property_refs() lines 1143-1151
Modified Lines Coverage: 5/5 lines (100.0%)
LineHitsSourceCommit
1143 3613 replace_property_refs(Oid propgraphid, Node *node, const List *mappings) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1144 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1145 3613 struct replace_property_refs_context context; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1146 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1147 3613 context.mappings = mappings; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1148 3613 context.propgraphid = propgraphid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1149 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1150 3613 return expression_tree_mutator(node, replace_property_refs_mutator, &context); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1151 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
build_edge_vertex_link_quals() lines 1157-1248
Modified Lines Coverage: 57/60 lines (95.0%)
LineHitsSourceCommit
1157 1782 build_edge_vertex_link_quals(HeapTuple edgetup, int edgerti, int refrti, Oid refid, AttrNumber catalog_key_attnum, AttrNumber catalog_ref_attnum, AttrNumber catalog_eqop_attnum) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1158 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1159 1782 List *quals = NIL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1160 1782 Form_pg_propgraph_element pgeform; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1161 1782 Datum datum; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1162 1782 Datum *d1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1163 - *d2, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1164 - *d3; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1165 1782 int n1, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1166 - n2, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1167 - n3; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1168 1782 ParseState *pstate = make_parsestate(NULL); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1169 1782 Oid refrelid = GetSysCacheOid1(PROPGRAPHELOID, Anum_pg_propgraph_element_pgerelid, ObjectIdGetDatum(refid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1170 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1171 1782 pgeform = (Form_pg_propgraph_element) GETSTRUCT(edgetup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1172 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1173 1782 datum = SysCacheGetAttrNotNull(PROPGRAPHELOID, edgetup, catalog_key_attnum); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1174 1782 deconstruct_array_builtin(DatumGetArrayTypeP(datum), INT2OID, &d1, NULL, &n1); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1175 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1176 1782 datum = SysCacheGetAttrNotNull(PROPGRAPHELOID, edgetup, catalog_ref_attnum); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1177 1782 deconstruct_array_builtin(DatumGetArrayTypeP(datum), INT2OID, &d2, NULL, &n2); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1178 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1179 1782 datum = SysCacheGetAttrNotNull(PROPGRAPHELOID, edgetup, catalog_eqop_attnum); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1180 1782 deconstruct_array_builtin(DatumGetArrayTypeP(datum), OIDOID, &d3, NULL, &n3); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1181 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1182 1782 if (n1 != n2) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1183 0 elog(ERROR, "array size key (%d) vs ref (%d) mismatch for element ID %u", catalog_key_attnum, catalog_ref_attnum, pgeform->oid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1184 1782 if (n1 != n3) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1185 0 elog(ERROR, "array size key (%d) vs operator (%d) mismatch for element ID %u", catalog_key_attnum, catalog_eqop_attnum, pgeform->oid); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1186 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1187 4050 for (int i = 0; i < n1; i++) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1188 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1189 2268 AttrNumber keyattn = DatumGetInt16(d1[i]); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1190 2268 AttrNumber refattn = DatumGetInt16(d2[i]); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1191 2268 Oid eqop = DatumGetObjectId(d3[i]); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1192 2268 Var *keyvar; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1193 2268 Var *refvar; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1194 2268 Oid atttypid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1195 2268 int32 atttypmod; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1196 2268 Oid attcoll; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1197 2268 HeapTuple tup; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1198 2268 Form_pg_operator opform; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1199 2268 List *args; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1200 2268 Oid actual_arg_types[2]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1201 2268 Oid declared_arg_types[2]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1202 2268 OpExpr *linkqual; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1203 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1204 2268 get_atttypetypmodcoll(pgeform->pgerelid, keyattn, &atttypid, &atttypmod, &attcoll); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1205 2268 keyvar = makeVar(edgerti, keyattn, atttypid, atttypmod, attcoll, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1206 2268 get_atttypetypmodcoll(refrelid, refattn, &atttypid, &atttypmod, &attcoll); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1207 2268 refvar = makeVar(refrti, refattn, atttypid, atttypmod, attcoll, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1208 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1209 2268 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(eqop)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1210 2268 if (!HeapTupleIsValid(tup)) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1211 0 elog(ERROR, "cache lookup failed for operator %u", eqop); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1212 2268 opform = (Form_pg_operator) GETSTRUCT(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1213 - /* An equality operator is a binary operator returning boolean result. */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1214 2268 Assert(opform->oprkind == 'b' 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1215 - && RegProcedureIsValid(opform->oprcode) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1216 - && opform->oprresult == BOOLOID 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1217 - && !get_func_retset(opform->oprcode)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1218 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1219 - /* 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1220 - * Prepare operands and cast them to the types required by the 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1221 - * equality operator. Similar to PK/FK qauls, referenced vertex key is 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1222 - * used as left operand and referencing edge key is used as right 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1223 - * operand. 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1224 - */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1225 2268 args = list_make2(refvar, keyvar); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1226 2268 actual_arg_types[0] = exprType((Node *) refvar); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1227 2268 actual_arg_types[1] = exprType((Node *) keyvar); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1228 2268 declared_arg_types[0] = opform->oprleft; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1229 2268 declared_arg_types[1] = opform->oprright; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1230 2268 make_fn_arguments(pstate, args, actual_arg_types, declared_arg_types); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1231 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1232 2268 linkqual = makeNode(OpExpr); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1233 2268 linkqual->opno = opform->oid; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1234 2268 linkqual->opfuncid = opform->oprcode; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1235 2268 linkqual->opresulttype = opform->oprresult; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1236 2268 linkqual->opretset = false; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1237 - /* opcollid and inputcollid will be set by parse_collate.c */ 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1238 2268 linkqual->args = args; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1239 2268 linkqual->location = -1; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1240 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1241 2268 ReleaseSysCache(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1242 2268 quals = lappend(quals, linkqual); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1243 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1244 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1245 1782 assign_expr_collations(pstate, (Node *) quals); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1246 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1247 1782 return quals; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1248 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
is_property_associated_with_label() lines 1258-1285
Modified Lines Coverage: 15/15 lines (100.0%)
LineHitsSourceCommit
1258 57 is_property_associated_with_label(Oid labeloid, Oid propoid) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1259 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1260 57 Relation rel; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1261 57 SysScanDesc scan; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1262 57 ScanKeyData key[1]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1263 57 HeapTuple tup; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1264 57 bool associated = false; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1265 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1266 57 rel = table_open(PropgraphElementLabelRelationId, RowShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1267 57 ScanKeyInit(&key[0], 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1268 - Anum_pg_propgraph_element_label_pgellabelid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1269 - BTEqualStrategyNumber, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1270 - F_OIDEQ, ObjectIdGetDatum(labeloid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1271 57 scan = systable_beginscan(rel, PropgraphElementLabelLabelIndexId, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1272 - true, NULL, 1, key); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1273 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1274 57 if (HeapTupleIsValid(tup = systable_getnext(scan))) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1275 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1276 57 Form_pg_propgraph_element_label ele_label = (Form_pg_propgraph_element_label) GETSTRUCT(tup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1277 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1278 57 associated = SearchSysCacheExists2(PROPGRAPHLABELPROP, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1279 - ObjectIdGetDatum(ele_label->oid), ObjectIdGetDatum(propoid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1280 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1281 57 systable_endscan(scan); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1282 57 table_close(rel, RowShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1283 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1284 57 return associated; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1285 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
get_element_property_expr() lines 1293-1329
Modified Lines Coverage: 21/21 lines (100.0%)
LineHitsSourceCommit
1293 39 get_element_property_expr(Oid elemoid, Oid propoid, int rtindex) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1294 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1295 39 Relation rel; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1296 39 SysScanDesc scan; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1297 39 ScanKeyData key[1]; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1298 39 HeapTuple labeltup; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1299 39 Node *n = NULL; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1300 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1301 39 rel = table_open(PropgraphElementLabelRelationId, RowShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1302 39 ScanKeyInit(&key[0], 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1303 - Anum_pg_propgraph_element_label_pgelelid, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1304 - BTEqualStrategyNumber, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1305 - F_OIDEQ, ObjectIdGetDatum(elemoid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1306 39 scan = systable_beginscan(rel, PropgraphElementLabelElementLabelIndexId, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1307 - true, NULL, 1, key); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1308 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1309 111 while (HeapTupleIsValid(labeltup = systable_getnext(scan))) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1310 - { 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1311 75 Form_pg_propgraph_element_label ele_label = (Form_pg_propgraph_element_label) GETSTRUCT(labeltup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1312 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1313 75 HeapTuple proptup = SearchSysCache2(PROPGRAPHLABELPROP, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1314 - ObjectIdGetDatum(ele_label->oid), ObjectIdGetDatum(propoid)); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1315 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1316 75 if (!proptup) 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1317 72 continue; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1318 3 n = stringToNode(TextDatumGetCString(SysCacheGetAttrNotNull(PROPGRAPHLABELPROP, 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1319 - proptup, Anum_pg_propgraph_label_property_plpexpr))); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1320 3 ChangeVarNodes(n, 1, rtindex, 0); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1321 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1322 3 ReleaseSysCache(proptup); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1323 3 break; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1324 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1325 39 systable_endscan(scan); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1326 39 table_close(rel, RowShareLock); 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1327 - 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1328 39 return n; 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)
1329 - } 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ)