Skip to content

Commit 388e75a

Browse files
committed
Replace run-time error check with assertion
The error message was checking that the structures returned from the parser matched expectations. That's something we usually use assertions for, not a full user-facing error message. So replace that with an assertion (hidden inside lfirst_node()). Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/452e9df8-ec89-e01b-b64a-8cc6ce830458%40enterprisedb.com
1 parent 2941138 commit 388e75a

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/backend/commands/statscmds.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,14 @@ CreateStatistics(CreateStatsStmt *stmt)
220220
*/
221221
foreach(cell, stmt->exprs)
222222
{
223-
Node *expr = (Node *) lfirst(cell);
224-
StatsElem *selem;
225-
HeapTuple atttuple;
226-
Form_pg_attribute attForm;
227-
TypeCacheEntry *type;
228-
229-
/*
230-
* We should not get anything else than StatsElem, given the grammar.
231-
* But let's keep it as a safety.
232-
*/
233-
if (!IsA(expr, StatsElem))
234-
ereport(ERROR,
235-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
236-
errmsg("only simple column references and expressions are allowed in CREATE STATISTICS")));
237-
238-
selem = (StatsElem *) expr;
223+
StatsElem *selem = lfirst_node(StatsElem, cell);
239224

240225
if (selem->name) /* column reference */
241226
{
242227
char *attname;
228+
HeapTuple atttuple;
229+
Form_pg_attribute attForm;
230+
TypeCacheEntry *type;
243231

244232
attname = selem->name;
245233

@@ -273,6 +261,7 @@ CreateStatistics(CreateStatsStmt *stmt)
273261
{
274262
Node *expr = selem->expr;
275263
Oid atttype;
264+
TypeCacheEntry *type;
276265

277266
Assert(expr != NULL);
278267

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy