Support request #348

Postgres errors "duplicate key value".

Added by Jake almost 5 years ago. Updated over 4 years ago.

Status:ClosedStart date:2015-01-09
Priority:HighDue date:
Assignee:Aaron% Done:

100%

Category:Bug
Target version:HRM Development - 3.2.2

Description

Hi.

Trying to get my HRM 3.2.1 install on Ubuntu Server 14.04 working, but I keep running into database issues, e.g.

duplicate key value violates unique constraint "username_pkey"  Key (name)=() already exists

One thing I have found is that even though I'm using postgres, it still requires php5-mysql, which makes no sense.

Further, I cannot actually insert or update records in the DB via the web frontend, as they are always met with:

2015-01-09 12:32:05 UTC ERROR:  duplicate key value violates unique constraint "username_pkey" 
2015-01-09 12:32:05 UTC DETAIL:  Key (name)=() already exists.
2015-01-09 12:32:05 UTC STATEMENT:  INSERT INTO username (name, password, email, research_group, status) VALUES ('', 'b9e5a415478e6cea972f38b7f52f457c', '', '', 

Perhaps I am doing something odd/wrong in the postgres setup, but I don't think so. This box already has an active and valid postgres db running on it, working just fine. The postgres db for HRM was created by the pre-population mechanism found in the updatedb.php tool you've written. It injected the correct users, the right passwords in the initial - but whenever I try to add a user, the web page says "There is a database problem. Contact the person in charge"...

Thoughts?

History

#1 Updated by Aaron almost 5 years ago

  • Assignee set to Daniel
  • Target version set to 3.2.2

#2 Updated by Niko almost 5 years ago

  • Subject changed from Postgres throwing errors "duplicate key value violates unique constraint "username_pkey" Key (name)=() already exists. to Postgres errors "duplicate key value".
  • Description updated (diff)
  • Category set to Bug

#3 Updated by Aaron over 4 years ago

  • Status changed from New to Wait For Feedback
  • Assignee changed from Daniel to Aaron

Hi,

first a question: are you really passing empty strings for 'name', 'email' and 'research_group'? It turns out that our columns allow empty strings, so if you try to add an empty string for 'name' twice, you will get exactly the error you report.

For completeness, I tried adding users via the HRM admin user management page and it worked for both MySQL and PostgreSQL. I then succesfully tried the following for both postgresql and mysql from console:

INSERT INTO username (name, password, email, research_group, status) VALUES ('test', 'testpwd', 'test@example.com', 'test_group', 'a');

If I try this, I get the error at the second query:

INSERT INTO username (name, password, email, research_group, status) VALUES ('', 'testpwd', 'test@example.com', 'test_group', 'a');
INSERT INTO username (name, password, email, research_group, status) VALUES ('', 'anoterpwd', 'another@example.com', 'test_group', 'a');

My test setup was Ubuntu 12.04, MySQL 5.5.40 and PostgreSQL 9.1.

#4 Updated by Aaron over 4 years ago

  • % Done changed from 0 to 100

#5 Updated by Aaron over 4 years ago

  • Status changed from Wait For Feedback to Closed

Also available in: Atom PDF