@@ -145,7 +145,7 @@ static double eqjoinsel_inner(Oid operator,
145145static double eqjoinsel_semi (Oid operator ,
146146VariableStatData * vardata1 ,VariableStatData * vardata2 );
147147static bool convert_to_scalar (Datum value ,Oid valuetypid ,double * scaledvalue ,
148- Datum lobound ,Datum hibound ,Oid boundstypid ,Oid boundscollid ,
148+ Datum lobound ,Datum hibound ,Oid boundstypid ,
149149double * scaledlobound ,double * scaledhibound );
150150static double convert_numeric_to_scalar (Datum value ,Oid typid );
151151static void convert_string_to_scalar (char * value ,
@@ -164,10 +164,10 @@ static double convert_one_string_to_scalar(char *value,
164164int rangelo ,int rangehi );
165165static double convert_one_bytea_to_scalar (unsignedchar * value ,int valuelen ,
166166int rangelo ,int rangehi );
167- static char * convert_string_datum (Datum value ,Oid typid , Oid collid );
167+ static char * convert_string_datum (Datum value ,Oid typid );
168168static double convert_timevalue_to_scalar (Datum value ,Oid typid );
169169static bool get_variable_range (PlannerInfo * root ,VariableStatData * vardata ,
170- Oid sortop ,Oid collation , Datum * min ,Datum * max );
170+ Oid sortop ,Datum * min ,Datum * max );
171171static bool get_actual_variable_range (PlannerInfo * root ,
172172VariableStatData * vardata ,
173173Oid sortop ,
@@ -285,6 +285,7 @@ var_eq_const(VariableStatData *vardata, Oid operator,
285285FmgrInfo eqproc ;
286286
287287fmgr_info (get_opcode (operator ),& eqproc );
288+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& eqproc );
288289
289290for (i = 0 ;i < nvalues ;i ++ )
290291{
@@ -514,7 +515,7 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt,
514515stats = (Form_pg_statistic )GETSTRUCT (vardata -> statsTuple );
515516
516517fmgr_info (get_opcode (operator ),& opproc );
517- fmgr_info_collation (vardata -> attcollation ,& opproc );
518+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& opproc );
518519
519520/*
520521 * If we have most-common-values info, add up the fractions of the MCV
@@ -839,7 +840,7 @@ ineq_histogram_selectivity(PlannerInfo *root,
839840 */
840841if (convert_to_scalar (constval ,consttype ,& val ,
841842values [i - 1 ],values [i ],
842- vardata -> vartype ,vardata -> attcollation ,
843+ vardata -> vartype ,
843844& low ,& high ))
844845{
845846if (high <=low )
@@ -1700,6 +1701,7 @@ scalararraysel(PlannerInfo *root,
17001701if (!oprsel )
17011702return (Selectivity )0.5 ;
17021703fmgr_info (oprsel ,& oprselproc );
1704+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& oprselproc );
17031705
17041706/* deconstruct the expression */
17051707Assert (list_length (clause -> args )== 2 );
@@ -2116,6 +2118,7 @@ eqjoinsel_inner(Oid operator,
21162118nmatches ;
21172119
21182120fmgr_info (get_opcode (operator ),& eqproc );
2121+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& eqproc );
21192122hasmatch1 = (bool * )palloc0 (nvalues1 * sizeof (bool ));
21202123hasmatch2 = (bool * )palloc0 (nvalues2 * sizeof (bool ));
21212124
@@ -2338,6 +2341,7 @@ eqjoinsel_semi(Oid operator,
23382341nmatches ;
23392342
23402343fmgr_info (get_opcode (operator ),& eqproc );
2344+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& eqproc );
23412345hasmatch1 = (bool * )palloc0 (nvalues1 * sizeof (bool ));
23422346hasmatch2 = (bool * )palloc0 (nvalues2 * sizeof (bool ));
23432347
@@ -2588,7 +2592,7 @@ icnlikejoinsel(PG_FUNCTION_ARGS)
25882592 */
25892593void
25902594mergejoinscansel (PlannerInfo * root ,Node * clause ,
2591- Oid opfamily ,Oid collation , int strategy ,bool nulls_first ,
2595+ Oid opfamily ,int strategy ,bool nulls_first ,
25922596Selectivity * leftstart ,Selectivity * leftend ,
25932597Selectivity * rightstart ,Selectivity * rightend )
25942598{
@@ -2757,20 +2761,20 @@ mergejoinscansel(PlannerInfo *root, Node *clause,
27572761/* Try to get ranges of both inputs */
27582762if (!isgt )
27592763{
2760- if (!get_variable_range (root ,& leftvar ,lstatop ,collation ,
2764+ if (!get_variable_range (root ,& leftvar ,lstatop ,
27612765& leftmin ,& leftmax ))
27622766gotofail ;/* no range available from stats */
2763- if (!get_variable_range (root ,& rightvar ,rstatop ,collation ,
2767+ if (!get_variable_range (root ,& rightvar ,rstatop ,
27642768& rightmin ,& rightmax ))
27652769gotofail ;/* no range available from stats */
27662770}
27672771else
27682772{
27692773/* need to swap the max and min */
2770- if (!get_variable_range (root ,& leftvar ,lstatop ,collation ,
2774+ if (!get_variable_range (root ,& leftvar ,lstatop ,
27712775& leftmax ,& leftmin ))
27722776gotofail ;/* no range available from stats */
2773- if (!get_variable_range (root ,& rightvar ,rstatop ,collation ,
2777+ if (!get_variable_range (root ,& rightvar ,rstatop ,
27742778& rightmax ,& rightmin ))
27752779gotofail ;/* no range available from stats */
27762780}
@@ -3371,7 +3375,7 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets)
33713375 */
33723376static bool
33733377convert_to_scalar (Datum value ,Oid valuetypid ,double * scaledvalue ,
3374- Datum lobound ,Datum hibound ,Oid boundstypid ,Oid boundscollid ,
3378+ Datum lobound ,Datum hibound ,Oid boundstypid ,
33753379double * scaledlobound ,double * scaledhibound )
33763380{
33773381/*
@@ -3424,9 +3428,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
34243428case TEXTOID :
34253429case NAMEOID :
34263430{
3427- char * valstr = convert_string_datum (value ,valuetypid , boundscollid );
3428- char * lostr = convert_string_datum (lobound ,boundstypid , boundscollid );
3429- char * histr = convert_string_datum (hibound ,boundstypid , boundscollid );
3431+ char * valstr = convert_string_datum (value ,valuetypid );
3432+ char * lostr = convert_string_datum (lobound ,boundstypid );
3433+ char * histr = convert_string_datum (hibound ,boundstypid );
34303434
34313435convert_string_to_scalar (valstr ,scaledvalue ,
34323436lostr ,scaledlobound ,
@@ -3670,7 +3674,7 @@ convert_one_string_to_scalar(char *value, int rangelo, int rangehi)
36703674 * before continuing, so as to generate correct locale-specific results.
36713675 */
36723676static char *
3673- convert_string_datum (Datum value ,Oid typid , Oid collid )
3677+ convert_string_datum (Datum value ,Oid typid )
36743678{
36753679char * val ;
36763680
@@ -3703,7 +3707,7 @@ convert_string_datum(Datum value, Oid typid, Oid collid)
37033707return NULL ;
37043708}
37053709
3706- if (!lc_collate_is_c (collid ))
3710+ if (!lc_collate_is_c (DEFAULT_COLLATION_OID ))
37073711{
37083712char * xfrmstr ;
37093713size_t xfrmlen ;
@@ -4102,7 +4106,6 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
41024106vardata -> rel = find_base_rel (root ,var -> varno );
41034107vardata -> atttype = var -> vartype ;
41044108vardata -> atttypmod = var -> vartypmod ;
4105- vardata -> attcollation = var -> varcollid ;
41064109vardata -> isunique = has_unique_index (vardata -> rel ,var -> varattno );
41074110
41084111rte = root -> simple_rte_array [var -> varno ];
@@ -4188,7 +4191,6 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
41884191vardata -> var = node ;
41894192vardata -> atttype = exprType (node );
41904193vardata -> atttypmod = exprTypmod (node );
4191- vardata -> attcollation = exprCollation (node );
41924194
41934195if (onerel )
41944196{
@@ -4397,7 +4399,7 @@ get_variable_numdistinct(VariableStatData *vardata)
43974399 * be "<" not ">", as only the former is likely to be found in pg_statistic.
43984400 */
43994401static bool
4400- get_variable_range (PlannerInfo * root ,VariableStatData * vardata ,Oid sortop ,Oid collation ,
4402+ get_variable_range (PlannerInfo * root ,VariableStatData * vardata ,Oid sortop ,
44014403Datum * min ,Datum * max )
44024404{
44034405Datum tmin = 0 ;
@@ -4482,7 +4484,7 @@ get_variable_range(PlannerInfo *root, VariableStatData *vardata, Oid sortop, Oid
44824484FmgrInfo opproc ;
44834485
44844486fmgr_info (get_opcode (sortop ),& opproc );
4485- fmgr_info_collation (collation ,& opproc );
4487+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& opproc );
44864488
44874489for (i = 0 ;i < nvalues ;i ++ )
44884490{
@@ -5109,6 +5111,7 @@ prefix_selectivity(PlannerInfo *root, VariableStatData *vardata,
51095111if (cmpopr == InvalidOid )
51105112elog (ERROR ,"no >= operator for opfamily %u" ,opfamily );
51115113fmgr_info (get_opcode (cmpopr ),& opproc );
5114+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& opproc );
51125115
51135116prefixsel = ineq_histogram_selectivity (root ,vardata ,& opproc , true,
51145117prefixcon -> constvalue ,
@@ -5130,6 +5133,7 @@ prefix_selectivity(PlannerInfo *root, VariableStatData *vardata,
51305133if (cmpopr == InvalidOid )
51315134elog (ERROR ,"no < operator for opfamily %u" ,opfamily );
51325135fmgr_info (get_opcode (cmpopr ),& opproc );
5136+ fmgr_info_collation (DEFAULT_COLLATION_OID ,& opproc );
51335137
51345138greaterstrcon = make_greater_string (prefixcon ,& opproc );
51355139if (greaterstrcon )