Re: How to use record variable with non-null domain in plpgsql - Mailing list pgsql-general

From Tom Lane
Subject Re: How to use record variable with non-null domain in plpgsql
Date
Msg-id 17664.1440258228@sss.pgh.pa.us
Whole thread Raw
In response to How to use record variable with non-null domain in plpgsql  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to use record variable with non-null domain in plpgsql
How to speed up delete where not in
List pgsql-general
"Andrus" <kobruleht2@hot.ee> writes:
> I'm looging for a way to use tebool type records in plpgsql method starting from Postgres 9.1
> I tried code below but got error

> domain tebool does not allow null values
> Domain tebool default value is false so plpgsql must assing false to it and should not throw error.

> How to fix this so that such record variable can created ?

TBH, the problem here is with the not-null constraint on the domain.
Get rid of that and you'll be much happier.  Data types that try to
insist on not being NULL are fundamentally incompatible with SQL
semantics --- to take one example, what do you think will happen
to a column of such a type when it's on the outside of a LEFT JOIN?

It's reasonable to assign NOT NULL requirements to individual table
columns, but not to think of it as being a property of a data type.

Or another way to put it: NULL in SQL is a type-independent concept.
Individual data types simply don't get to opt out of that without
creating more problems than they solve.

            regards, tom lane


pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: How to use record variable with non-null domain in plpgsql
Next
From: Karsten Hilbert
Date:
Subject: Re: PostgreSQL Developer Best Practices