diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index e7efb811f66..a334f6b42b1 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -169,7 +169,8 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt, * generated columns are not yet computed when the filtering * happens. */ - if (TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated) + if (attno > 0 && + TupleDescAttr(RelationGetDescr(rel), attno - 1)->attgenerated) ereport(ERROR, errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("generated columns are not supported in COPY FROM WHERE conditions"),