pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: jian he <jian.universality@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Kirill Reshke <reshkekirill@gmail.com>
Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Date: Mon, 20 Oct 2025 09:31:38 +0200
Message-ID: <202510200724.udgwkvemgo7v@alvherre.pgsql> (raw)
In-Reply-To: <CACJufxGsnzD1Hp1aTSaMoKq7kTifodn3ZiK8UF63SK1tE1LF=A@mail.gmail.com>

On 2025-Oct-20, jian he wrote:

> On Fri, Oct 17, 2025 at 8:13 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:

> /*
>  * transformStatsStmt - parse analysis for CREATE STATISTICS
>  *
>  * To avoid race conditions, it's important that this function relies only on
>  * the passed-in rel (and not on stmt->relation) as the target relation.
>  */
> CreateStatsStmt *
> transformStatsStmt(Relation rel, CreateStatsStmt *stmt, const char *queryString)

> the (Relation rel) effectively comes from "stmt->relations", which
> conflict with the above comments.

Hmm?  It does not.  The whole point is that the relation name (RangeVar
stmt->relations) has already been resolved to an OID and locked, which
is what we pass as 'Relation rel'.  Trying to resolve the name to an OID
again opens us up for race conditions.  This is alleviated if the
relation has already been locked, so maybe we can relax this comment;
but it's not outright contradictory AFAICS.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
"Oh, great altar of passive entertainment, bestow upon me thy discordant images
at such speed as to render linear thought impossible" (Calvin a la TV)





view thread (33+ messages)  latest in thread

Message-ID: <202510200724.udgwkvemgo7v@alvherre.pgsql>
Permalink:  ../202510200724.udgwkvemgo7v@alvherre.pgsql/
Also on:    postgresql.org/message-id/202510200724.udgwkvemgo7v@alvherre.pgsql

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@kurilemu.de, jian.universality@gmail.com, peter@eisentraut.org, tgl@sss.pgh.pa.us, reshkekirill@gmail.com
  Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
  In-Reply-To: <202510200724.udgwkvemgo7v@alvherre.pgsql>

* 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