Remove unnecessary type violation in tsvectorrecv().
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Apr 2025 20:17:43 +0000 (16:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Apr 2025 20:18:08 +0000 (16:18 -0400)
commitbe625caf3dad63bae39296b553fc8f856d7fb9b7
treeb5610b342253c1573a7e53e70e378534c14c067b
parent4934d38759cdb65965db4ccf10aa767d9bee5e00
Remove unnecessary type violation in tsvectorrecv().

compareentry() is declared to work on WordEntryIN structs, but
tsvectorrecv() is using it in two places to work on WordEntry
structs.  This is almost okay, since WordEntry is the first
field of WordEntryIN.  But on machines with 8-byte pointers,
WordEntryIN will have a larger alignment spec than WordEntry,
and it's at least theoretically possible that the compiler
could generate code that depends on the larger alignment.

Given the lack of field reports, this may be just a hypothetical bug
that upsets nothing except sanitizer tools.  Or it may be real on
certain hardware but nobody's tried to use tsvectorrecv() on such
hardware.  In any case we should fix it, and the fix is trivial:
just change compareentry() so that it works on WordEntry without any
mention of WordEntryIN.  We can also get rid of the quite-useless
intermediate function WordEntryCMP.

Bug: #18875
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/18875-07a29c49c825a608@postgresql.org
Backpatch-through: 13
src/backend/utils/adt/tsvector.c