postgresql/src/backend
Michael Paquier dde5b01c33 Fix various issues with ALTER TEXT SEARCH CONFIGURATION
This commit addresses a set of issues when changing token type mappings
in a text search configuration when using duplicated token names:
- ADD MAPPING would fail on insertion because of a constraint failure
after inserting the same mapping.
- ALTER MAPPING with an "overridden" configuration failed with "tuple
already updated by self" when the token mappings are removed.
- DROP MAPPING failed with "tuple already updated by self", like
previously, but in a different code path.

The code is refactored so the token names (with their numbers) are
handled as a List with unique members rather than an array with numbers,
ensuring that no duplicates mess up with the catalog inserts, updates
and deletes.  The list is generated by getTokenTypes(), with the same
error handling as previously while duplicated tokens are discarded from
the list used to work on the catalogs.

Regression tests are expanded to cover much more ground for the cases
fixed by this commit, as there was no coverage for the code touched in
this commit.  A bit more is done regarding the fact that a token name
not supported by a configuration's parser should result in an error even
if IF EXISTS is used in a DROP MAPPING clause.  This is implied in the
code but there was no coverage for that, and it was very easy to miss.

These issues exist since at least their introduction in core with
140d4ebcb4, so backpatch all the way down.

Reported-by: Alexander Lakhin
Author: Tender Wang, Michael Paquier
Discussion: https://postgr.es/m/18310-1eb233c5908189c8@postgresql.org
Backpatch-through: 12
2024-01-31 13:16:47 +09:00
..
access Fix locking when fixing an incomplete split of a GIN internal page 2024-01-29 13:46:43 +02:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Improve handling of dropped partitioned indexes for REINDEX INDEX 2024-01-18 16:31:50 +09:00
commands Fix various issues with ALTER TEXT SEARCH CONFIGURATION 2024-01-31 13:16:47 +09:00
executor Fix indentation in ExecParallelHashIncreaseNumBatches() 2024-01-08 19:57:58 +02:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Track LLVM 18 changes. 2024-01-25 13:46:38 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Avoid masking EOF (no-password-supplied) conditions in auth.c. 2024-01-03 17:40:38 -05:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:38 +09:00
nodes Remove inappropriate raw_expression_tree_walker() code 2023-06-29 10:35:53 +02:00
optimizer Allow subquery pullup to wrap a PlaceHolderVar in another one. 2024-01-11 15:28:13 -05:00
parser Compute aggregate argument types correctly in transformAggregateCall(). 2023-11-06 10:38:00 -05:00
partitioning Fix incorrect step generation in HASH partition pruning 2023-10-12 19:52:31 +13:00
po Translation updates 2023-11-06 13:19:51 +01:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Avoid calling proc_exit() in processes forked by system(). 2023-10-17 10:42:12 -05:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:32 -07:00
replication Fix catalog lookup due to wrong snapshot for subtransactions during decoding. 2024-01-29 10:34:03 +05:30
rewrite Fix typo in comment. 2023-06-16 10:19:33 +09:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Remove unnecessary code in dependency_is_compatible_expression(). 2023-03-14 11:10:45 -04:00
storage lwlock: Fix quadratic behavior with very long wait lists 2024-01-18 11:12:38 +09:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Fix incompatibilities with libxml2 >= 2.12.0. 2024-01-29 12:06:08 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00