mirror of https://github.com/postgres/postgres
499edb0974
Previously, a Query generated through the transform phase would have
unset stmt_location, tracking the starting point of a query string.
Extensions relying on the statement location to extract its relevant
parts in the source text string would fallback to use the whole
statement instead, leading to confusing results like in
pg_stat_statements for queries relying on nested queries, like:
- EXPLAIN, with top-level and nested query using the same query string,
and a query ID coming from the nested query when the non-top-level
entry.
- Multi-statements, with only partial portions of queries being
normalized.
- COPY TO with a query, SELECT or DMLs.
This patch improves things by keeping track of the statement locations
and propagate it to Query during transform, allowing PGSS to only show
the relevant part of the query for nested query. This leads to less
bloat in entries for non-top-level entries, as queries can now be
grouped within the same (toplevel, queryid) duos in pg_stat_statements.
The result gives a stricter one-one mapping between query IDs and its
query strings.
The regression tests introduced in
|
||
---|---|---|
.. | ||
cleanup.sql | ||
cursors.sql | ||
dml.sql | ||
entry_timestamp.sql | ||
extended.sql | ||
level_tracking.sql | ||
oldextversions.sql | ||
parallel.sql | ||
planning.sql | ||
privileges.sql | ||
select.sql | ||
user_activity.sql | ||
utility.sql | ||
wal.sql |