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

Commit b05ff39

Browse files
committed
Fix binary_oper_exact() so that the heuristic 'an unknown literal on
one side of a binary operator is probably supposed to be the same type as the other operand' will be applied for domain types. This worked in 7.3 but was broken in 7.4 due to code rearrangements. Mea culpa.
1 parent f98cbb7 commit b05ff39

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/backend/parser/parse_oper.c

+31-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.75 2003/09/25 06:58:01 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.76 2003/10/06 20:09:47 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -386,24 +386,48 @@ oprfuncid(Operator op)
386386
* Check for an "exact" match to the specified operand types.
387387
*
388388
* If one operand is an unknown literal, assume it should be taken to be
389-
* the same type as the other operand for this purpose.
389+
* the same type as the other operand for this purpose. Also, consider
390+
* the possibility that the other operand is a domain type that needs to
391+
* be reduced to its base type to find an "exact" match.
390392
*/
391393
static Oid
392394
binary_oper_exact(Oid arg1, Oid arg2,
393395
FuncCandidateList candidates)
394396
{
397+
FuncCandidateList cand;
398+
bool was_unknown = false;
399+
395400
/* Unspecified type for one of the arguments? then use the other */
396401
if ((arg1 == UNKNOWNOID) && (arg2 != InvalidOid))
402+
{
397403
arg1 = arg2;
404+
was_unknown = true;
405+
}
398406
else if ((arg2 == UNKNOWNOID) && (arg1 != InvalidOid))
407+
{
399408
arg2 = arg1;
409+
was_unknown = true;
410+
}
400411

401-
while (candidates != NULL)
412+
for (cand = candidates; cand != NULL; cand = cand->next)
402413
{
403-
if (arg1 == candidates->args[0] &&
404-
arg2 == candidates->args[1])
405-
return candidates->oid;
406-
candidates = candidates->next;
414+
if (arg1 == cand->args[0] && arg2 == cand->args[1])
415+
return cand->oid;
416+
}
417+
418+
if (was_unknown)
419+
{
420+
/* arg1 and arg2 are the same here, need only look at arg1 */
421+
Oid basetype = getBaseType(arg1);
422+
423+
if (basetype != arg1)
424+
{
425+
for (cand = candidates; cand != NULL; cand = cand->next)
426+
{
427+
if (basetype == cand->args[0] && basetype == cand->args[1])
428+
return cand->oid;
429+
}
430+
}
407431
}
408432

409433
return InvalidOid;

0 commit comments

Comments
 (0)