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