@@ -87,10 +87,57 @@ static Datum get_vertex(Oid graph_oid, int64 graphid)
8787
8888PG_FUNCTION_INFO_V1 (retrieve_vertex );
8989Datum retrieve_vertex (PG_FUNCTION_ARGS ) {
90- gtype * graph_oid = GT_ARG_TO_INT4_DATUM (0 );
91- graphid id = AG_GETARG_GRAPHID (1 );
90+
91+ //PG_RETURN_POINTER(get_vertex(graph_oid, id));
92+
93+ //gtype *graph_oid = GT_ARG_TO_INT4_DATUM(0);
94+ //graphid id = AG_GETARG_GRAPHID(1);
9295
93- PG_RETURN_POINTER (get_vertex (graph_oid , id ));
96+ //lquery *label = PG_GETARG_LQUERY_P(1);
97+ //bool include_props = PG_GETARG_BOOL(2);
98+ FuncCallContext * funcctx ;
99+ if (SRF_IS_FIRSTCALL ())
100+ {
101+ MemoryContext oldcontext ;
102+ TupleDesc tupdesc ;
103+
104+ funcctx = SRF_FIRSTCALL_INIT ();
105+ oldcontext = MemoryContextSwitchTo (funcctx -> multi_call_memory_ctx );
106+
107+ tupdesc = CreateTemplateTupleDesc (1 );
108+
109+ tupdesc -> tdtypeid = RECORDOID ; /* not right, but we don't care */
110+ tupdesc -> tdtypmod = -1 ;
111+ TupleDescInitEntry (tupdesc , (AttrNumber ) 1 , "properties" ,
112+ GTYPEOID , -1 , 0 );
113+
114+ funcctx -> tuple_desc = BlessTupleDesc (tupdesc );
115+
116+ MemoryContextSwitchTo (oldcontext );
117+
118+ funcctx = SRF_PERCALL_SETUP ();
119+
120+
121+ Datum values [1 ];
122+ bool nulls [1 ];
123+ HeapTuple tuple1 ;
124+ gtype * graph_oid = GT_ARG_TO_INT4_DATUM (0 );
125+ graphid id = AG_GETARG_GRAPHID (1 );
126+
127+ bool isnull ;
128+ values [0 ] = get_vertex (graph_oid , id );
129+ nulls [0 ] = true;
130+ tuple1 = heap_form_tuple (funcctx -> tuple_desc , values , nulls );
131+ SRF_RETURN_NEXT (funcctx , HeapTupleGetDatum (tuple1 ));
132+ }
133+
134+ SRF_RETURN_DONE (funcctx );
135+
136+
137+
138+
139+
140+
94141}
95142
96143
@@ -190,7 +237,7 @@ Datum edge_search(PG_FUNCTION_ARGS)
190237 //ereport(WARNING, errmsg("value %lu", DatumGetInt64(values[2])));
191238 values [3 ] = heap_getattr (cxt -> slot -> tts_ops -> get_heap_tuple (cxt -> slot ), 4 , RelationGetDescr (vertex_desc -> desc [0 ]-> rs_rd ), & isnull );
192239 nulls [3 ] = isnull ;
193- tuple1 = heap_form_tuple (funcctx -> tuple_desc , & values , & nulls );
240+ tuple1 = heap_form_tuple (funcctx -> tuple_desc , values , nulls );
194241 //cxt->slot->tts_ops->get_heap_tuple(cxt->slot);
195242
196243 //tuple1 = cxt->slot->tts_ops->copy_heap_tuple(cxt->slot);
0 commit comments