Skip site navigation (1) Skip section navigation (2)

Re: BUG #3965: UNIQUE constraint fails on long column values

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Juho Saarikko <juhos(at)mbnet(dot)fi>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3965: UNIQUE constraint fails on long column values
Date: 2008-02-18 22:12:28
Message-ID: 200802182212.m1IMCSD14587@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-docs
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(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

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

In response to

Responses

pgsql-docs by date

Next:From: Tom LaneDate: 2008-02-18 22:25:46
Subject: Re: BUG #3965: UNIQUE constraint fails on long column values
Previous:From: Gregory StarkDate: 2008-02-18 15:29:44
Subject: Re: BUG #3965: UNIQUE constraint fails on long column values

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-02-18 22:25:46
Subject: Re: BUG #3965: UNIQUE constraint fails on long column values
Previous:From: Faheem MithaDate: 2008-02-18 22:03:21
Subject: BUG #3968: ssh tunnel instructions could use improvement

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group