|
45 | 45 | #include "utils/ag_cache.h" |
46 | 46 | #include "utils/graphid.h" |
47 | 47 |
|
48 | | - |
49 | | - |
50 | | - |
51 | | -static ResultRelInfo *create_entity_result_rel_info(EState *estate, char *graph_name, |
52 | | - char *label_name); |
53 | | - |
54 | 48 | PG_FUNCTION_INFO_V1(ltree_in); |
55 | 49 | PG_FUNCTION_INFO_V1(ltree_addltree); |
56 | 50 |
|
@@ -282,111 +276,4 @@ RangeVar *get_label_range_var(char *graph_name, Oid graph_oid, |
282 | 276 | return makeRangeVar(graph_name, relname, 2); |
283 | 277 | } |
284 | 278 |
|
285 | | -#include "parser/parse_node.h" |
286 | | -/* |
287 | | - * Given the graph name and the label name, create a ResultRelInfo for the table |
288 | | - * those to variables represent. Open the Indices too. |
289 | | - */ |
290 | | -ResultRelInfo *create_entity_result_rel_info(EState *estate, char *graph_name, |
291 | | - char *label_name) |
292 | | -{ |
293 | | - RangeVar *rv; |
294 | | - Relation label_relation; |
295 | | - ResultRelInfo *resultRelInfo; |
296 | | - |
297 | | - ParseState *pstate = make_parsestate(NULL); |
298 | | - |
299 | | - resultRelInfo = palloc(sizeof(ResultRelInfo)); |
300 | | - |
301 | | - if (strlen(label_name) == 0) |
302 | | - { |
303 | | - rv = makeRangeVar(graph_name, AG_DEFAULT_LABEL_VERTEX, -1); |
304 | | - } |
305 | | - else |
306 | | - { |
307 | | - rv = makeRangeVar(graph_name, label_name, -1); |
308 | | - } |
309 | | - |
310 | | - label_relation = parserOpenTable(pstate, rv, RowExclusiveLock); |
311 | | - |
312 | | - // initialize the resultRelInfo |
313 | | - InitResultRelInfo(resultRelInfo, label_relation, |
314 | | - list_length(estate->es_range_table), NULL, |
315 | | - estate->es_instrument); |
316 | | - |
317 | | - // open the parse state |
318 | | - ExecOpenIndices(resultRelInfo, false); |
319 | | - |
320 | | - free_parsestate(pstate); |
321 | | - |
322 | | - return resultRelInfo; |
323 | | -} |
324 | | - |
325 | 279 |
|
326 | | -/* |
327 | | - * Retrieves a list of all the names of a graph. |
328 | | - * |
329 | | - * XXX: We may want to use the cache system for this function, |
330 | | - * however the cache system currently requires us to know the |
331 | | - * name of the label we want. |
332 | | - */ |
333 | | -List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid) |
334 | | -{ |
335 | | - List *labels = NIL; |
336 | | - ScanKeyData scan_keys[2]; |
337 | | - Relation ag_label; |
338 | | - TableScanDesc scan_desc; |
339 | | - HeapTuple tuple; |
340 | | - TupleTableSlot *slot; |
341 | | - ResultRelInfo *resultRelInfo; |
342 | | - |
343 | | - // setup scan keys to get all edges for the given graph oid |
344 | | - ScanKeyInit(&scan_keys[1], Anum_ag_label_graph, BTEqualStrategyNumber, |
345 | | - F_OIDEQ, ObjectIdGetDatum(graph_oid)); |
346 | | - ScanKeyInit(&scan_keys[0], Anum_ag_label_kind, BTEqualStrategyNumber, |
347 | | - F_CHAREQ, CharGetDatum(LABEL_TYPE_EDGE)); |
348 | | - |
349 | | - // setup the table to be scanned |
350 | | - ag_label = table_open(ag_label_relation_id(), RowExclusiveLock); |
351 | | - scan_desc = table_beginscan(ag_label, estate->es_snapshot, 2, scan_keys); |
352 | | - |
353 | | - resultRelInfo = create_entity_result_rel_info(estate, CATALOG_SCHEMA, |
354 | | - "ag_label"); |
355 | | - |
356 | | - slot = ExecInitExtraTupleSlot( |
357 | | - estate, RelationGetDescr(resultRelInfo->ri_RelationDesc), |
358 | | - &TTSOpsHeapTuple); |
359 | | - |
360 | | - // scan through the results and get all the label names. |
361 | | - while(true) |
362 | | - { |
363 | | - Name label; |
364 | | - bool isNull; |
365 | | - Datum datum; |
366 | | - |
367 | | - tuple = heap_getnext(scan_desc, ForwardScanDirection); |
368 | | - |
369 | | - // no more labels to process |
370 | | - if (!HeapTupleIsValid(tuple)) |
371 | | - break; |
372 | | - |
373 | | - ExecStoreHeapTuple(tuple, slot, false); |
374 | | - |
375 | | - datum = slot_getattr(slot, Anum_ag_label_name, &isNull); |
376 | | - label = DatumGetName(datum); |
377 | | - |
378 | | - labels = lappend(labels, label); |
379 | | - } |
380 | | - |
381 | | - table_endscan(scan_desc); |
382 | | - |
383 | | - // close the indices |
384 | | - ExecCloseIndices(resultRelInfo); |
385 | | - |
386 | | - // close the rel |
387 | | - table_close(resultRelInfo->ri_RelationDesc, RowExclusiveLock); |
388 | | - |
389 | | - table_close(resultRelInfo->ri_RelationDesc, RowExclusiveLock); |
390 | | - |
391 | | - return labels; |
392 | | -} |
0 commit comments