Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Bryn Llewellyn <bryn(at)yugabyte(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type
Date: 2021-08-09 21:13:47
Message-ID: 3575571.1628543627@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> Some errors like this, but not this can be detected by plpgsql_check
> https://github.com/okbob/plpgsql_check - probably the heuristic for type
> check is not complete.

STRICTMULTIASSIGNMENT would detect most cases of this, except that
the condition is checked too late. We'd need to count the fields
*before* trying to assign values, not after.

In the meantime, it does seem like the docs could be more explicit
about this, and perhaps give an example showing the (x).* solution.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2021-08-09 23:17:36 archive_command / single user mode
Previous Message Pavel Stehule 2021-08-09 20:44:13 Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type