Re: select (17, 42)::s.t2 into... fails with "invalid input syntax" - Mailing list pgsql-general

From David G. Johnston
Subject Re: select (17, 42)::s.t2 into... fails with "invalid input syntax"
Date
Msg-id CAKFQuwZiR4paFEjiJP4py4HpHBeur=QZqi7Ys1p_XY8-WiCEYw@mail.gmail.com
Whole thread Raw
In response to Re: select (17, 42)::s.t2 into... fails with "invalid input syntax"  (Bryn Llewellyn <bryn@yugabyte.com>)
Responses Re: select (17, 42)::s.t2 into... fails with "invalid input syntax"  (Bryn Llewellyn <bryn@yugabyte.com>)
List pgsql-general
On Wed, Mar 8, 2023 at 7:58 PM Bryn Llewellyn <bryn@yugabyte.com> wrote:

    r := (my_c1, my_c2)::s.t;

If you write s.x there it will also work.

Your first and third assignments are identical in syntax/nature.  These are both the first examples here[1]

Yes, the behavior of INTO in the second assignment is somewhat non-intuitive; but covered here[2].  Probably it could use more examples.

The final form fits into a procedural flow better than the SQL-based one.  Since plpgsql allows for procedural flow this makes sense.  The composite variable reference is simply: main_type_name.field_name  Hence the second example here[1]


David J.

pgsql-general by date:

Previous
From: Chris Travers
Date:
Subject: Blog post series on commitfests and patches
Next
From: Pavel Stehule
Date:
Subject: Re: Behavior of PL/pgSQL function following drop and re-create of a table that it uses