Re: Duplicate records in a table inspite of a primary key

From: Rex Mabry <rexmabry(at)yahoo(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Cc: subamathy <subamathy(at)gmail(dot)com>
Subject: Re: Duplicate records in a table inspite of a primary key
Date: 2008-08-12 14:31:44
Message-ID: 462594.24414.qm@web35907.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

You have to be careful when using characters as your PK.  A trailing space could give the appearance of duplicate keys.
Example:
"user1"
"user1 " (This one has a space at the end)

--- On Tue, 8/12/08, Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> wrote:

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Subject: Re: [ADMIN] Duplicate records in a table inspite of a primary key
To: pgsql-admin(at)postgresql(dot)org
Cc: "subamathy" <subamathy(at)gmail(dot)com>
Date: Tuesday, August 12, 2008, 9:27 AM

On Tuesday 12 August 2008 02:47:58 subamathy wrote:
> Hi,
> We are having problems resulting from users being able to create
duplicate
> records
> in table.
>
> Below is the description of the table
> Column | Type | Modifiers
> -----------------------+------------------------+-----------
> user_id | character varying(128) | not null
> person_email_required | numeric(5,0) |
> wddx_data | text |
> proxy_id | character varying(128) |
> email_to | character varying(6) |
> password | character varying(60) |
> user_name | character varying(64) |
> language_preference | character varying(20) |
> enable_autosearch | character varying(6) |
> country_id | character varying(16) |
> Indexes:
> "i_personalise" PRIMARY KEY, btree (user_id)
> "i_personalise_proxy_id" btree (proxy_id)
> "i_personalise_user_id" btree (user_id)
>
>
> database version: PostgreSQL 8.0.1
>
> i_personalise- index
>
> conn type: Primary (constriant Type)
> condeferrable: False
> conkey: 1 (column which has constraint)
>
> Could you please help me out in finding the reason for such dupicate
> records existing
>
>
> Could you pls help me out in finding the reson for duplicate records being
> inserted.

I'm pretty sure that between 8.0.1 and 8.0.17 there are a couple of
bugfixes
related to duplicate rows with pk scenarios, you should probably take some
time to upgrade before you spend too much time digging into this (make sure
to read all of the release notes for those versions in between, i'm also
thinking there are some special instructions that might need to be done
somewhere in there)

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bruce Momjian 2008-08-12 17:48:41 Re: [HACKERS] [ADMIN] shared_buffers and shmmax
Previous Message Robert Treat 2008-08-12 14:27:53 Re: Duplicate records in a table inspite of a primary key