Re: [SQL] Guarantee uniqueness of PGP key

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "andre" <andre(at)liquidprivacy(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: [SQL] Guarantee uniqueness of PGP key
Date: 2002-05-21 00:21:53
Message-ID: JGEPJNMCKODMDHGOBKDNAENNCOAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

Haven't tried, but would the md5 routine in pg_crypto (contrib/) work for
you? The odds of your discovering two keys that reduce to the same md5 key
is incredibly small, so it's close enough to check for uniqueness.

Don't know if that will take input that large, tho'.

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of andre
> Sent: Monday, May 20, 2002 4:17 PM
> To: pgsql-sql(at)postgresql(dot)org
> Cc: pgsql-novice(at)postgresql(dot)org
> Subject: [SQL] Guarantee uniqueness of PGP key
>
>
> 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 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message D. Duccini 2002-05-21 02:37:33 Re: Guarantee uniqueness of PGP key
Previous Message andre 2002-05-20 20:17:09 Guarantee uniqueness of PGP key

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Lane 2002-05-21 01:59:32 Re: MacOS X Shared Buffers (SHMMAX)?
Previous Message Josh Berkus 2002-05-20 22:34:32 Bug with Daylight Savings Time & Interval