SPI-functions and transaction control

From: "Mikko Partio" <mpartio(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: SPI-functions and transaction control
Date: 2008-02-18 07:15:01
Message-ID: 2ca799770802172315s4d4caf77t3693843697982014@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hermann Muster 2008-02-18 10:05:21 Re: msvcr80.dll and PostgreSQL 8.3 under Windows XP
Previous Message Tim Hart 2008-02-18 06:26:07 Re: Question about the enum type