Re: tiny step toward threading: reduce dependence on setlocale()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tiny step toward threading: reduce dependence on setlocale()
Date: 2024-08-12 07:00:11
Message-ID: cc41de25-1dd2-4b38-98d8-69f47499eae6@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11.08.24 18:33, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>> We can address those as part of a separate thread. I'll count this as
>> committed.
>
> Coverity has a nit about this:
>
> *** CID 1616189: Null pointer dereferences (REVERSE_INULL)
> /srv/coverity/git/pgsql-git/postgresql/src/backend/utils/adt/like.c: 206 in Generic_Text_IC_like()
> 200 * on the pattern and text, but instead call SB_lower_char on each
> 201 * character. In the multi-byte case we don't have much choice :-(. Also,
> 202 * ICU does not support single-character case folding, so we go the long
> 203 * way.
> 204 */
> 205
>>>> CID 1616189: Null pointer dereferences (REVERSE_INULL)
>>>> Null-checking "locale" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
> 206 if (pg_database_encoding_max_length() > 1 || (locale && locale->provider == COLLPROVIDER_ICU))
> 207 {
> 208 pat = DatumGetTextPP(DirectFunctionCall1Coll(lower, collation,
> 209 PointerGetDatum(pat)));
> 210 p = VARDATA_ANY(pat);
> 211 plen = VARSIZE_ANY_EXHDR(pat);
>
> I assume it would now be okay to take out "locale &&" here?

Correct, that check is no longer necessary.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-08-12 07:04:23 Re: Remove support for old realpath() API
Previous Message jian he 2024-08-12 06:50:00 Re: Adding OLD/NEW support to RETURNING