Skip to content
Advertisement

EXPLAIN ANALYZE within PL/pgSQL gives error: “query has no destination for result data”

I am trying to understand the query plan for a select statement within a PL/pgSQL function, but I keep getting errors. My question: how do I get the query plan?

Following is a simple case that reproduces the problem.

The table in question is named test_table.

The function is as follows:

When I run

I get the error:

The function works fine if I uncomment the commented portion and comment out explain analyze.

Advertisement

Answer

Or you can use this simpler form with RETURN QUERY:

Call:

Works for me in Postgres 9.3.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement