Re: redundant check of msg in does_not_exist_skipping

From: Japin Li <japinli(at)hotmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Ted Yu <yuzhihong(at)gmail(dot)com>, peter(at)eisentraut(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: redundant check of msg in does_not_exist_skipping
Date: 2022-11-17 15:19:26
Message-ID: MEYP282MB1669B2020AAC59DBA6ACA9F1B6069@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Thu, 17 Nov 2022 at 23:06, Japin Li <japinli(at)hotmail(dot)com> wrote:
> On Thu, 17 Nov 2022 at 20:12, Ted Yu <yuzhihong(at)gmail(dot)com> wrote:
>> Hi,
>> I was looking at commit aca992040951c7665f1701cd25d48808eda7a809
>>
>> I think the check of msg after the switch statement is not necessary. The
>> variable msg is used afterward.
>> If there is (potential) missing case in switch statement, the compiler
>> would warn.
>>
>> How about removing the check ?
>>
>
> I think we cannot remove the check, for example, if objtype is OBJECT_OPFAMILY,
> and schema_does_not_exist_skipping() returns true, the so the msg keeps NULL,
> if we remove this check, a sigfault might be occurd in ereport().
>
> case OBJECT_OPFAMILY:
> {
> List *opfname = list_copy_tail(castNode(List, object), 1);
>
> if (!schema_does_not_exist_skipping(opfname, &msg, &name))
> {
> msg = gettext_noop("operator family \"%s\" does not exist for access method \"%s\", skipping");
> name = NameListToString(opfname);
> args = strVal(linitial(castNode(List, object)));
> }
> }
> break;

Sorry, I didn't look into schema_does_not_exist_skipping(), and after look
into schema_does_not_exist_skipping function and others, all paths that go
out switch branch has non-NULL for msg, so we can remove this check safely.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-11-17 15:36:29 Re: Introduce "log_connection_stages" setting.
Previous Message Peter Eisentraut 2022-11-17 15:09:22 Re: libpq compression (part 2)