Commit d6651620 authored by Alvaro Herrera's avatar Alvaro Herrera

Don't try to use a constraint name as domain name

The bug that caused this to be discovered is that the code was trying to
dereference a NULL or ill-defined pointer, as reported by Michael Mueller;
but what it was doing was wrong anyway, per Heikki.

This patch is Heikki's suggested fix.
parent 9f084527
...@@ -2096,13 +2096,13 @@ AlterDomainValidateConstraint(List *names, char *constrName) ...@@ -2096,13 +2096,13 @@ AlterDomainValidateConstraint(List *names, char *constrName)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("constraint \"%s\" of domain \"%s\" does not exist", errmsg("constraint \"%s\" of domain \"%s\" does not exist",
constrName, NameStr(con->conname)))); constrName, TypeNameToString(typename))));
if (con->contype != CONSTRAINT_CHECK) if (con->contype != CONSTRAINT_CHECK)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("constraint \"%s\" of domain \"%s\" is not a check constraint", errmsg("constraint \"%s\" of domain \"%s\" is not a check constraint",
constrName, NameStr(con->conname)))); constrName, TypeNameToString(typename))));
val = SysCacheGetAttr(CONSTROID, tuple, val = SysCacheGetAttr(CONSTROID, tuple,
Anum_pg_constraint_conbin, Anum_pg_constraint_conbin,
......
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