Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type
От | Bryn Llewellyn |
---|---|
Тема | Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type |
Дата | |
Msg-id | 0B8B7D5F-96C2-46B6-8050-37199598C002@yugabyte.com обсуждение исходный текст |
Ответ на | Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: PL/pgSQL: Spurious 22P02 error on "select col into var" when col is user-defined type
|
Список | pgsql-general |
tgl@sss.pgh.pa.us wrote:pavel.stehule@gmail.com writes:Some errors like this, but not this can be detected by plpgsql_check
https://www.google.com/url?q=https://github.com/okbob/plpgsql_check&source=gmail-imap&ust=1629148434000000&usg=AOvVaw3f9UAP7RvDPC2QKi3_4Mj0 - 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.
Tom, Pavel, and John, thanks for your quick responses. I've filed them all away and I'm hoping that I won't be caught out by this in the future.
It now seems to me to be odd, in the light of the explanations for why the naïve (PL/SQL-style) syntax doesn't work in PL/pgSQL, that assigning a scalar subquery to a variable of the composite type in question _does_ work! But don't take that as a question. I'm going to regard this as "case closed".
В списке pgsql-general по дате отправления: