SPI-functions and transaction control - Mailing list pgsql-general

From Mikko Partio
Subject SPI-functions and transaction control
Date
Msg-id 2ca799770802172315s4d4caf77t3693843697982014@mail.gmail.com
Whole thread Raw
Responses Re: SPI-functions and transaction control
List pgsql-general
Hello list

I am trying to write a function in c that would 'merge' two tables together.

The idea is that we insert rows from one table to another, and if there is a constraint violation, update the old row with the new row. I have done this succesfully with plpgsql, but alas, the tables are so big that it takes quite some time for the function to finish.

Now, I was wondering if a c function would be faster, and with the help of the manual I have written a function that can insert tuples from one table to another. As the manual states (http://www.postgresql.org/docs/8.3/interactive/spi.html), there is no way to catch the constraint violation error with SPI though. The manual still mentions that there is an undocumented way of doing this, has anybody ever done this? I was looking the 'exception' code at src/pl/plpgsql/src/pl_exec.c but it's quite frightening since I really don't have that much experience in c :)

Regards

Mikko

pgsql-general by date:

Previous
From: Tim Hart
Date:
Subject: Re: Question about the enum type
Next
From: Hermann Muster
Date:
Subject: Re: msvcr80.dll and PostgreSQL 8.3 under Windows XP