From: | "Andrij Korud" <akorud(at)polynet(dot)lviv(dot)ua> |
---|---|
To: | "Jan Wieck" <wieck(at)debis(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] Trigger aborted on error |
Date: | 1999-11-01 07:03:56 |
Message-ID: | Pine.BSF.3.96.991101085312.76608B-100000@NetSurfer.lp.lviv.ua |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, 31 Oct 1999, Jan Wieck wrote:
> >
> > Hi.
> > I've such problem :
> > I table with primary key and in trigger try to insert into this table data
> > wich violate constrain (not uniq). When ectually executing SPI_execp I got
> > a message "ERROR: cannot insert a duplicate key into a unique index" and
> > trigger executing is aborted. What should I do in order to get this error
> > as a result from SPI_execp and continue trigger execution?
> >
> > Thanks in advance,
> > Andriy Korud, Lviv, Ukraine
>
> No chance, ERROR messages cannot be caught in any way by a
> trigger. They abort the entire transaction.
>
> The only possibility you have is to check via SELECT prior to
> the INSERT. Unfortunately you would need an exclusive table
> lock to avoid race conditions.
>
>
> Jan
>
Let's make another question: Is there some way to insert uniq data into
table without first cheking using SELECT. Because this table contain >1M
records and SELECT on it is very slow. If there is no way of doing it I
should consider moving from Postgres to other database :(
Andriy Korud
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 1999-11-01 07:10:27 | Re: [HACKERS] sort on huge table |
Previous Message | Vadim Mikheev | 1999-11-01 07:02:04 | Re: [HACKERS] Backend crashes (6.5.2 linux) |