Set query_id for query contained in utility statement - Mailing list pgsql-hackers

From Anthonin Bonnefoy
Subject Set query_id for query contained in utility statement
Date
Msg-id CAO6_XqqM6S9bQ2qd=75W+yKATwoazxSNhv5sjW06fjGAtHbTUA@mail.gmail.com
Whole thread Raw
Responses Re: Set query_id for query contained in utility statement
List pgsql-hackers
Hi all,

Some utility statements like Explain, CreateTableAs and DeclareCursor
contain a query which will be planned and executed. During post parse,
only the top utility statement is jumbled, leaving the contained query
without a query_id set. Explain does the query jumble in ExplainQuery
but for the contained query but CreateTableAs and DeclareCursor were
left with unset query_id.

This leads to extensions relying on query_id like pg_stat_statements
to not be able to track those nested queries as the query_id was 0.

This patch fixes this by recursively jumbling queries contained in
those utility statements during post_parse, setting the query_id for
those contained queries and removing the need for ExplainQuery to do
it for the Explain statements.

Regards,
Anthonin Bonnefoy

Attachment

pgsql-hackers by date:

Previous
From: Steven Niu
Date:
Subject: Re: [Patch] remove duplicated smgrclose
Next
From: Kirill Reshke
Date:
Subject: Small refactoring around vacuum_open_relation