pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: make_greater_string() does not return a string in some cases
Date: Wed, 23 Jun 2010 18:42:46 +0900
Message-ID: <4C21D716.70808@oss.ntt.co.jp> (raw)
In-Reply-To: <13689.1277136605@sss.pgh.pa.us>
References: <4C1F389B.1010606@oss.ntt.co.jp>
	<13689.1277136605@sss.pgh.pa.us>

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




view thread (57+ messages)  latest in thread

Message-ID: <4C21D716.70808@oss.ntt.co.jp>
Permalink:  ../4C21D716.70808@oss.ntt.co.jp/
Also on:    postgresql.org/message-id/4C21D716.70808@oss.ntt.co.jp

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kasahara.tatsuhito@oss.ntt.co.jp, tgl@sss.pgh.pa.us
  Subject: Re: make_greater_string() does not return a string in some cases
  In-Reply-To: <4C21D716.70808@oss.ntt.co.jp>
  References: <4C1F389B.1010606@oss.ntt.co.jp> <13689.1277136605@sss.pgh.pa.us> <4C21D716.70808@oss.ntt.co.jp>

* 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