pgsql: RLS comment fixes.

2017-11-24 Thread Dean Rasheed
RLS comment fixes. The comments in get_policies_for_relation() say that CREATE POLICY does not support defining restrictive policies. This is no longer true, starting from PG10. Branch -- REL_10_STABLE Details ---

pgsql: RLS comment fixes.

2017-11-24 Thread Dean Rasheed
RLS comment fixes. The comments in get_policies_for_relation() say that CREATE POLICY does not support defining restrictive policies. This is no longer true, starting from PG10. Branch -- master Details ---

Re: pgsql: Provide separate header file for built-in float types

2018-08-07 Thread Dean Rasheed
On 29 July 2018 at 02:43, Tomas Vondra wrote: > Provide separate header file for built-in float types It looks like this commit broke float8_accum() and float4_accum() when not invoked as aggregates (transdatums is no longer being populated). Possibly it would be worth having regression tests

pgsql: Guard against rare RAND_bytes() failures in pg_strong_random().

2018-07-20 Thread Dean Rasheed
it using RAND_poll(). Back-patch to v10, where pg_strong_random() was introduced. Dean Rasheed and Michael Paquier. Discussion: https://postgr.es/m/CAEZATCXMtxbzSAvyKKk5uCRf9pNt4UV%2BF_5v%3DgLfJUuPxU4Ytg%40mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg

pgsql: Guard against rare RAND_bytes() failures in pg_strong_random().

2018-07-20 Thread Dean Rasheed
it using RAND_poll(). Back-patch to v10, where pg_strong_random() was introduced. Dean Rasheed and Michael Paquier. Discussion: https://postgr.es/m/CAEZATCXMtxbzSAvyKKk5uCRf9pNt4UV%2BF_5v%3DgLfJUuPxU4Ytg%40mail.gmail.com Branch -- REL_11_STABLE Details --- https://git.postgresql.org/pg

pgsql: Guard against rare RAND_bytes() failures in pg_strong_random().

2018-07-20 Thread Dean Rasheed
it using RAND_poll(). Back-patch to v10, where pg_strong_random() was introduced. Dean Rasheed and Michael Paquier. Discussion: https://postgr.es/m/CAEZATCXMtxbzSAvyKKk5uCRf9pNt4UV%2BF_5v%3DgLfJUuPxU4Ytg%40mail.gmail.com Branch -- REL_10_STABLE Details --- https://git.postgresql.org/pg

pgsql: Improve ANALYZE's strategy for finding MCVs.

2018-03-22 Thread Dean Rasheed
Improve ANALYZE's strategy for finding MCVs. Previously, a value was included in the MCV list if its frequency was 25% larger than the estimated average frequency of all nonnull values in the table. For uniform distributions, that can lead to values being included in the MCV list and

pgsql: Improve the accuracy of floating point statistical aggregates.

2018-10-06 Thread Dean Rasheed
Improve the accuracy of floating point statistical aggregates. When computing statistical aggregates like variance, the common schoolbook algorithm which computes the sum of the squares of the values and subtracts the square of the mean can lead to a large loss of precision when using floating

pgsql: Perform RLS subquery checks as the right user when going via a v

2019-04-02 Thread Dean Rasheed
Perform RLS subquery checks as the right user when going via a view. When accessing a table with RLS via a view, the RLS checks are performed as the view owner. However, the code neglected to propagate that to any subqueries in the RLS checks. Fix that by calling setRuleCheckAsUser() for all RLS

pgsql: Perform RLS subquery checks as the right user when going via a v

2019-04-02 Thread Dean Rasheed
Perform RLS subquery checks as the right user when going via a view. When accessing a table with RLS via a view, the RLS checks are performed as the view owner. However, the code neglected to propagate that to any subqueries in the RLS checks. Fix that by calling setRuleCheckAsUser() for all RLS

pgsql: Perform RLS subquery checks as the right user when going via a v

2019-04-02 Thread Dean Rasheed
Perform RLS subquery checks as the right user when going via a view. When accessing a table with RLS via a view, the RLS checks are performed as the view owner. However, the code neglected to propagate that to any subqueries in the RLS checks. Fix that by calling setRuleCheckAsUser() for all RLS

