pgsql: Remove duplicate line

2025-07-16 Thread Amit Langote
Remove duplicate line In 231b7d670b21, while copy-pasting some code into ExecEvalJsonCoercionFinish(), I (amitlan) accidentally introduced a duplicate line. Remove it. Reported-by: Jian He Discussion: https://postgr.es/m/CACJufxHcf=bpmrajcjgfjoufv76mwknyz1x3erxswl26eaf...@mail.gmail.com Branc

pgsql: Remove duplicate line

2025-07-16 Thread Amit Langote
Remove duplicate line In 231b7d670b21, while copy-pasting some code into ExecEvalJsonCoercionFinish(), I (amitlan) accidentally introduced a duplicate line. Remove it. Reported-by: Jian He Discussion: https://postgr.es/m/CACJufxHcf=bpmrajcjgfjoufv76mwknyz1x3erxswl26eaf...@mail.gmail.com Branc

pgsql: Remove duplicate line

2025-07-16 Thread Amit Langote
Remove duplicate line In 231b7d670b21, while copy-pasting some code into ExecEvalJsonCoercionFinish(), I (amitlan) accidentally introduced a duplicate line. Remove it. Reported-by: Jian He Discussion: https://postgr.es/m/CACJufxHcf=bpmrajcjgfjoufv76mwknyz1x3erxswl26eaf...@mail.gmail.com Branc

pgsql: Fix typos in comments

2025-07-01 Thread Amit Langote
Fix typos in comments Commit 19d8e2308bc added enum values with the prefix TU_, but a few comments still referred to TUUI_, which was used in development versions of the patches committed as 19d8e2308bc. Author: Yugo Nagata Discussion: https://postgr.es/m/20250701110216.8ac8a9e4c6f607f1d954f...

pgsql: Fix typos in comments

2025-07-01 Thread Amit Langote
Fix typos in comments Commit 19d8e2308bc added enum values with the prefix TU_, but a few comments still referred to TUUI_, which was used in development versions of the patches committed as 19d8e2308bc. Author: Yugo Nagata Discussion: https://postgr.es/m/20250701110216.8ac8a9e4c6f607f1d954f...

pgsql: Fix typos in comments

2025-07-01 Thread Amit Langote
Fix typos in comments Commit 19d8e2308bc added enum values with the prefix TU_, but a few comments still referred to TUUI_, which was used in development versions of the patches committed as 19d8e2308bc. Author: Yugo Nagata Discussion: https://postgr.es/m/20250701110216.8ac8a9e4c6f607f1d954f...

pgsql: Fix typos in comments

2025-07-01 Thread Amit Langote
Fix typos in comments Commit 19d8e2308bc added enum values with the prefix TU_, but a few comments still referred to TUUI_, which was used in development versions of the patches committed as 19d8e2308bc. Author: Yugo Nagata Discussion: https://postgr.es/m/20250701110216.8ac8a9e4c6f607f1d954f...

pgsql: Revert "Don't lock partitions pruned by initial pruning"

2025-05-22 Thread Amit Langote
Revert "Don't lock partitions pruned by initial pruning" As pointed out by Tom Lane, the patch introduced fragile and invasive design around plan invalidation handling when locking of prunable partitions was deferred from plancache.c to the executor. In particular, it violated assumptions about Ca

pgsql: Add assertion to verify derived clause has constant RHS

2025-04-03 Thread Amit Langote
generate_base_implied_equalities_const(). Author: Ashutosh Bapat Reviewed-by: Amit Langote Discussion: https://postgr.es/m/caexhw5scmxyfrqofe6odmbiw2rnvbemeeca-p4w_cyueiku...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/887160d1beaec607187261ab1a9411040da3d7b5

pgsql: Make derived clause lookup in EquivalenceClass more efficient

2025-04-03 Thread Amit Langote
This design incorporates suggestions by David Rowley, who proposed both the key canonicalization and the initial sizing approach to balance memory usage and CPU efficiency. Author: Ashutosh Bapat Reviewed-by: Amit Langote Reviewed-by: David Rowley Tested-by: Dmitry Dolgov <9erthali...@g

