>>>>> "Charles" == Charles Cui <charles.cui1...@gmail.com> writes:
Charles> Thanks you guys for answering my questions, and sorry for confusion. Charles> To clarify, I think my question is functions like json_each or Charles> json_object_keys() are Charles> set returning functions ( Charles> https://www.postgresql.org/docs/9.5/static/functions-srf.html), Charles> which means it returns a set of results into a Datum. No. Set-returning functions follow a somewhat complex call protocol that may involve the function being called multiple times (returning one row each time as a composite Datum) or may involve the function being called once and returning a tuplestore (not as the return value but via the ReturnSetInfo struct). I would not try calling a SRF directly from C code without going through SPI (i.e. setting up and running an actual query from inside your function). I definitely think you should be looking at pg_parse_json instead. -- Andrew (irc:RhodiumToad)