| From: | Ewan Young <kdbase(dot)hack(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Use ereport() instead of elog() for invalid weights in setweight() |
| Date: | 2026-06-03 15:39:05 |
| Message-ID: | CAON2xHNaeLAUzRCXL5AmXLcXaSE_gWAVjWQRmLzc_oZ=1_Vf4Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
I noticed that setweight() reports an internal error (SQLSTATE XX000)
when the weight argument is not one of A/a, B/b, C/c, D/d, even though
the weight comes directly from user input. The two-argument variant
also prints the weight as a raw ASCII code, which is a bit unfriendly:
=# SELECT setweight('cat:1'::tsvector, 'p');
ERROR: unrecognized weight: 112
ts_filter() in the same file (tsvector_op.c) already handles the
equivalent case with ereport() and ERRCODE_INVALID_PARAMETER_VALUE,
so the attached patch simply makes tsvector_setweight() and
tsvector_setweight_by_filter() do the same, and adds regression tests
covering the three error paths (none of which were covered before).
This seems to be in the same spirit as the earlier cleanup of
user-reachable internal error codes [1]; these two sites appear to
have been missed there.
The patch is against the master and passes make check. Please let me know
if I've missed anything -- I'd be happy to revise.
[1] https://postgr.es/m/Zic_GNgos5sMxKoa@paquier.xyz
Best regards,
Ewan Young
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Use-ereport-not-elog-for-invalid-weights-in-setweight.patch | application/octet-stream | 4.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mingwei Jia | 2026-06-03 15:40:18 | Re: [RFC PATCH v2 RESEND 04/10] umbra: add patch 3 metadata disk format and identity mapping bootstrap |
| Previous Message | Andres Freund | 2026-06-03 15:35:42 | Re: Heads Up: cirrus-ci is shutting down June 1st |