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

Guarantee uniqueness of PGP key

From: andre <andre(at)liquidprivacy(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Guarantee uniqueness of PGP key
Date: 2002-05-20 20:17:09
Message-ID: 20020520201709.A3F8A80269@pepe.lfcity.org (view raw or flat)
Thread:
Lists: pgsql-novicepgsql-sql
Hi,

More generically, how do I best guarantee that any large varchar is unique 
before inserting?

In my application, I need to ensure that each e-mail address and 
corresponding PGP public key are both unique.

I originally implemented this by adding a uniqueness contrainst to both 
columns.  easy.

The problem is that some PGP keys are over 2713 bytes, and postgres (7.2) 
gives the error:

ERROR: btree: index item size 4336 exceeds maximum 2713

I thought perhaps I could use a hash or rtree index, but neither of them work 
for unique-ness.

I saw in another posting that it may be possible to raise this limit to 8k or 
so, but I don't want to do this because 1) it requires a recompile of 
postgres (and rollout to dev, stage, prod machines), and 2) a key could 
theoretically be longer than 8k anyway.

I can guarantee unique-ness by removing the index and doing a select before 
the insert.  If there is a matching row, then I am trying to insert a dup. 
bail.

My concern is that doing this without an index will be monumentally slow for 
any large-ish number of keys.

Any bright ideas? All suggestions appreciated.

/andre


Responses

pgsql-novice by date

Next:From: Joel BurtonDate: 2002-05-21 00:21:53
Subject: Re: [SQL] Guarantee uniqueness of PGP key
Previous:From: ghinchliffeDate: 2002-05-20 15:29:57
Subject: Transactions over several db sessions

pgsql-sql by date

Next:From: Josh BerkusDate: 2002-05-20 22:34:32
Subject: Bug with Daylight Savings Time & Interval
Previous:From: DinoDate: 2002-05-20 18:36:57
Subject: [INIMSS] problem with user privileges

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