Re: Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")

2022-06-27 Thread Bryn Llewellyn
> david.g.johns...@gmail.com wrote: > > Allowing domains to be defined as not null at this point is simply something > that we don't support but don't error out upon in the interest of backward > compatibility. (IMO, the documentation is not this strongly worded.) It, as > you note, has some co

Re: Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")

2022-06-19 Thread David G. Johnston
On Sun, Jun 19, 2022 at 2:31 PM Bryn Llewellyn wrote: > It would be foolish, therefore, to define the target table for > "insert-select" using "CTAS where false". > SQL is a strongly typed language where the structure of the query output is determined without any consideration of whether said qu

Re: Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")

2022-06-19 Thread Tom Lane
Bryn Llewellyn writes: > Self-evidently, a view does *not* inherit constraints from the columns of its > base table(s). Check. > A view on a single table doesn't necessarily inherit the data types of its > base table's columns. Rather, the view compilation's analysis is *sometimes* > clever e

Outer joins and NULLs (old subject "ERROR: failed to find conversion function from key_vals_nn to record[]")

2022-06-19 Thread Bryn Llewellyn
> b...@yugabyte.com wrote: > >> david.g.johns...@gmail.com wrote: >> >>> b...@yugabyte.com wrote: >>> >>> Can anybody show me an implementation of a realistic use case that follows >>> proper practice — like "every table must a prim

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

2022-06-17 Thread Peter J. Holzer
On 2022-06-16 23:58:23 -0700, Bryn Llewellyn wrote: > david.g.johns...@gmail.com wrote: > > b...@yugabyte.com wrote: > > Can anybody show me an implementation of a realistic use case that > follows proper practice — like "every table must a primary key", "a > f

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

2022-06-16 Thread Bryn Llewellyn
> david.g.johns...@gmail.com wrote: > >> b...@yugabyte.com wrote: >> >> Can anybody show me an implementation of a realistic use case that follows >> proper practice — like "every table must a primary key", "a foreign key must >> refer to a primary key", and "joins may be made only "on" columns

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

2022-06-16 Thread David G. Johnston
On Thu, Jun 16, 2022 at 8:28 PM Bryn Llewellyn wrote: > > *Back to NULLs...* > > Your code examples ran without error and produced the results that you > described. I do understand the fact that, on its face, the NULLs in the > two cases arise for different reasons. But this (still) seems to me

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

2022-06-16 Thread Bryn Llewellyn
> david.g.johns...@gmail.com wrote: > >> b...@yugabyte.com wrote: >> >> This is what the doc promises. But how can you see it as anything but a bug? >> The subquery evaluates to "null", and only then is the attempt made to >> create a new row which self-evidently violates the domain's constrain

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

2022-06-16 Thread Tom Lane
"David G. Johnston" writes: > The fact that a domain over an array isn’t being seen as an array here > seems like a bug. Hmm. The attached quick-hack patch seems to make this better, but I'm not sure whether there are any cases it makes worse. regards, tom lane diff --g

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

2022-06-15 Thread David G. Johnston
On Wed, Jun 15, 2022 at 11:07 PM Bryn Llewellyn wrote: > This is what the doc promises. But how can you see it as anything but a > bug? The subquery evaluates to "null", and only then is the attempt made to > create a new row which self-evidently violates the domain's constraint. How > is it any

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

2022-06-15 Thread Bryn Llewellyn
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

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

2022-06-15 Thread David G. Johnston
he 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:

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

2022-06-15 Thread Bryn Llewellyn
ant key_val[] := kvs_nn; begin case which when 'without NOT NULL safety' then return (kv1 = any(kvs)); when 'as intended' then return (kv1_nn = any(kvs_nn)); when 'workaround' then return (kv1_0 = any(kvs_0)); end case; end; $body$; se