pgsql: Ensure first ModifyTable rel initialized if all are pruned

2025-03-18 Thread Amit Langote
Ensure first ModifyTable rel initialized if all are pruned Commit cbc127917e introduced tracking of unpruned relids to avoid processing pruned relations, and changed ExecInitModifyTable() to initialize only unpruned result relations. As a result, MERGE statements that prune all target partitions c

pgsql: Fix copy-paste error in datum_to_jsonb_internal()

2025-03-12 Thread Amit Langote
Fix copy-paste error in datum_to_jsonb_internal() Commit 3c152a27b06 mistakenly repeated JSONTYPE_JSON in a condition, omitting JSONTYPE_CAST. As a result, datum_to_jsonb_internal() failed to reject inputs that were casts (e.g., from an enum to json as in the example below) when used as keys in JS

pgsql: Fix copy-paste error in datum_to_jsonb_internal()

2025-03-12 Thread Amit Langote
Fix copy-paste error in datum_to_jsonb_internal() Commit 3c152a27b06 mistakenly repeated JSONTYPE_JSON in a condition, omitting JSONTYPE_CAST. As a result, datum_to_jsonb_internal() failed to reject inputs that were casts (e.g., from an enum to json as in the example below) when used as keys in JS

Re: pgsql: Track unpruned relids to avoid processing pruned relations

2025-03-03 Thread Amit Langote
On Mon, Mar 3, 2025 at 6:33 PM Robins Tharakan wrote: > On Fri, 7 Feb 2025 at 18:45, Amit Langote wrote: >> >> Track unpruned relids to avoid processing pruned relations >> > > Since this change, the SQL in the bug-report #18830 [1] segfaults reliably. > > T

pgsql: Fix bug in cbc127917 to handle nested Append correctly

2025-02-24 Thread Amit Langote
Fix bug in cbc127917 to handle nested Append correctly A non-leaf partition with a subplan that is an Append node was omitted from PlannedStmt.unprunableRelids because it was mistakenly included in PlannerGlobal.prunableRelids due to the way PartitionedRelPruneInfo.leafpart_rti_map[] is constructe

pgsql: Remove unstable test suite added by 525392d57

2025-02-21 Thread Amit Langote
Remove unstable test suite added by 525392d57 The 'cached-plan-inval' test suite, introduced in 525392d57 under src/test/modules/delay_execution, aimed to verify that cached plan invalidation triggers replanning after deferred locks are taken. However, its ExecutorStart_hook-based approach relies

pgsql: Don't lock partitions pruned by initial pruning

2025-02-20 Thread Amit Langote
Don't lock partitions pruned by initial pruning Before executing a cached generic plan, AcquireExecutorLocks() in plancache.c locks all relations in a plan's range table to ensure the plan is safe for execution. However, this locks runtime-prunable relations that will later be pruned during "initi

Re: pgsql: doc: Fix some issues with JSON_TABLE() exampls

2025-02-19 Thread Amit Langote
On Wed, Feb 19, 2025 at 3:33 PM Amit Langote wrote: > doc: Fix some issues with JSON_TABLE() exampls > > 1. Remove an unused PASSING variable. > > 2. Adjust formatting of JSON data used in an example to be valid > under strict mode > > Reported-by: Miłosz Chmura

pgsql: doc: Fix some issues with JSON_TABLE() examples

2025-02-18 Thread Amit Langote
doc: Fix some issues with JSON_TABLE() examples 1. Remove an unused PASSING variable. 2. Adjust formatting of JSON data used in an example to be valid under strict mode Reported-by: Miłosz Chmura Author: Robert Treat Discussion: https://postgr.es/m/173859550337.1071.4748984213168572...@

pgsql: doc: Fix some issues with JSON_TABLE() exampls

2025-02-18 Thread Amit Langote
doc: Fix some issues with JSON_TABLE() exampls 1. Remove an unused PASSING variable. 2. Adjust formatting of JSON data used in an example to be valid under strict mode Reported-by: Miłosz Chmura Author: Robert Treat Discussion: https://postgr.es/m/173859550337.1071.4748984213168572...@w

