From: | David Steele <david(at)pgmasters(dot)net> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: making the backend's json parser work in frontend code |
Date: | 2020-01-17 17:36:26 |
Message-ID: | f7a23062-18d6-8aa3-e168-23f5bc38652a@pgmasters.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Robert,
On 1/16/20 11:51 AM, Robert Haas wrote:
> On Thu, Jan 16, 2020 at 1:37 PM David Steele <david(at)pgmasters(dot)net> wrote:
>
>> The next question in my mind is given the caveat that the error handing
>> is questionable in the front end, can we at least render/parse valid
>> JSON with the code?
>
> That's a real good question. Thanks for offering to test it; I think
> that would be very helpful.
It seems to work just fine. I didn't stress it too hard but I did put
in one escape and a multi-byte character and check the various data types.
Attached is a test hack on pg_basebackup which produces this output:
START
FIELD "number", null 0
SCALAR TYPE 2: 123
FIELD "string", null 0
SCALAR TYPE 1: val ue-丏
FIELD "bool", null 0
SCALAR TYPE 9: true
FIELD "null", null 1
SCALAR TYPE 11: null
END
I used the callbacks because that's the first method I found but it
seems like json_lex() might be easier to use in practice.
I think it's an issue that the entire string must be passed to the lexer
at once. That will not be great for large manifests. However, I don't
think it will be all that hard to implement an optional "want more"
callback in the lexer so JSON data can be fed in from the file in chunks.
So, that just leaves ereport() as the largest remaining issue? I'll
look at that today and Tuesday and see what I can work up.
Regards,
--
-David
david(at)pgmasters(dot)net
Attachment | Content-Type | Size |
---|---|---|
json-api-client-test.diff | text/plain | 1.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | David Steele | 2020-01-17 17:41:10 | Re: making the backend's json parser work in frontend code |
Previous Message | Dave Cramer | 2020-01-17 17:26:41 | Re: Binary support for pgoutput plugin |