pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Denis Rodionov <denis.rodionov@tantorlabs.com>
To: pgsql-hackers@lists.postgresql.org
Subject: [PATCH] Remove obsolete tupDesc assignment in extended statistics
Date: Thu, 28 May 2026 18:58:39 +0300
Message-ID: <4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com> (raw)

Hi hackers,

Attached is a small cleanup patch for extended statistics.

lookup_var_attr_stats() assigns tupDesc to VacAttrStats entries created 
for expressions. That appears to be obsolete: make_build_data() uses 
tupDesc only when fetching values for regular columns, while expressions 
are handled separately using VacAttrStats entries created by 
examine_expression().

The old comment also points at statext_mcv_build(), but this does not 
seem to match the current code anymore.  If some future code needs a 
tuple descriptor for expression entries here, it should probably set up 
that dependency explicitly rather than rely on copying vacatts[0]->tupDesc.

The patch removes the assignment and the outdated XXX comment.

Best regards,
Denis Rodionov
Tantor Labs LLC,
https://tantorlabs.com/

Attachments:

v1-0001-Remove-obsolete-tupDesc-assignment-in-extended-st.patch (text/x-patch, 1.4K) download From 5c092b86955f9df47e02e393c1ee5a4bf6e6c79c Mon Sep 17 00:00:00 2001 From: Denis Rodionov <denis.rodionov@tantorlabs.ru> Date: Thu, 28 May 2026 17:56:09 +0300 Subject: [PATCH v1] Remove obsolete tupDesc assignment in extended statistics lookup_var_attr_stats() assigns tupDesc to VacAttrStats entries built for expressions. This appears to be obsolete. make_build_data() uses tupDesc only for regular columns, when fetching attribute values from sample rows. For expressions, it creates separate VacAttrStats entries with examine_expression(), so the entries built by lookup_var_attr_stats() do not need tupDesc. Remove the assignment and the outdated XXX comment. --- src/backend/statistics/extended_stats.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 2b83355d26e..049933896b4 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -785,14 +785,6 @@ lookup_var_attr_stats(Bitmapset *attrs, List *exprs, return NULL; } - /* - * XXX We need tuple descriptor later, and we just grab it from - * stats[0]->tupDesc (see e.g. statext_mcv_build). But as coded - * examine_attribute does not set that, so just grab it from the first - * vacatts element. - */ - stats[i]->tupDesc = vacatts[0]->tupDesc; - i++; } -- 2.34.1

view thread (6+ messages)  latest in thread

Message-ID: <4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com>
Permalink:  ../4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com/
Also on:    postgresql.org/message-id/4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com

 ·  · 

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-hackers@postgresql.org
  Cc: denis.rodionov@tantorlabs.com
  Subject: Re: [PATCH] Remove obsolete tupDesc assignment in extended statistics
  In-Reply-To: <4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com>
  References: <4cb9e2ae-9ac4-4e2d-a840-c4accb9d105d@tantorlabs.com>

* 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