Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita23faee

Browse files
committed
Remove bogus code in oper_exact --- if it didn't find an exact
match then it tried for a self-commutative operator with the reversed inputdata types. This is pretty silly; there could never be such an operator,except maybe in binary-compatible-type scenarios, and we have oper_inexactfor that. Besides which, the oprsanity regress test would complain aboutsuch an operator. Remove nonfunctional code and simplify routine callingconvention accordingly.
1 parente8140ad commita23faee

File tree

4 files changed

+33
-105
lines changed

4 files changed

+33
-105
lines changed

‎src/backend/parser/parse_node.c

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.30 1999/08/22 20:15:04 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.31 1999/08/23 23:48:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -31,10 +31,6 @@
3131
#include"utils/syscache.h"
3232

3333
staticvoiddisallow_setop(char*op,Typeoptype,Node*operand);
34-
staticNode*make_operand(char*opname,
35-
Node*tree,
36-
Oidorig_typeId,
37-
Oidtrue_typeId);
3834

3935
/* make_parsestate()
4036
* Allocate and initialize a new ParseState.
@@ -58,31 +54,31 @@ make_parsestate(ParseState *parentParseState)
5854
/* make_operand()
5955
* Ensure argument type match by forcing conversion of constants.
6056
*/
61-
staticNode*
57+
Node*
6258
make_operand(char*opname,
6359
Node*tree,
6460
Oidorig_typeId,
65-
Oidtrue_typeId)
61+
Oidtarget_typeId)
6662
{
6763
Node*result;
68-
Typetrue_type;
64+
Typetarget_type;
6965

7066
if (tree!=NULL)
7167
{
7268
result=tree;
73-
true_type=typeidType(true_typeId);
74-
disallow_setop(opname,true_type,result);
69+
target_type=typeidType(target_typeId);
70+
disallow_setop(opname,target_type,result);
7571

7672
/* must coerce? */
77-
if (true_typeId!=orig_typeId)
78-
result=coerce_type(NULL,tree,orig_typeId,true_typeId,-1);
73+
if (target_typeId!=orig_typeId)
74+
result=coerce_type(NULL,tree,orig_typeId,target_typeId,-1);
7975
}
8076
/* otherwise, this is a NULL value */
8177
else
8278
{
8379
Const*con=makeNode(Const);
8480

85-
con->consttype=true_typeId;
81+
con->consttype=target_typeId;
8682
con->constlen=0;
8783
con->constvalue= (Datum) (structvarlena*)NULL;
8884
con->constisnull= true;
@@ -128,47 +124,31 @@ make_op(char *opname, Node *ltree, Node *rtree)
128124
*right;
129125
Expr*result;
130126

127+
ltypeId= (ltree==NULL) ?UNKNOWNOID :exprType(ltree);
128+
rtypeId= (rtree==NULL) ?UNKNOWNOID :exprType(rtree);
129+
131130
/* right operator? */
132131
if (rtree==NULL)
133132
{
134-
ltypeId= (ltree==NULL) ?UNKNOWNOID :exprType(ltree);
135133
tup=right_oper(opname,ltypeId);
136134
opform= (Form_pg_operator)GETSTRUCT(tup);
137135
left=make_operand(opname,ltree,ltypeId,opform->oprleft);
138136
right=NULL;
139-
140137
}
141138

142139
/* left operator? */
143140
elseif (ltree==NULL)
144141
{
145-
rtypeId= (rtree==NULL) ?UNKNOWNOID :exprType(rtree);
146142
tup=left_oper(opname,rtypeId);
147143
opform= (Form_pg_operator)GETSTRUCT(tup);
148144
right=make_operand(opname,rtree,rtypeId,opform->oprright);
149145
left=NULL;
150-
151146
}
152147

153148
/* otherwise, binary operator */
154149
else
155150
{
156-
/* binary operator */
157-
ltypeId= (ltree==NULL) ?UNKNOWNOID :exprType(ltree);
158-
rtypeId= (rtree==NULL) ?UNKNOWNOID :exprType(rtree);
159-
160-
/* check for exact match on this operator... */
161-
if (HeapTupleIsValid(tup=oper_exact(opname,ltypeId,rtypeId,&ltree,&rtree, TRUE)))
162-
{
163-
ltypeId=exprType(ltree);
164-
rtypeId=exprType(rtree);
165-
}
166-
/* try to find a match on likely candidates... */
167-
elseif (!HeapTupleIsValid(tup=oper_inexact(opname,ltypeId,rtypeId,&ltree,&rtree, FALSE)))
168-
{
169-
/* Won't return from oper_inexact() without a candidate... */
170-
}
171-
151+
tup=oper(opname,ltypeId,rtypeId, FALSE);
172152
opform= (Form_pg_operator)GETSTRUCT(tup);
173153
left=make_operand(opname,ltree,ltypeId,opform->oprleft);
174154
right=make_operand(opname,rtree,rtypeId,opform->oprright);

‎src/backend/parser/parse_oper.c

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -25,6 +25,8 @@
2525

2626
staticOid*oper_select_candidate(intnargs,Oid*input_typeids,
2727
CandidateListcandidates);
28+
staticOperatoroper_exact(char*op,Oidarg1,Oidarg2);
29+
staticOperatoroper_inexact(char*op,Oidarg1,Oidarg2);
2830
staticintbinary_oper_get_candidates(char*opname,
2931
OidleftTypeId,
3032
OidrightTypeId,
@@ -376,15 +378,14 @@ oper_select_candidate(int nargs,
376378

377379

378380
/* oper_exact()
379-
* Given operator, and arguments, return oper struct.
381+
* Given operator, and arguments, return oper struct or NULL.
380382
* Inputs:
381383
* arg1, arg2: Type IDs
382384
*/
383-
Operator
384-
oper_exact(char*op,Oidarg1,Oidarg2,Node**ltree,Node**rtree,boolnoWarnings)
385+
staticOperator
386+
oper_exact(char*op,Oidarg1,Oidarg2)
385387
{
386388
HeapTupletup;
387-
Node*tree;
388389

389390
/* Unspecified type for one of the arguments? then use the other */
390391
if ((arg1==UNKNOWNOID)&& (arg2!=InvalidOid))
@@ -398,51 +399,17 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
398399
ObjectIdGetDatum(arg2),
399400
CharGetDatum('b'));
400401

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_operatoropform;
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-
returntup;
402+
return (Operator)tup;
436403
}/* oper_exact() */
437404

438405

439406
/* 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.
441408
* Inputs:
442409
* arg1, arg2: Type IDs
443410
*/
444-
Operator
445-
oper_inexact(char*op,Oidarg1,Oidarg2,Node**ltree,Node**rtree,boolnoWarnings)
411+
staticOperator
412+
oper_inexact(char*op,Oidarg1,Oidarg2)
446413
{
447414
HeapTupletup;
448415
CandidateListcandidates;
@@ -458,13 +425,9 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
458425

459426
ncandidates=binary_oper_get_candidates(op,arg1,arg2,&candidates);
460427

461-
/* No operators found? Thenthrow error orreturn null... */
428+
/* No operators found? Then return null... */
462429
if (ncandidates==0)
463-
{
464-
if (!noWarnings)
465-
op_error(op,arg1,arg2);
466430
returnNULL;
467-
}
468431

469432
/* Or found exactly one? Then proceed... */
470433
elseif (ncandidates==1)
@@ -493,18 +456,6 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
493456
}
494457
else
495458
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-
returnNULL;
507-
}
508459
}
509460
return (Operator)tup;
510461
}/* oper_inexact() */
@@ -521,17 +472,16 @@ oper(char *opname, Oid ltypeId, Oid rtypeId, bool noWarnings)
521472
HeapTupletup;
522473

523474
/* 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)))
525476
{
526477
}
527478
/* try to find a match on likely candidates... */
528-
elseif (HeapTupleIsValid(tup=oper_inexact(opname,ltypeId,rtypeId,NULL,NULL, TRUE)))
479+
elseif (HeapTupleIsValid(tup=oper_inexact(opname,ltypeId,rtypeId)))
529480
{
530481
}
531482
elseif (!noWarnings)
532483
{
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);
535485
}
536486

