pgsql: doc: Mention all options equivalent to pg_dump --filter patterns

2024-06-10 Thread Dean Rasheed
doc: Mention all options equivalent to pg_dump --filter patterns. In the documentation for pg_dump's new --filter option, added by commit a5cf808be5, each object pattern should match some other existing pg_dump option, but some had been omitted, so add them. Noted by Daniel Gustafsson, reviewed

pgsql: Fix PL/pgSQL's handling of integer ranges containing underscores

2024-06-04 Thread Dean Rasheed
Fix PL/pgSQL's handling of integer ranges containing underscores. Commit faff8f8e47 allowed integer literals to contain underscores, but failed to update the lexer's "numericfail" rule. As a result, a decimal integer literal containing underscores would fail to parse, if used in an integer range

pgsql: Fix PL/pgSQL's handling of integer ranges containing underscores

2024-06-04 Thread Dean Rasheed
Fix PL/pgSQL's handling of integer ranges containing underscores. Commit faff8f8e47 allowed integer literals to contain underscores, but failed to update the lexer's "numericfail" rule. As a result, a decimal integer literal containing underscores would fail to parse, if used in an integer range

pgsql: Fix another couple of outdated comments for MERGE RETURNING.

2024-06-04 Thread Dean Rasheed
Fix another couple of outdated comments for MERGE RETURNING. Oversights in c649fa24a4 which added RETURNING support to MERGE. Discussion: https://postgr.es/m/caaphdvpqp6vtuzg-_josueibgyqnrnvxj-vdf+hjlxjhdhz...@mail.gmail.com Branch -- master Details ---

pgsql: Use macro NUM_MERGE_MATCH_KINDS instead of '3' in MERGE code.

2024-04-19 Thread Dean Rasheed
Use macro NUM_MERGE_MATCH_KINDS instead of '3' in MERGE code. Code quality improvement for 0294df2f1f84. Aleksander Alekseev, reviewed by Richard Guo. Discussion: https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com Branch -- master Details ---

pgsql: Add support for MERGE ... WHEN NOT MATCHED BY SOURCE.

2024-03-30 Thread Dean Rasheed
or BY TARGET is equivalent to writing WHEN NOT MATCHED BY TARGET. Dean Rasheed, reviewed by Alvaro Herrera, Ted Yu and Vik Fearing. Discussion: https://postgr.es/m/CAEZATCWqnKGc57Y_JanUBHQXNKcXd7r=0r4nezuvwp+syrk...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg

pgsql: Add functions to generate random numbers in a specified range.

2024-03-27 Thread Dean Rasheed
file. The existing random(), random_normal(), and setseed() functions are moved there too, so that they can all share the same PRNG state, which is kept private to that file. Dean Rasheed, reviewed by Jian He, David Zhang, Aleksander Alekseev, and Tomas Vondra. Discussion: https://postgr.es

pgsql: Add "--exclude-extension" to pg_dump's options.

2024-03-20 Thread Dean Rasheed
Add "--exclude-extension" to pg_dump's options. This option (or equivalently specifying "exclude extension pattern" in a filter file) allows extensions matching the specified pattern to be excluded from the dump. Ayush Vatsa, reviewed by Junwang Zhao, Dean Rasheed, a

pgsql: Fix PDF doc generation.

2024-03-17 Thread Dean Rasheed
Fix PDF doc generation. Commit c649fa24a4 broke PDF generation, due to a misplaced id attribute. Per buildfarm member crake. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/7eb9a8201890f3b208fd4c109a5b08bf139b692a Modified Files --

pgsql: Add RETURNING support to MERGE.

2024-03-17 Thread Dean Rasheed
of a MERGE query's RETURNING list. Dean Rasheed, reviewed by Isaac Morland, Vik Fearing, Alvaro Herrera, Gurjeet Singh, Jian He, Jeff Davis, Merlin Moncure, Peter Eisentraut, and Wolfgang Walther. Discussion: http://postgr.es/m/CAEZATCWePEGQR5LBn-vD6SfeLZafzEm2Qy_L_Oky2=qw2w3...@mail.gmail.com

pgsql: Fix EXPLAIN output for subplans in MERGE.

2024-03-17 Thread Dean Rasheed
Fix EXPLAIN output for subplans in MERGE. Given a subplan in a MERGE query, EXPLAIN would sometimes fail to properly display expressions involving Params referencing variables in other parts of the plan tree. This would affect subplans outside the topmost join plan node, for which expansion of

