| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | dqetool(at)126(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19342: ERROR: function gcd(smallint, smallint) is not unique |
| Date: | 2025-12-02 13:36:27 |
| Message-ID: | 8A24510F-611D-46C1-AAB4-8AD7B759E737@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
> On 2 Dec 2025, at 14:02, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 19342
> Logged by: Jason Smith
> Email address: dqetool(at)126(dot)com
> PostgreSQL version: 18.0
> Operating system: Ubuntu 22.04
> Description:
>
> Run the following statements, where the error may be not expected.
> ```sql
> CREATE TABLE t1 (c1 SMALLINT);
> SELECT (gcd(c1, c1)) FROM t1; -- ERROR: function gcd(smallint, smallint) is
> not unique
> ```
gcd() is - as is documented - only available for integer, bigint and numeric.
What happens here is that postgres attempts to automatically cast the input
into a supported datatype, but since smallint can be cast into more than one of
the possible input types the error you see is thrown.
If you yourself cast it to integer it works as you expected.
postgres=# SELECT gcd(c1::integer, c1::integer) FROM t1;
gcd
-----
(0 rows)
--
Daniel Gustafsson
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oleg Ivanov | 2025-12-02 14:05:23 | Re: BUG #19340: Wrong result from CORR() function |
| Previous Message | PG Bug reporting form | 2025-12-02 13:02:53 | BUG #19342: ERROR: function gcd(smallint, smallint) is not unique |