Re: making the backend's json parser work in frontend code

Поиск
Список
Период
Сортировка
От David Steele
Тема Re: making the backend's json parser work in frontend code
Дата
Msg-id f7a23062-18d6-8aa3-e168-23f5bc38652a@pgmasters.net
обсуждение исходный текст
Ответ на Re: making the backend's json parser work in frontend code  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: making the backend's json parser work in frontend code
Список 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@pgmasters.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@pgmasters.net

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Binary support for pgoutput plugin
Следующее
От: David Steele
Дата:
Сообщение: Re: making the backend's json parser work in frontend code