ALTER TYPE 1: recheck index-based constraints

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ALTER TYPE 1: recheck index-based constraints
Date: 2011-01-09 22:00:23
Message-ID: 20110109220023.GB5777@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When ALTER TABLE rewrites a table, it reindexes, but the reindex does not
revalidate UNIQUE/EXCLUDE constraints. This behaves badly in cases like this,
neglecting to throw an error on the new UNIQUE violation:

CREATE TABLE t (c numeric UNIQUE);
INSERT INTO t VALUES (1.1),(1.2);
ALTER TABLE t ALTER c TYPE int;

The comment gave a reason for skipping the checks: it would cause deadlocks when
we rewrite a system catalog. So, this patch changes things to only skip the
check for system catalogs.

Attachment Content-Type Size
at1-check-unique.patch text/plain 4.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2011-01-09 22:01:41 ALTER TYPE 2: skip already-provable no-work rewrites
Previous Message Noah Misch 2011-01-09 21:59:52 ALTER TYPE 0: Introduction; test cases