Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)
Date: 2023-09-10 22:24:27
Message-ID: ZP5CG6o8sdMBg1Zs@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Sep 10, 2023 at 06:28:08PM -0300, Ranier Vilela wrote:
> +1
> But as Jeff mentioned, when the locale is NULL,
> the provider is known to be COLLPROVIDER_LIBC.
>
> I think we can use this to provide an error message,
> when the locale is NULL.
>
> What do you think about v3 attached?

This does not apply for me on HEAD, and it seems to me that the patch
has some parts that apply on top of v2 (or v1?) while others would
apply to HEAD.

Anyway, what you are suggesting to change compared to v2 is that:

+ /*
+ * if locale is NULL, then
+ * the provider is known to be COLLPROVIDER_LIBC
+ */
if (!locale)
- elog(ERROR, "unsupported collprovider");
+ elog(ERROR, "collprovider '%c' does not support (%s)",
+ COLLPROVIDER_LIBC, "pg_strxfrm_prefix");

I'm OK with enforcing COLLPROVIDER_LIBC in this path, but I also value
consistency across all the error messages of this file. After
sleeping on it, and as that's a set of elogs, "unsupported
collprovider" is fine for me across the board as these should not be
user-visible.

This should be made consistent down to 16, I guess, but only after
16.0 is tagged as we are in release week.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-09-10 22:33:16 Re: [PATCH] Add inline comments to the pg_hba_file_rules view
Previous Message Ranier Vilela 2023-09-10 21:28:08 Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)