Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Posts
    3

    Unanswered: Duplicated rows with the same primary key

    I use PostgreSQL 7.3 on Windows in Cygwin installation. Data base are used by java application via jdbc (pg73jdbc3.jar). I use only one connection which are sometimes shared beetween several threads, but the methods which manipulate on the same tables are synchronized. From times to times I see multiple rows with the same value of primary keys. It cause that my application works wrong. I have no idea what I do wrong and what I can make better. Any suggestions?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Valdes
    From times to times I see multiple rows with the same value of primary keys.
    not that i doubt you, but this cannot be right

    either it isn't really a primary key, or you're not seeing it correctly, or something

    because if postgresql is allowing duplicate primary key values, then postgresql is b0rk3n, and you wouldn't have been the first to discover it
    Last edited by r937; 09-18-04 at 09:02.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2004
    Posts
    3
    I haven't seen it in my database, but in database of our clients. They can make a buckup with a java program which dump a database to a xml file. And the restore of data on my database from this file is of course not possible because of duplicated keys which I can also see in xml file. Furthermore our application make a log of all error witch have somethig in common with database. I have seen an error "Can't insert ....because of duplicate key" from database which occurd in the line of code that do sql UPDATE!! I don't consider that it's surely a fault of database. Maybe it's a fault of jdbc driver, maybe cygwin cause that database don't work corretly. Perhaps I should use more than one connection to simultaneous work of threads on database. Please trust me, I really have this problem, I'm sure that there are primary keys and I'm sure that I see it correctly. It happens only on databases larger than 500 MB.

  4. #4
    Join Date
    Mar 2004
    Posts
    110

    check you dumpfile

    What could be possible that your dumpfile contains a row with numbers that arent unique.

    When you copy it to your postgres db and you use those numbers as a unique number, you might have a problem.

    Im almost certain the problem is within the original dumpfile.

  5. #5
    Join Date
    Sep 2004
    Posts
    3
    Ok. If someone wants to see that duplicated keys I will send a database. Size of compressed files with database is 4MB. Please email me (marcinwok@o2.pl) and I will send a archive in a way that you choose. I hope that nobody will say that I had prepared the files. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •