Re: making the backend's json parser work in frontend code
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: David Steele <david@pgmasters.net>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-01-22T19:57:01Z
Lists: pgsql-hackers
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. 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 I'm not wedded to that. It just looks like the most natural thing from where we are now. Thoughts? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Add jsonapi.c to Mkvcbuild.pm's @pgcommonallfiles.
- 006b9dcad419 13.0 landed
-
Move jsonapi.c and jsonapi.h to src/common.
- beb4699091e9 13.0 landed
-
Move some code from jsonapi.c to jsonfuncs.c.
- 73ce2a03f30b 13.0 landed
-
Adjust pg_parse_json() so that it does not directly ereport().
- 1f3a021730be 13.0 landed
-
Remove jsonapi.c's lex_accept().
- 530609aa4263 13.0 landed
-
Split JSON lexer/parser from 'json' data type support.
- 11b5e3e35d39 13.0 landed
-
Rationalize code placement between wchar.c, encnames.c, and mbutils.c.
- 5afaa2e42655 13.0 landed
-
Move wchar.c and encnames.c to src/common/.
- e6afa8918c46 13.0 landed
-
Update header comments for wchar.c and encnames.c.
- 3d4cb5d6c180 13.0 landed
-
Make StringInfo available to frontend code.
- 26aaf97b683d 13.0 cited
-
Use SASLprep to normalize passwords for SCRAM authentication.
- 60f11b87a234 10.0 cited