How are jsonb_path_query SRFs $.datetime() defined ?

From: Markur Sens <markursens(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: How are jsonb_path_query SRFs $.datetime() defined ?
Date: 2023-09-26 04:19:06
Message-ID: F736DFB9-F796-47EF-A101-DD6B80308A1F@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

Browse pgsql-hackers by date

  From Date Subject
Next Message Karl O. Pinc 2023-09-26 04:30:38 Re: Various small doc improvements; plpgsql, schemas, permissions, oidvector
Previous Message Michael Paquier 2023-09-26 04:15:03 Re: [HACKERS] Should logtape.c blocks be of type long?