537487
return (Operator)tup;
@@ -741,8 +691,7 @@ op_error(char *op, Oid arg1, Oid arg2)
741691
"\n\tProbably a bad attribute name",op);
742692
}
743693

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",
747696
op,typeTypeName(tp1),typeTypeName(tp2));
748697
}

‎src/include/parser/parse_node.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: parse_node.h,v 1.15 1999/07/19 00:26:17 tgl Exp $
8+
* $Id: parse_node.h,v 1.16 1999/08/23 23:48:37 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -33,6 +33,8 @@ typedef struct ParseState
3333

3434
externParseState*make_parsestate(ParseState*parentParseState);
3535
externExpr*make_op(char*opname,Node*ltree,Node*rtree);
36+
externNode*make_operand(char*opname,Node*tree,
37+
Oidorig_typeId,Oidtarget_typeId);
3638
externVar*make_var(ParseState*pstate,Oidrelid,char*refname,
3739
char*attrname);
3840
externArrayRef*transformArraySubscripts(ParseState*pstate,

‎src/include/parser/parse_oper.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: parse_oper.h,v 1.8 1999/07/15 15:21:27 momjian Exp $
9+
* $Id: parse_oper.h,v 1.9 1999/08/23 23:48:38 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,7 +23,4 @@ extern Operator oper(char *op, Oid arg1, Oid arg2, bool noWarnings);
2323
externOperatorright_oper(char*op,Oidarg);
2424
externOperatorleft_oper(char*op,Oidarg);
2525

26-
externOperatoroper_exact(char*op,Oidarg1,Oidarg2,Node**ltree,Node**rtree,boolnoWarnings);
27-
externOperatoroper_inexact(char*op,Oidarg1,Oidarg2,Node**ltree,Node**rtree,boolnoWarnings);
28-
2926
#endif/* PARSE_OPER_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp