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

2021-08-10 Thread Bryn Llewellyn
> On 10-Aug-2021, at 13:12, Pavel Stehule wrote: > > >> >> r := (select (b, t)::type1 -- it is composite with labels again > > > postgres=# do $$ > declare r record; > begin > r := (select (10,20)); > raise notice '%', to_json(r); > end; > $$; > NOTICE: {"f1":10,"f2":20} > DO >

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

2021-08-10 Thread Pavel Stehule
> > r := (select (b, t)::type1 -- it is composite with labels again > > > postgres=# do $$ declare r record; begin r := (select (10,20)); raise notice '%', to_json(r); end; $$; NOTICE: {"f1":10,"f2":20} DO postgres=# do $$ declare r record; begin r := (select (10,20)::footype); raise

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

2021-08-10 Thread Bryn Llewellyn
> pavel.steh...@gmail.com wrote: > > b...@yugabyte.com wrote: > >> pavel.steh...@gmail.com wrote: >> >>> t...@sss.pgh.pa.us wrote: >>> pavel.steh...@gmail.com wrote:

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

2021-08-10 Thread Pavel Stehule
út 10. 8. 2021 v 21:25 odesílatel Pavel Stehule napsal: > >>> I can get the reference by field name that I prefer with a schema-level >>> type: >>> >>> create type tmp as (b text, t type1); >>> >>> and by declaring "r" with this data type. But this is a greater >>> discomfort than using the

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

2021-08-10 Thread Pavel Stehule
po 9. 8. 2021 v 23:13 odesílatel Tom Lane napsal: > Pavel Stehule 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

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

2021-08-10 Thread Pavel Stehule
> > >> I can get the reference by field name that I prefer with a schema-level >> type: >> >> create type tmp as (b text, t type1); >> >> and by declaring "r" with this data type. But this is a greater >> discomfort than using the dynamically shaped "record" because it needs you >> to create a

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

2021-08-10 Thread Pavel Stehule
út 10. 8. 2021 v 19:48 odesílatel Bryn Llewellyn napsal: > pavel.steh...@gmail.com wrote: > > t...@sss.pgh.pa.us wrote: > > *pavel.steh...@gmail.com wrote:* > > Some errors like this, but not this can be detected by plpgsql_check > https://github.com/okbob/plpgsql_check > probably the heuristic

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

2021-08-10 Thread Bryn Llewellyn
> pavel.steh...@gmail.com wrote: > >> t...@sss.pgh.pa.us wrote: >> >>> pavel.steh...@gmail.com wrote: >>> >>> 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. >> >>

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

2021-08-09 Thread Pavel Stehule
> > > > 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

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

2021-08-09 Thread Pavel Stehule
po 9. 8. 2021 v 23:13 odesílatel Tom Lane napsal: > Pavel Stehule 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

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

2021-08-09 Thread Bryn Llewellyn
> t...@sss.pgh.pa.us wrote: > >> pavel.steh...@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=gmail-imap=162914843400=AOvVaw3f9UAP7RvDPC2QKi3_4Mj0 >> - probably the heuristic

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

2021-08-09 Thread Tom Lane
Pavel Stehule 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.

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

2021-08-09 Thread Pavel Stehule
po 9. 8. 2021 v 21:41 odesílatel Bryn Llewellyn napsal: > *The problem that I report here seems to be known and seems, too, to > astonish and annoy users. It's a bare "computer says No". **It's hard to > find anything of ultimate use with Google search (either constrained to the > PG doc or

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

2021-08-09 Thread John W Higgins
On Mon, Aug 9, 2021 at 12:41 PM Bryn Llewellyn wrote: > > *https://stackoverflow.com/questions/41843016/how-do-i-pass-a-user-defined-type-variable-to-a-function-as-a-parameter >

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

2021-08-09 Thread Bryn Llewellyn
The problem that I report here seems to be known and seems, too, to astonish and annoy users. It's a bare "computer says No". It's hard to find anything of ultimate use with Google search (either constrained to the PG doc or unconstrained). Here's an example on stackoverflow: