88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.108 2009/06/11 14:49:00 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.109 2009/06/13 15:42:09 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -203,7 +203,7 @@ get_sort_group_operators(Oid argtype,
203203 * If the datatype is an array, then we can use array_lt and friends ...
204204 * but only if there are suitable operators for the element type. (This
205205 * check is not in the raw typcache.c code ... should it be?) Testing all
206- * three operator IDs here should be redundant.
206+ * three operator IDs here should be redundant, but let's do it anyway .
207207 */
208208if (lt_opr == ARRAY_LT_OP ||
209209eq_opr == ARRAY_EQ_OP ||
@@ -215,12 +215,31 @@ get_sort_group_operators(Oid argtype,
215215{
216216typentry = lookup_type_cache (elem_type ,
217217TYPECACHE_LT_OPR |TYPECACHE_EQ_OPR |TYPECACHE_GT_OPR );
218- if (! OidIsValid ( typentry -> lt_opr ))
219- lt_opr = InvalidOid ; /*element type has no "<" */
218+ #ifdef NOT_USED
219+ /*We should do this ... */
220220if (!OidIsValid (typentry -> eq_opr ))
221- eq_opr = InvalidOid ;/* element type has no "=" */
222- if (!OidIsValid (typentry -> gt_opr ))
223- gt_opr = InvalidOid ;/* element type has no ">" */
221+ {
222+ /* element type is neither sortable nor hashable */
223+ lt_opr = eq_opr = gt_opr = InvalidOid ;
224+ }
225+ else if (!OidIsValid (typentry -> lt_opr )||
226+ !OidIsValid (typentry -> gt_opr ))
227+ {
228+ /* element type is hashable but not sortable */
229+ lt_opr = gt_opr = InvalidOid ;
230+ }
231+ #else
232+ /*
233+ * ... but for the moment we have to do this. This is because
234+ * anyarray has sorting but not hashing support. So, if the
235+ * element type is only hashable, there is nothing we can do
236+ * with the array type.
237+ */
238+ if (!OidIsValid (typentry -> lt_opr )||
239+ !OidIsValid (typentry -> eq_opr )||
240+ !OidIsValid (typentry -> gt_opr ))
241+ lt_opr = eq_opr = gt_opr = InvalidOid ;/* not sortable */
242+ #endif
224243}
225244else
226245lt_opr = eq_opr = gt_opr = InvalidOid ;/* bogus array type? */