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

From Andrus
Subject Re: How to use record variable with non-null domain in plpgsql
Date
Msg-id 4615C04672CE45D4971088CC35984D04@dell2
Whole thread Raw
In response to Re: How to use record variable with non-null domain in plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi!

>TBH, the problem here is with the not-null constraint on the domain.
>Get rid of that and you'll be much happier.

Is the only reasonable way is to change domain using

ALTER DOMAIN tebool DROP  NOT NULL   ?

bool types of columns are never used in database. Instead of them tebool type is alway used.

There are alrge number of tebool columns in database. In different installations there may be additional tebool columns

not know at design time.
Will everything work after such change ?

How to disable null values in tebool columns then ?
Should script created which loops over all tebool columns in all tables and adds not null constraint to them ?

Or is there some better solution ?

> 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?

I tried:

create temp table test  ( test tebool, test2 numeric ) on commit drop ;
create temp table test1  ( test tebool, test2 numeric ) on commit drop ;
insert into test values (false,1);

select test1.test  from test left join test1 on false;

query returns null value.

I also tried to cast result to tebool

select test1.test::tebool  from test left join test1 on false;

and

select null::ebool

This returns also null. So Postgres allows null values in this type instance.
There are no problems.


Andrus.



pgsql-general by date:

Previous
From: Igor Sosa Mayor
Date:
Subject: Re: Problem with pl/python procedure connecting to the internet
Next
From: Melvin Davidson
Date:
Subject: Re: PostgreSQL Developer Best Practices