Case Insensitive Foreign Key Constraint

From: "George Weaver" <gweaver(at)shaw(dot)ca>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Case Insensitive Foreign Key Constraint
Date: 2011-01-18 17:53:55
Message-ID: CCEEA79D5B0743C28D93A1C60029C48A@D420
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

Is there a way to have text-type foreign keys be case insensitive?

development=# CREATE TABLE foo (foo text PRIMARY KEY);

NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
CREATE TABLE

development=# INSERT INTO foo VALUES ('foo');
INSERT 0 1

development=# CREATE TABLE foo1 (foo text REFERENCES foo);
CREATE TABLE

development=# INSERT INTO foo1 VALUES ('FOO');

ERROR: insert or update on table "foo1" violates foreign key constraint "foo1_foo_fkey"
DETAIL: Key (foo)=(FOO) is not present in table "foo".

Thanks,
George

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2011-01-18 17:58:47 Re: Case Insensitive Foreign Key Constraint
Previous Message tuanhoanganh 2011-01-18 17:36:29 PostgreSQL 9.0.1 PITR can not copy WAL file