On 23/01/2026 12:50, Tommi Prami wrote:
> Hello
>
> If I created the domains as follows, it works the way I expected it to.
>
> -- STEP 1: Create Domains and Table
> CREATE DOMAIN D_INT AS INTEGER;
> CREATE DOMAIN D_INTID AS INTEGER NOT NULL CHECK(VALUE >= 0);
> CREATE DOMAIN D_STR AS VARCHAR(50);
>
> And about the Ticket, I am not sure what it should be about?
That adding a column with a DEFAULT but without a NOT NULL constraint
should also set the default for existing columns; not just when there is
a NOT NULL constraint
> Was thinking that could this fail
>
> CREATE DOMAIN D_INTID AS INTEGER CHECK((VALUE IS NOT NULL) AND (VALUE >=
> 0));
>
> Because it has check that does not fire. I mean " (VALUE IS NOT NULL)
> " Engine could give user error that you have check that is not logical
> and never ever has a effect.
As Dimitry said, the engine doesn't evaluate CHECK constraints when
adding a column, only NOT NULL constraints. Funnily enough, I can't find
a reference in the standard whether they should be evaluated or not when
adding columns, but in that regard the standard can be a real pain in
the ass.
> As I see it
>
> CREATE DOMAIN D_INTID AS INTEGER CHECK((VALUE IS NOT NULL) AND (VALUE >=
> 0));
> and
> CREATE DOMAIN D_INTID AS INTEGER CHECK(VALUE >= 0);
>
> Are both basically exactly the same. For sure there can be some other
> case when the " (VALUE IS NOT NULL) AND " part could make some
> sense though, I dunno.
They may be the same to you, but definitionally they are different things.
Mark
--
Mark Rotteveel