BUG #3328: initialization complex types with domain column - Mailing list pgsql-bugs

From Sergey Morgalev
Subject BUG #3328: initialization complex types with domain column
Date
Msg-id 200705311327.l4VDRjWC044319@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3328
Logged by:          Sergey Morgalev
Email address:      sergo@virtonomica.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:

Previous
From: "Johndhihj"
Date:
Subject: BUG #3327: Hi great site great work thank you!
Next
From: "Thekkayil Joy Thomas"
Date:
Subject: BUG #3329: Issue with INSERT INTO for japanese katakana characters.