| From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix numeric log() with an infinite value and 0<base<=1 |
| Date: | 2026-10-15 10:41:19 |
| Message-ID: | CAEze2WgSWNfebjWoAPzrV_tMngJ2w36e=ADi7_uU1jeuUv1HAw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, 15 Oct 2026 at 04:16, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
>
> > On Oct 14, 2026, at 23:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> writes:
> >
> >> So, I'd suggest something like
> >
> >> + if (cmp_var(, const_one) == 0)
> >> + ereport(ERROR,
> >> + errcode(ERRCODE_INVALID_ARGUMENT_FOR_LOG),
> >> + errmsg("cannot take logarithm using base 1"));
> >
> > Agreed, but if we want that, we must do it for a finite second input
> > too. Right now you do get
> >
> > regression=# select log(1, 33);
> > ERROR: division by zero
> >
> > Chao proposes matching that, which isn't insane, but I like a
> > specialized error message better.
> >
>
> That’s why I chose that error message, because the existing test has this:
> ```
> select log(1.0, 12.34);
> ERROR: division by zero
> ```
Ah, I see, thanks for clarifying. This wasn't quite clear from the
initial post.
> After thinking it over, I think we can add a check for base 1 in log_var(), and numeric_log() can just defer base 1 handling to log_var(). Please see v2, which implements this approach.
LGTM.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-10-15 10:43:21 | Re: Avoid repeated scans of the output buffer in oidvectortypes() |
| Previous Message | David Rowley | 2026-10-15 10:34:25 | Re: Bug in logical decoding with DDL and subtransactions |