From: Janne <snoopgd@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Serious problems with non-primary foreign keys
Date: Fri, 11 Sep 2009 06:26:13 -0700 (PDT)
Message-ID: <793249.77906.qm@web39808.mail.mud.yahoo.com> (raw)
I'm having some serious problems using PostgreSQL with symfony and Doctrine. Here is the error that I've been fighting with for the last couple of days: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block. Failing Query: CREATE INDEX company_id ON sf_guard_user_profile (company_id) It seems to affect every single non-primary foreign key. Turning the key to primary foreign fixes the problem but I don't want it to be primary. I can't think of any logical reason why this error would happen. Generally there's nothing wrong with using a non-primary (not null) foreign key. But Postgre seems to think there is. I know PostgreSQL creates an index for every primary key. Since turning the key also into primary seems to fix it, should I just define an index for it? I've tried it but nothing changes. Here's the relevant SQL:
CREATE TABLE sf_guard_user_profile (id BIGINT, company_id BIGINT NOT NULL, PRIMARY KEY(id));
CREATE TABLE company (company_id INT, PRIMARY KEY(company_id)); Any ideas on how to fix this?
Thank you,
janneaa
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: snoopgd@yahoo.com
Subject: Re: Serious problems with non-primary foreign keys
In-Reply-To: <793249.77906.qm@web39808.mail.mud.yahoo.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