Re: json api WIP patch

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: json api WIP patch
Date: 2013-01-10 23:42:09
Message-ID: 50EF51D1.7020507@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 01/04/2013 03:23 PM, Andrew Dunstan wrote:
>
> On 01/02/2013 05:51 PM, Andrew Dunstan wrote:
>>
>> On 01/02/2013 04:45 PM, Robert Haas wrote:
>>> On Wed, Dec 26, 2012 at 3:33 PM, Andrew Dunstan
>>> <andrew(at)dunslane(dot)net> wrote:
>>>> Here is a patch for the first part of the JSON API that was recently
>>>> discussed. It includes the json parser hook infrastructure and
>>>> functions
>>>> for json_get and friends, plus json_keys.
>
>
> Udated patch that contains most of the functionality I'm after. One
> piece left is populate_recordset (populate a set of records from a
> single json datum which is an array of objects, in one pass). That
> requires a bit of thought.
>
> I hope most of the whitespace issues are fixed.
>
>

This updated patch contains all the intended functionality, including
operators for the json_get_path functions, so you can say things like

select jsonval->array['f1','0','f2] ...

It also removes any requirement to copy the json value before setting up
the lexer by removing the lexer's requirement to have a nul terminated
string. Instead the lexer is told the input length and relies on that.
For this reason, json_in() now calls cstring_get_text() before rather
than after calling the validation routine, but that's really not
something worth bothering about.

A couple of points worth noting: it's a pity that we have to run CREATE
OR REPLACE FUNCTION in system_views.sql in order to set up default
values for builtin functions. That feels very kludgy. Also, making
operators for variadic functions is a bit of a pain. I had to set up
non-variadic version of the same functions (see json_get_path_op and
json_get_path_as_text_op) just so I could set up the operators. Neither
of these are exactly showstopper items, just mild annoyances.

I will continue hunting memory leaks, but when Merlin gets done with
docco I think we'll be far enough advanced to add this to the commitfest.

cheers

andrew

Attachment Content-Type Size
jsonapi4.patch text/x-patch 113.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2013-01-11 00:14:53 Re: Reducing size of WAL record headers
Previous Message Tom Lane 2013-01-10 22:30:30 Re: PL/perl should fail on configure, not make