Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Peter Eisentraut <peter@eisentraut.org>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Kirill Reshke <reshkekirill@gmail.com>
Date: 2025-11-13T03:44:45Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
CREATE STATISTICS: improve misleading error message
- cbd3732cbbaa 14.20 landed
- 4529861cc408 15.15 landed
- f30c04682cdf 16.11 landed
- f9b41f3e1ecd 17.7 landed
- 38883916e41c 18.0 landed
- 9ec0b29976b6 19 (unreleased) landed
- f9a7622483c3 15.15 landed
- f225473cbae2 19 (unreleased) landed
- e9fb314c7ad8 17.7 landed
- d84a6c3dad1f 16.11 landed
- b830f9d67463 14.20 landed
- 3eea4dc2c7cf 18.0 landed
-
Glossary: improve definition of "relation"
- 16a9165ce4a4 19 (unreleased) landed
-
Extended statistics on expressions
- a4d75c86bf15 14.0 cited
Attachments
- v5-0001-Restructure-CreateStatsStmt-parse-analysis-processing.patch (text/x-patch) patch v5-0001
hi. new patch attached. Summary of the problem we’re trying to solve: 1. ProcessUtility for T_CreateStatsStmt, there’s a lot of code that doesn’t belong there. 2. The current pattern of repeatedly performing RangeVar lookups isn’t ideal — we should perform the lookup once and then use the corresponding relation OID for subsequent operations. The main part this patch is copied from https://postgr.es/m/CA+TgmobyMXzoEzscCRDCggHRCTp1TW=Dm9pEhmwOYKos43WDAg@mail.gmail.com Below is a copy of the commit message. ------------------ Previously, a lot of code would be run in the ProcessUtility pipeline, where it is not welcome (that's supposed to be just a giant dispatcher switch). Move the parse analysis code to CreateStatistics() instead, which then means we don't need to open the relation twice; it also allows us to give a better error message when something other than a relation name is given in the FROM clause. Generally we should avoid look up the same less-than-fully-qualified name multiple times, we might get different answers due to concurrent activity, and that might create a security vulnerability, along the lines of CVE-2014-0062. Refactor so that a CreateStatsStmt carries both the untransformed FROM clause and the range table that we get when it's transformed. That way, once the name lookups have been done, we can propagate the results forward to future processing steps and avoid ever repeating the lookup. ------------------ -- jian https://www.enterprisedb.com/