diff options
author | Álvaro Herrera | 2025-07-02 15:02:27 +0000 |
---|---|---|
committer | Álvaro Herrera | 2025-07-02 15:02:27 +0000 |
commit | c989affb527d330898e92e6223e2218e702176ed (patch) | |
tree | 5221a3a1293193588f1b954f0c0e4cf144ea1b4c /src/backend | |
parent | bd3f59fdb71721921bb0aca7e16d483f72e95779 (diff) |
Fix error message for ALTER CONSTRAINT ... NOT VALID
Trying to alter a constraint so that it becomes NOT VALID results in an
error that assumes the constraint is a foreign key. This is potentially
wrong, so give a more generic error message.
While at it, give CREATE CONSTRAINT TRIGGER a better error message as
well.
Co-authored-by: jian he <[email protected]>
Co-authored-by: Fujii Masao <[email protected]>
Co-authored-by: Álvaro Herrera <[email protected]>
Co-authored-by: Amul Sul <[email protected]>
Discussion: https://postgr.es/m/CACJufxHSp2puxP=q8ZtUGL1F+heapnzqFBZy5ZNGUjUgwjBqTQ@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/parser/gram.y | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 1c11b235aa6..a2e084b8f64 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -2668,6 +2668,12 @@ alter_table_cmd: c->alterDeferrability = true; if ($4 & CAS_NO_INHERIT) c->alterInheritability = true; + /* handle unsupported case with specific error message */ + if ($4 & CAS_NOT_VALID) + ereport(ERROR, + errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("constraints cannot be altered to be NOT VALID"), + parser_errposition(@4)); processCASbits($4, @4, "FOREIGN KEY", &c->deferrable, &c->initdeferred, |