Re: Make EXPLAIN generate a generic plan for a parameterized query

Laurenz Albe <laurenz.albe@cybertec.at>

From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Michel Pelletier <pelletier.michel@gmail.com>
Cc: Julien Rouhaud <rjuju123@gmail.com>, pgsql-hackers@postgresql.org
Date: 2023-01-09T16:40:01Z
Lists: pgsql-hackers

Attachments

On Tue, 2022-12-27 at 14:37 -0800, Michel Pelletier wrote:
> I built and tested this patch for review and it works well, although I got the following warning when building:
> 
> analyze.c: In function 'transformStmt':
> analyze.c:2919:35: warning: 'generic_plan' may be used uninitialized in this function [-Wmaybe-uninitialized]
>  2919 |         pstate->p_generic_explain = generic_plan;
>       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
> analyze.c:2909:25: note: 'generic_plan' was declared here
>  2909 |         bool            generic_plan;
>       |                         ^~~~~~~~~~~~

Thanks for checking.  The variable should indeed be initialized, although
my compiler didn't complain.

Attached is a fixed version.

Yours,
Laurenz Albe

Commits

  1. Invent GENERIC_PLAN option for EXPLAIN.