pgsql: Perform RLS subquery checks as the right user when going via a v

2019-04-02 Thread Dean Rasheed
Perform RLS subquery checks as the right user when going via a view. When accessing a table with RLS via a view, the RLS checks are performed as the view owner. However, the code neglected to propagate that to any subqueries in the RLS checks. Fix that by calling setRuleCheckAsUser() for all RLS

pgsql: Perform RLS subquery checks as the right user when going via a v

2019-04-02 Thread Dean Rasheed
Perform RLS subquery checks as the right user when going via a view. When accessing a table with RLS via a view, the RLS checks are performed as the view owner. However, the code neglected to propagate that to any subqueries in the RLS checks. Fix that by calling setRuleCheckAsUser() for all RLS

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Further fixing for multi-row VALUES lists for updatable views.

2019-03-03 Thread Dean Rasheed
Further fixing for multi-row VALUES lists for updatable views. Previously, rewriteTargetListIU() generated a list of attribute numbers from the targetlist, which were passed to rewriteValuesRTE(), which expected them to contain the same number of entries as there are columns in the VALUES RTE,

pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie

2019-02-20 Thread Dean Rasheed
Fix DEFAULT-handling in multi-row VALUES lists for updatable views. INSERT ... VALUES for a single VALUES row is implemented differently from a multi-row VALUES list, which causes inconsistent behaviour in the way that DEFAULT items are handled. In particular, when inserting into an

pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie

2019-02-20 Thread Dean Rasheed
Fix DEFAULT-handling in multi-row VALUES lists for updatable views. INSERT ... VALUES for a single VALUES row is implemented differently from a multi-row VALUES list, which causes inconsistent behaviour in the way that DEFAULT items are handled. In particular, when inserting into an

pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie

2019-02-20 Thread Dean Rasheed
Fix DEFAULT-handling in multi-row VALUES lists for updatable views. INSERT ... VALUES for a single VALUES row is implemented differently from a multi-row VALUES list, which causes inconsistent behaviour in the way that DEFAULT items are handled. In particular, when inserting into an

pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie

2019-02-20 Thread Dean Rasheed
Fix DEFAULT-handling in multi-row VALUES lists for updatable views. INSERT ... VALUES for a single VALUES row is implemented differently from a multi-row VALUES list, which causes inconsistent behaviour in the way that DEFAULT items are handled. In particular, when inserting into an

pgsql: Fix DEFAULT-handling in multi-row VALUES lists for updatable vie

2019-02-20 Thread Dean Rasheed
Fix DEFAULT-handling in multi-row VALUES lists for updatable views. INSERT ... VALUES for a single VALUES row is implemented differently from a multi-row VALUES list, which causes inconsistent behaviour in the way that DEFAULT items are handled. In particular, when inserting into an

Re: pgsql: Drop test user when done with it.

2019-06-25 Thread Dean Rasheed
On Mon, 24 Jun 2019 at 17:37, Tom Lane wrote: > > Drop test user when done with it. > > Commit d7f8d26d9 added a test case that created a user, but forgot > to drop it again. This is no good; for one thing, it causes repeated > "make installcheck" runs to fail. > Ah, I see .. yes, my bad.

pgsql: Add security checks to the multivariate MCV estimation code.

2019-06-23 Thread Dean Rasheed
to the current user, even if they have table or column privileges. Thus we further insist that the operator be leakproof in this case. Dean Rasheed, reviewed by Tomas Vondra. Discussion: https://postgr.es/m/CAEZATCUhT9rt7Ui=Vdx4N==VV5XOK5dsXfnGgVOz_JhAicB=z...@mail.gmail.com Branch -- master Details

pgsql: Fix security checks for selectivity estimation functions with RL

2019-05-09 Thread Dean Rasheed
the leakproofness check will only be skipped if there are no securityQuals and the user has table or column privileges on the table -- i.e., only if we know that the user has access to all the data in the column. Back-patch to 9.5 where RLS was added. Dean Rasheed, reviewed by Jonathan Katz and Stephen