pgsql: Fix EXPLAIN output for subplans in MERGE.

2024-03-17 Thread Dean Rasheed
Fix EXPLAIN output for subplans in MERGE. Given a subplan in a MERGE query, EXPLAIN would sometimes fail to properly display expressions involving Params referencing variables in other parts of the plan tree. This would affect subplans outside the topmost join plan node, for which expansion of

pgsql: Fix EXPLAIN output for subplans in MERGE.

2024-03-17 Thread Dean Rasheed
Fix EXPLAIN output for subplans in MERGE. Given a subplan in a MERGE query, EXPLAIN would sometimes fail to properly display expressions involving Params referencing variables in other parts of the plan tree. This would affect subplans outside the topmost join plan node, for which expansion of

pgsql: doc: Improve a couple of places in the MERGE docs.

2024-03-13 Thread Dean Rasheed
doc: Improve a couple of places in the MERGE docs. In the synopsis, make the syntax for merge_update consistent with the syntax for a plain UPDATE command. It was missing the optional "ROW" keyword that can be used in a multi-column assignment, and the option to assign from a multi-column

pgsql: doc: Improve a couple of places in the MERGE docs.

2024-03-13 Thread Dean Rasheed
doc: Improve a couple of places in the MERGE docs. In the synopsis, make the syntax for merge_update consistent with the syntax for a plain UPDATE command. It was missing the optional "ROW" keyword that can be used in a multi-column assignment, and the option to assign from a multi-column

pgsql: doc: Improve a couple of places in the MERGE docs.

2024-03-13 Thread Dean Rasheed
doc: Improve a couple of places in the MERGE docs. In the synopsis, make the syntax for merge_update consistent with the syntax for a plain UPDATE command. It was missing the optional "ROW" keyword that can be used in a multi-column assignment, and the option to assign from a multi-column

pgsql: Fix handling of self-modified tuples in MERGE.

2024-03-07 Thread Dean Rasheed
Fix handling of self-modified tuples in MERGE. When an UPDATE or DELETE action in MERGE returns TM_SelfModified, there are 2 possible causes: 1). The target tuple was already updated or deleted by the current command. This can happen if the target row joins to more than one source row,

pgsql: Fix handling of self-modified tuples in MERGE.

2024-03-07 Thread Dean Rasheed
Fix handling of self-modified tuples in MERGE. When an UPDATE or DELETE action in MERGE returns TM_SelfModified, there are 2 possible causes: 1). The target tuple was already updated or deleted by the current command. This can happen if the target row joins to more than one source row,

pgsql: Fix handling of self-modified tuples in MERGE.

2024-03-07 Thread Dean Rasheed
Fix handling of self-modified tuples in MERGE. When an UPDATE or DELETE action in MERGE returns TM_SelfModified, there are 2 possible causes: 1). The target tuple was already updated or deleted by the current command. This can happen if the target row joins to more than one source row,

pgsql: Fix doc omission for MERGE into updatable views.

2024-03-04 Thread Dean Rasheed
Fix doc omission for MERGE into updatable views. Commit 5f2e179bd3 missed one place in rules.sgml that should have mentioned MERGE. Also, be more specific when saying that MERGE doesn't support rules, since it does support SELECT rules. Branch -- master Details ---

pgsql: Support MERGE into updatable views.

2024-02-29 Thread Dean Rasheed
there is no rewriter support for non-SELECT rules with MERGE operations. Dean Rasheed, reviewed by Jian He and Alvaro Herrera. Discussion: https://postgr.es/m/CAEZATCVcB1g0nmxuEc-A+gGB0HnfcGQNGYH7gS=7rq0u0zo...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg

pgsql: Remove field UpdateContext->updated in nodeModifyTable.c

2024-02-29 Thread Dean Rasheed
ate(), ensuring that ExecUpdateEpilogue() is always called if ExecUpdateAct() returns TM_Ok, reducing the chance of bugs. Dean Rasheed, reviewed by Alvaro Herrera. Discussion: https://postgr.es/m/CAEZATCWGGmigGBzLHkJm5Ccv2mMxXmwi3%2Buq0yhwDHm-tsvSLg%40mail.gmail.com Branch -- master Deta

pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.

2023-12-21 Thread Dean Rasheed
, so that it updates the command tag if it does a cross-partition update, making this code path in ExecMergeMatched() consistent with ExecUpdate(). Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Richard Guo and Jian He. Discussion

pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.

2023-12-21 Thread Dean Rasheed
, so that it updates the command tag if it does a cross-partition update, making this code path in ExecMergeMatched() consistent with ExecUpdate(). Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Richard Guo and Jian He. Discussion

pgsql: Fix BEFORE ROW trigger handling in cross-partition MERGE update.

2023-12-21 Thread Dean Rasheed
, so that it updates the command tag if it does a cross-partition update, making this code path in ExecMergeMatched() consistent with ExecUpdate(). Per bug #18238 from Alexander Lakhin. Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Richard Guo and Jian He. Discussion

pgsql: psql: Add tab completion for view options.

2023-11-28 Thread Dean Rasheed
psql: Add tab completion for view options. Add support for tab completion of WITH (...) options to CREATE VIEW, and for the corresponding SET/RESET (...) options in ALTER VIEW. Christoph Heiss, reviewed by Melih Mutlu, Vignesh C, Jim Jones, Mikhail Gribkov, David Zhang, Shubham Khanna, and me.

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: Guard against overflow in interval_mul() and interval_div().

2023-11-18 Thread Dean Rasheed
Guard against overflow in interval_mul() and interval_div(). Commits 146604ec43 and a898b409f6 added overflow checks to interval_mul(), but not to interval_div(), which contains almost identical code, and so is susceptible to the same kinds of overflows. In addition, those checks did not catch

pgsql: doc: improve description of privileges for MERGE and update glos

2023-11-18 Thread Dean Rasheed
doc: improve description of privileges for MERGE and update glossary. On the MERGE page, the description of the privileges required could be taken to imply that the SELECT privilege is required on all columns of the data source, whereas actually it is only required on the columns referred to by

pgsql: doc: improve description of privileges for MERGE and update glos

2023-11-18 Thread Dean Rasheed
doc: improve description of privileges for MERGE and update glossary. On the MERGE page, the description of the privileges required could be taken to imply that the SELECT privilege is required on all columns of the data source, whereas actually it is only required on the columns referred to by

pgsql: doc: improve description of privileges for MERGE and update glos

2023-11-18 Thread Dean Rasheed
doc: improve description of privileges for MERGE and update glossary. On the MERGE page, the description of the privileges required could be taken to imply that the SELECT privilege is required on all columns of the data source, whereas actually it is only required on the columns referred to by

pgsql: Support +/- infinity in the interval data type.

2023-11-14 Thread Dean Rasheed
Support +/- infinity in the interval data type. This adds support for infinity to the interval data type, using the same input/output representation as the other date/time data types that support infinity. This allows various arithmetic operations on infinite dates, timestamps and intervals. The

pgsql: Avoid integer overflow hazard in interval_time().

2023-11-09 Thread Dean Rasheed
Avoid integer overflow hazard in interval_time(). When casting an interval to a time, the original code suffered from 64-bit integer overflow for inputs with a sufficiently large negative "time" field, leading to bogus results. Fix by rewriting the algorithm in a simpler form, that more

pgsql: Fix AFTER ROW trigger execution in MERGE cross-partition update.

2023-11-09 Thread Dean Rasheed
Fix AFTER ROW trigger execution in MERGE cross-partition update. When executing a MERGE UPDATE action, if the UPDATE is turned into a cross-partition DELETE then INSERT, do not attempt to invoke AFTER UPDATE ROW triggers, or any of the other post-update actions in ExecUpdateEpilogue(). For

pgsql: Fix AFTER ROW trigger execution in MERGE cross-partition update.

2023-11-09 Thread Dean Rasheed
Fix AFTER ROW trigger execution in MERGE cross-partition update. When executing a MERGE UPDATE action, if the UPDATE is turned into a cross-partition DELETE then INSERT, do not attempt to invoke AFTER UPDATE ROW triggers, or any of the other post-update actions in ExecUpdateEpilogue(). For

pgsql: Fix AFTER ROW trigger execution in MERGE cross-partition update.

