Strange DOMAIN behavior - Mailing list pgsql-sql

From Alex Ignatov
Subject Strange DOMAIN behavior
Date
Msg-id 559E470F.6020002@postgrespro.ru
Whole thread Raw
Responses Strange DOMAIN behavior
List pgsql-sql
Hello everyone!!!
Got strange DOMAIN behavior in the following plpgsql code:

postgres=# DROP DOMAIN lexema_str CASCADE;
DROP DOMAIN
postgres=# CREATE DOMAIN lexema_str TEXT DEFAULT 'abc';
CREATE DOMAIN
postgres=# DO $$
postgres$# DECLARE
postgres$#    lex lexema_str;
postgres$# BEGIN
postgres$#    RAISE NOTICE 'lex = %', lex;
postgres$# END;
postgres$# $$;
NOTICE:  lex = <NULL>
DO

But i expect that lex = abc!

So default value of DOMAIN type is not set in pgplsql block but:

postgres=# DROP DOMAIN lexema_str CASCADE;
DROP DOMAIN
postgres=# CREATE DOMAIN lexema_str TEXT DEFAULT 'abc' NOT NULL;
CREATE DOMAIN
postgres=# DO $$
postgres$# DECLARE
postgres$#    lex lexema_str;
postgres$# BEGIN
postgres$#    RAISE NOTICE 'lex = %', lex;
postgres$# END;
postgres$# $$;
ERROR:  domain lexema_str does not allow null values
CONTEXT:  PL/pgSQL function inline_code_block line 4 during statement 
block local variable initialization

So constraints in DOMAIN type work in pgplsql !

Is this correct behavior??




-- 
Alex Ignatov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus




pgsql-sql by date:

Previous
From: Vinayak
Date:
Subject: Re: Octal to UTF-8
Next
From: "David G. Johnston"
Date:
Subject: Strange DOMAIN behavior