pgsql: Fix security checks for selectivity estimation functions with RL

2019-05-09 Thread Dean Rasheed
the leakproofness check will only be skipped if there are no securityQuals and the user has table or column privileges on the table -- i.e., only if we know that the user has access to all the data in the column. Back-patch to 9.5 where RLS was added. Dean Rasheed, reviewed by Jonathan Katz and Stephen

pgsql: Fix security checks for selectivity estimation functions with RL

2019-05-09 Thread Dean Rasheed
the leakproofness check will only be skipped if there are no securityQuals and the user has table or column privileges on the table -- i.e., only if we know that the user has access to all the data in the column. Back-patch to 9.5 where RLS was added. Dean Rasheed, reviewed by Jonathan Katz and Stephen

pgsql: Fix security checks for selectivity estimation functions with RL

2019-05-09 Thread Dean Rasheed
the leakproofness check will only be skipped if there are no securityQuals and the user has table or column privileges on the table -- i.e., only if we know that the user has access to all the data in the column. Back-patch to 9.5 where RLS was added. Dean Rasheed, reviewed by Jonathan Katz and Stephen

pgsql: Fix security checks for selectivity estimation functions with RL

2019-05-09 Thread Dean Rasheed
the leakproofness check will only be skipped if there are no securityQuals and the user has table or column privileges on the table -- i.e., only if we know that the user has access to all the data in the column. Back-patch to 9.5 where RLS was added. Dean Rasheed, reviewed by Jonathan Katz and Stephen

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Use checkAsUser for selectivity estimator checks, if it's set.