pgsql: Fix an oversight in cbc127917 to handle MERGE correctly

2025-02-16 Thread Amit Langote
Fix an oversight in cbc127917 to handle MERGE correctly ExecInitModifyTable() forgot to trim MERGE-related lists to exclude entries for result relations pruned during initial pruning, so fix that. While at it, make the function's use of the pruned resultRelations list, rather than ModifyTable.res

pgsql: Track unpruned relids to avoid processing pruned relations

2025-02-07 Thread Amit Langote
Track unpruned relids to avoid processing pruned relations This commit introduces changes to track unpruned relations explicitly, making it possible for top-level plan nodes, such as ModifyTable and LockRows, to avoid processing partitions pruned during initial pruning. Scan-level nodes, such as

pgsql: Add commit 76aa615943 to .git-blame-ignore-revs

2025-01-31 Thread Amit Langote
Add commit 76aa615943 to .git-blame-ignore-revs Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/79e872fedb4d2f73baa0a80ba572480774edc61b Modified Files -- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+)

pgsql: Fix bad indentation introduced in commit d47cbf474

2025-01-30 Thread Amit Langote
Fix bad indentation introduced in commit d47cbf474 Per buildfarm member koel Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/76aa615943049c04efd36ab4765c06eda89cdfea Modified Files -- src/backend/executor/execPartition.c | 6 +++--- 1 file changed, 3 ins

pgsql: Perform runtime initial pruning outside ExecInitNode()

2025-01-30 Thread Amit Langote
Perform runtime initial pruning outside ExecInitNode() This commit builds on the prior change that moved PartitionPruneInfos out of individual plan nodes into a list in PlannedStmt, making it possible to initialize PartitionPruneStates without traversing the plan tree and perform runtime initial p

pgsql: Move PartitionPruneInfo out of plan nodes into PlannedStmt

2025-01-29 Thread Amit Langote
Move PartitionPruneInfo out of plan nodes into PlannedStmt This moves PartitionPruneInfo from plan nodes to PlannedStmt, simplifying traversal by centralizing all PartitionPruneInfo structures in a single list in it, which holds all instances for the main query and its subqueries. Instead of plan

pgsql: Refactor ExecScan() to allow inlining of its core logic

2025-01-20 Thread Amit Langote
Refactor ExecScan() to allow inlining of its core logic This commit refactors ExecScan() by moving its tuple-fetching, filtering, and projection logic into an inline-able function, ExecScanExtended(), defined in src/include/executor/execScan.h. ExecScanExtended() accepts parameters for EvalPlanQua

pgsql: Add missing word in comment

2024-11-12 Thread Amit Langote
Add missing word in comment Discussion: https://postgr.es/m/CA+HiwqFgdp8=0_gi+du0fpwzbg7qy3kz_c1wj1devzxc4bc...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/bfeeb065ea2c870cf4d9dfcd552d23d72432e692 Modified Files -- src/include/storag

Re: pgsql: Fix broken collate.icu.utf8 test in v12 branch.

2024-11-11 Thread Amit Langote
t that it was broken. > We didn't have enable_incremental_sort in v12, plus EXPLAIN makes > different table alias choices than later branches. Sorry for the blunder, and thank you for taking care of it. -- Thanks, Amit Langote

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise join when collations don't match

2024-11-08 Thread Amit Langote
Disallow partitionwise join when collations don't match If the collation of any join key column doesn’t match the collation of the corresponding partition key, partitionwise joins can yield incorrect results. For example, rows that would match under the join key collation might be located in diffe

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: Remove unnecessary word in a comment

2024-10-23 Thread Amit Langote
Remove unnecessary word in a comment Relations opened by the executor are only closed once in ExecCloseRangeTableRelations(), so the word "again" in the comment for ExecGetRangeTableRelation() is misleading and unnecessary. Discussion: https://postgr.es/m/CA+HiwqHnw-zR+u060i3jp4ky5UR0CjByRFQz50o

pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7

2024-10-19 Thread Amit Langote
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

pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7

2024-10-19 Thread Amit Langote
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

pgsql: SQL/JSON: Fix some oversights in commit b6e1157e7

2024-10-19 Thread Amit Langote
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

Re: pgsql: Fix typo in comment of transformJsonAggConstructor()

2024-10-16 Thread Amit Langote
On Wed, Oct 16, 2024 at 8:39 PM Amit Langote wrote: > > Fix typo in comment of transformJsonAggConstructor() > > An oversight of 3a8a1f3254b. > > Reported-by: Tender Wang > Author: Tender Wang > Backpatch-through: 16 Sorry, I forgot to put the Discussion link: ht

pgsql: Fix typo in comment of transformJsonAggConstructor()

2024-10-16 Thread Amit Langote
Fix typo in comment of transformJsonAggConstructor() An oversight of 3a8a1f3254b. Reported-by: Tender Wang Author: Tender Wang Backpatch-through: 16 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c259b1578e006b2f808595fac4d8e45c5cce9d73 Modified Files -

pgsql: Fix typo in comment of transformJsonAggConstructor()

2024-10-16 Thread Amit Langote
Fix typo in comment of transformJsonAggConstructor() An oversight of 3a8a1f3254b. Reported-by: Tender Wang Author: Tender Wang Backpatch-through: 16 Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/064e04008533b2b8a82b5dbff7da10abd6e41565 Modified Files --

pgsql: Fix typo in comment of transformJsonAggConstructor()

2024-10-16 Thread Amit Langote
Fix typo in comment of transformJsonAggConstructor() An oversight of 3a8a1f3254b. Reported-by: Tender Wang Author: Tender Wang Backpatch-through: 16 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/4a933eefe11208d02552f34c8fb3a2b13caeb286 Modified Files --

Re: pgsql: Fix expression list handling in ATExecAttachPartition()

2024-10-03 Thread Amit Langote
On Thu, Oct 3, 2024 at 7:12 PM Amit Langote wrote: > On Thu, Oct 3, 2024 at 18:57 Alexander Korotkov wrote: >> >> Hi, Amit! >> >> On Thu, Oct 3, 2024 at 6:01 AM Amit Langote wrote: >> > Fix expression list handling in ATExecAttachPartition() >> >>

pgsql: Replace Unicode apostrophe with ASCII apostrophe

2024-10-03 Thread Amit Langote
Replace Unicode apostrophe with ASCII apostrophe In commit babb3993dbe9, I accidentally introduced a Unicode apostrophe (U+2019). This commit replaces it with the ASCII apostrophe (U+0027) for consistency. Reported-by: Alexander Korotkov Discussion: https://postgr.es/m/capphfdunwmbjkjftqxjremk6

Re: pgsql: Fix expression list handling in ATExecAttachPartition()

2024-10-03 Thread Amit Langote
On Thu, Oct 3, 2024 at 18:57 Alexander Korotkov wrote: > Hi, Amit! > > On Thu, Oct 3, 2024 at 6:01 AM Amit Langote > wrote: > > Fix expression list handling in ATExecAttachPartition() > > +* since it’s needed later to construct the constraint expression for >

pgsql: Fix expression list handling in ATExecAttachPartition()

2024-10-02 Thread Amit Langote
Fix expression list handling in ATExecAttachPartition() This commit addresses two issues related to the manipulation of the partition constraint expression list in ATExecAttachPartition(). First, the current use of list_concat() to combine the partition's constraint (retrieved via get_qual_from_p

pgsql: SQL/JSON: Update example in JSON_QUERY() documentation

2024-09-13 Thread Amit Langote
SQL/JSON: Update example in JSON_QUERY() documentation Commit e6c45d85dc fixed the behavior of JSON_QUERY() when WITH CONDITIONAL WRAPPER is used, but the documentation example wasn't updated to reflect this change. This commit updates the example to show the correct result. Per off-list report f

pgsql: SQL/JSON: Update example in JSON_QUERY() documentation

