Refactoring identifier checks to consistently use strcmp

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Refactoring identifier checks to consistently use strcmp
Date: 2017-04-03 09:58:05
Message-ID: 29405B24-564E-476B-98C0-677A29805B84@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Testing DefElem options is done with both strcmp() and pg_strcasecmp() a bit
mixed. Since the option defnames are all lowercased, either via IDENT, keyword
rules or “by hand” with makeString(), using strcmp() is safe (and assumed to be
so in quite a lot of places).

While it’s not incorrect per se to use pg_strcasecmp(), it has the potential to
hide a DefElem created with a mixed-case defname where it in other places is
expected to be in lowercase, which may lead to subtle bugs.

The attached patch refactors to use strcmp() consistently for option processing
in the command code as a pre-emptive belts+suspenders move against such subtle
bugs and to make the code more consistent. Also reorders a few checks to have
all in the same “format” and removes a comment related to the above.

Tested with randomizing case on options in make check (not included in patch).

cheers ./daniel

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kuntal Ghosh 2017-04-03 10:08:56 Re: strange parallel query behavior after OOM crashes
Previous Message Ashutosh Bapat 2017-04-03 09:47:47 Re: [BUGS] BUG #14600: Passwords in user mappings leaked by psql \deu+ command