Re: [PATCH] Add support function for containment operators

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Kim Johan Andersson <kimjand(at)kimmet(dot)dk>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add support function for containment operators
Date: 2023-10-19 16:01:40
Message-ID: a78242587cd008096a61de9e858202d47413dda0.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2023-10-13 at 14:26 +0800, jian he wrote:
> Collation problem seems solved.

I didn't review your patch in detail, there is still a problem
with my example:

CREATE TYPE textrange AS RANGE (
SUBTYPE = text,
SUBTYPE_OPCLASS = text_pattern_ops
);

CREATE TABLE tx (t text COLLATE "cs-CZ-x-icu");

INSERT INTO tx VALUES ('a'), ('c'), ('d'), ('ch');

SELECT * FROM tx WHERE t <@ textrange('a', 'd');

t
════
a
c
ch
(3 rows)

That was correct.

EXPLAIN SELECT * FROM tx WHERE t <@ textrange('a', 'd');

QUERY PLAN
════════════════════════════════════════════════════
Seq Scan on tx (cost=0.00..30.40 rows=7 width=32)
Filter: ((t >= 'a'::text) AND (t < 'd'::text))
(2 rows)

But that was weird. The operators seem wrong. Look at that
query:

SELECT * FROM tx WHERE t >= 'a' AND t < 'd';

t
═══
a
c
(2 rows)

But the execution plan is identical...

I am not sure what is the problem here, but in my opinion the
operators shown in the execution plan should be like this:

SELECT * FROM tx WHERE t ~>=~ 'a' AND t ~<~ 'd';

t
════
a
c
ch
(3 rows)

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-10-19 16:05:35 Re: trying again to get incremental backup
Previous Message Tom Lane 2023-10-19 16:00:21 Re: Allow ALTER SYSTEM SET on unrecognized custom GUCs