v1-0001-Fix-like_fixed_prefix_ci-selectivity.patch
text/x-patch
Filename: v1-0001-Fix-like_fixed_prefix_ci-selectivity.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: Fix like_fixed_prefix_ci() selectivity.
| File | + | − |
|---|---|---|
| src/backend/utils/adt/like_support.c | 2 | 2 |
From 9b89afcf1a5cba13781382f904a7c0a20039a48a Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
Date: Mon, 6 Jul 2026 13:38:25 -0700
Subject: [PATCH v1] Fix like_fixed_prefix_ci() selectivity.
A wrong calculation introduced by 9c8de15969 could cause trailing
characters from the prefix to be passed to like_selectivity() rather
than just the "rest".
Backpatch-through: 19
---
src/backend/utils/adt/like_support.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 01cd6b10730..3ad3c9ca358 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -1138,12 +1138,12 @@ like_fixed_prefix_ci(Const *patt_const, Oid collation, Const **prefix_const,
if (rest_selec != NULL)
{
- int wrestlen = wpattlen - wmatch_pos;
+ int wrestlen = wpattlen - wpos;
char *rest;
int rest_mblen;
rest = palloc(pg_database_encoding_max_length() * wrestlen + 1);
- rest_mblen = pg_wchar2mb_with_len(&wpatt[wmatch_pos], rest, wrestlen);
+ rest_mblen = pg_wchar2mb_with_len(&wpatt[wpos], rest, wrestlen);
*rest_selec = like_selectivity(rest, rest_mblen, true);
pfree(rest);
--
2.43.0