Re: How to use record variable with non-null domain in plpgsql

Поиск
Список
Период
Сортировка
От Andrus
Тема Re: How to use record variable with non-null domain in plpgsql
Дата
Msg-id 4615C04672CE45D4971088CC35984D04@dell2
обсуждение исходный текст
Ответ на Re: How to use record variable with non-null domain in plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Igor Sosa Mayor
Дата:
Сообщение: Re: Problem with pl/python procedure connecting to the internet
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: PostgreSQL Developer Best Practices