Re: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar
Date: 2013-06-13 21:44:01
Message-ID: 19327.1371159841@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> The issue with the regexp_matches call generally is that absence of a "g"
> modifier means that the set-returning function will never return a set. It
> would seem to make more sense to not make that a modifier but instead have
> one function defined to return a set (i.e., the current definition) and
> another one defined to return a simply text[].

Well, it does return a set, namely either zero or one row. The point of
the sub-SELECT workaround is to transform the zero-row case to a scalar
NULL.

I tend to agree that this API wasn't that well thought out, but it's
really not regexp_matches()'s fault that you're running into this
problem --- rather, it's the fact that one arm of the CASE can return a
set while the other can't.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-06-13 23:50:40 Re: BUG #8225: logging options don't change after reload
Previous Message David Johnston 2013-06-13 21:21:57 Re: BUG #8228: Unexpected "set-valued function" with varchar(n) but not varchar