Re: json results parsing

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Charles Cui <charles(dot)cui1984(at)gmail(dot)com>
Cc: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>, Aleksandr Parfenov <a(dot)parfenov(at)postgrespro(dot)ru>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: json results parsing
Date: 2018-06-01 01:56:24
Message-ID: 87wovjxovd.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Charles" == Charles Cui <charles(dot)cui1984(at)gmail(dot)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)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2018-06-01 01:57:59 Re: json results parsing
Previous Message Charles Cui 2018-06-01 00:20:24 Re: json results parsing