Re: ERROR: failed to find conversion function from key_vals_nn to record[]

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ERROR: failed to find conversion function from key_vals_nn to record[]
Date: 2022-06-16 03:13:42
Message-ID: CAKFQuwZordXQdGAFuuVabhsoCN8ecmo4cbt89LcUmRSvTCEr+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, June 15, 2022, Bryn Llewellyn <bryn(at)yugabyte(dot)com> wrote:

> I’ve copied a self-contained testcase below. Is the error that the "as
> intended" test causes due to a known limitation—or even a semantic dilemma
> that I'm failing to spot? Or might it be due to a bug?
>

I read the note in create domain as basically “don’t do this” (the not null
part) but the issue you are pointing out seems unrelated to that.

> */**
>
>
>
>
>
> * This one cases the error, thus: ERROR: failed to find conversion
> function from key_vals_nn to record[] CONTEXT: SQL expression "(kv1_nn =
> any(kvs_nn))"*/;select f('as intended');*
>

The fact that a domain over an array isn’t being seen as an array here
seems like a bug. POLA violation at least, and I don’t recall any notes
regarding this dynamic in the docs.

However, a more trivial case does work, at least in HEAD:

postgres=# create domain mytext as text[] not null;
CREATE DOMAIN
postgres=# select '1' = any(array['1','2']::mytext);
?column?
----------
t
(1 row)

However, as you show:

postgres=# create type kv AS ( key text, val text );
CREATE TYPE

postgres=# create domain kvarr as kv[];
CREATE DOMAIN

postgres=# select ('1','one')::kv = any (array[('1','one')::kv]);
?column?
----------
t
(1 row)

postgres=# select ('1','one')::kv = any ((array[('1','one')::kv])::kvarr);
ERROR: failed to find conversion function from kvarr to record[]

So the interaction of a composite type and the domain over array seems to
be the scope of the issue - which makes me thing bug even more.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Noah Misch 2022-06-16 05:42:18 Re: Extension pg_trgm, permissions and pg_dump order
Previous Message Bryn Llewellyn 2022-06-16 02:27:38 ERROR: failed to find conversion function from key_vals_nn to record[]