2023-11-09 Thread Dean Rasheed
Fix AFTER ROW trigger execution in MERGE cross-partition update. When executing a MERGE UPDATE action, if the UPDATE is turned into a cross-partition DELETE then INSERT, do not attempt to invoke AFTER UPDATE ROW triggers, or any of the other post-update actions in ExecUpdateEpilogue(). For

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Fix corner-case 64-bit integer subtraction bug on some platforms

2023-11-09 Thread Dean Rasheed
Fix corner-case 64-bit integer subtraction bug on some platforms. When computing "0 - INT64_MIN", most platforms would report an overflow error, which is correct. However, platforms without integer overflow builtins or 128-bit integers would fail to spot the overflow, and incorrectly return

pgsql: Guard against overflow in make_interval().

2023-10-29 Thread Dean Rasheed
Guard against overflow in make_interval(). The original code did very little to guard against integer or floating point overflow when computing the interval's fields. Detect any such overflows and error out, rather than silently returning bogus results. Joseph Koshakow, reviewed by Ashutosh

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: btree_gin: Fix calculation of leftmost interval value.

2023-10-29 Thread Dean Rasheed
terval values. Fix by setting all fields of the leftmost interval to their minimum values, ensuring that the result is less than any other possible interval. Since this only affects index searches, no index rebuild is necessary. Back-patch to all supported branches. Dean Rasheed, reviewed by

pgsql: Fix EvalPlanQual rechecking during MERGE.

2023-09-30 Thread Dean Rasheed
to return the same source tuples when re-running the join query. Fix by ensuring that preprocess_rowmarks() sets up PlanRowMarks for all non-target relations used in MERGE, in the same way that it does for UPDATE and DELETE. Per bug #18103. Back-patch to v15, where MERGE was introduced. Dean Rasheed

pgsql: Fix EvalPlanQual rechecking during MERGE.

2023-09-30 Thread Dean Rasheed
to return the same source tuples when re-running the join query. Fix by ensuring that preprocess_rowmarks() sets up PlanRowMarks for all non-target relations used in MERGE, in the same way that it does for UPDATE and DELETE. Per bug #18103. Back-patch to v15, where MERGE was introduced. Dean Rasheed

pgsql: Fix EvalPlanQual rechecking during MERGE.

2023-09-30 Thread Dean Rasheed
to return the same source tuples when re-running the join query. Fix by ensuring that preprocess_rowmarks() sets up PlanRowMarks for all non-target relations used in MERGE, in the same way that it does for UPDATE and DELETE. Per bug #18103. Back-patch to v15, where MERGE was introduced. Dean Rasheed

pgsql: Fix RLS policy usage in MERGE.

2023-08-10 Thread Dean Rasheed
policies to the join). Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Stephen Frost. Security: CVE-2023-39418 Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/cb2ae5741f2458a474ed3c31458d242e678ff229 Modified Files

pgsql: Fix RLS policy usage in MERGE.

2023-08-10 Thread Dean Rasheed
policies to the join). Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Stephen Frost. Security: CVE-2023-39418 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c2e08b04c9e71ac6aabdc7d9b3f8e785e164d770 Modified Files -- src

pgsql: Fix RLS policy usage in MERGE.

2023-08-10 Thread Dean Rasheed
policies to the join). Back-patch to v15, where MERGE was introduced. Dean Rasheed, reviewed by Stephen Frost. Security: CVE-2023-39418 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/67a007dc0cdb8578726c2000a7abc513109cb4a2 Modified Files

pgsql: Add support for the error functions erf() and erfc().

2023-03-14 Thread Dean Rasheed
implementations. However, past experience has shown that there are almost certainly going to be additional unexpected portability issues, so these tests may well need further adjustments, based on the buildfarm results. Dean Rasheed, reviewed by Nathan Bossart and Thomas Munro. Discussion: https

pgsql: Fix MERGE command tag for actions blocked by BEFORE ROW triggers

