mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Add some sanity checks in executor for query ID reporting
This commit adds three sanity checks in code paths of the executor where it is possible to use hooks, checking that a query ID is reported in pg_stat_activity if compute_query_id is enabled: - ExecutorRun() - ExecutorFinish() - ExecutorEnd() This causes the test in pg_stat_statements added in 933848d16dc9 to complain immediately in ExecutorRun(). The idea behind this commit is to help extensions to detect if they are missing query ID reports when a query goes through the executor. Perhaps this will prove to be a bad idea, but let's see where this experience goes in v18 and newer versions. Reviewed-by: Sami Imseih Discussion: https://postgr.es/m/ZuJb5xCKHH0A9tMN@paquier.xyz
This commit is contained in:
parent
4f08ab5545
commit
24f5205948
@ -50,6 +50,7 @@
|
|||||||
#include "foreign/fdwapi.h"
|
#include "foreign/fdwapi.h"
|
||||||
#include "mb/pg_wchar.h"
|
#include "mb/pg_wchar.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
#include "nodes/queryjumble.h"
|
||||||
#include "parser/parse_relation.h"
|
#include "parser/parse_relation.h"
|
||||||
#include "rewrite/rewriteHandler.h"
|
#include "rewrite/rewriteHandler.h"
|
||||||
#include "tcop/utility.h"
|
#include "tcop/utility.h"
|
||||||
@ -295,6 +296,9 @@ ExecutorRun(QueryDesc *queryDesc,
|
|||||||
ScanDirection direction, uint64 count,
|
ScanDirection direction, uint64 count,
|
||||||
bool execute_once)
|
bool execute_once)
|
||||||
{
|
{
|
||||||
|
/* If enabled, the query ID should be set. */
|
||||||
|
Assert(!IsQueryIdEnabled() || pgstat_get_my_query_id() != 0);
|
||||||
|
|
||||||
if (ExecutorRun_hook)
|
if (ExecutorRun_hook)
|
||||||
(*ExecutorRun_hook) (queryDesc, direction, count, execute_once);
|
(*ExecutorRun_hook) (queryDesc, direction, count, execute_once);
|
||||||
else
|
else
|
||||||
@ -403,6 +407,9 @@ standard_ExecutorRun(QueryDesc *queryDesc,
|
|||||||
void
|
void
|
||||||
ExecutorFinish(QueryDesc *queryDesc)
|
ExecutorFinish(QueryDesc *queryDesc)
|
||||||
{
|
{
|
||||||
|
/* If enabled, the query ID should be set. */
|
||||||
|
Assert(!IsQueryIdEnabled() || pgstat_get_my_query_id() != 0);
|
||||||
|
|
||||||
if (ExecutorFinish_hook)
|
if (ExecutorFinish_hook)
|
||||||
(*ExecutorFinish_hook) (queryDesc);
|
(*ExecutorFinish_hook) (queryDesc);
|
||||||
else
|
else
|
||||||
@ -463,6 +470,9 @@ standard_ExecutorFinish(QueryDesc *queryDesc)
|
|||||||
void
|
void
|
||||||
ExecutorEnd(QueryDesc *queryDesc)
|
ExecutorEnd(QueryDesc *queryDesc)
|
||||||
{
|
{
|
||||||
|
/* If enabled, the query ID should be set. */
|
||||||
|
Assert(!IsQueryIdEnabled() || pgstat_get_my_query_id() != 0);
|
||||||
|
|
||||||
if (ExecutorEnd_hook)
|
if (ExecutorEnd_hook)
|
||||||
(*ExecutorEnd_hook) (queryDesc);
|
(*ExecutorEnd_hook) (queryDesc);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user