2024-09-13 Thread Amit Langote
SQL/JSON: Update example in JSON_QUERY() documentation Commit 2c27346ed684 fixed the behavior of JSON_QUERY() when WITH CONDITIONAL WRAPPER is used, but the documentation example wasn't updated to reflect this change. This commit updates the example to show the correct result. Per off-list report

pgsql: SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

2024-09-11 Thread Amit Langote
multiple SQL/JSON items in the result. Reported-by: Peter Eisentraut Author: Peter Eisentraut Author: Amit Langote Reviewed-by: Andrew Dunstan Discussion: https://postgr.es/m/8022e067-818b-45d3-8fab-6e0d94d03626%40eisentraut.org Backpatch-through: 17 Branch -- master Details --- https

pgsql: SQL/JSON: Fix JSON_QUERY(... WITH CONDITIONAL WRAPPER)

2024-09-11 Thread Amit Langote
multiple SQL/JSON items in the result. Reported-by: Peter Eisentraut Author: Peter Eisentraut Author: Amit Langote Reviewed-by: Andrew Dunstan Discussion: https://postgr.es/m/8022e067-818b-45d3-8fab-6e0d94d03626%40eisentraut.org Backpatch-through: 17 Branch -- REL_17_STABLE Details

pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-09 Thread Amit Langote
Jian He Author: Jian He Author: Amit Langote Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/77aebe9a8d3cccd4c54b43be87a38f2bae6

pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-08 Thread Amit Langote
Jian He Author: Jian He Author: Amit Langote Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/dd8bea88abf4794d99270ced884a8bc1e387255d Mod

pgsql: SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

2024-09-06 Thread Amit Langote
SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE Use EMPTY ARRAY instead of EMPTY. This change does not affect the runtime behavior of JSON_TABLE(), which continues to return an empty relation ON ERROR. It only alters whether the default ON ERROR behavior is shown in the deparsed output. R

pgsql: SQL/JSON: Fix JSON_TABLE() column deparsing

2024-09-06 Thread Amit Langote
SQL/JSON: Fix JSON_TABLE() column deparsing The deparsing code in get_json_expr_options() unnecessarily emitted the default column-specific ON ERROR / EMPTY behavior when the top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that by not overriding the column-specific default, determi

pgsql: SQL/JSON: Fix JSON_TABLE() column deparsing

2024-09-06 Thread Amit Langote
SQL/JSON: Fix JSON_TABLE() column deparsing The deparsing code in get_json_expr_options() unnecessarily emitted the default column-specific ON ERROR / EMPTY behavior when the top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that by not overriding the column-specific default, determi

pgsql: SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

2024-09-06 Thread Amit Langote
SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE Use EMPTY ARRAY instead of EMPTY. This change does not affect the runtime behavior of JSON_TABLE(), which continues to return an empty relation ON ERROR. It only alters whether the default ON ERROR behavior is shown in the deparsed output. R

Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-05 Thread Amit Langote
On Fri, Sep 6, 2024 at 1:19 PM Tom Lane wrote: > Amit Langote writes: > > Yes, thanks for the note. Will change the test case to test what are > > deparsing related changes in some other manner. > > I usually prefer to test ruleutils.c by deparsing a suitable view. Yeah

Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-05 Thread Amit Langote
On Fri, Sep 6, 2024 at 1:09 PM Tom Lane wrote: > Amit Langote writes: > > This or one of the other of my recent commits have broken some BF > > animals, so reverting for now. > > Unfiltered EXPLAIN VERBOSE output in a regression test is a > guaranteed fail. Yes, th

pgsql: Revert recent SQL/JSON related commits

2024-09-05 Thread Amit Langote
Revert recent SQL/JSON related commits Reverts 68222851d5a8, 565caaa79af, and 3a97460970f, because a few BF animals didn't like one or all of them. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/4d7e24e0f4d05b546228488ccdc2848a80245ffb Modified Files -

pgsql: Revert recent SQL/JSON related commits

