pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17951: hashtext('input') returning non-integer value for certain inputs
2+ messages / 2 participants
[nested] [flat]

* BUG #17951: hashtext('input') returning non-integer value for certain inputs
@ 2023-05-30 07:07 PG Bug reporting form <noreply@postgresql.org>
  2023-05-30 07:55 ` Re: BUG #17951: hashtext('input') returning non-integer value for certain inputs Ilkka Kaakkola <ilkka.kaakkola@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2023-05-30 07:07 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: ilkka.kaakkola+github@gmail.com

The following bug has been logged on the website:

Bug reference:      17951
Logged by:          Ilkka Kaakkola
Email address:      ilkka.kaakkola+github@gmail.com
PostgreSQL version: 15.3
Operating system:   Linux (Docker)
Description:        

Startup command:

user@host % docker run --rm -d --name psql -e POSTGRES_PASSWORD=password -e
POSTGRES_DB=app postgres:15.3 postgres
028d012d418351520815376f2111d47c105bfa0a0dfcc95125dbcacc3318c7d6

user@host % docker exec -it psql bash

(inside container)
root@028d012d4183:/# uname -a
Linux 028d012d4183 5.15.96-0-virt #1-Alpine SMP Sun, 26 Feb 2023 15:14:12
+0000 x86_64 GNU/Linux

root@028d012d4183:/# psql -U postgres app
psql (15.3 (Debian 15.3-1.pgdg110+1))
Type "help" for help.

app=#


PostgreSQL version:

app=# select VERSION();
                                                           version
-----------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 15.3 (Debian 15.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
(1 row)

----

Steps to reproduce:

app=# CREATE TABLE bug ( id varchar(128) );
CREATE TABLE


app=# \d bug
                        Table "public.bug"
 Column |          Type          | Collation | Nullable | Default
--------+------------------------+-----------+----------+---------
 id     | character varying(128) |           |          |


app=# insert into bug (id) values ('18122447326473c034-214042692253025');
INSERT 0 1


app=# select ABS(HASHTEXT(id)) FROM bug;
ERROR:  22003: integer out of range
LOCATION:  int4abs, int.c:1196

The resulting value of hashtext() for the given input overflows an integer
by 1 as can be seen by casting it manually

app=# select ABS(CAST(HASHTEXT(ID) as BIGINT)) FROM bug;
    abs
------------
 2147483648
(1 row)


This can also be directly observed by selecting
HASHTEXT('18122447326473c034-214042692253025'):

app=# SELECT HASHTEXT('18122447326473c034-214042692253025');
  hashtext
-------------
 -2147483648
(1 row)

Expected the output from hashtext('input') to always be a valid integer.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #17951: hashtext('input') returning non-integer value for certain inputs
  2023-05-30 07:07 BUG #17951: hashtext('input') returning non-integer value for certain inputs PG Bug reporting form <noreply@postgresql.org>
@ 2023-05-30 07:55 ` Ilkka Kaakkola <ilkka.kaakkola@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Ilkka Kaakkola @ 2023-05-30 07:55 UTC (permalink / raw)
  To: ilkka.kaakkola+github@gmail.com; pgsql-bugs@lists.postgresql.org

Hi,

This is an invalid bug report and can be ignored.

The return value is a signed integer, happening to have the minimum value (-2147483648) which is too large to be represented as a positive integer (with a max value of 2147483647), hence abs() is correctly throwing an error. 

Cheers,

Ilkka


> On 30. May 2023, at 10.07, PG Bug reporting form <noreply@postgresql.org> wrote:
> 
> The following bug has been logged on the website:
> 
> Bug reference:      17951
> Logged by:          Ilkka Kaakkola
> Email address:      ilkka.kaakkola+github@gmail.com
> PostgreSQL version: 15.3
> Operating system:   Linux (Docker)
> Description:        
> 
> Startup command:
> 
> user@host % docker run --rm -d --name psql -e POSTGRES_PASSWORD=password -e
> POSTGRES_DB=app postgres:15.3 postgres
> 028d012d418351520815376f2111d47c105bfa0a0dfcc95125dbcacc3318c7d6
> 
> user@host % docker exec -it psql bash
> 
> (inside container)
> root@028d012d4183:/# uname -a
> Linux 028d012d4183 5.15.96-0-virt #1-Alpine SMP Sun, 26 Feb 2023 15:14:12
> +0000 x86_64 GNU/Linux
> 
> root@028d012d4183:/# psql -U postgres app
> psql (15.3 (Debian 15.3-1.pgdg110+1))
> Type "help" for help.
> 
> app=#
> 
> 
> PostgreSQL version:
> 
> app=# select VERSION();
>                                                           version
> -----------------------------------------------------------------------------------------------------------------------------
> PostgreSQL 15.3 (Debian 15.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled
> by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
> (1 row)
> 
> ----
> 
> Steps to reproduce:
> 
> app=# CREATE TABLE bug ( id varchar(128) );
> CREATE TABLE
> 
> 
> app=# \d bug
>                        Table "public.bug"
> Column |          Type          | Collation | Nullable | Default
> --------+------------------------+-----------+----------+---------
> id     | character varying(128) |           |          |
> 
> 
> app=# insert into bug (id) values ('18122447326473c034-214042692253025');
> INSERT 0 1
> 
> 
> app=# select ABS(HASHTEXT(id)) FROM bug;
> ERROR:  22003: integer out of range
> LOCATION:  int4abs, int.c:1196
> 
> The resulting value of hashtext() for the given input overflows an integer
> by 1 as can be seen by casting it manually
> 
> app=# select ABS(CAST(HASHTEXT(ID) as BIGINT)) FROM bug;
>    abs
> ------------
> 2147483648
> (1 row)
> 
> 
> This can also be directly observed by selecting
> HASHTEXT('18122447326473c034-214042692253025'):
> 
> app=# SELECT HASHTEXT('18122447326473c034-214042692253025');
>  hashtext
> -------------
> -2147483648
> (1 row)
> 
> Expected the output from hashtext('input') to always be a valid integer.
> 






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2023-05-30 07:55 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 07:07 BUG #17951: hashtext('input') returning non-integer value for certain inputs PG Bug reporting form <noreply@postgresql.org>
2023-05-30 07:55 ` Ilkka Kaakkola <ilkka.kaakkola@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox