pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: michalalbrycht@gmail.com
Subject: BUG #16840: Rows not found in table partitioned by hash when not all partitions exists
Date: Wed, 27 Jan 2021 17:02:21 +0000
Message-ID: <16840-571a22976f829ad4@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16840
Logged by:          MichaƂ Albrycht
Email address:      michalalbrycht@gmail.com
PostgreSQL version: 13.1
Operating system:   Ubuntu 18
Description:        

Lets create a table partitioned by hash:

CREATE TABLE dir (
   id SERIAL,
   volume_id BIGINT,
   path TEXT
) PARTITION BY HASH (volume_id);


Now let's create just one partition:

CREATE TABLE  dir_part_2 PARTITION OF dir FOR VALUES WITH (modulus 3,
remainder 2);

Insert sample value:

INSERT INTO dir (volume_id, path) VALUES
    (1, 'abc'),
    (1, 'def'),
    (1, 'ghi');
    
Queries to verify db state:
SELECT * FROM dir WHERE volume_id=1 AND path='abc'; -- returns 1 row - OK
SELECT * FROM dir WHERE volume_id=1 AND (path='abc' OR path='def')  --
returns 0 rows - NOT OK!
SELECT * FROM dir_part_2 WHERE volume_id=1 AND (path='abc' or path='def') --
returns 2 rows - OK

Now lets add missing partitions:
CREATE TABLE  dir_part_0 PARTITION OF dir FOR VALUES WITH (modulus 3,
remainder 0);
CREATE TABLE  dir_part_1 PARTITION OF dir FOR VALUES WITH (modulus 3,
remainder 1);

And run problematic query one more time:
SELECT * FROM dir WHERE volume_id=1 AND (path='abc' OR path='def')  --
returns 2 rows - OK


So Postgres silently fails to find a rows, and does not throw any error when
not all hash partitions are present.



view thread (6+ messages)  latest in thread

Message-ID: <16840-571a22976f829ad4@postgresql.org>
Permalink:  ../16840-571a22976f829ad4@postgresql.org/
Also on:    postgresql.org/message-id/16840-571a22976f829ad4@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, michalalbrycht@gmail.com
  Subject: Re: BUG #16840: Rows not found in table partitioned by hash when not all partitions exists
  In-Reply-To: <16840-571a22976f829ad4@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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