Re: making the backend's json parser work in frontend code
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Bruce Momjian <bruce@momjian.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Mark Dilger <mark.dilger@enterprisedb.com>, David Steele <david@pgmasters.net>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-01-23T19:00:23Z
Lists: pgsql-hackers
On Thu, Jan 23, 2020 at 1:22 PM Bruce Momjian <bruce@momjian.us> wrote: > Yes, good point. I think my one concern is that someone might specify > both keys in the JSON, which would be very odd. I think that if a tool other than PostgreSQL chooses to generate a PostreSQL backup manifest, it must take care to do it in a manner that is compatible with what PostgreSQL would generate. If it doesn't, well, that sucks for them, but we can't prevent other people from writing bad code. On a very good day, we can prevent ourselves from writing bad code. There is in general the question of how rigorous PostgreSQL ought to be when validating a backup manifest. The proposal on the table is to store four (4) fields per file: name, size, last modification time, and checksum. So a JSON object representing a file should have four keys, say "path", "size", "mtime", and "checksum". The "checksum" key could perhaps be optional, in case the user disables checksums, or we could represent that case in some other way, like "checksum" => null, "checksum" => "", or "checksum" => "NONE". There is an almost unlimited scope for bike-shedding here, but let's leave that to one side for the moment. Suppose that someone asks PostgreSQL's backup manifest verification tool to validate a backup manifest where there's an extra key. Say, in addition to the four keys listed in the previous paragraph, there is an additional key, "momjian". On the one hand, our backup manifest verification tool could take this as a sign that the manifest is invalid, and accordingly throw an error. Or, it could assume that some third-party backup tool generated the backup manifest and that the "momjian" field is there to track something which is of interest to that tool but not to PostgreSQL core, in which case it should just be ignored. Incidentally, some research seems to suggest that the problem of filenames which don't form a valid UTF-8 sequence cannot occur on Windows. This blog post may be helpful in understanding the issues: http://beets.io/blog/paths.html -- 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