Discussion:
Nested composite types again
(too old to reply)
Michael Kolomeitsev
2012-11-28 11:02:47 UTC
Permalink
Hi,

I have already read this
http://www.postgresql.org/docs/9.2/static/rowtypes.html#AEN7304
but it didn't help.

CREATE TABLE nodes (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT NOT NULL
);

CREATE TYPE pathId AS (
id INTEGER,
node nodes
);

CREATE OR REPLACE FUNCTION test_AEN7304() RETURNS void AS $$
DECLARE
r pathId;
n nodes;
BEGIN
n.name := 'abc';
r.id := 1;
r.node := n; -- All is ok
-- r.node.name := 'def'; -- << Error here
-- (r).node.name := 'def'; -- << and here
((r).node).name := 'def'; -- << and here
END;
$$ LANGUAGE 'plpgsql';

And I can't even make 'n' as ALIAS FOR r.node (to simulate C-like pointer).

What is the right syntax?
Thanks
Vibhor Kumar
2012-11-28 15:37:07 UTC
Permalink
Post by Michael Kolomeitsev
Hi,
I have already read this
http://www.postgresql.org/docs/9.2/static/rowtypes.html#AEN7304
but it didn't help.
CREATE TABLE nodes (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TYPE pathId AS (
id INTEGER,
node nodes
);
CREATE OR REPLACE FUNCTION test_AEN7304() RETURNS void AS $$
DECLARE
r pathId;
n nodes;
BEGIN
n.name := 'abc';
r.id := 1;
r.node := n; -- All is ok
-- r.node.name := 'def'; -- << Error here
-- (r).node.name := 'def'; -- << and here
((r).node).name := 'def'; -- << and here
END;
$$ LANGUAGE 'plpgsql';
And I can't even make 'n' as ALIAS FOR r.node (to simulate C-like pointer).
What is the right syntax?
Thanks
I have verified that plpgsql doesn't allow assignment like r.node.name='def' or (r).node.name or ((r).node).name

In Above case, you can use some variable like n and update the n composite variable and assigned it to r.node as you have already done in plpgsql.

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Blog:http://vibhork.blogspot.com
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Michael Kolomeitsev
2012-11-28 16:51:52 UTC
Permalink
Ok.
How do you think should I report this as a bug?
Post by Michael Kolomeitsev
Post by Michael Kolomeitsev
Hi,
I have already read this
http://www.postgresql.org/docs/9.2/static/rowtypes.html#AEN7304
but it didn't help.
CREATE TABLE nodes (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TYPE pathId AS (
id INTEGER,
node nodes
);
CREATE OR REPLACE FUNCTION test_AEN7304() RETURNS void AS $$
DECLARE
r pathId;
n nodes;
BEGIN
n.name := 'abc';
r.id := 1;
r.node := n; -- All is ok
-- r.node.name := 'def'; -- << Error here
-- (r).node.name := 'def'; -- << and here
((r).node).name := 'def'; -- << and here
END;
$$ LANGUAGE 'plpgsql';
And I can't even make 'n' as ALIAS FOR r.node (to simulate C-like
pointer).
Post by Michael Kolomeitsev
What is the right syntax?
Thanks
I have verified that plpgsql doesn't allow assignment like r.node.name='def'
or (r).node.name or ((r).node).name
In Above case, you can use some variable like n and update the n composite
variable and assigned it to r.node as you have already done in plpgsql.
Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Blog:http://vibhork.blogspot.com
Christian Hammers
2012-11-28 17:59:42 UTC
Permalink
Hello

Try http://www.postgresql.org/support/submitbug/

bye,

-christian-


On Wed, 28 Nov 2012 23:51:52 +0700
Post by Michael Kolomeitsev
Ok.
How do you think should I report this as a bug?
Post by Michael Kolomeitsev
Post by Michael Kolomeitsev
Hi,
I have already read this
http://www.postgresql.org/docs/9.2/static/rowtypes.html#AEN7304
but it didn't help.
CREATE TABLE nodes (
id SERIAL NOT NULL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TYPE pathId AS (
id INTEGER,
node nodes
);
CREATE OR REPLACE FUNCTION test_AEN7304() RETURNS void AS $$
DECLARE
r pathId;
n nodes;
BEGIN
n.name := 'abc';
r.id := 1;
r.node := n; -- All is ok
-- r.node.name := 'def'; -- << Error here
-- (r).node.name := 'def'; -- << and here
((r).node).name := 'def'; -- << and here
END;
$$ LANGUAGE 'plpgsql';
And I can't even make 'n' as ALIAS FOR r.node (to simulate C-like
pointer).
Post by Michael Kolomeitsev
What is the right syntax?
Thanks
I have verified that plpgsql doesn't allow assignment like r.node.name='def'
or (r).node.name or ((r).node).name
In Above case, you can use some variable like n and update the n composite
variable and assigned it to r.node as you have already done in plpgsql.
Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Blog:http://vibhork.blogspot.com
--
Network Engineering & Design; Content Delivery Platform & IP

NETCOLOGNE Gesellschaft für Telekommunikation mbH
Am Coloneum 9 | 50829 Köln
Tel: 0221 2222-8711 | Fax: 0221 2222-78711
www.netcologne.de

Geschäftsführer:
Dr. Hans Konle (Sprecher)
Dipl.-Ing. Karl-Heinz Zankel
HRB 25580, AG Köln



Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sollten Sie diese
Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch
Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu
löschen. Die E-Mail darf in diesem Fall weder vervielfältigt noch in anderer
Weise verwendet werden.
--
Sent via pgsql-novice mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Loading...