found a possible bug, modulus of an integer on a partition table appears to be wrong

From: "Howard A(dot) Chou" <maingroup(at)yahoo(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: found a possible bug, modulus of an integer on a partition table appears to be wrong
Date: 2023-03-05 18:45:38
Message-ID: 382692025.2538273.1678041938275@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

postgres(at)osboxes:~/pgdata1$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy
postgres(at)osboxes:~/pgdata1$

psql (14.2 (Ubuntu 14.2-1ubuntu1))
Type "help" for help.

postgres=# \x
Expanded display is on.
postgres=# select version();
-[ RECORD 1 ]--------------------------------------------------------------------------------------------------------------------
version | PostgreSQL 14.2 (Ubuntu 14.2-1ubuntu1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit

postgres=#

postgres=# create table t1 (c1 int) partition by hash (c1);
CREATE TABLE
postgres=# create table t1_0 partition of t1 for values with (modulus 2, remainder 0);
CREATE TABLE
postgres=# create table t1_1 partition of t1 for values with (modulus 2, remainder 1);
CREATE TABLE
postgres=# \dt
              List of relations
 Schema | Name |       Type        |  Owner
--------+------+-------------------+----------
 public | t1   | partitioned table | postgres
 public | t1_0 | table             | postgres
 public | t1_1 | table             | postgres
(3 rows)

postgres=# insert into t1 values (4),(6), (8);
INSERT 0 3
postgres=# select * from t1_0;
 c1
----
(0 rows)

postgres=# select * from t1_1;
 c1
----
  4
  6
  8
(3 rows)

postgres=# select 4 % 2, 6 % 2, 8 % 2;
 ?column? | ?column? | ?column?
----------+----------+----------
        0 |        0 |        0
(1 row)

The remainder of 4, 6, 8 mod 2 should be 0.  Instead of inserting into t1_0, all values were inserted into t1_1

Thanks,

Howard A Chou

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marco Boeringa 2023-03-05 21:38:40 'CLUSTER' in one database prevents running it in two others on the same database cluster (PG15.2)
Previous Message Alexander Lakhin 2023-03-05 09:00:01 Re: BUG #17116: Assert failed in SerialSetActiveSerXmin() on commit of parallelized serializable transaction