postgresql/src/backend
David Rowley 8b26769bc4 Fix an assortment of improper usages of string functions
In a similar effort to f736e188c and 110d81728, fixup various usages of
string functions where a more appropriate function is available and more
fit for purpose.

These changes include:

1. Use cstring_to_text_with_len() instead of cstring_to_text() when
   working with a StringInfoData and the length can easily be obtained.
2. Use appendStringInfoString() instead of appendStringInfo() when no
   formatting is required.
3. Use pstrdup(...) instead of psprintf("%s", ...)
4. Use pstrdup(...) instead of psprintf(...) (with no formatting)
5. Use appendPQExpBufferChar() instead of appendPQExpBufferStr() when the
   length of the string being appended is 1.
6. appendStringInfoChar() instead of appendStringInfo() when no formatting
   is required and string is 1 char long.
7. Use appendPQExpBufferStr(b, .) instead of appendPQExpBuffer(b, "%s", .)
8. Don't use pstrdup when it's fine to just point to the string constant.

I (David) did find other cases of #8 but opted to use #4 instead as I
wasn't certain enough that applying #8 was ok (e.g in hba.c)

Author: Ranier Vilela, David Rowley
Discussion: https://postgr.es/m/CAApHDvo2j2+RJBGhNtUz6BxabWWh2Jx16wMUMWKUjv70Ver1vg@mail.gmail.com
2022-09-06 13:19:44 +12:00
..
access Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
backup Remove obsolete comment 2022-08-26 10:44:50 +02:00
bootstrap Build all Flex files standalone 2022-09-04 12:09:01 +07:00
catalog Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
commands Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
executor Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
foreign Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
jit Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
lib More -Wshadow=compatible-local warning fixes 2022-08-26 02:35:40 +12:00
libpq Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
main Fix outdated --help message for postgres -f 2022-08-15 13:36:36 +09:00
nodes Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
optimizer Fix planner to consider matches to boolean columns in extension indexes. 2022-09-02 17:01:51 -04:00
parser Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
partitioning Fix planner to consider matches to boolean columns in extension indexes. 2022-09-02 17:01:51 -04:00
po NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00
port Cleanup more code and comments related to Windows NT4 (XP days) 2022-08-30 09:52:58 +09:00
postmaster Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
regex Defend against stack overrun in a few more places. 2022-08-24 13:02:19 -04:00
replication Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
rewrite More -Wshadow=compatible-local warning fixes 2022-08-26 02:35:40 +12:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrect uses of Datum conversion macros 2022-09-05 13:30:44 +02:00
storage Expand the use of get_dirent_type(), shaving a few calls to stat()/lstat() 2022-09-02 16:58:06 +09:00
tcop Allow grant-level control of role inheritance behavior. 2022-08-25 10:06:02 -04:00
tsearch Defend against stack overrun in a few more places. 2022-08-24 13:02:19 -04:00
utils Fix an assortment of improper usages of string functions 2022-09-06 13:19:44 +12:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove SUBSYS.o rule in common.mk, hasn't been used in a long time 2022-08-24 20:38:14 -07:00
Makefile Build all Flex files standalone 2022-09-04 12:09:01 +07:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00