2023-03-13 Thread Dean Rasheed
Fix MERGE command tag for actions blocked by BEFORE ROW triggers. This ensures that the row count in the command tag for a MERGE is correctly computed in the case where UPDATEs or DELETEs are skipped due to a BEFORE ROW trigger returning NULL (the INSERT case was already handled correctly by

pgsql: Fix MERGE command tag for actions blocked by BEFORE ROW triggers

2023-03-13 Thread Dean Rasheed
Fix MERGE command tag for actions blocked by BEFORE ROW triggers. This ensures that the row count in the command tag for a MERGE is correctly computed in the case where UPDATEs or DELETEs are skipped due to a BEFORE ROW trigger returning NULL (the INSERT case was already handled correctly by

pgsql: Fix concurrent update issues with MERGE.

2023-03-13 Thread Dean Rasheed
Fix concurrent update issues with MERGE. If MERGE attempts an UPDATE or DELETE on a table with BEFORE ROW triggers, or a cross-partition UPDATE (with or without triggers), and a concurrent UPDATE or DELETE happens, the merge code would fail. In some cases this would lead to a crash, while in

pgsql: Fix concurrent update issues with MERGE.

2023-03-13 Thread Dean Rasheed
Fix concurrent update issues with MERGE. If MERGE attempts an UPDATE or DELETE on a table with BEFORE ROW triggers, or a cross-partition UPDATE (with or without triggers), and a concurrent UPDATE or DELETE happens, the merge code would fail. In some cases this would lead to a crash, while in

pgsql: Doc: Miscellaneous doc updates for MERGE.

2023-02-26 Thread Dean Rasheed
Doc: Miscellaneous doc updates for MERGE. Update a few places in the documentation that should mention MERGE among the list of applicable commands. In a couple of places, a slightly more detailed description of what happens for MERGE seems appropriate. Reviewed by Alvaro Herrera. Discussion:

pgsql: Doc: Miscellaneous doc updates for MERGE.

2023-02-26 Thread Dean Rasheed
Doc: Miscellaneous doc updates for MERGE. Update a few places in the documentation that should mention MERGE among the list of applicable commands. In a couple of places, a slightly more detailed description of what happens for MERGE seems appropriate. Reviewed by Alvaro Herrera. Discussion:

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix mishandling of OLD/NEW references in subqueries in rule acti

2023-02-25 Thread Dean Rasheed
, at rule-definition time, the user isn't required to mark the subquery with LATERAL, and so it can fail when the rule is used. Fix this by marking such subqueries as lateral in the rewriter, at the point where they're used. Dean Rasheed and Tom Lane, per report from Alexander Lakhin. Back-patch to all

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- REL_11_STABLE Details --- https://git.postgresql.org/

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- REL_14_STABLE Details --- https://git.postgresql.org/

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- REL_12_STABLE Details --- https://git.postgresql.org/

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- REL_15_STABLE Details --- https://git.postgresql.org/

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- REL_13_STABLE Details --- https://git.postgresql.org/

pgsql: Fix multi-row DEFAULT handling for INSERT ... SELECT rules.

2023-02-23 Thread Dean Rasheed
points to has rtekind == RTE_SUBQUERY. Per bug #17803, from Alexander Lakhin. Back-patch to all supported branches. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/17803-53c63ed4ecb4eac6%40postgresql.org Branch -- master Details --- https://git.postgresql.org/

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Add missing support for the latest SPI status codes.

2023-02-22 Thread Dean Rasheed
Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from

pgsql: Fix Assert failure for MERGE into a partitioned table with RLS.

2023-02-22 Thread Dean Rasheed
Fix Assert failure for MERGE into a partitioned table with RLS. In ExecInitPartitionInfo(), the Assert when building the WITH CHECK OPTION list for the new partition assumed that the command would be an INSERT or UPDATE, but it can also be a MERGE. This can be triggered by a MERGE into a

pgsql: Fix Assert failure for MERGE into a partitioned table with RLS.

2023-02-22 Thread Dean Rasheed
Fix Assert failure for MERGE into a partitioned table with RLS. In ExecInitPartitionInfo(), the Assert when building the WITH CHECK OPTION list for the new partition assumed that the command would be an INSERT or UPDATE, but it can also be a MERGE. This can be triggered by a MERGE into a

pgsql: Fix MERGE command tag for cross-partition updates.

2023-02-22 Thread Dean Rasheed
Fix MERGE command tag for cross-partition updates. This ensures that the row count in the command tag for a MERGE is correctly computed. Previously, if MERGE updated a partitioned table, the row count would be incorrect if any row was moved to a different partition, since such updates were

pgsql: Fix MERGE command tag for cross-partition updates.

2023-02-22 Thread Dean Rasheed
Fix MERGE command tag for cross-partition updates. This ensures that the row count in the command tag for a MERGE is correctly computed. Previously, if MERGE updated a partitioned table, the row count would be incorrect if any row was moved to a different partition, since such updates were

pgsql: Allow underscores in integer and numeric constants.

2023-02-04 Thread Dean Rasheed
is allowed between any 2 digits, or immediately after the base prefix indicator of non-decimal integers, per SQL:202x draft. Peter Eisentraut and Dean Rasheed Discussion: https://postgr.es/m/84aae844-dc55-a4be-86d9-4f0fa405cc97%40enterprisedb.com Branch -- master Details --- https

pgsql: Make int64_div_fast_to_numeric() more robust.

2023-02-03 Thread Dean Rasheed
ch to v14, where it was introduced. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/CAEZATCW8gXgW0tgPxPgHDPhVX71%2BSWFRkhnXy%2BTfGDsKLepu2g%40mail.gmail.com Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/86bfbeab4f439ad527318d9edeb3c71ea4

pgsql: Make int64_div_fast_to_numeric() more robust.

2023-02-03 Thread Dean Rasheed
ch to v14, where it was introduced. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/CAEZATCW8gXgW0tgPxPgHDPhVX71%2BSWFRkhnXy%2BTfGDsKLepu2g%40mail.gmail.com Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/4f74741a5cea38228fdb0fb2967fa2137e

pgsql: Make int64_div_fast_to_numeric() more robust.

2023-02-03 Thread Dean Rasheed
ch to v14, where it was introduced. Dean Rasheed, reviewed by Tom Lane. Discussion: https://postgr.es/m/CAEZATCW8gXgW0tgPxPgHDPhVX71%2BSWFRkhnXy%2BTfGDsKLepu2g%40mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/b2d47928908d7a99b8e39198d0e8e9e0cb2b024b

Re: pgsql: Ensure that numeric.c compiles with other NBASE values.

2023-02-03 Thread Dean Rasheed
On Fri, 3 Feb 2023 at 01:18, Tom Lane wrote: > > Dean Rasheed writes: > > > 1). It doesn't work if log10val2 < 0, because then m < 0, and it > > doesn't multiply by the remainder. And it then throws an overflow > > error, because result.dscale comes out wrong w

Re: pgsql: Ensure that numeric.c compiles with other NBASE values.

2023-02-02 Thread Dean Rasheed
On Thu, 2 Feb 2023 at 15:15, Tom Lane wrote: > > Looking at this diff made me wonder why the static pow10[] array > isn't marked "const"? > Good point. However, looking more closely, I think this function is more or less completely broken: 1). It doesn't work if log10val2 < 0, because then m <

pgsql: Ensure that numeric.c compiles with other NBASE values.

2023-02-02 Thread Dean Rasheed
Ensure that numeric.c compiles with other NBASE values. As noted in the comments, support for different NBASE values is really only of historical interest, but as long as we're keeping it, we might as well make sure that it compiles. Joel Jacobson Discussion:

pgsql: Clarify the choice of rscale in numeric_sqrt().

2023-02-02 Thread Dean Rasheed
the computation in that case. Joel Jacobson and Dean Rasheed Discussion: https://postgr.es/m/06712c29-98e9-43b3-98da-f234d81c6e49%40app.fastmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/0736fc1ceb0659a9f73699910ac56603336daeee Modified Files

pgsql: Ensure that MERGE recomputes GENERATED expressions properly.

2023-01-30 Thread Dean Rasheed
that could be relaxed, by allowing some generated columns to be skipped for a MERGE without an INSERT action, but it's not clear that it's worth the effort. Noticed while investigating bug #17759. Back-patch to v15, where MERGE was added. Dean Rasheed, reviewed by Tom Lane. Discussion: https

pgsql: Ensure that MERGE recomputes GENERATED expressions properly.

2023-01-30 Thread Dean Rasheed
that could be relaxed, by allowing some generated columns to be skipped for a MERGE without an INSERT action, but it's not clear that it's worth the effort. Noticed while investigating bug #17759. Back-patch to v15, where MERGE was added. Dean Rasheed, reviewed by Tom Lane. Discussion: https

pgsql: Add non-decimal integer support to type numeric.

2023-01-23 Thread Dean Rasheed
Add non-decimal integer support to type numeric. This enhances the numeric type input function, adding support for hexadecimal, octal, and binary integers of any size, up to the limits of the numeric type. Since 6fcda9aba8, such non-decimal integers have been accepted by the parser as integer

  1   2   3   >