7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.29 1999/07/17 20:17:25 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.30 1999/08/23 23:48:39 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
25
25
26
26
static Oid * oper_select_candidate (int nargs , Oid * input_typeids ,
27
27
CandidateList candidates );
28
+ static Operator oper_exact (char * op , Oid arg1 , Oid arg2 );
29
+ static Operator oper_inexact (char * op , Oid arg1 , Oid arg2 );
28
30
static int binary_oper_get_candidates (char * opname ,
29
31
Oid leftTypeId ,
30
32
Oid rightTypeId ,
@@ -376,15 +378,14 @@ oper_select_candidate(int nargs,
376
378
377
379
378
380
/* oper_exact()
379
- * Given operator, and arguments, return oper struct.
381
+ * Given operator, and arguments, return oper struct or NULL .
380
382
* Inputs:
381
383
* arg1, arg2: Type IDs
382
384
*/
383
- Operator
384
- oper_exact (char * op , Oid arg1 , Oid arg2 , Node * * ltree , Node * * rtree , bool noWarnings )
385
+ static Operator
386
+ oper_exact (char * op , Oid arg1 , Oid arg2 )
385
387
{
386
388
HeapTuple tup ;
387
- Node * tree ;
388
389
389
390
/* Unspecified type for one of the arguments? then use the other */
390
391
if ((arg1 == UNKNOWNOID ) && (arg2 != InvalidOid ))
@@ -398,51 +399,17 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
398
399
ObjectIdGetDatum (arg2 ),
399
400
CharGetDatum ('b' ));
400
401
401
- /*
402
- * Did not find anything? then try flipping arguments on a commutative
403
- * operator...
404
- */
405
- if (!HeapTupleIsValid (tup ) && (arg1 != arg2 ))
406
- {
407
- tup = SearchSysCacheTuple (OPRNAME ,
408
- PointerGetDatum (op ),
409
- ObjectIdGetDatum (arg2 ),
410
- ObjectIdGetDatum (arg1 ),
411
- CharGetDatum ('b' ));
412
-
413
- if (HeapTupleIsValid (tup ))
414
- {
415
- Form_pg_operator opform ;
416
-
417
- opform = (Form_pg_operator ) GETSTRUCT (tup );
418
- if (opform -> oprcom == tup -> t_data -> t_oid )
419
- {
420
- if ((ltree != NULL ) && (rtree != NULL ))
421
- {
422
- tree = * ltree ;
423
- * ltree = * rtree ;
424
- * rtree = tree ;
425
- }
426
- }
427
- /* disable for now... - thomas 1998-05-14 */
428
- else
429
- tup = NULL ;
430
- }
431
- if (!HeapTupleIsValid (tup ) && (!noWarnings ))
432
- op_error (op , arg1 , arg2 );
433
- }
434
-
435
- return tup ;
402
+ return (Operator ) tup ;
436
403
} /* oper_exact() */
437
404
438
405
439
406
/* oper_inexact()
440
- * Given operator, types of arg1, and arg2, return oper struct.
407
+ * Given operator, types of arg1, and arg2, return oper struct or NULL .
441
408
* Inputs:
442
409
* arg1, arg2: Type IDs
443
410
*/
444
- Operator
445
- oper_inexact (char * op , Oid arg1 , Oid arg2 , Node * * ltree , Node * * rtree , bool noWarnings )
411
+ static Operator
412
+ oper_inexact (char * op , Oid arg1 , Oid arg2 )
446
413
{
447
414
HeapTuple tup ;
448
415
CandidateList candidates ;
@@ -458,13 +425,9 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
458
425
459
426
ncandidates = binary_oper_get_candidates (op , arg1 , arg2 , & candidates );
460
427
461
- /* No operators found? Then throw error or return null... */
428
+ /* No operators found? Then return null... */
462
429
if (ncandidates == 0 )
463
- {
464
- if (!noWarnings )
465
- op_error (op , arg1 , arg2 );
466
430
return NULL ;
467
- }
468
431
469
432
/* Or found exactly one? Then proceed... */
470
433
else if (ncandidates == 1 )
@@ -493,18 +456,6 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
493
456
}
494
457
else
495
458
tup = NULL ;
496
-
497
- /* Could not choose one, for whatever reason... */
498
- if (!HeapTupleIsValid (tup ))
499
- {
500
- if (!noWarnings )
501
- {
502
- elog (ERROR , "Unable to identify an operator '%s' for types '%s' and '%s'"
503
- "\n\tYou will have to retype this query using an explicit cast" ,
504
- op , typeTypeName (typeidType (arg1 )), typeTypeName (typeidType (arg2 )));
505
- }
506
- return NULL ;
507
- }
508
459
}
509
460
return (Operator ) tup ;
510
461
} /* oper_inexact() */
@@ -521,17 +472,16 @@ oper(char *opname, Oid ltypeId, Oid rtypeId, bool noWarnings)
521
472
HeapTuple tup ;
522
473
523
474
/* check for exact match on this operator... */
524
- if (HeapTupleIsValid (tup = oper_exact (opname , ltypeId , rtypeId , NULL , NULL , TRUE )))
475
+ if (HeapTupleIsValid (tup = oper_exact (opname , ltypeId , rtypeId )))
525
476
{
526
477
}
527
478
/* try to find a match on likely candidates... */
528
- else if (HeapTupleIsValid (tup = oper_inexact (opname , ltypeId , rtypeId , NULL , NULL , TRUE )))
479
+ else if (HeapTupleIsValid (tup = oper_inexact (opname , ltypeId , rtypeId )))
529
480
{
530
481
}
531
482
else if (!noWarnings )
532
483
{
533
- elog (ERROR , "Unable to identify a binary operator '%s' for types %s and %s" ,
534
- opname , typeTypeName (typeidType (ltypeId )), typeTypeName (typeidType (rtypeId )));
484
+ op_error (opname , ltypeId , rtypeId );
535
485
}
536
486
537
487
return (Operator ) tup ;
@@ -741,8 +691,7 @@ op_error(char *op, Oid arg1, Oid arg2)
741
691
"\n\tProbably a bad attribute name" , op );
742
692
}
743
693
744
- elog (ERROR , "There is no operator '%s' for types '%s' and '%s'"
745
- "\n\tYou will either have to retype this query using an explicit cast,"
746
- "\n\tor you will have to define the operator using CREATE OPERATOR" ,
694
+ elog (ERROR , "Unable to identify an operator '%s' for types '%s' and '%s'"
695
+ "\n\tYou will have to retype this query using an explicit cast" ,
747
696
op , typeTypeName (tp1 ), typeTypeName (tp2 ));
748
697
}
0 commit comments