agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Alex Ignatov <a.ignatov@postgrespro.ru>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Strange DOMAIN behavior
Date: Thu, 09 Jul 2015 17:10:40 +0300
Message-ID: <559E80E0.8000002@postgrespro.ru> (raw)
In-Reply-To: <CAKFQuwYOZQ22qNtPe0m4w047DLhnDati8+Yqhcd6S2SOYL2GDQ@mail.gmail.com>
References: <559E470F.6020002@postgrespro.ru>
<CAKFQuwYOZQ22qNtPe0m4w047DLhnDati8+Yqhcd6S2SOYL2GDQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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.ignatov@postgrespro.ru
> <javascript:_e(%7B%7D,'cvml','a.ignatov@postgrespro.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
view thread (7+ messages) latest in thread
Message-ID: <559E80E0.8000002@postgrespro.ru>
Permalink: ../559E80E0.8000002@postgrespro.ru/
Also on: postgresql.org/message-id/559E80E0.8000002@postgrespro.ru
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: a.ignatov@postgrespro.ru, david.g.johnston@gmail.com
Subject: Re: Strange DOMAIN behavior
In-Reply-To: <559E80E0.8000002@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox