From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | "lucvanlind(dot)en(at)gmail(dot)com" <lucvanlind(dot)en(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #18239: select position ('' in 'A') returns 1 |
Date: | 2023-12-10 16:13:00 |
Message-ID: | 1886034.1702224780@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Sunday, December 10, 2023, PG Bug reporting form <noreply(at)postgresql(dot)org>
> wrote:
>> select position ('' in 'A') returns 1
>> Thus, case a field has an empty string while, checking positions in another
>> string, it seems to always fit the position 1.
> Just as an empty set is a subset of all sets the empty string is a
> substring within all strings.
Yes. This behavior is explicitly required by the SQL standard:
2) If <string position expression> is specified, then
Case:
a) If the first <string value expression> has a length of 0
(zero), then the result is 1 (one).
b) [ otherwise, ... ]
> I do not believe we document or refer to this external rule anywhere though.
No, our documentation for position() is just one sentence. With the
new function-table layout it'd be possible to add a second example
to exhibit this behavior, but I'm not sure it's worth the trouble.
Personally I don't find this surprising.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Alena Rybakina | 2023-12-10 23:36:26 | Re: BUG #16925: ERROR: invalid DSA memory alloc request size 1073741824 CONTEXT: parallel worker |
Previous Message | David G. Johnston | 2023-12-10 15:20:03 | Re: BUG #18239: select position ('' in 'A') returns 1 |