From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: sql/json remaining issue |
Date: | 2024-04-15 12:46:31 |
Message-ID: | CA+HiwqEWEYCvR9tHDgHcgA1ex6AbZKxB16uCa2eUNr6LFjxUMg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Sat, Apr 13, 2024 at 11:12 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> On Fri, Apr 12, 2024 at 5:44 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> >
> > > elog(ERROR, "unrecognized json wrapper %d", wrapper);
> > > should be
> > > elog(ERROR, "unrecognized json wrapper %d", (int) wrapper);
> >
> > Fixed in 0003.
> >
> the fix seems not in 0003?
> other than that, everything looks fine.
>
>
> <programlisting>
> SELECT * FROM JSON_TABLE (
> '{"favorites":
> {"movies":
> [{"name": "One", "director": "John Doe"},
> {"name": "Two", "director": "Don Joe"}],
> "books":
> [{"name": "Mystery", "authors": [{"name": "Brown Dan"}]},
> {"name": "Wonder", "authors": [{"name": "Jun Murakami"},
> {"name":"Craig Doe"}]}]
> }}'::json, '$.favs[*]'
> COLUMNS (user_id FOR ORDINALITY,
> NESTED '$.movies[*]'
> COLUMNS (
> movie_id FOR ORDINALITY,
> mname text PATH '$.name',
> director text),
> NESTED '$.books[*]'
> COLUMNS (
> book_id FOR ORDINALITY,
> bname text PATH '$.name',
> NESTED '$.authors[*]'
> COLUMNS (
> author_id FOR ORDINALITY,
> author_name text PATH '$.name'))));
> </programlisting>
>
> I actually did run the query, it returns null.
> '$.favs[*]'
> should be
> '$.favorites[*]'
Oops, fixed.
I've combined these patches into one -- attached 0001. Will push tomorrow.
> one more minor thing, I previously mentioned in getJsonPathVariable
> ereport(ERROR,
> (errcode(ERRCODE_UNDEFINED_OBJECT),
> errmsg("could not find jsonpath variable \"%s\"",
> pnstrdup(varName, varNameLength))));
>
> do we need to remove pnstrdup?
Looking at this again, it seems like that's necessary because varName,
being a string extracted from JsonPathItem, is not necessarily
null-terminated. There are many pndstrdup()s in jsonpath_exec.c
because of that aspect.
Now studying the JsonBehavior DEFAULT expression issue and your patch.
--
Thanks, Amit Langote
Attachment | Content-Type | Size |
---|---|---|
v4-0001-SQL-JSON-Miscellaneous-fixes-and-improvements.patch | application/octet-stream | 18.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bertrand Drouvot | 2024-04-15 12:51:05 | Re: promotion related handling in pg_sync_replication_slots() |
Previous Message | Daniel Gustafsson | 2024-04-15 12:25:45 | Re: Typos in the code and README |