2019-05-06 Thread Dean Rasheed
safeguards controlling access to pg_statistic for direct table access (in which case checkAsUser won't be set) and for security barrier views, because of the nearby checks on rte->security_barrier and rte->securityQuals. Back-patch to all supported branches because e2d4ef8de8 was. Dean R

pgsql: Fix intermittent self-test failures caused by the stats_ext test

2019-09-15 Thread Dean Rasheed
that unsafe. This led to intermittent failures of the rules test on the buildfarm, although I wasn't able to reproduce that locally. Fix by creating the view in a different schema. Tomas Vondra and Dean Rasheed, report and diagnosis by Thomas Munro. Discussion: https://postgr.es/m/ca

pgsql: Fix intermittent self-test failures caused by the stats_ext test

2019-09-15 Thread Dean Rasheed
that unsafe. This led to intermittent failures of the rules test on the buildfarm, although I wasn't able to reproduce that locally. Fix by creating the view in a different schema. Tomas Vondra and Dean Rasheed, report and diagnosis by Thomas Munro. Discussion: https://postgr.es/m/ca

pgsql: Fix corner-case loss of precision in numeric ln().

2020-03-01 Thread Dean Rasheed
Fix corner-case loss of precision in numeric ln(). When deciding on the local rscale to use for the Taylor series expansion, ln_var() neglected to account for the fact that the result is subsequently multiplied by a factor of 2^(nsqrt+1), where nsqrt is the number of square root operations

pgsql: Add functions gcd() and lcm() for integer and numeric types.

2020-01-25 Thread Dean Rasheed
Add functions gcd() and lcm() for integer and numeric types. These compute the greatest common divisor and least common multiple of a pair of numbers using the Euclidean algorithm. Vik Fearing, reviewed by Fabien Coelho. Discussion:

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Make rewriter prevent auto-updates on views with conditional INS

2020-01-14 Thread Dean Rasheed
Make rewriter prevent auto-updates on views with conditional INSTEAD rules. A view with conditional INSTEAD rules and no unconditional INSTEAD rules or INSTEAD OF triggers is not auto-updatable. Previously we relied on a check in the executor to catch this, but that's problematic since the

pgsql: Improve the performance and accuracy of numeric sqrt() and ln().

2020-03-28 Thread Dean Rasheed
Improve the performance and accuracy of numeric sqrt() and ln(). Instead of using Newton's method to compute numeric square roots, use the Karatsuba square root algorithm, which performs better for numbers of all sizes. In practice, this is 3-5 times faster for inputs with just a few digits and

pgsql: Prevent functional dependency estimates from exceeding column es

2020-03-28 Thread Dean Rasheed
Prevent functional dependency estimates from exceeding column estimates. Formerly we applied a functional dependency "a => b with dependency degree f" using the formula P(a,b) = P(a) * [f + (1-f)*P(b)] This leads to the possibility that the combined selectivity P(a,b) could exceed P(b), which

pgsql: Improve estimation of OR clauses using multiple extended statist

2020-12-08 Thread Dean Rasheed
object do not apply to clauses covered by other statistics objects. Dean Rasheed, reviewed by Tomas Vondra. Discussion: https://postgr.es/m/CAEZATCW=J65GUFm50RcPv-iASnS2mTXQbr=cfbvwrvhflj_...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Improve estimation of ANDs under ORs using extended statistics.

2020-12-08 Thread Dean Rasheed
bare AND clauses, looking for compatible RestrictInfo clauses underneath them. Dean Rasheed, reviewed by Tomas Vondra. Discussion: https://postgr.es/m/CAEZATCW=J65GUFm50RcPv-iASnS2mTXQbr=cfbvwrvhflj_...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg

pgsql: Improve estimation of OR clauses using extended statistics.

2020-12-03 Thread Dean Rasheed
Improve estimation of OR clauses using extended statistics. Formerly we only applied extended statistics to an OR clause as part of the clauselist_selectivity() code path for an OR clause appearing in an implicitly-ANDed list of clauses. This meant that it could only use extended statistics if

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- REL_12_STABLE Details ---

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- REL9_6_STABLE Details ---

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- master Details ---

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- REL_13_STABLE Details ---

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- REL_11_STABLE Details ---

pgsql: Add an explicit cast to double when using fabs().

2021-01-05 Thread Dean Rasheed
Add an explicit cast to double when using fabs(). Commit bc43b7c2c0 used fabs() directly on an int variable, which apparently requires an explicit cast on some platforms. Per buildfarm. Branch -- REL_10_STABLE Details ---

pgsql: Fix numeric_power() when the exponent is INT_MIN.

2021-01-05 Thread Dean Rasheed
Fix numeric_power() when the exponent is INT_MIN. In power_var_int(), the computation of the number of significant digits to use in the computation used log(Abs(exp)), which isn't safe because Abs(exp) returns INT_MIN when exp is INT_MIN. Use fabs() instead of Abs(), so that the exponent is cast

pgsql: Fix numeric_power() when the exponent is INT_MIN.

2021-01-05 Thread Dean Rasheed
Fix numeric_power() when the exponent is INT_MIN. In power_var_int(), the computation of the number of significant digits to use in the computation used log(Abs(exp)), which isn't safe because Abs(exp) returns INT_MIN when exp is INT_MIN. Use fabs() instead of Abs(), so that the exponent is cast

pgsql: Fix numeric_power() when the exponent is INT_MIN.

2021-01-05 Thread Dean Rasheed
Fix numeric_power() when the exponent is INT_MIN. In power_var_int(), the computation of the number of significant digits to use in the computation used log(Abs(exp)), which isn't safe because Abs(exp) returns INT_MIN when exp is INT_MIN. Use fabs() instead of Abs(), so that the exponent is cast

pgsql: Fix numeric_power() when the exponent is INT_MIN.

2021-01-05 Thread Dean Rasheed
Fix numeric_power() when the exponent is INT_MIN. In power_var_int(), the computation of the number of significant digits to use in the computation used log(Abs(exp)), which isn't safe because Abs(exp) returns INT_MIN when exp is INT_MIN. Use fabs() instead of Abs(), so that the exponent is cast

pgsql: Fix numeric_power() when the exponent is INT_MIN.

2021-01-05 Thread Dean Rasheed
Fix numeric_power() when the exponent is INT_MIN. In power_var_int(), the computation of the number of significant digits to use in the computation used log(Abs(exp)), which isn't safe because Abs(exp) returns INT_MIN when exp is INT_MIN. Use fabs() instead of Abs(), so that the exponent is cast

pgsql: Prevent numeric overflows in parallel numeric aggregates.

2021-07-05 Thread Dean Rasheed
Prevent numeric overflows in parallel numeric aggregates. Formerly various numeric aggregate functions supported parallel aggregation by having each worker convert partial aggregate values to Numeric and use numeric_send() as part of serializing their state. That's problematic, since the range of

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
Fix numeric_mul() overflow due to too many digits after decimal point. This fixes an overflow error when using the numeric * operator if the result has more than 16383 digits after the decimal point by rounding the result. Overflow errors should only occur if the result has too many digits

Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal

2021-07-10 Thread Dean Rasheed
On Sat, 10 Jul 2021 at 16:01, Tom Lane wrote: > > I think this needs a bit more thought. Before, a case like > select 1e-16000 * 1e-16000; > produced > ERROR: value overflows numeric format > Now you get an exact zero (with a lot of trailing zeroes, but still > it's just zero).

pgsql: Fix pgbench permute tests.

2021-05-19 Thread Dean Rasheed
Fix pgbench permute tests. One of the tests for the pgbench permute() function added by 6b258e3d68 fails on some 32-bit platforms, due to variations in the floating point computations in getrand(). The remaining tests give sufficient coverage, so just remove the failing test. Reported by

pgsql: pgbench: Function to generate random permutations.

2021-04-06 Thread Dean Rasheed
pgbench: Function to generate random permutations. This adds a new function, permute(), that generates pseudorandom permutations of arbitrary sizes. This can be used to randomly shuffle a set of values to remove unwanted correlations. For example, permuting the output from a non-uniform random

pgsql: Improve reporting of "conflicting or redundant options" errors.

2021-07-15 Thread Dean Rasheed
Improve reporting of "conflicting or redundant options" errors. When reporting "conflicting or redundant options" errors, try to ensure that errposition() is used, to help the user identify the offending option. Formerly, errposition() was invoked in less than 60% of cases. This patch raises

pgsql: Improve numeric_power() tests for large integer powers.

2021-08-05 Thread Dean Rasheed
Improve numeric_power() tests for large integer powers. Two of the tests added by 4dd5ce2fd fail on buildfarm member castoroides, though it's not clear why. Improve the tests to report the actual values produced, if they're not what was expected. Apply to v11 only for now, until it's clearer

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix corner-case errors and loss of precision in numeric_power().

2021-07-31 Thread Dean Rasheed
nsistently return zero for cases like this where the result is indistinguishable from zero. Some paths through this code already returned zero in such cases, but others were throwing overflow errors. Dean Rasheed, reviewed by Yugo Nagata. Discussion: http://postgr.es/m/CAEZATCW6Dvq7+3wN3tt5jLj-FyOcUg

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Fix division-by-zero error in to_char() with 'EEEE' format.

2021-08-05 Thread Dean Rasheed
Fix division-by-zero error in to_char() with '' format. This fixes a long-standing bug when using to_char() to format a numeric value in scientific notation -- if the value's exponent is less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a division-by-zero error. The reason for this

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Adjust the integer overflow tests in the numeric code.

2021-08-06 Thread Dean Rasheed
Adjust the integer overflow tests in the numeric code. Formerly, the numeric code tested whether an integer value of a larger type would fit in a smaller type by casting it to the smaller type and then testing if the reverse conversion produced the original value. That's perfectly fine, except

pgsql: Fix corner-case loss of precision in numeric_power().

2021-10-06 Thread Dean Rasheed
Fix corner-case loss of precision in numeric_power(). This fixes a loss of precision that occurs when the first input is very close to 1, so that its logarithm is very small. Formerly, during the initial low-precision calculation to estimate the result weight, the logarithm was computed to a

pgsql: Fix corner-case loss of precision in numeric_power().

2021-10-06 Thread Dean Rasheed
Fix corner-case loss of precision in numeric_power(). This fixes a loss of precision that occurs when the first input is very close to 1, so that its logarithm is very small. Formerly, during the initial low-precision calculation to estimate the result weight, the logarithm was computed to a

  1   2   3   >