Re: Re: issue: record or row variable cannot be part of multiple-item INTO list

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Anthony Bykov <a(dot)bykov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: issue: record or row variable cannot be part of multiple-item INTO list
Date: 2017-09-19 21:21:25
Message-ID: CAKFQuwaT=-Qkd25_CC-mOUPrKbm8J9kp9Ns2v6q4dBY3=OFLdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 19, 2017 at 2:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > Actually, this does work, just not the way one would immediately expect.
>
> On closer inspection, what's actually happening in your example is that
> you're getting the SELECT's ct1 result crammed into the first column of
> c1, and then a default NULL is stuck into its second column:
>
> > ​ct1: (text, text)​
>
> > DO $$
> > SELECT ('1', '2')::ct1 INTO c1;
> > RAISE NOTICE '%', c1;
> > END;
> > $$;
>
> > ​Notice: ("(1,2)",)
>
> Notice the parens/comma positioning. It's only because text is such
> a lax datatype that you didn't notice the problem.
>
>
​I saw exactly what you described - that it didn't error out and that the
text representation of the single output composite was being stored in the
first field of the target composite. i.e., that it "worked". Does that
fact that it only works if the first field of the composite type is text
change your opinion that the behavior is OK to break?

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-09-19 21:22:58 Re: CREATE COLLATION does not sanitize ICU's BCP 47 language tags. Should it?
Previous Message Andres Freund 2017-09-19 21:21:13 Re: Show backtrace when tap tests fail