From: | Arturo Guadagnin <tuirutuiru(at)gmail(dot)com> |
---|---|
To: | "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | embedded composite types |
Date: | 2021-02-20 14:41:09 |
Message-ID: | 60311f89.1c69fb81.3220e.2fd4@mx.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have defined a composite type containing attributes of an other composite type, e.g.
create type MyPoint as (
x int,
y int
);
create Type Point2 as (
pt1 MyPoint,
pt2 MyPoint
);
accessing the first level using the dot operator works flawlessly, e.g.
do $$
DECLARE
p MyPoint;
BEGIN
p.x := 1;
p.y := 2;
RAISE NOTICE 'p=%', p;
END;
$$
p=(1,2)
But trying to navigate further gives an error:
do $$
DECLARE
p Point2;
x int;
BEGIN
p.pt1 := (1,2);
p.pt2 := (3,4);
x := p.pt1.x;
END;
$$
[42P01] ERROR: missing FROM-clause entry for table "pt1"
Where: PL/pgSQL function inline_code_block line 8 at assignment
doing it in 2 separate steps works (but is not nice)
do $$
DECLARE
p Point2;
pt1 MyPoint;
x int;
BEGIN
p.pt1 := (1,2);
pt1 := p.pt1;
x := pt1.x;
END;
$$
I’m just wondering whether this is the expected behaviour or if there is any syntactical magic I’m not aware of ....
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2021-02-20 15:07:49 | Re: embedded composite types |
Previous Message | Steve Midgley | 2021-02-09 16:44:15 | Re: Relationship between PostgreSQL and Datalakes and etc on Azure |