Commit 388e75ad authored by Peter Eisentraut's avatar Peter Eisentraut

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: default avatarTom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/452e9df8-ec89-e01b-b64a-8cc6ce830458%40enterprisedb.com
parent 2941138e
...@@ -220,26 +220,14 @@ CreateStatistics(CreateStatsStmt *stmt) ...@@ -220,26 +220,14 @@ CreateStatistics(CreateStatsStmt *stmt)
*/ */
foreach(cell, stmt->exprs) foreach(cell, stmt->exprs)
{ {
Node *expr = (Node *) lfirst(cell); StatsElem *selem = lfirst_node(StatsElem, cell);
StatsElem *selem;
HeapTuple atttuple;
Form_pg_attribute attForm;
TypeCacheEntry *type;
/*
* We should not get anything else than StatsElem, given the grammar.
* But let's keep it as a safety.
*/
if (!IsA(expr, StatsElem))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("only simple column references and expressions are allowed in CREATE STATISTICS")));
selem = (StatsElem *) expr;
if (selem->name) /* column reference */ if (selem->name) /* column reference */
{ {
char *attname; char *attname;
HeapTuple atttuple;
Form_pg_attribute attForm;
TypeCacheEntry *type;
attname = selem->name; attname = selem->name;
...@@ -273,6 +261,7 @@ CreateStatistics(CreateStatsStmt *stmt) ...@@ -273,6 +261,7 @@ CreateStatistics(CreateStatsStmt *stmt)
{ {
Node *expr = selem->expr; Node *expr = selem->expr;
Oid atttype; Oid atttype;
TypeCacheEntry *type;
Assert(expr != NULL); Assert(expr != NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment