Re: indexable and locale - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: indexable and locale |
Date | |
Msg-id | 199911300152.UAA20933@candle.pha.pa.us Whole thread Raw |
In response to | indexable and locale (Goran Thyni <goran@kirra.net>) |
List | pgsql-hackers |
Sorry, found messages of people objecting to the patch. Patch reversed out. [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@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
pgsql-hackers by date: