pgsql: Remove unnecessary type violation in tsvectorrecv().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove unnecessary type violation in tsvectorrecv().
Date: 2025-04-02 20:18:39
Message-ID: E1u04Xn-002Luj-2o@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/18875-07a29c49c825a608@postgresql.org
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a7187c3723b41057522038c5e5db329d84f41ac4

Modified Files
--------------
src/backend/utils/adt/tsvector.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2025-04-03 06:57:34 pgsql: Fix slot synchronization for two_phase enabled slots.
Previous Message Andres Freund 2025-04-02 19:35:39 pgsql: Remove HeapBitmapScan's skip_fetch optimization