pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14330: can not select into `composite data types` in plpgsql
3+ messages / 2 participants
[nested] [flat]
* BUG #14330: can not select into `composite data types` in plpgsql
@ 2016-09-21 03:51 zoulx1982@163.com
0 siblings, 1 reply; 3+ messages in thread
From: zoulx1982@163.com @ 2016-09-21 03:51 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 14330
Logged by: lx zou
Email address: zoulx1982@163.com
PostgreSQL version: 9.5.1
Operating system: win7 6.1.7601
Description:
Hi,
when i use composite type in plpgsql, i found it does't work when i
select a composite type column into a composite type variable.
But it can work well when i use another style like this:
select (y).a,(y).b into tmp from t....
following is a full example. Thanks.
create type mytype(a int, b text);
create table mytab(x int, y mytype);
insert into mytab values(1, (1, 'abcd'));
do $$
declare
tmp mytype;
begin
--ERROR: invalid input syntax for integer: "(1,asddd)"
--CONTEXT: PL/pgSQL function inline_code_block line 6 at SQL statement
select y into strict tmp from mytab;
raise notice '%,%', (tmp).a, (tmp).b;
end;
$$;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14330: can not select into `composite data types` in plpgsql
@ 2016-09-21 07:12 Pavel Stehule <pavel.stehule@gmail.com>
parent: zoulx1982@163.com
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Stehule @ 2016-09-21 07:12 UTC (permalink / raw)
To: zoulx1982@163.com; +Cc: pgsql-bugs
Hi
2016-09-21 5:51 GMT+02:00 <zoulx1982@163.com>:
> The following bug has been logged on the website:
>
> Bug reference: 14330
> Logged by: lx zou
> Email address: zoulx1982@163.com
> PostgreSQL version: 9.5.1
> Operating system: win7 6.1.7601
> Description:
>
> Hi,
> when i use composite type in plpgsql, i found it does't work when i
> select a composite type column into a composite type variable.
> But it can work well when i use another style like this:
> select (y).a,(y).b into tmp from t....
> following is a full example. Thanks.
>
> create type mytype(a int, b text);
> create table mytab(x int, y mytype);
> insert into mytab values(1, (1, 'abcd'));
> do $$
> declare
> tmp mytype;
> begin
> --ERROR: invalid input syntax for integer: "(1,asddd)"
> --CONTEXT: PL/pgSQL function inline_code_block line 6 at SQL
> statement
> select y into strict tmp from mytab;
> raise notice '%,%', (tmp).a, (tmp).b;
> end;
> $$;
>
It is not bug - although I understand so this behave is not unfriendly. The
pattern composite var := composite value is not supported due possible
ambiguous assignment internally in PLpgSQL implementation.
Regards
Pavel Stehule
>
> It is no
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14330: can not select into `composite data types` in plpgsql
@ 2016-09-21 10:30 Pavel Stehule <pavel.stehule@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Stehule @ 2016-09-21 10:30 UTC (permalink / raw)
To: 自己 <zoulx1982@163.com>; +Cc: pgsql-bugs
Hi
2016-09-21 10:08 GMT+02:00 自己 <zoulx1982@163.com>:
> > It is not bug - although I understand so this behave is not unfriendly.
> The pattern composite var := composite value is not supported due possible
> ambiguous
> > assignment internally in PLpgSQL implementation.
>
> Thank you for your reply.
> It seems work well for the pattern "composite var := composite value" in
> plpgsql body, but not in declare sestion(default value).
> Besides this, i want to know if i want to implement this pattern, which
> part is difficult?
>
the result of SQL query is result set. when you use composite type, then
result will be nested compose type. But you don't have simply access to
original query, and you don't know if you should or should not do unnesting.
Regards
Pavel Stehule
>
>
> 2016-09-21 15:12:33,"Pavel Stehule" <pavel.stehule@gmail.com>
>
> Hi
>
> 2016-09-21 5:51 GMT+02:00 <zoulx1982@163.com>:
>
>> The following bug has been logged on the website:
>>
>> Bug reference: 14330
>> Logged by: lx zou
>> Email address: zoulx1982@163.com
>> PostgreSQL version: 9.5.1
>> Operating system: win7 6.1.7601
>> Description:
>>
>> Hi,
>> when i use composite type in plpgsql, i found it does't work when i
>> select a composite type column into a composite type variable.
>> But it can work well when i use another style like this:
>> select (y).a,(y).b into tmp from t....
>> following is a full example. Thanks.
>>
>> create type mytype(a int, b text);
>> create table mytab(x int, y mytype);
>> insert into mytab values(1, (1, 'abcd'));
>> do $$
>> declare
>> tmp mytype;
>> begin
>> --ERROR: invalid input syntax for integer: "(1,asddd)"
>> --CONTEXT: PL/pgSQL function inline_code_block line 6 at SQL
>> statement
>> select y into strict tmp from mytab;
>> raise notice '%,%', (tmp).a, (tmp).b;
>> end;
>> $$;
>>
>
> It is not bug - although I understand so this behave is not unfriendly.
> The pattern composite var := composite value is not supported due possible
> ambiguous assignment internally in PLpgSQL implementation.
>
> Regards
>
> Pavel Stehule
>
>
>>
>> It is no
>>
>> --
>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-bugs
>>
>
>
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2016-09-21 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 03:51 BUG #14330: can not select into `composite data types` in plpgsql zoulx1982@163.com
2016-09-21 07:12 ` Pavel Stehule <pavel.stehule@gmail.com>
2016-09-21 10:30 ` Pavel Stehule <pavel.stehule@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox