diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index cd23ab3b25..e4451b1d36 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -572,9 +572,18 @@ DefineIndex(Oid relationId, Oid root_save_userid; int root_save_sec_context; int root_save_nestlevel; + ListCell *lc; root_save_nestlevel = NewGUCNestLevel(); + foreach (lc, stmt->indexParams) + { + IndexElem *ielem = castNode(IndexElem, lfirst(lc)); + if (IsA(ielem->expr, Var) && castNode(Var, ielem->expr)->varattno == 0) + ereport(ERROR, + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("cannot create index on whole-row expression of table '%s'", ielem->indexcolname))); + } /* * Some callers need us to run with an empty default_tablespace; this is a * necessary hack to be able to reproduce catalog state accurately when