Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5f6a140

Browse files
committed
Fix get_sort_group_operators() so that it doesn't think arrays can be grouped
via hashing. Eventually we ought to make that possible, but it won't happen for 8.4. Per yesterday's report from Robert Haas.
1 parent 215ea9b commit 5f6a140

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/backend/parser/parse_oper.c

+26-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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
*/
208208
if (lt_opr == ARRAY_LT_OP ||
209209
eq_opr == ARRAY_EQ_OP ||
@@ -215,12 +215,31 @@ get_sort_group_operators(Oid argtype,
215215
{
216216
typentry = lookup_type_cache(elem_type,
217217
TYPECACHE_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 ... */
220220
if (!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
}
225244
else
226245
lt_opr = eq_opr = gt_opr = InvalidOid; /* bogus array type? */

0 commit comments

Comments
 (0)