pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSerious problems with non-primary foreign keys
2+ messages / 2 participants
[nested] [flat]
* Serious problems with non-primary foreign keys
@ 2009-09-11 13:26 Janne <snoopgd@yahoo.com>
2009-09-13 18:37 ` Re: Serious problems with non-primary foreign keys Adrian Klaver <aklaver@comcast.net>
0 siblings, 1 reply; 2+ messages in thread
From: Janne @ 2009-09-11 13:26 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Serious problems with non-primary foreign keys
2009-09-11 13:26 Serious problems with non-primary foreign keys Janne <snoopgd@yahoo.com>
@ 2009-09-13 18:37 ` Adrian Klaver <aklaver@comcast.net>
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Klaver @ 2009-09-13 18:37 UTC (permalink / raw)
To: pgsql-sql; +Cc: Janne <snoopgd@yahoo.com>
On Friday 11 September 2009 6:26:13 am Janne wrote:
> 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
I think more information is required. First the complete transaction. Second the
complete error message, especially the part that explains what is causing the
CREATE INDEX command to fail. Third I do not see a FOREIGN KEY reference in the
SQL you posted.
--
Adrian Klaver
aklaver@comcast.net
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2009-09-13 18:37 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-09-11 13:26 Serious problems with non-primary foreign keys Janne <snoopgd@yahoo.com>
2009-09-13 18:37 ` Adrian Klaver <aklaver@comcast.net>
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