pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Daniel J Peacock <bluedanunit@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Erroneous behavior of primary key
Date: Mon, 27 Aug 2018 14:30:34 -0600
Message-ID: <1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com> (raw)
In-Reply-To: <CAPQSkmPR82gk9RRH8TZjCYzXpNZUyeP4_=nbPdi5qStySoQGJg@mail.gmail.com>
References: <CAPQSkmPR82gk9RRH8TZjCYzXpNZUyeP4_=nbPdi5qStySoQGJg@mail.gmail.com>



> On Aug 27, 2018, at 1:50 PM, Daniel J Peacock <bluedanunit@gmail.com> wrote:
> 
> Good afternoon, all.
> I've got an odd situation with a table that has a varchar(255) as the primary key that is getting key values from an Elasticsearch engine.  What I'm finding is that even though there is a primary key on the table, I am getting duplicated keys in the data and the constraint is not blocking these.  When I do a "select <pk_field>,count(*) from <table> group by <pk_field> having count(*) > 1" I get no results.  Yet, when I search the table for a value that is like a key I know to be duplicated, I get multiple results.  When I select from the table where field is equal to the duplicated field I get one result.  I verified that they are distinct row with ctid.  I also created a clone of the table with CTAS and then tried to create a unique index on the id varchar field but that failed with "duplicate keys found".  I'm stumped as to what could be the problem.
> The only thing that I can think of is that the primary key is somehow corrupt.  I've noticed this behavior on other tables on this database.  
> What could be causing this sort of problem?
> 
> Thanks in advance for any insights.
> 
> Dan Peacock
> Auto-wares, Inc.
Check for trailing white space



view thread (5+ messages)  latest in thread

Message-ID: <1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com>
Permalink:  ../1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com/
Also on:    postgresql.org/message-id/1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com

 · 

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-general@postgresql.org
  Cc: robjsargent@gmail.com, bluedanunit@gmail.com
  Subject: Re: Erroneous behavior of primary key
  In-Reply-To: <1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com>
  References: <CAPQSkmPR82gk9RRH8TZjCYzXpNZUyeP4_=nbPdi5qStySoQGJg@mail.gmail.com> <1B74B41D-936B-464D-9D53-A7374C27F3A2@gmail.com>

* 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