pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: terry.gilbert@sas.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Ltree pattern matching
Date: Fri, 12 Nov 2021 10:37:04 -0500
Message-ID: <1696142.1636731424@sss.pgh.pa.us> (raw)
In-Reply-To: <163664521217.8082.8625825759427310603@wrigleys.postgresql.org>
References: <163664521217.8082.8625825759427310603@wrigleys.postgresql.org>

PG Doc comments form <noreply@postgresql.org> writes:
> In v12 ltree doc (I've not checked other versions)
> "The behavior of % is a bit complicated. It tries to match words rather than
> the entire label. For example foo_bar% matches foo_bar_baz but not
> foo_barbaz. If combined with *, prefix matching applies to each word
> separately, for example foo_bar%* matches foo1_bar2_baz but not
> foo1_br2_baz.

> I believe foo1 is in error (if I understood the operators), it should be
> foo.

A quick test shows that the examples are correct as stated:

contrib_regression=# select 'foo_bar_baz'::ltree ~ 'foo_bar%'::lquery;
 ?column? 
----------
 t
(1 row)

contrib_regression=# select 'foo_barbaz'::ltree ~ 'foo_bar%'::lquery;
 ?column? 
----------
 f
(1 row)

contrib_regression=# select 'foo1_bar2_baz'::ltree ~ 'foo_bar%*'::lquery;
 ?column? 
----------
 t
(1 row)

contrib_regression=# select 'foo1_br2_baz'::ltree ~ 'foo_bar%*'::lquery;
 ?column? 
----------
 f
(1 row)

I'd be the first to admit that this paragraph doesn't seem to measure up
to our usual standards of clarity, but I'm not sure about what would be
better wording.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <1696142.1636731424@sss.pgh.pa.us>
Permalink:  ../1696142.1636731424@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1696142.1636731424@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, terry.gilbert@sas.com, pgsql-docs@lists.postgresql.org
  Subject: Re: Ltree pattern matching
  In-Reply-To: <1696142.1636731424@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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