Re: making the backend's json parser work in frontend code
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-01-16T21:24:42Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes: > On Thu, Jan 16, 2020 at 3:11 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Here's a reviewed version of 0001. You missed fixing the MSVC build, >> and there were assorted comments and other things referencing wchar.c >> that needed to be cleaned up. > Wow, thanks. Pushed that. >> Another thing I'm wondering about is if any of the #ifndef FRONTEND >> code should get moved *back* to src/backend/utils/mb. But that >> could be a separate commit, too. > +1 for moving that stuff to a separate backend-only file. After a brief look, I propose the following: * I think we should just shove the "#ifndef FRONTEND" stuff in wchar.c into mbutils.c. It doesn't seem worth inventing a whole new file for that code, especially when it's arguably within the remit of mbutils.c anyway. * Let's remove the "#ifndef FRONTEND" restriction on the ICU-related stuff in encnames.c. Even if we don't need that stuff in frontend today, it's hardly unlikely that we will need it tomorrow. And there's not that much bulk there anyway. * The one positive reason for that restriction is the ereport() in get_encoding_name_for_icu. We could change that to be the usual #ifdef-ereport-or-printf dance, but I think there's a better way: put the ereport at the caller, by redefining that function to return NULL for an unsupported encoding. There's only one caller today anyhow. * PG_char_to_encoding() and PG_encoding_to_char() can be moved to mbutils.c; they'd fit reasonably well beside getdatabaseencoding and pg_client_encoding. (I also thought about utils/adt/misc.c, but that's not obviously better.) Barring objections I'll go make this happen shortly. >> Lastly, it strikes me that maybe pg_wchar.h, or parts of it, should >> migrate over to src/include/common. But that'd be far more invasive >> to other source files, so I've not touched the issue here. > I don't have a view on this. If anyone is hot to do this part, please have at it. I'm not. regards, tom lane
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