hi. create table t(a int, constraint cc check(a = 1)); ALTER TABLE t ALTER CONSTRAINT cc not valid; ERROR: FOREIGN KEY constraints cannot be marked NOT VALID LINE 1: ALTER TABLE t ALTER CONSTRAINT cc not valid; ^
the error message seems misleading, should we consider it as a bug for pg18? the entry point is in gram.y, following part: | ALTER CONSTRAINT name ConstraintAttributeSpec { AlterTableCmd *n = makeNode(AlterTableCmd); ATAlterConstraint *c = makeNode(ATAlterConstraint); n->subtype = AT_AlterConstraint; n->def = (Node *) c; c->conname = $3; if ($4 & (CAS_NOT_ENFORCED | CAS_ENFORCED)) c->alterEnforceability = true; if ($4 & (CAS_DEFERRABLE | CAS_NOT_DEFERRABLE | CAS_INITIALLY_DEFERRED | CAS_INITIALLY_IMMEDIATE)) c->alterDeferrability = true; if ($4 & CAS_NO_INHERIT) c->alterInheritability = true; processCASbits($4, @4, "FOREIGN KEY", &c->deferrable, &c->initdeferred, &c->is_enforced, NULL, &c->noinherit, yyscanner); $$ = (Node *) n; }