On 2020-Jan-22, Robert Haas wrote:
> On Wed, Jan 22, 2020 at 2:26 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> > I'm not sure I see the point of keeping json.h split from jsonapi.h. It
> > seems to me that you could move back all the contents from jsonapi.h
> > into json.h, and everything would work just as well. (Evidently the
> > Datum in JsonEncodeDateTime's proto is problematic ... perhaps putting
> > that prototype in jsonfuncs.h would work.)
> >
> > I don't really object to your 0001 patch as posted, though.
>
> The goal is to make it possible to use the JSON parser in the
> frontend, and we can't do that if the header files that would have to
> be included on the frontend side rely on things that only work in the
> backend. As written, the patch series leaves json.h with a dependency
> on Datum, so the stuff that it leaves in jsonapi.h (which is intended
> to be the header that gets moved to src/common and included by
> frontend code) can't be merged with it.
Right, I agree with that goal, and as I said, I don't object to your
patch as posted.
> Now, we could obviously rearrange that. I don't think any of the file
> naming here is great. But I think we probably want, as far as
> possible, for the code in FOO.c to correspond to the prototypes in
> FOO.h. What I'm thinking we should work towards is:
>
> json.c/h - support for the 'json' data type
> jsonb.c/h - support for the 'jsonb' data type
> jsonfuncs.c/h - backend code that doesn't fit in either of the above
> jsonapi.c/h - lexing/parsing code that can be used in either the
> frontend or the backend
... it would probably require more work to make this 100% attainable,
but I don't really care all that much.
> I'm not wedded to that. It just looks like the most natural thing from
> where we are now.
Let's go with it.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services