Thread: pgsql: Common SQL/JSON clauses
Common SQL/JSON clauses This introduces some of the building blocks used by the SQL/JSON constructor and query functions. Specifically, it provides node executor and grammar support for the FORMAT JSON [ENCODING foo] clause, and values decorated with it, and for the RETURNING clause. The following SQL/JSON patches will leverage these. Nikita Glukhov (who probably deserves an award for perseverance). Reviewers have included (in no particular order) Andres Freund, Alexander Korotkov, Pavel Stehule, Andrew Alsup. Erik Rijkers, Zihong Yu and Himanshu Upadhyaya. Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/865fe4d5df560a6f5353da652018ff876978ad2d Modified Files -------------- src/backend/executor/execExpr.c | 22 +++++ src/backend/nodes/copyfuncs.c | 55 +++++++++++ src/backend/nodes/equalfuncs.c | 39 ++++++++ src/backend/nodes/makefuncs.c | 54 +++++++++++ src/backend/nodes/nodeFuncs.c | 66 +++++++++++++ src/backend/nodes/outfuncs.c | 39 ++++++++ src/backend/nodes/readfuncs.c | 51 ++++++++++ src/backend/optimizer/util/clauses.c | 23 +++++ src/backend/parser/gram.y | 65 ++++++++++++- src/backend/parser/parse_expr.c | 181 +++++++++++++++++++++++++++++++++++ src/backend/utils/adt/ruleutils.c | 56 +++++++++++ src/backend/utils/misc/queryjumble.c | 26 +++++ src/include/nodes/makefuncs.h | 5 + src/include/nodes/nodes.h | 4 + src/include/nodes/parsenodes.h | 13 +++ src/include/nodes/primnodes.h | 59 ++++++++++++ src/include/parser/kwlist.h | 2 + 17 files changed, 758 insertions(+), 2 deletions(-)
Hi, On 2022-03-22 21:34:25 +0000, Andrew Dunstan wrote: > Common SQL/JSON clauses > > This introduces some of the building blocks used by the SQL/JSON > constructor and query functions. Specifically, it provides node > executor and grammar support for the FORMAT JSON [ENCODING foo] > clause, and values decorated with it, and for the RETURNING clause. > > The following SQL/JSON patches will leverage these. This currently triggers a number of warnings. I assume that's because of the following patches not being there yet? How far out are those? /home/andres/src/postgresql/src/backend/parser/gram.y: warning: 6 nonterminals useless in grammar [-Wother] /home/andres/src/postgresql/src/backend/parser/gram.y: warning: 9 rules useless in grammar [-Wother] /home/andres/src/postgresql/src/backend/parser/gram.y:15249.1-15: warning: nonterminal useless in grammar: json_value_expr[-Wother] 15249 | json_value_expr: | ^~~~~~~~~~~~~~~ /home/andres/src/postgresql/src/backend/parser/gram.y:15256.1-22: warning: nonterminal useless in grammar: json_format_clause_opt[-Wother] 15256 | json_format_clause_opt: | ^~~~~~~~~~~~~~~~~~~~~~ /home/andres/src/postgresql/src/backend/parser/gram.y:15268.1-19: warning: nonterminal useless in grammar: json_representation[-Wother] 15268 | json_representation: | ^~~~~~~~~~~~~~~~~~~ /home/andres/src/postgresql/src/backend/parser/gram.y:15276.1-24: warning: nonterminal useless in grammar: json_encoding_clause_opt[-Wother] 15276 | json_encoding_clause_opt: | ^~~~~~~~~~~~~~~~~~~~~~~~ /home/andres/src/postgresql/src/backend/parser/gram.y:15281.1-13: warning: nonterminal useless in grammar: json_encoding[-Wother] 15281 | json_encoding: | ^~~~~~~~~~~~~ /home/andres/src/postgresql/src/backend/parser/gram.y:15285.1-22: warning: nonterminal useless in grammar: json_output_clause_opt[-Wother] 15285 | json_output_clause_opt: | ^~~~~~~~~~~~~~~~~~~~~~ Greetings, Andres Freund
On 3/22/22 18:33, Andres Freund wrote: > Hi, > > On 2022-03-22 21:34:25 +0000, Andrew Dunstan wrote: >> Common SQL/JSON clauses >> >> This introduces some of the building blocks used by the SQL/JSON >> constructor and query functions. Specifically, it provides node >> executor and grammar support for the FORMAT JSON [ENCODING foo] >> clause, and values decorated with it, and for the RETURNING clause. >> >> The following SQL/JSON patches will leverage these. > This currently triggers a number of warnings. I assume that's because of the > following patches not being there yet? How far out are those? > Tomorrow, with the SQL/JSON constructors patch should resolve it. So roughly 24 hours. It's not his fault but this happened because Alvaro asked me to stagger the commits. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
Andrew Dunstan <andrew@dunslane.net> writes: > On 3/22/22 18:33, Andres Freund wrote: >> This currently triggers a number of warnings. I assume that's because of the >> following patches not being there yet? How far out are those? > Tomorrow, with the SQL/JSON constructors patch should resolve it. So > roughly 24 hours. It's not his fault but this happened because Alvaro > asked me to stagger the commits. Sounds like all you have to do is merge this commit with the next one in the series? Might as well do it if so. But please don't push something that generates warnings. regards, tom lane
On 2022-Mar-22, Andrew Dunstan wrote: > Tomorrow, with the SQL/JSON constructors patch should resolve it. So > roughly 24 hours. It's not his fault but this happened because Alvaro > asked me to stagger the commits. Ouch, yeah. This kind of problem can be observed by using something like git rebase -i origin/master -x "make install" this will generate a rebase "todo list" that includes a "make install" step after each individual commit, so you can verify that each commit is warning-clean. (By default there is no pause after each commit if there is a failure; my strategy for dealing with that is to change each patch in the rebase-todo-list from "pick" to "edit", so I can fix any problems, add them to the commit, then continue the rebase.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "En las profundidades de nuestro inconsciente hay una obsesiva necesidad de un universo lógico y coherente. Pero el universo real se halla siempre un paso más allá de la lógica" (Irulan)
On 3/22/22 20:08, Tom Lane wrote: > Andrew Dunstan <andrew@dunslane.net> writes: >> On 3/22/22 18:33, Andres Freund wrote: >>> This currently triggers a number of warnings. I assume that's because of the >>> following patches not being there yet? How far out are those? >> Tomorrow, with the SQL/JSON constructors patch should resolve it. So >> roughly 24 hours. It's not his fault but this happened because Alvaro >> asked me to stagger the commits. > Sounds like all you have to do is merge this commit with the next > one in the series? Might as well do it if so. But please don't > push something that generates warnings. > > Yes, mea maxima culpa. I am working on a newer development machine than the one I have used for years and I forgot to add check_warnings to the test setup. That's remedied now. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com