2024-09-05 Thread Amit Langote
Revert recent SQL/JSON related commits Reverts c88ce386c4d, 5067c230b8e, and e4e27976a68, because a few BF animals didn't like one or all of them. Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/eef5195f300bb9cf2864d48761c0db2ad93842c1 Modified Files --

Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-05 Thread Amit Langote
On Fri, Sep 6, 2024 at 12:07 PM Amit Langote wrote: > SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps > > When the ON ERROR / ON EMPTY behavior is to return NULL, returning > NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's > no nee

pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-05 Thread Amit Langote
Jian He Author: Jian He Author: Amit Langote Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/3a97460970f344660971ee75d7f5a181bf87f633 Mod

pgsql: SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

2024-09-05 Thread Amit Langote
SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE Use EMPTY ARRAY instead of EMPTY. This change does not affect the runtime behavior of JSON_TABLE(), which continues to return an empty relation ON ERROR. It only alters whether the default ON ERROR behavior is shown in the deparsed output. R

pgsql: Update comment about ExprState.escontext

2024-09-05 Thread Amit Langote
Update comment about ExprState.escontext The updated comment provides more helpful guidance by mentioning that escontext should be set when soft error handling is needed. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Back

pgsql: SQL/JSON: Fix JSON_TABLE() column deparsing

2024-09-05 Thread Amit Langote
SQL/JSON: Fix JSON_TABLE() column deparsing The deparsing code in get_json_expr_options() unnecessarily emitted the default column-specific ON ERROR / EMPTY behavior when the top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that by not overriding the column-specific default, determi

pgsql: SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE

2024-09-05 Thread Amit Langote
SQL/JSON: Fix default ON ERROR behavior for JSON_TABLE Use EMPTY ARRAY instead of EMPTY. This change does not affect the runtime behavior of JSON_TABLE(), which continues to return an empty relation ON ERROR. It only alters whether the default ON ERROR behavior is shown in the deparsed output. R

pgsql: Update comment about ExprState.escontext

2024-09-05 Thread Amit Langote
Update comment about ExprState.escontext The updated comment provides more helpful guidance by mentioning that escontext should be set when soft error handling is needed. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Back

pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste

2024-09-05 Thread Amit Langote
Jian He Author: Jian He Author: Amit Langote Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/e4e27976a687dd641c1c8251fad3a90a087

pgsql: SQL/JSON: Fix JSON_TABLE() column deparsing

2024-09-05 Thread Amit Langote
SQL/JSON: Fix JSON_TABLE() column deparsing The deparsing code in get_json_expr_options() unnecessarily emitted the default column-specific ON ERROR / EMPTY behavior when the top-level ON ERROR behavior in JSON_TABLE was set to ERROR. Fix that by not overriding the column-specific default, determi

pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE

2024-07-29 Thread Amit Langote
s TRUE and FALSE already works like that because the parser creates a cast expression including the cast function, but the coercion of the actual result value is not handled by the parser. Tests by Jian He. Reported-by: Jian He Author: Jian He Author: Amit Langote Discussion: https://p

pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting

2024-07-29 Thread Amit Langote
ser itself. jsonb-valued expressions are now always coerced at runtime and boolean expressions too if the target type is a string type for the reasons mentioned above. Tests are taken from a patch that Jian He posted. Reported-by: Jian He Author: Jian He Author: Amit Langote Discuss

pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting

2024-07-29 Thread Amit Langote
instead of at parse time. Reported-by: Jian He Author: Jian He Author: Amit Langote Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Branch -- REL_17_STABLE Details --- https://git.pos

pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE

2024-07-29 Thread Amit Langote
s TRUE and FALSE already works like that because the parser creates a cast expression including the cast function, but the coercion of the actual result value is not handled by the parser. Tests by Jian He. Reported-by: Jian He Author: Jian He Author: Amit Langote Discussion: https://p

pgsql: SQL/JSON: Improve error-handling of JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Improve error-handling of JsonBehavior expressions Instead of returning a NULL when the JsonBehavior expression value could not be coerced to the RETURNING type, throw the error message informing the user that it is the JsonBehavior expression that caused the error with the actual coerci

