Re: [HACKERS] Refactoring identifier checks to consistently use strcmp

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Refactoring identifier checks to consistently use strcmp
Date: 2017-11-30 11:40:15
Message-ID: 0450C452-25BA-4BBC-9260-062300B5F30E@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 28 Nov 2017, at 02:07, Michael Paquier <michael(dot)paquier(at)gmail(dot)com> wrote:
>
> On Tue, Nov 28, 2017 at 12:11 AM, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>>> The patch needs a rebase, and there are a couple of places that need
>>> an extra lookup I think:
>>> $ git grep defname -- *.c | grep strcasecmp | wc -l
>>> 39
>>
>> Rebased and handled a few more places which I had either missed in the last
>> round, or that had been added in the meantime. “PARALLEL” in aggregatecmds.c
>> is intentionally using pg_strcasecmp() due to the old-style syntax which is
>> still supported.
>
> This meritates a comment. Code readers may get confused.

Good point, added. I also sent a separate doc patch for this to -docs the
other day.

>> AFAICS this covers all relevant codepaths from the 39 above.
>
> I was just looking at the tsearch code which uses pg_strcmpcase, and
> those are defined with makeDefElem() so you should switch to strcmp in
> this case as well, no? If I patch the code myself I would get an error
> when double-quoting, making those command more consistent with the
> rest of what you are patching here:
> create extension unaccent;
> alter text search dictionary unaccent (Rules = 'unaccent'); -- ok
> alter text search dictionary unaccent (RuLes = 'unaccent'); -- ok
> alter text search dictionary unaccent ("Rules" = 'unaccent'); — error

For reasons unknown to me I had avoided poking in contrib/. Attached patch
handles the additional defname comparisons in contrib that are applicable.

The remainder of the pg_strcasecmp() calls in the text search code are
operating on a defelem list created in deserialize_deflist() rather than in the
parser, so I opted for keeping that as is rather than casefolding in the list
generation.

cheers ./daniel

Attachment Content-Type Size
defname_strcmp-v3.patch application/octet-stream 29.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-11-30 12:02:36 Re: [HACKERS] Proposal: Local indexes for partitioned table
Previous Message Masahiko Sawada 2017-11-30 11:20:32 Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager