Thread: Query that will not run a ValuePerCall SRF to completion?

Query that will not run a ValuePerCall SRF to completion?

From
Chapman Flack
Date:
Hi,

I am trying to improve (i.e. have any at all) test coverage of the
ExprContextCallback for a ValuePerCall SRF function handler.

I'm having difficulty coming up with a query that actually doesn't
run the SRF to completion.

The form I've been trying looks like

SELECT *
FROM
 executeSelectToRecords('SELECT * FROM generate_series(1,1000000)')
 AS (thing int)
 LIMIT 10;

but even that query calls executeSelectToRecords for all 1000000 rows
and then shows me ten of them, and the callback isn't tested.

Is there a way to write a simple query that won't run the SRF to
completion?

Thanks!

Regards,
-Chap



Re: Query that will not run a ValuePerCall SRF to completion?

From
Tom Lane
Date:
Chapman Flack <chap@anastigmatix.net> writes:
> I'm having difficulty coming up with a query that actually doesn't
> run the SRF to completion.

From memory, nodeFunctionscan always populates the tuplestore immediately.
I've looked into changing that but not got it done.

If you write the function in the targetlist, ie

    select srf(...) limit N;

I think it will act more like you expect.

            regards, tom lane