Re: Add CREATE support to event triggers - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add CREATE support to event triggers
Date
Msg-id CAB7nPqTP754LSDpNWi7mbaqE47-jUHdLa_BuKigwiEY2SA6SUQ@mail.gmail.com
Whole thread Raw
In response to Re: Add CREATE support to event triggers  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Add CREATE support to event triggers
List pgsql-hackers
On Thu, Oct 30, 2014 at 2:40 AM, Robert Haas <robertmhaas@gmail.com> wrote:
On Tue, Oct 28, 2014 at 6:00 AM, Andres Freund <andres@2ndquadrant.com> wrote:
>> Uhm.  Obviously we didn't have jsonb when I started this and we do have
>> them now, so I could perhaps see about updating the patch to do things
>> this way; but I'm not totally sold on that idea, as my ObjTree stuff is
>> a lot easier to manage and the jsonb API is pretty ugly.
>
> I looked at this as well, and I think trying to do so would not result
> in readable code.

That doesn't speak very well of jsonb.  :-(
 
Just did the same and I played a bit with the APIs. And I am getting the impression that the jsonb API is currently focused on the fact of deparsing and parsing Jsonb strings to/from containers but there is no real interface that allows to easily manipulate the containers where the values are located. So, what I think is missing is really a friendly interface to manipulate JsonbContainers directly, and I think that we are not far from it with something like this set, roughly:
- Initialization of an empty container
- Set of APIs to directly push a value to a container (boolean, array, null, string, numeric or other jsonb object)
- Initialization of JsonbValue objects
With this basic set of APIs patch 4 could for example use JsonbToCString to then convert the JSONB bucket back to a string it sends to client. Note as well that there is already findJsonbValueFromContainer present to get back a value in a container.

In short, my point is: instead of re-creating the wheel like what this series of patch is trying to do with ObjTree, I think that it would be more fruitful to have a more solid in-place JSONB infrastructure that allows to directly manipulate JSONB objects. This feature as well as future extensions could benefit from that.
Feel free to comment.
Regards,
--
Michael

pgsql-hackers by date:

Previous
From: Fabrízio de Royes Mello
Date:
Subject: Re: CREATE IF NOT EXISTS INDEX
Next
From: Andrew Dunstan
Date:
Subject: Re: TAP test breakage on MacOS X