Skip site navigation (1) Skip section navigation (2)

BUG #3328: initialization complex types with domain column

From: "Sergey Morgalev" <sergo(at)virtonomica(dot)ru>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3328: initialization complex types with domain column
Date: 2007-05-31 13:27:45
Message-ID: 200705311327.l4VDRjWC044319@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      3328
Logged by:          Sergey Morgalev
Email address:      sergo(at)virtonomica(dot)ru
PostgreSQL version: 8.2.4
Operating system:   windows xp, free bsd
Description:        initialization complex types with domain column
Details: 

Hello.
When user defined complex type with user defined DOMAIN with NOT NULL AND
DEFAULT attrubute, postgres can't initialize variable in DECLARE section of
PROCEDURE

for example:

-- create some DOMAIN
CREATE DOMAIN my_domain AS numeric DEFAULT 0 NOT NULL;

-- create complex type
CREATE TYPE t_my_type AS (
  int id,
  name vachar,
  value my_domain
)


PostgreSQL 8.2.4
does not allow the declare variable with type 't_my_type' in a FUNCTION

CREATE OR REPLACE FUNCTION m_function() RETURNS SETOF t_my_type AS $$
DECLARE
  _my_var t_my_type;
------- skipped ------


ERROR:  domain my_domain does not allow null values
CONTEXT:  PL/pgSQL function "my_function" line 4 at block variables
initialization

Ok.
will declare the '_my_var' variable with type 'RECORD' and initialize record
in the FUNCTION body.
Postgres will cast the record var to t_my_type and allow return SETOF.

But.
When FUNCTION accept argument with complex type, it is not possible.
PostgreSQL can't cast record to user defined type.

It is not possible use complex types with such domains in procedures.

In previous version - 8.2.1 it's worked normaly.

pgsql-bugs by date

Next:From: Thekkayil Joy ThomasDate: 2007-06-01 05:47:23
Subject: BUG #3329: Issue with INSERT INTO for japanese katakana characters.
Previous:From: JohndhihjDate: 2007-05-31 12:41:11
Subject: BUG #3327: Hi great site great work thank you!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group