How are jsonb_path_query SRFs $.datetime() defined ? - Mailing list pgsql-hackers

From Markur Sens
Subject How are jsonb_path_query SRFs $.datetime() defined ?
Date
Msg-id F736DFB9-F796-47EF-A101-DD6B80308A1F@gmail.com
Whole thread Raw
List pgsql-hackers
Hi,

In the regression test I see tests the one below [1], but generally, jsonb_path_query is a SRF,
and the definition in pg_proc.dat has it as such [0], looking at the implementation it doesn’t look like it calls jsonb_query_first behind the scenes (say if it detects it’s being called in  SELECT), which would explain it.

How would I re-create this same behaviour with say another $.func() in jsonb or any SRF in general.

{ oid => '4006', descr => 'jsonpath query',
proname => 'jsonb_path_query', prorows => '1000', proretset => 't',
prorettype => 'jsonb', proargtypes => 'jsonb jsonpath jsonb bool',
prosrc => 'jsonb_path_query' },


select jsonb_path_query('"10-03-2017"', '$.datetime("dd-mm-yyyy")');
jsonb_path_query
------------------
"2017-03-10"
(1 row)

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Should logtape.c blocks be of type long?
Next
From: "Karl O. Pinc"
Date:
Subject: Re: Various small doc improvements; plpgsql, schemas, permissions, oidvector