From: | Vegard Bønes <vegard(dot)bones(at)met(dot)no> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple |
Date: | 2011-02-15 07:43:04 |
Message-ID: | 87288500.70191.1297755784580.JavaMail.root@imap1b |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Ok, I tried to modify the example functions get_data_alternative_a() and get_data_alternative_b(), so that they start with SPI_connect, and end with SPI_finish. Also I removed SPI_connect and SPI_finish from the main function. As I understand you, that should have solved the problem. The result, however, is exactly the same as before.
Please keep in mind that I can call either alternative a or alternative b as many times as I wish during the same sql function call, but I can not mix them.
VG
----- Original Message -----
Fra: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Til: "vegard bones" <vegard(dot)bones(at)met(dot)no>
Kopi: pgsql-bugs(at)postgresql(dot)org
Sendt: 14. februar 2011 17:39:07
Emne: Re: [BUGS] BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple
"" <vegard(dot)bones(at)met(dot)no> writes:
> When creating a server-side C function, things go wrong when I (in the same
> function) return some results via SPI_returntuple, and other results by
> manually creating HeapTuples. This applies even if the source for both
> returns are the same data in the same table.
I think the part of this example that doesn't work is returning from the
function without having exited your SPI context. If you need to produce
multiple rows from a single SPI query, the best solution is to collect
them all during a single call and return them in a tuplestore. You can
*not* return without having called SPI_finish to balance your
SPI_connect.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Maxim Boguk | 2011-02-15 10:55:14 | Re: BUG #5885: Strange rows estimation for left join |
Previous Message | Tom Lane | 2011-02-15 03:27:31 | Re: BUG #5885: Strange rows estimation for left join |