@@ -300,11 +300,10 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
300300 ResultRelInfo * resultRelInfo ;
301301 Oid index_oid ;
302302
303- index_oid = get_relname_relid ("ag_label_graph_oid_index" ,
304- get_namespace_oid ("ag_catalog" , false));
305-
306303 /* setup the table to be scanned */
307- ag_label = table_open (ag_label_relation_id (), RowExclusiveLock );
304+ ag_label = table_open (ag_label_relation_id (), AccessShareLock );
305+
306+ index_oid = find_usable_index_for_attr (ag_label , Anum_ag_label_graph );
308307
309308 resultRelInfo = create_entity_result_rel_info (estate , "ag_catalog" ,
310309 "ag_label" );
@@ -318,9 +317,13 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
318317 estate , RelationGetDescr (resultRelInfo -> ri_RelationDesc ),
319318 & TTSOpsBufferHeapTuple );
320319
321- index_rel = index_open (index_oid , RowExclusiveLock );
320+ index_rel = index_open (index_oid , AccessShareLock );
322321
323- ScanKeyInit (& scan_keys [0 ], Anum_ag_label_name , BTEqualStrategyNumber ,
322+ /*
323+ * Use 1 as the attribute number because 'graph' is the 1st column
324+ * in the ag_label_graph_oid_index
325+ */
326+ ScanKeyInit (& scan_keys [0 ], 1 , BTEqualStrategyNumber ,
324327 F_OIDEQ , ObjectIdGetDatum (graph_oid ));
325328
326329 index_scan_desc = index_beginscan (ag_label , index_rel , estate -> es_snapshot , NULL , 1 , 0 );
@@ -355,22 +358,23 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
355358 }
356359
357360 index_endscan (index_scan_desc );
358- index_close (index_rel , RowExclusiveLock );
359- } else
361+ index_close (index_rel , AccessShareLock );
362+ }
363+ else
360364 {
361365 slot = ExecInitExtraTupleSlot (
362366 estate , RelationGetDescr (resultRelInfo -> ri_RelationDesc ),
363367 & TTSOpsHeapTuple );
364368
365- // setup scan keys to get all edges for the given graph oid
369+ /* setup scan keys to get all edges for the given graph oid */
366370 ScanKeyInit (& scan_keys [1 ], Anum_ag_label_graph , BTEqualStrategyNumber ,
367371 F_OIDEQ , ObjectIdGetDatum (graph_oid ));
368372 ScanKeyInit (& scan_keys [0 ], Anum_ag_label_kind , BTEqualStrategyNumber ,
369373 F_CHAREQ , CharGetDatum (LABEL_TYPE_EDGE ));
370374
371375 scan_desc = table_beginscan (ag_label , estate -> es_snapshot , 2 , scan_keys );
372376
373- // scan through the results and get all the label names.
377+ /* scan through the results and get all the label names. */
374378 while (true)
375379 {
376380 Name label ;
@@ -380,7 +384,7 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
380384
381385 tuple = heap_getnext (scan_desc , ForwardScanDirection );
382386
383- // no more labels to process
387+ /* no more labels to process */
384388 if (!HeapTupleIsValid (tuple ))
385389 break ;
386390
@@ -398,7 +402,7 @@ List *get_all_edge_labels_per_graph(EState *estate, Oid graph_oid)
398402 }
399403
400404 destroy_entity_result_rel_info (resultRelInfo );
401- table_close (resultRelInfo -> ri_RelationDesc , RowExclusiveLock );
405+ table_close (resultRelInfo -> ri_RelationDesc , AccessShareLock );
402406
403407 return labels ;
404408}
0 commit comments