pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ignore IntoClause.viewQuery in query jumbling
Date: Wed, 08 Mar 2023 02:42:21 +0000
Message-ID: <E1pZjkz-002RAx-97@gemulon.postgresql.org> (raw)

Ignore IntoClause.viewQuery in query jumbling

IntoClause.viewQuery is a copy of the parsed-but-not-rewritten SELECT
clause copied to IntoClause when transforming CreateTableAsStmt for a
materialized view.  Including a second copy of the SELECT Query into the
query jumbling was leading to an incorrect numbering of the Const node
locations, as these would be counted twice instead of once.

This becomes visible once the query normalization is applied to CREATE
MATERIALIZED VIEW in pg_stat_statements in the shape of a query string
using only odd numbers for the normalized constants, (regression tests
added in pg_stat_statements as of de2aca2 would show the difference).
Including the original Query from CreateTableAsStmt is enough for the
query jumbling.

Reviewed-by: Bertrand Drouvot
Discussion: https://postgr.es/m/Y+MRdEq9W9XVa2AB@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d69cd3a2e29c68a3fdfd4e97167f9a7c6ad29e80

Modified Files
--------------
src/include/nodes/primnodes.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)



Message-ID: <E1pZjkz-002RAx-97@gemulon.postgresql.org>
Permalink:  ../E1pZjkz-002RAx-97@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pZjkz-002RAx-97@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Ignore IntoClause.viewQuery in query jumbling
  In-Reply-To: <E1pZjkz-002RAx-97@gemulon.postgresql.org>
  References: <E1pZjkz-002RAx-97@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox