BUG #14209: Rules don't validate duplicated keys

From: juniorperezpy(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14209: Rules don't validate duplicated keys
Date: 2016-06-22 22:40:47
Message-ID: 20160622224047.5790.20517@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14209
Logged by: Abdel Perez
Email address: juniorperezpy(at)gmail(dot)com
PostgreSQL version: 9.5.1
Operating system: Window 7 Professional
Description:

I've a list with duplicates values I use like pk and I create a rule like
this:

CREATE OR REPLACE RULE db_table_ignore_duplicate_inserts AS
ON INSERT TO products
WHERE (EXISTS ( SELECT 1
FROM products
WHERE products.id = new.id AND btrim(products.description::text) =
btrim(new.description::text))) DO INSTEAD NOTHING;

when I insert individually the rule works and its says me he ignores the
duplicate row, but when insert this way:

insert into products (id, description) values (1, 'product1'), (1,
'producto1);

he inserts anyway the two rows.

I didn't see in the documentation that the rule must ignore this cases.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-06-22 23:58:03 Re: BUG #14209: Rules don't validate duplicated keys
Previous Message Stephen Frost 2016-06-22 18:52:14 Re: pg_dump doesn't dump new objects created in schemas from extensions