Re: BUG #3965: UNIQUE constraint fails on long column values - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #3965: UNIQUE constraint fails on long column values
Date
Msg-id 200802182212.m1IMCSD14587@momjian.us
Whole thread Raw
In response to BUG #3965: UNIQUE constraint fails on long column values  ("Juho Saarikko" <juhos@mbnet.fi>)
Responses Re: BUG #3965: UNIQUE constraint fails on long column values
Re: BUG #3965: UNIQUE constraint fails on long column values
List pgsql-bugs
Juho Saarikko wrote:
> While I didn't test, I'd imagine that this would also mean that any attempt
> to insert such values to an already unique column would fail.

Works here in 8.3:

    test=> create table test (x text unique);
    NOTICE:  CREATE TABLE / UNIQUE will create implicit index "test_x_key" for table "test"
    CREATE TABLE
    test=> insert into test values (repeat('a', 50000));
    INSERT 0 1

Even this works:

    test=> insert into test values (repeat('a', 50000) || 'b');

I believe the index only indexes 8192 bytes but checks the heap for
longer values to check the full length.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3966: problem with implicit cast array parameter
Next
From: Tom Lane
Date:
Subject: Re: BUG #3965: UNIQUE constraint fails on long column values