| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Subject: | Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt |
| Date: | 2025-11-13 03:44:45 |
| Message-ID: | CACJufxHJ4xXM_svKE3y3=cdsKuM1Ke4PXY0K=xZcCmWw4sjwBQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
------------------
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Restructure-CreateStatsStmt-parse-analysis-processing.patch | text/x-patch | 17.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2025-11-13 03:47:11 | Re: Suggestion to add --continue-client-on-abort option to pgbench |
| Previous Message | jian he | 2025-11-13 03:44:38 | Re: code cleanup for CREATE STATISTICS |