Re: Why my C function is called twice?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: billowgao(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why my C function is called twice?
Date: 2007-12-12 04:25:58
Message-ID: 11700.1197433558@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Billow Gao" <billowgy(at)gmail(dot)com> writes:
> A very simple C function which I copied from the manual.
> And I found that it's called twice.

You do realize that it's *supposed* to be called twice? Once to
return the first row, and again to say it's done returning rows.

But the info messages you show are strange anyway. I tried your example
here and got the results I'd expect:

regression=# select * from retcomposite(1,48);
INFO: 1
INFO: 2
INFO: 3
INFO: 4
INFO: 2
INFO: 5
f1 | f2 | f3
----+----+-----
48 | 96 | 144
(1 row)

I think the code you showed must not quite match what you're actually
executing. Maybe you recompiled the code and forgot to do a LOAD or
start a fresh session to bring in the new .so file?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2007-12-12 04:30:03 Re: WORM and Read Only Tables (v0.1)
Previous Message Tom Lane 2007-12-12 03:32:07 Re: [hensa22@yahoo.es: Re: [pgsql-es-ayuda] SLL error 100% cpu]