public inbox for [email protected]  
help / color / mirror / Atom feed
pgsql: Fix more multibyte issues in ltree.
8+ messages / 3 participants
[nested] [flat]

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:30  Jeff Davis <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:30 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
master

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

Modified Files
--------------
contrib/ltree/lquery_op.c    | 103 +++++++++++++++++++++----------------------
contrib/ltree/ltree.h        |  10 ++---
contrib/ltree/ltxtquery_op.c |  11 +++--
3 files changed, 60 insertions(+), 64 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:30  Jeff Davis <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:30 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_18_STABLE

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

Modified Files
--------------
contrib/ltree/lquery_op.c    | 111 +++++++++++++++++++++----------------------
contrib/ltree/ltree.h        |  10 ++--
contrib/ltree/ltxtquery_op.c |  11 ++---
3 files changed, 63 insertions(+), 69 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:30  Jeff Davis <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:30 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_17_STABLE

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

Modified Files
--------------
contrib/ltree/lquery_op.c    | 65 +++++++++++++++++++++++---------------------
contrib/ltree/ltree.h        | 10 +++----
contrib/ltree/ltxtquery_op.c | 11 ++++----
3 files changed, 43 insertions(+), 43 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:31  Jeff Davis <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:31 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3ed2c7ef7aa40e6c5c6a1bc16433f9768d98787d

Modified Files
--------------
contrib/ltree/lquery_op.c    | 65 +++++++++++++++++++++++---------------------
contrib/ltree/ltree.h        | 10 +++----
contrib/ltree/ltxtquery_op.c | 11 ++++----
3 files changed, 43 insertions(+), 43 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:31  Jeff Davis <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:31 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b993167fc85fb41729dc0980639504ccc356e02

Modified Files
--------------
contrib/ltree/lquery_op.c    | 65 +++++++++++++++++++++++---------------------
contrib/ltree/ltree.h        | 10 +++----
contrib/ltree/ltxtquery_op.c | 11 ++++----
3 files changed, 43 insertions(+), 43 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 20:31  Jeff Davis <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 20:31 UTC (permalink / raw)
  To: [email protected]

Fix more multibyte issues in ltree.

Commit 84d5efa7e3 missed some multibyte issues caused by short-circuit
logic in the callers. The callers assumed that if the predicate string
is longer than the label string, then it couldn't possibly be a match,
but it can be when using case-insensitive matching (LVAR_INCASE) if
casefolding changes the byte length.

Fix by refactoring to get rid of the short-circuit logic as well as
the function pointer, and consolidate the logic in a replacement
function ltree_label_match().

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/058710d415ee5bab4daf6be5c33149a32066384a

Modified Files
--------------
contrib/ltree/lquery_op.c    | 65 +++++++++++++++++++++++---------------------
contrib/ltree/ltree.h        | 10 +++----
contrib/ltree/ltxtquery_op.c | 11 ++++----
3 files changed, 43 insertions(+), 43 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 21:40  Tom Lane <[email protected]>
  parent: Jeff Davis <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2026-02-26 21:40 UTC (permalink / raw)
  To: Jeff Davis <[email protected]>; +Cc: [email protected]

Jeff Davis <[email protected]> writes:
> Fix more multibyte issues in ltree.

Buildfarm is showing there is something wrong with this,
but only in v18 branch:

diff -U3 /Users/buildfarm/bf-data/REL_18_STABLE/pgsql.build/contrib/ltree/expected/ltree.out /Users/buildfarm/bf-data/REL_18_STABLE/pgsql.build/contrib/ltree/results/ltree.out
--- /Users/buildfarm/bf-data/REL_18_STABLE/pgsql.build/contrib/ltree/expected/ltree.out	2026-02-26 16:21:27
+++ /Users/buildfarm/bf-data/REL_18_STABLE/pgsql.build/contrib/ltree/results/ltree.out	2026-02-26 16:32:07
@@ -689,7 +689,7 @@
 SELECT 'aa.b.c.d.e'::ltree ~ '[email protected]';
  ?column? 
 ----------
- f
+ t
 (1 row)
 
 SELECT 'aa.b.c.d.e'::ltree ~ 'A*.b.c.d.e';
@@ -1242,7 +1242,7 @@
 SELECT 'tree.awdfg'::ltree @ 'tree & aWdf@'::ltxtquery;
  ?column? 
 ----------
- f
+ t
 (1 row)
 
 SELECT 'tree.awdfg'::ltree @ 'tree & aWdf*'::ltxtquery;


			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Fix more multibyte issues in ltree.
@ 2026-02-26 22:36  Jeff Davis <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Jeff Davis @ 2026-02-26 22:36 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; Jeff Davis <[email protected]>; +Cc: [email protected]

On Thu, 2026-02-26 at 16:40 -0500, Tom Lane wrote:
> Jeff Davis <[email protected]> writes:
> > Fix more multibyte issues in ltree.
> 
> Buildfarm is showing there is something wrong with this,
> but only in v18 branch:

Investigating...

Regards,
	Jeff Davis







^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2026-02-26 22:36 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 20:30 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>
2026-02-26 20:30 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>
2026-02-26 21:40 ` Tom Lane <[email protected]>
2026-02-26 22:36   ` Jeff Davis <[email protected]>
2026-02-26 20:30 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>
2026-02-26 20:31 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>
2026-02-26 20:31 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>
2026-02-26 20:31 pgsql: Fix more multibyte issues in ltree. Jeff Davis <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox