Strange DOMAIN behavior

From: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Strange DOMAIN behavior
Date: 2015-07-09 10:03:59
Message-ID: 559E470F.6020002@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2015-07-09 12:49:30 Strange DOMAIN behavior
Previous Message Vinayak 2015-07-09 09:35:19 Re: Octal to UTF-8