@@ -54,10 +54,18 @@ void _PG_init(void);
54
54
static Node * wrapper_make_expression (WrapperNode * wrap , int index , bool * alwaysTrue );
55
55
56
56
static void handle_const (const Const * c ,
57
+ const Oid collid ,
57
58
const int strategy ,
58
59
const WalkerContext * context ,
59
60
WrapperNode * result );
60
61
62
+ static void handle_array (ArrayType * array ,
63
+ const Oid collid ,
64
+ const int strategy ,
65
+ const bool use_or ,
66
+ const WalkerContext * context ,
67
+ WrapperNode * result );
68
+
61
69
static void handle_boolexpr (const BoolExpr * expr ,
62
70
const WalkerContext * context ,
63
71
WrapperNode * result );
@@ -406,9 +414,9 @@ append_child_relation(PlannerInfo *root, Relation parent_relation,
406
414
407
415
408
416
/*
409
- * --------------------------
410
- * RANGE partition prunning
411
- * --------------------------
417
+ * -------------------------
418
+ * RANGE partition pruning
419
+ * -------------------------
412
420
*/
413
421
414
422
/* Given 'value' and 'ranges', return selected partitions list */
@@ -613,7 +621,8 @@ walk_expr_tree(Expr *expr, const WalkerContext *context)
613
621
{
614
622
/* Useful for INSERT optimization */
615
623
case T_Const :
616
- handle_const ((Const * ) expr , BTEqualStrategyNumber , context , result );
624
+ handle_const ((Const * ) expr , ((Const * ) expr )-> constcollid ,
625
+ BTEqualStrategyNumber , context , result );
617
626
return result ;
618
627
619
628
/* AND, OR, NOT expressions */
@@ -718,6 +727,7 @@ wrapper_make_expression(WrapperNode *wrap, int index, bool *alwaysTrue)
718
727
/* Const handler */
719
728
static void
720
729
handle_const (const Const * c ,
730
+ const Oid collid ,
721
731
const int strategy ,
722
732
const WalkerContext * context ,
723
733
WrapperNode * result ) /* ret value #1 */
@@ -806,8 +816,7 @@ handle_const(const Const *c,
806
816
FmgrInfo cmp_finfo ;
807
817
808
818
/* Cannot do much about non-equal strategies + diff. collations */
809
- if (strategy != BTEqualStrategyNumber &&
810
- c -> constcollid != prel -> ev_collid )
819
+ if (strategy != BTEqualStrategyNumber && collid != prel -> ev_collid )
811
820
{
812
821
goto handle_const_return ;
813
822
}
@@ -817,7 +826,7 @@ handle_const(const Const *c,
817
826
getBaseType (prel -> ev_type ));
818
827
819
828
select_range_partitions (c -> constvalue ,
820
- c -> constcollid ,
829
+ collid ,
821
830
& cmp_finfo ,
822
831
PrelGetRangesArray (context -> prel ),
823
832
PrelChildrenCount (context -> prel ),
@@ -841,6 +850,7 @@ handle_const(const Const *c,
841
850
/* Array handler */
842
851
static void
843
852
handle_array (ArrayType * array ,
853
+ const Oid collid ,
844
854
const int strategy ,
845
855
const bool use_or ,
846
856
const WalkerContext * context ,
@@ -898,7 +908,7 @@ handle_array(ArrayType *array,
898
908
c .constbyval = elem_byval ;
899
909
c .location = -1 ;
900
910
901
- handle_const (& c , strategy , context , & wrap );
911
+ handle_const (& c , collid , strategy , context , & wrap );
902
912
903
913
/* Should we use OR | AND? */
904
914
ranges = use_or ?
@@ -1020,7 +1030,8 @@ handle_arrexpr(const ScalarArrayOpExpr *expr,
1020
1030
1021
1031
/* Examine array */
1022
1032
handle_array (DatumGetArrayTypeP (c -> constvalue ),
1023
- strategy , expr -> useOr , context , result );
1033
+ expr -> inputcollid , strategy ,
1034
+ expr -> useOr , context , result );
1024
1035
1025
1036
/* Save expression */
1026
1037
result -> orig = (const Node * ) expr ;
@@ -1063,10 +1074,12 @@ handle_arrexpr(const ScalarArrayOpExpr *expr,
1063
1074
1064
1075
/* Examine array */
1065
1076
handle_array (DatumGetArrayTypeP (c -> constvalue ),
1066
- strategy , expr -> useOr , context , & wrap );
1077
+ expr -> inputcollid , strategy ,
1078
+ expr -> useOr , context , & wrap );
1067
1079
}
1068
1080
/* ... or a single element? */
1069
- else handle_const (c , strategy , context , & wrap );
1081
+ else handle_const (c , expr -> inputcollid ,
1082
+ strategy , context , & wrap );
1070
1083
1071
1084
/* Should we use OR | AND? */
1072
1085
ranges = expr -> useOr ?
@@ -1131,6 +1144,7 @@ handle_opexpr(const OpExpr *expr,
1131
1144
if (IsConstValue (param , context ))
1132
1145
{
1133
1146
handle_const (ExtractConst (param , context ),
1147
+ expr -> inputcollid ,
1134
1148
strategy , context , result );
1135
1149
1136
1150
/* Save expression */
0 commit comments