On Wednesday, June 15, 2022, Bryn Llewellyn <b...@yugabyte.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.

Reply via email to