Hi,
Went through the added code for domain check, and I guess the pattern
is similar to check and is correct, tested it.
> @@ -4499,13 +4501,22 @@ ExecEvalConstraintCheck(ExprState *state,
> ExprEvalStep *op)
> if (!*op->d.domaincheck.checknull &&
> !DatumGetBool(*op->d.domaincheck.checkvalue))
> {
> char *check_desc;
>
> check_desc =
> deparse_expression(stringToNode(op->d.domaincheck.constraint->check_expr_bin),
> NIL, false, false);
>
> errsave((Node *) op->d.domaincheck.escontext,
> (errcode(ERRCODE_CHECK_VIOLATION),
> errmsg("value for domain %s violates check constraint \"%s\"",
> format_type_be(op->d.domaincheck.resulttype),
> op->d.domaincheck.constraintname),
> op->d.domaincheck.constraint->name),
> check_desc ?
> errdetail("Check constraint expression: %s.",
> check_desc) : 0,
> errdomainconstraint(op->d.domaincheck.resulttype,
> op->d.domaincheck.constraintname)));
Only one thing I wanted to point out is the check for 'check_desc' in
errsave, I guess it could be removed as 'deparse_expression' which
calls 'deparse_expression_pretty' initializes the string to be
returned using palloc and on failure it reports error instead of
returning NULL so check_desc shouldn't be NULL, am I missing anything?
Regards,
Yash