Re: make_greater_string() does not return a string in some cases - Mailing list pgsql-bugs

From Tatsuhito Kasahara
Subject Re: make_greater_string() does not return a string in some cases
Date
Msg-id 4C21D716.70808@oss.ntt.co.jp
Whole thread Raw
In response to Re: make_greater_string() does not return a string in some cases  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: make_greater_string() does not return a string in some cases  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane wrote:
> The patch you propose for this is really untenable: it will re-introduce
> many corner cases that we got rid of years ago, for example cases
> wherein pg_verifymbstr and pg_mbcliplen index off the end of the string
> because they think the last character occupies more bytes than are
> there.

> Another problem is that if the last character is several bytes long,
> this coding would cause us to iterate through potentially many millions
> of character values before giving up and truncating off the last
> character.
Hmm...  OK, I see your points.

I have another idea.

1. We prepare new operators ( <,<=,>,=>,= ) for text and bytea.
2. In make_greater_string(), if
   multi-byte-string was set and
   using locale-C and
   could not find greater string,
   returns bytea which has greater byte-code of last-character.

User will get the following result.

=======================================================================================================
-- $B@>(B : 0xe8a5bf
=# EXPLAIN ANALYZE SELECT * FROM test WHERE name LIKE '$B@>(B%';
                                                   QUERY PLAN
----------------------------------------------------------------------------------------------------------------
 Index Scan using test_name on test  (cost=0.00..8.28 rows=1 width=4) (actual time=0.022..0.024 rows=1 loops=1)
   Index Cond: ((name >= '$B@>(B'::text) AND (name < '\\xe8a5c0'::bytea))
   Filter: (name ~~ '$B@>(B%'::text)
 Total runtime: 0.053 ms
(4 rows)
=======================================================================================================

Is the idea reasonable ?

Best regards,

--
NTT OSS Center
Tatsuhito Kasahara

pgsql-bugs by date:

Previous
From: "S. Brett Sutton"
Date:
Subject: Re: BUG #5511: Handling of case in Username and database names are inconsistant.
Next
From: Liang Giap Wee
Date:
Subject: Postgres on AIX5.3 and AIX6.1