pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 3+ messages / 1 participants [nested] [flat]
* pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 @ 2024-10-20 03:40 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Langote @ 2024-10-20 03:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org SQL/JSON: Fix some oversights in commit b6e1157e7 The decision in b6e1157e7 to ignore raw_expr when evaluating a JsonValueExpr was incorrect. While its value is not ultimately used (since formatted_expr's value is), failing to initialize it can lead to problems, for instance, when the expression tree in raw_expr contains Aggref nodes, which must be initialized to ensure the parent Agg node works correctly. Also, optimize eval_const_expressions_mutator()'s handling of JsonValueExpr a bit. Currently, when formatted_expr cannot be folded into a constant, we end up processing it twice -- once directly in eval_const_expressions_mutator() and again recursively via ece_generic_processing(). This recursive processing is required to handle raw_expr. To avoid the redundant processing of formatted_expr, we now process raw_expr directly in eval_const_expressions_mutator(). Finally, update the comment of JsonValueExpr to describe the roles of raw_expr and formatted_expr more clearly. Bug: #18657 Reported-by: Alexander Lakhin <exclusion@gmail.com> Diagnosed-by: Fabio R. Sluzala <fabio3rs@gmail.com> Diagnosed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18657-1b90ccce2b16bdb8@postgresql.org Backpatch-through: 16 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fa4f11854c8b56e094c12c7c25e23d9d456cd5cb Modified Files -------------- src/backend/executor/execExpr.c | 2 ++ src/backend/optimizer/util/clauses.c | 24 ++++++++++++----- src/include/nodes/primnodes.h | 14 ++++++---- src/test/regress/expected/sqljson.out | 49 +++++++++++++++++++++++++++++++++++ src/test/regress/sql/sqljson.sql | 14 ++++++++++ 5 files changed, 92 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 @ 2024-10-20 03:40 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Langote @ 2024-10-20 03:40 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org SQL/JSON: Fix some oversights in commit b6e1157e7 The decision in b6e1157e7 to ignore raw_expr when evaluating a JsonValueExpr was incorrect. While its value is not ultimately used (since formatted_expr's value is), failing to initialize it can lead to problems, for instance, when the expression tree in raw_expr contains Aggref nodes, which must be initialized to ensure the parent Agg node works correctly. Also, optimize eval_const_expressions_mutator()'s handling of JsonValueExpr a bit. Currently, when formatted_expr cannot be folded into a constant, we end up processing it twice -- once directly in eval_const_expressions_mutator() and again recursively via ece_generic_processing(). This recursive processing is required to handle raw_expr. To avoid the redundant processing of formatted_expr, we now process raw_expr directly in eval_const_expressions_mutator(). Finally, update the comment of JsonValueExpr to describe the roles of raw_expr and formatted_expr more clearly. Bug: #18657 Reported-by: Alexander Lakhin <exclusion@gmail.com> Diagnosed-by: Fabio R. Sluzala <fabio3rs@gmail.com> Diagnosed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18657-1b90ccce2b16bdb8@postgresql.org Backpatch-through: 16 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7148cb3e3067a21f98031ff4d01be8895b5d164e Modified Files -------------- src/backend/executor/execExpr.c | 2 ++ src/backend/optimizer/util/clauses.c | 24 ++++++++++++----- src/include/nodes/primnodes.h | 14 ++++++---- src/test/regress/expected/sqljson.out | 49 +++++++++++++++++++++++++++++++++++ src/test/regress/sql/sqljson.sql | 14 ++++++++++ 5 files changed, 92 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 @ 2024-10-20 03:41 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Amit Langote @ 2024-10-20 03:41 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org SQL/JSON: Fix some oversights in commit b6e1157e7 The decision in b6e1157e7 to ignore raw_expr when evaluating a JsonValueExpr was incorrect. While its value is not ultimately used (since formatted_expr's value is), failing to initialize it can lead to problems, for instance, when the expression tree in raw_expr contains Aggref nodes, which must be initialized to ensure the parent Agg node works correctly. Also, optimize eval_const_expressions_mutator()'s handling of JsonValueExpr a bit. Currently, when formatted_expr cannot be folded into a constant, we end up processing it twice -- once directly in eval_const_expressions_mutator() and again recursively via ece_generic_processing(). This recursive processing is required to handle raw_expr. To avoid the redundant processing of formatted_expr, we now process raw_expr directly in eval_const_expressions_mutator(). Finally, update the comment of JsonValueExpr to describe the roles of raw_expr and formatted_expr more clearly. Bug: #18657 Reported-by: Alexander Lakhin <exclusion@gmail.com> Diagnosed-by: Fabio R. Sluzala <fabio3rs@gmail.com> Diagnosed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18657-1b90ccce2b16bdb8@postgresql.org Backpatch-through: 16 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/11c87216d134a606938531e52edab6189bce6c2d Modified Files -------------- src/backend/executor/execExpr.c | 2 ++ src/backend/optimizer/util/clauses.c | 24 ++++++++++++----- src/include/nodes/primnodes.h | 14 ++++++---- src/test/regress/expected/sqljson.out | 49 +++++++++++++++++++++++++++++++++++ src/test/regress/sql/sqljson.sql | 14 ++++++++++ 5 files changed, 92 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-10-20 03:41 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-10-20 03:40 pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 Amit Langote <amitlan@postgresql.org> 2024-10-20 03:40 pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 Amit Langote <amitlan@postgresql.org> 2024-10-20 03:41 pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7 Amit Langote <amitlan@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox