aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-25 20:33:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-25 20:33:54 +0000
commitbbea3643a3a6425f92d0db9ff16c7f73a31a466c (patch)
treef13bea7c027c5e4e5155eb802a16e0e2c1d3a0c8 /src/backend/optimizer/path/indxpath.c
parent0432ce994d3971ced6e336e9f58444d5322c3270 (diff)
downloadpostgresql-bbea3643a3a6425f92d0db9ff16c7f73a31a466c.tar.gz
postgresql-bbea3643a3a6425f92d0db9ff16c7f73a31a466c.zip
Store current LC_COLLATE and LC_CTYPE settings in pg_control during initdb;
re-adopt these settings at every postmaster or standalone-backend startup. This should fix problems with indexes becoming corrupt due to failure to provide consistent locale environment for postmaster at all times. Also, refuse to start up a non-locale-enabled compilation in a database originally initdb'd with a non-C locale. Suppress LIKE index optimization if locale is not "C" or "POSIX" (are there any other locales where it's safe?). Issue NOTICE during initdb if selected locale disables LIKE optimization.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c82
1 files changed, 47 insertions, 35 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 43577f94f99..63e3a53af5a 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.98 2000/11/16 22:30:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.99 2000/11/25 20:33:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1746,56 +1746,68 @@ match_special_index_operator(Expr *clause, Oid opclass, Oid relam,
case OID_BPCHAR_LIKE_OP:
case OID_VARCHAR_LIKE_OP:
case OID_NAME_LIKE_OP:
- /* the right-hand const is type text for all of these */
- patt = DatumGetCString(DirectFunctionCall1(textout,
- constvalue));
- isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like,
- &prefix, &rest) != Pattern_Prefix_None;
- if (prefix)
- pfree(prefix);
- pfree(patt);
+ if (locale_is_like_safe())
+ {
+ /* the right-hand const is type text for all of these */
+ patt = DatumGetCString(DirectFunctionCall1(textout,
+ constvalue));
+ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like,
+ &prefix, &rest) != Pattern_Prefix_None;
+ if (prefix)
+ pfree(prefix);
+ pfree(patt);
+ }
break;
case OID_TEXT_ICLIKE_OP:
case OID_BPCHAR_ICLIKE_OP:
case OID_VARCHAR_ICLIKE_OP:
case OID_NAME_ICLIKE_OP:
- /* the right-hand const is type text for all of these */
- patt = DatumGetCString(DirectFunctionCall1(textout,
- constvalue));
- isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like_IC,
- &prefix, &rest) != Pattern_Prefix_None;
- if (prefix)
- pfree(prefix);
- pfree(patt);
+ if (locale_is_like_safe())
+ {
+ /* the right-hand const is type text for all of these */
+ patt = DatumGetCString(DirectFunctionCall1(textout,
+ constvalue));
+ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like_IC,
+ &prefix, &rest) != Pattern_Prefix_None;
+ if (prefix)
+ pfree(prefix);
+ pfree(patt);
+ }
break;
case OID_TEXT_REGEXEQ_OP:
case OID_BPCHAR_REGEXEQ_OP:
case OID_VARCHAR_REGEXEQ_OP:
case OID_NAME_REGEXEQ_OP:
- /* the right-hand const is type text for all of these */
- patt = DatumGetCString(DirectFunctionCall1(textout,
- constvalue));
- isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex,
- &prefix, &rest) != Pattern_Prefix_None;
- if (prefix)
- pfree(prefix);
- pfree(patt);
+ if (locale_is_like_safe())
+ {
+ /* the right-hand const is type text for all of these */
+ patt = DatumGetCString(DirectFunctionCall1(textout,
+ constvalue));
+ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex,
+ &prefix, &rest) != Pattern_Prefix_None;
+ if (prefix)
+ pfree(prefix);
+ pfree(patt);
+ }
break;
case OID_TEXT_ICREGEXEQ_OP:
case OID_BPCHAR_ICREGEXEQ_OP:
case OID_VARCHAR_ICREGEXEQ_OP:
case OID_NAME_ICREGEXEQ_OP:
- /* the right-hand const is type text for all of these */
- patt = DatumGetCString(DirectFunctionCall1(textout,
- constvalue));
- isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex_IC,
- &prefix, &rest) != Pattern_Prefix_None;
- if (prefix)
- pfree(prefix);
- pfree(patt);
+ if (locale_is_like_safe())
+ {
+ /* the right-hand const is type text for all of these */
+ patt = DatumGetCString(DirectFunctionCall1(textout,
+ constvalue));
+ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex_IC,
+ &prefix, &rest) != Pattern_Prefix_None;
+ if (prefix)
+ pfree(prefix);
+ pfree(patt);
+ }
break;
}
@@ -2053,8 +2065,8 @@ prefix_quals(Var *leftop, Oid expr_op,
result = makeList1(expr);
/*
- * If we can create a string larger than the prefix, say "x <
- * greaterstr".
+ * If we can create a string larger than the prefix, we can say
+ * "x < greaterstr".
*/
greaterstr = make_greater_string(prefix, datatype);
if (greaterstr)