|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -386,24 +386,48 @@ oprfuncid(Operator op)
|
386 | 386 | * Check for an "exact" match to the specified operand types.
|
387 | 387 | *
|
388 | 388 | * 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. |
390 | 392 | */
|
391 | 393 | static Oid
|
392 | 394 | binary_oper_exact(Oid arg1, Oid arg2,
|
393 | 395 | FuncCandidateList candidates)
|
394 | 396 | {
|
| 397 | + FuncCandidateList cand; |
| 398 | + bool was_unknown = false; |
| 399 | + |
395 | 400 | /* Unspecified type for one of the arguments? then use the other */
|
396 | 401 | if ((arg1 == UNKNOWNOID) && (arg2 != InvalidOid))
|
| 402 | + { |
397 | 403 | arg1 = arg2;
|
| 404 | + was_unknown = true; |
| 405 | + } |
398 | 406 | else if ((arg2 == UNKNOWNOID) && (arg1 != InvalidOid))
|
| 407 | + { |
399 | 408 | arg2 = arg1;
|
| 409 | + was_unknown = true; |
| 410 | + } |
400 | 411 |
|
401 |
| - while (candidates != NULL) |
| 412 | + for (cand = candidates; cand != NULL; cand = cand->next) |
402 | 413 | {
|
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 | + } |
407 | 431 | }
|
408 | 432 |
|
409 | 433 | return InvalidOid;
|
|
0 commit comments