Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt - Mailing list pgsql-hackers

From jian he
Subject Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Date
Msg-id CACJufxHJ4xXM_svKE3y3=cdsKuM1Ke4PXY0K=xZcCmWw4sjwBQ@mail.gmail.com
Whole thread Raw
In response to Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt  (Álvaro Herrera <alvherre@kurilemu.de>)
Responses Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
List 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.
------------------

--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: code cleanup for CREATE STATISTICS
Next
From: Fujii Masao
Date:
Subject: Re: Suggestion to add --continue-client-on-abort option to pgbench