pgsql: SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb

2024-07-26 Thread Amit Langote
SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb populate_domain() didn't take into account the omit_quotes flag passed down to json_populate_type() by ExecEvalJsonCoercion() and that led to incorrect behavior when the RETURNING type is a domain over jsonb. Fix that by passing the

pgsql: SQL/JSON: Remove useless code in ExecInitJsonExpr()

2024-07-26 Thread Amit Langote
SQL/JSON: Remove useless code in ExecInitJsonExpr() The code was for adding an unconditional JUMP to the next step, which is unnecessary processing. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Bra

pgsql: SQL/JSON: Fix error-handling of some JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Fix error-handling of some JsonBehavior expressions To ensure that the errors of executing a JsonBehavior expression that is coerced in the parser are caught instead of being thrown directly, pass ErrorSaveContext to ExecInitExprRec() when initializing it. Also, add a EEOP_JSONEXPR_COERC

pgsql: SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb

2024-07-26 Thread Amit Langote
SQL/JSON: Respect OMIT QUOTES when RETURNING domains over jsonb populate_domain() didn't take into account the omit_quotes flag passed down to json_populate_type() by ExecEvalJsonCoercion() and that led to incorrect behavior when the RETURNING type is a domain over jsonb. Fix that by passing the

pgsql: SQL/JSON: Remove useless code in ExecInitJsonExpr()

2024-07-26 Thread Amit Langote
SQL/JSON: Remove useless code in ExecInitJsonExpr() The code was for adding an unconditional JUMP to the next step, which is unnecessary processing. Reported-by: Jian He Discussion: https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com Backpatch-through: 17 Bra

pgsql: SQL/JSON: Fix error-handling of some JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Fix error-handling of some JsonBehavior expressions To ensure that the errors of executing a JsonBehavior expression that is coerced in the parser are caught instead of being thrown directly, pass ErrorSaveContext to ExecInitExprRec() when initializing it. Also, add a EEOP_JSONEXPR_COERC

pgsql: SQL/JSON: Improve error-handling of JsonBehavior expressions

2024-07-26 Thread Amit Langote
SQL/JSON: Improve error-handling of JsonBehavior expressions Instead of returning a NULL when the JsonBehavior expression value could not be coerced to the RETURNING type, throw the error message informing the user that it is the JsonBehavior expression that caused the error with the actual coerci

pgsql: SQL/JSON: Rethink c2d93c3802b

2024-07-17 Thread Amit Langote
SQL/JSON: Rethink c2d93c3802b This essentially reverts c2d93c3802b except tests. The problem with c2d93c3802b was that it only changed the casting behavior for types with typmod, and had coding issues noted in the post-commit review. This commit changes coerceJsonFuncExpr() to use assignment-leve

pgsql: SQL/JSON: Rethink c2d93c3802b

2024-07-17 Thread Amit Langote
SQL/JSON: Rethink c2d93c3802b This essentially reverts c2d93c3802b except tests. The problem with c2d93c3802b was that it only changed the casting behavior for types with typmod, and had coding issues noted in the post-commit review. This commit changes coerceJsonFuncExpr() to use assignment-leve

pgsql: SQL/JSON: Fix a paragraph in JSON_TABLE documentation

2024-07-15 Thread Amit Langote
SQL/JSON: Fix a paragraph in JSON_TABLE documentation Using text inside parantheses is not a common or good style, so rephrase a sentence to avoid that style. Also rephrase the text in that paragraph a bit while at it. Reported-by: Marcos Pegoraro Author: Jian He Reviewed-by: Daniel Gustafsson

pgsql: SQL/JSON: Fix a paragraph in JSON_TABLE documentation

2024-07-15 Thread Amit Langote
SQL/JSON: Fix a paragraph in JSON_TABLE documentation Using text inside parantheses is not a common or good style, so rephrase a sentence to avoid that style. Also rephrase the text in that paragraph a bit while at it. Reported-by: Marcos Pegoraro Author: Jian He Reviewed-by: Daniel Gustafsson

  1   2   3   >