Re: indexable and locale

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Goran Thyni <goran(at)kirra(dot)net>
Cc: PostgreSQL-development <hackers(at)postgreSQL(dot)org>, Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Subject: Re: indexable and locale
Date: 1999-11-30 01:49:52
Message-ID: 199911300149.UAA20827@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Applied.

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello again,
> I thought I should start making some small contibutions before 7.0.
>
> Attached is a patch to the old problem discussed feverly before 6.5.
> What is does:
> for locale-enabled servers:
> use index if last char before '%' is ascii.
> for non-locale servers:
> do not use locale if last char is non-ascii since it is wrong anyway.
>
> Comments?
>
> regards,
> --
> -----------------
> G_ran Thyni
> On quiet nights you can hear Windows NT reboot!

> diff -c pgsql/src/backend/optimizer/path/indxpath.c work/pgsql/src/backend/optimizer/path/indxpath.c
> *** pgsql/src/backend/optimizer/path/indxpath.c Wed Oct 6 18:33:57 1999
> --- work/pgsql/src/backend/optimizer/path/indxpath.c Fri Oct 15 19:54:34 1999
> ***************
> *** 1934,1968 ****
> op = makeOper(optup->t_data->t_oid, InvalidOid, BOOLOID, 0, NULL);
> expr = make_opclause(op, leftop, (Var *) con);
> result = lcons(expr, NIL);
> -
> /*
> ! * In ASCII locale we say "x <= prefix\377". This does not
> ! * work for non-ASCII collation orders, and it's not really
> ! * right even for ASCII. FIX ME!
> ! * Note we assume the passed prefix string is workspace with
> ! * an extra byte, as created by the xxx_fixed_prefix routines above.
> */
> ! #ifndef USE_LOCALE
> ! prefixlen = strlen(prefix);
> ! prefix[prefixlen] = '\377';
> ! prefix[prefixlen+1] = '\0';
> !
> ! optup = SearchSysCacheTuple(OPRNAME,
> ! PointerGetDatum("<="),
> ! ObjectIdGetDatum(datatype),
> ! ObjectIdGetDatum(datatype),
> ! CharGetDatum('b'));
> ! if (!HeapTupleIsValid(optup))
> ! elog(ERROR, "prefix_quals: no <= operator for type %u", datatype);
> ! conval = (datatype == NAMEOID) ?
> ! (void*) namein(prefix) : (void*) textin(prefix);
> ! con = makeConst(datatype, ((datatype == NAMEOID) ? NAMEDATALEN : -1),
> ! PointerGetDatum(conval),
> ! false, false, false, false);
> ! op = makeOper(optup->t_data->t_oid, InvalidOid, BOOLOID, 0, NULL);
> ! expr = make_opclause(op, leftop, (Var *) con);
> ! result = lappend(result, expr);
> ! #endif
> !
> return result;
> }
> --- 1934,1970 ----
> op = makeOper(optup->t_data->t_oid, InvalidOid, BOOLOID, 0, NULL);
> expr = make_opclause(op, leftop, (Var *) con);
> result = lcons(expr, NIL);
> /*
> ! * If last is in ascii range make it indexable,
> ! * else let it be.
> ! * FIXME: find way to use locate for this to support
> ! * indexing of non-ascii characters.
> */
> ! prefixlen = strlen(prefix) - 1;
> ! elog(DEBUG, "XXX1 %s", prefix);
> ! if ((unsigned) prefix[prefixlen] < 126)
> ! {
> ! prefix[prefixlen]++;
> ! elog(DEBUG, "XXX2 %s", prefix);
> ! optup = SearchSysCacheTuple(OPRNAME,
> ! PointerGetDatum("<="),
> ! ObjectIdGetDatum(datatype),
> ! ObjectIdGetDatum(datatype),
> ! CharGetDatum('b'));
> ! if (!HeapTupleIsValid(optup))
> ! elog(ERROR, "prefix_quals: no <= operator for type %u", datatype);
> ! conval = (datatype == NAMEOID) ?
> ! (void*) namein(prefix) : (void*) textin(prefix);
> ! con = makeConst(datatype, ((datatype == NAMEOID) ? NAMEDATALEN : -1),
> ! PointerGetDatum(conval),
> ! false, false, false, false);
> ! op = makeOper(optup->t_data->t_oid, InvalidOid, BOOLOID, 0, NULL);
> ! expr = make_opclause(op, leftop, (Var *) con);
> ! result = lappend(result, expr);
> ! }
> return result;
> }

[application/x-gzip is not supported, skipping...]

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-11-30 01:51:27 Re: [HACKERS] indexable and locale
Previous Message Tim Holloway 1999-11-30 01:46:30 Re: [HACKERS] How to get info about deadlocks?