Re: BUG #18451: NULL fails to coerce to string when performing string comparison

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: darryl(dot)dixon(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18451: NULL fails to coerce to string when performing string comparison
Date: 2024-04-30 21:34:31
Message-ID: CAApHDvqRG-cd92D2YV8+C3wLAT0_1ut=X4yX0DetGQ+gGAhtRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 1 May 2024 at 09:06, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> postdb=# select where 'ab'||NULL like '%a%';
> --
> (0 rows)
>
> postdb=# select where 'ab'||NULL::text like '%a%';
> --
> (0 rows)

You've not mentioned where you think the bug is, but if you think it's
in either of the above, PostgreSQL is following the SQL standard here.

The SQL2016 copy I have here says:

"6.31 <string value expression>

If at least one of S1 and S2 is the null value, then the result of the
<concatenation> is the null value."

There are a few RDBMSs that are lax on this rule, perhaps you're here
because PostgreSQL isn't doing what you're used to?

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Darryl Dixon 2024-04-30 21:38:56 Re: BUG #18451: NULL fails to coerce to string when performing string comparison
Previous Message Darryl Dixon 2024-04-30 21:25:33 Re: BUG #18451: NULL fails to coerce to string when performing string comparison