Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlYc6-0001hp-P1 for pgsql-docs@arkaria.postgresql.org; Fri, 12 Nov 2021 15:37:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mlYc5-00046g-7Y for pgsql-docs@arkaria.postgresql.org; Fri, 12 Nov 2021 15:37:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlYc4-00046W-Vi for pgsql-docs@lists.postgresql.org; Fri, 12 Nov 2021 15:37:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlYby-0003N7-Fx for pgsql-docs@lists.postgresql.org; Fri, 12 Nov 2021 15:37:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1ACFb4aL1696143; Fri, 12 Nov 2021 10:37:04 -0500 From: Tom Lane To: terry.gilbert@sas.com cc: pgsql-docs@lists.postgresql.org Subject: Re: Ltree pattern matching In-reply-to: <163664521217.8082.8625825759427310603@wrigleys.postgresql.org> References: <163664521217.8082.8625825759427310603@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Thu, 11 Nov 2021 15:40:12 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1696141.1636731423.1@sss.pgh.pa.us> Date: Fri, 12 Nov 2021 10:37:04 -0500 Message-ID: <1696142.1636731424@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form 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