pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D. Duccini <duccini@backpack.com>
To: andre <andre@liquidprivacy.net>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-novice@postgresql.org
Subject: Re: Guarantee uniqueness of PGP key
Date: Mon, 20 May 2002 21:37:33 -0500 (CDT)
Message-ID: <Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net> (raw)
In-Reply-To: <20020520201709.A3F8A80269@pepe.lfcity.org>


good grief

yeah, look at using the MD5 or SHA1 hash of the key itself

-d

On Mon, 20 May 2002, andre wrote:

> 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
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 


-----------------------------------------------------------------------------
david@backpack.com            BackPack Software, Inc.        www.backpack.com
+1 651.645.7550 voice       "Life is an Adventure.    
+1 651.645.9798 fax            Don't forget your BackPack!"   
-----------------------------------------------------------------------------




view thread (5+ messages)  latest in thread

Message-ID: <Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net>
Permalink:  ../Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net/
Also on:    postgresql.org/message-id/Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: duccini@backpack.com, andre@liquidprivacy.net, pgsql-novice@postgresql.org
  Subject: Re: Guarantee uniqueness of PGP key
  In-Reply-To: <Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net>
  References: <20020520201709.A3F8A80269@pepe.lfcity.org> <Pine.GSO.4.03.10205202136460.18715-100000@ra.bpsi.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox