Show json field name instead of ?column? - Mailing list pgsql-hackers

From Chao Li
Subject Show json field name instead of ?column?
Date
Msg-id CAEoWx2mtGd12bLpPXPGOWX3p8iUiRefbMdbN-q72NU7jPsSCtA@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi Hackers,

While reviewing Json Simplified Accessor Support [1], I noticed that with the new accessor, it will show the actual json field name, for example:
```
evantest=# select (j).b.c from ttt;
 c
----

 20
(2 rows)
```

"c" is the last segment of the accessor, so the column name shows as "c".

While now "->" and "->" operators will show "?column?" as column names when accessing Json fields. It had been my concern for many years when I was a PG user. Now as I started to work on PG itself, I want to change that.

With this PoC patch, it will also use the last segment of an accessor path as field name:
```
evantest=# select j->'b'->'c' from ttt;
 c
----

 20
(2 rows)

evantest=# select j#>array['b','c'] from ttt;
 c
----

 20
(2 rows)
```

But this patch has not handled case of:
```
evantest=# select j#>'{b,c}' from ttt;
 ?column?
----------

 20
(2 rows)
```

Because I don't find an existing function to parse '{b,c}' to an array as it is the parse phase, array_int() is not usable.

This patch is not ready for review, code is not polished, tests are not updated. I just want to throw out the idea first to see any interest and objection.


Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: allow benign typedef redefinitions (C11)
Next
From: Masahiko Sawada
Date:
Subject: Re: Support getrandom() for pg_strong_random() source