dbTalk Databases Forums  

duplicates on primary key column

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss duplicates on primary key column in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marcin Gil
 
Posts: n/a

Default duplicates on primary key column - 12-23-2003 , 08:30 AM






Same problem I reported earlier.
I have a column declared as PK but PostgreSQL 7.4 allowed it
to create entries with the same key..

Schemas, database dump available at:
http://www.vernet.pl/sql/

All files there..
Thanks!

PS. I am also available at jabber. My JID: dentharg (at) chrome pl
--
Marcin Gil :: marcin.gil (AT) audax (DOT) com.pl
OIS Audax Sp. z o.o., ul. Barlickiego 4, 97-200 Tomaszów Mazowiecki
tel (44) 7247530 w/22, 7244401 w/22 -- fax w/25

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 09:06 AM






Marcin Gil <marcin.gil (AT) audax (DOT) com.pl> writes:
Quote:
Same problem I reported earlier.
I have a column declared as PK but PostgreSQL 7.4 allowed it
to create entries with the same key..

Schemas, database dump available at:
http://www.vernet.pl/sql/
I see no duplicate keys in your dump. How do you provoke the problem
exactly?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Marcin Gil
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 09:14 AM



Tom Lane wrote:

Quote:
I see no duplicate keys in your dump. How do you provoke the problem
exactly?

That seems very odd.
Hmm.. It's enough to do 'select docid from documents where docid=0'
and I get 3 answers (3 rows).

Basically it's a simple web cms system with some kind of versioning.
Duplicate keys are created (probably) at updating the row.
After issuing an update op the row gets updated and new one with the
same data is created; ie. after an update all rows with the same docid
get same contents.
So, when doc is inserted I got one doc. After 1st update I get
(almost certainly) 2 rows, after 2nd update -- 3 rows, etc.

I'll try to investigate a little more on this but I'am very novice
pg admin
--
Marcin Gil :: marcin.gil (AT) audax (DOT) com.pl
OIS Audax Sp. z o.o., ul. Barlickiego 4, 97-200 Tomaszów Mazowiecki
tel (44) 7247530 w/22, 7244401 w/22 -- fax w/25

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #4  
Old   
Marcin Gil
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 09:23 AM



Quote:
I'll try to investigate a little more on this but I'am very novice
pg admin
Maybe you could tell what can I do to help solving the problem?

--
Marcin Gil :: marcin.gil (AT) audax (DOT) com.pl
OIS Audax Sp. z o.o., ul. Barlickiego 4, 97-200 Tomaszów Mazowiecki
tel (44) 7247530 w/22, 7244401 w/22 -- fax w/25

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 09:43 AM



Marcin Gil <marcin.gil (AT) audax (DOT) com.pl> writes:
Quote:
Tom Lane wrote:
I see no duplicate keys in your dump. How do you provoke the problem
exactly?

Hmm.. It's enough to do 'select docid from documents where docid=0'
and I get 3 answers (3 rows).
That's because you made "archives" inherit from "documents", so the scan
includes the rows in "archives" that have docid=0.

You could do "SELECT docid FROM ONLY documents" if you don't want the
scan to include child tables. But it's probably a bad idea to use
inheritance for the archives table at all.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Reply With Quote
  #6  
Old   
Marcin Gil
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 09:52 AM



Quote:
Tom Lane wrote:

That's because you made "archives" inherit from "documents", so the scan
includes the rows in "archives" that have docid=0.

I see. That's my first time with inheriting tables. I though that it
would be something as C++, ie. structure inherit only.

Quote:
You could do "SELECT docid FROM ONLY documents" if you don't want the
scan to include child tables. But it's probably a bad idea to use
inheritance for the archives table at all.

Why it's a bad idea? Some pointing out or links would be very
helpful.

Thanks for your kindness!
--
Marcin Gil :: marcin.gil (AT) audax (DOT) com.pl
OIS Audax Sp. z o.o., ul. Barlickiego 4, 97-200 Tomaszów Mazowiecki
tel (44) 7247530 w/22, 7244401 w/22 -- fax w/25

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings



Reply With Quote
  #7  
Old   
Tom Lane
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 10:05 AM



Marcin Gil <marcin.gil (AT) audax (DOT) com.pl> writes:
Quote:
I see. That's my first time with inheriting tables. I though that it
would be something as C++, ie. structure inherit only.
As of 7.4 there is a way to do structural inheritance, but it's not this
syntax.

Quote:
You could do "SELECT docid FROM ONLY documents" if you don't want the
scan to include child tables. But it's probably a bad idea to use
inheritance for the archives table at all.

Why it's a bad idea?
Just because it's error prone. I can't see that you'd ever want to
include the archives table in searches or updates of the documents table
--- but the default behavior will be to do so.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #8  
Old   
Marcin Gil
 
Posts: n/a

Default Re: duplicates on primary key column - 12-23-2003 , 10:29 AM



Tom Lane wrote:

Quote:
As of 7.4 there is a way to do structural inheritance, but it's not this
syntax.



Ok. I'll do my reading. Is it ok to do structural inheritance for my
archives
or do you suggest to do separate structures?

Thanks
-Marcin Gil


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.