Re: Strange DOMAIN behavior

From: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Strange DOMAIN behavior
Date: 2015-07-09 14:10:40
Message-ID: 559E80E0.8000002@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thank you for your reply.
In fact i want to use domains in the following case:

DROP DOMAIN lexema_str CASCADE;
CREATE DOMAIN lexema_str TEXT DEFAULT 'abc' NOT NULL;
DROP TYPE lexema_test CASCADE;
CREATE TYPE lexema_test AS (
lex lexema_str,
lex2 BIGINT
);
DROP TABLE ttt;
CREATE TABLE ttt (
a lexema_test,
b BIGINT
);
INSERT INTO ttt (b) VALUES (1);
SELECT *
FROM ttt;
a | b
---+---
| 1
(1 row)

a.lex is null again not 'abc' as I expected like in plpgsql.

All i want is to have default values in composite types. Feature that
Oracle have.
I thought that with domain type it should be possible.

On 09.07.2015 15:49, David G. Johnston wrote:
> On Thursday, July 9, 2015, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru
> <javascript:_e(%7B%7D,'cvml','a(dot)ignatov(at)postgrespro(dot)ru');>> wrote:
>
> Hello everyone!!!
> Got strange DOMAIN behavior in the following plpgsql code:
>
> But i expect that lex = abc!
>
> So default value of DOMAIN type is not set in pgplsql block but:
>
> Is this correct behavior??
>
>
> If you read the create domain sql command documentation carefully the
> default clause is only used when inserting into a table that has a
> column of the domain type that is not explicitly provided a value.
> Each language deals with domains differently and the behavior you
> expect is not currently implemented in pl/pgsql. If you want a
> default inside the procedure you need to declare one explicitly.
>
> David J.

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2015-07-09 14:23:19 Re: Strange DOMAIN behavior
Previous Message David G. Johnston 2015-07-09 12:49:30 Strange DOMAIN behavior