Re: array of domain types - Mailing list pgsql-hackers

From Rod Taylor
Subject Re: array of domain types
Date
Msg-id CAKddOFAGwxWKciPjavo+Yfd0RaGJ9TgJP=9yyFVgSw9JkJuk+A@mail.gmail.com
Whole thread Raw
In response to Re: array of domain types  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Responses Re: array of domain types  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
List pgsql-hackers


On Thu, Jun 2, 2016 at 10:42 AM, Konstantin Knizhnik <k.knizhnik@postgrespro.ru> wrote:
On 02.06.2016 17:22, Tom Lane wrote:
konstantin knizhnik <k.knizhnik@postgrespro.ru> writes:
Attached please find patch for DefineDomain function.
You didn't attach the patch,

Sorry, but I did attached the patch - I see the attachment in my mail received from the group.
Multidimensional arrays work fine:

knizhnik=# SELECT '{{14},{20}}'::teenager[][];
ERROR:  value for domain teenager violates check constraint "teenager_check"
LINE 1: SELECT '{{14},{20}}'::teenager[][];
               ^
knizhnik=# SELECT '{{14},{19}}'::teenager[][];
  teenager
-------------
 {{14},{19}}
(1 row)

knizhnik=# SELECT ('{{14},{19}}'::teenager[][])[1][1];
 teenager
----------
       14
(1 row)


Domain of array of domain also works:


I applied the domain.patch from above on HEAD, and all I get is cache lookup failures. The type_sanity regression test fails too.

postgres=# CREATE DOMAIN teenager AS int CHECK (VALUE BETWEEN 13 AND 20);
CREATE DOMAIN
postgres=# CREATE DOMAIN teenager_groups AS teenager[];
CREATE DOMAIN
postgres=# CREATE TABLE x (col teenager_groups);
ERROR:  cache lookup failed for type 0


Anyway, if that worked for me I would have done this which I expect will succeed when it shouldn't.

INSERT INTO x VALUES (ARRAY[13,14,20]);
ALTER DOMAIN teenager DROP CONSTRAINT teenager_check;
ALTER DOMAIN teenager ADD CHECK (VALUE BETWEEN 13 AND 19);

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: IPv6 link-local addresses and init data type
Next
From: Thomas Munro
Date:
Subject: Re: kqueue