Commit 2ca64c6f authored by Peter Eisentraut's avatar Peter Eisentraut

Replace LookupFuncNameTypeNames() with LookupFuncWithArgs()

The old function took function name and function argument list as
separate arguments.  Now that all function signatures are passed around
as ObjectWithArgs structs, this is no longer necessary and can be
replaced by a function that takes ObjectWithArgs directly.  Similarly
for aggregates and operators.
Reviewed-by: default avatarJim Nasby <Jim.Nasby@BlueTreble.com>
Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
parent 8b6d6cf8
...@@ -670,8 +670,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames) ...@@ -670,8 +670,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
ObjectWithArgs *func = (ObjectWithArgs *) lfirst(cell); ObjectWithArgs *func = (ObjectWithArgs *) lfirst(cell);
Oid funcid; Oid funcid;
funcid = LookupFuncNameTypeNames(func->objname, funcid = LookupFuncWithArgs(func, false);
func->objargs, false);
objects = lappend_oid(objects, funcid); objects = lappend_oid(objects, funcid);
} }
break; break;
......
...@@ -868,36 +868,20 @@ get_object_address(ObjectType objtype, Node *object, ...@@ -868,36 +868,20 @@ get_object_address(ObjectType objtype, Node *object,
address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok); address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok);
break; break;
case OBJECT_AGGREGATE: case OBJECT_AGGREGATE:
{ address.classId = ProcedureRelationId;
ObjectWithArgs *owa = castNode(ObjectWithArgs, object); address.objectId = LookupAggWithArgs(castNode(ObjectWithArgs, object), missing_ok);
address.classId = ProcedureRelationId; address.objectSubId = 0;
address.objectId = break;
LookupAggNameTypeNames(owa->objname, owa->objargs, missing_ok);
address.objectSubId = 0;
break;
}
case OBJECT_FUNCTION: case OBJECT_FUNCTION:
{ address.classId = ProcedureRelationId;
ObjectWithArgs *owa = castNode(ObjectWithArgs, object); address.objectId = LookupFuncWithArgs(castNode(ObjectWithArgs, object), missing_ok);
address.classId = ProcedureRelationId; address.objectSubId = 0;
address.objectId = break;
LookupFuncNameTypeNames(owa->objname, owa->objargs, missing_ok);
address.objectSubId = 0;
break;
}
case OBJECT_OPERATOR: case OBJECT_OPERATOR:
{ address.classId = OperatorRelationId;
ObjectWithArgs *owa = castNode(ObjectWithArgs, object); address.objectId = LookupOperWithArgs(castNode(ObjectWithArgs, object), missing_ok);
address.classId = OperatorRelationId; address.objectSubId = 0;
Assert(list_length(owa->objargs) == 2); break;
address.objectId =
LookupOperNameTypeNames(NULL, owa->objname,
castNode(TypeName, linitial(owa->objargs)),
castNode(TypeName, lsecond(owa->objargs)),
missing_ok, -1);
address.objectSubId = 0;
break;
}
case OBJECT_COLLATION: case OBJECT_COLLATION:
address.classId = CollationRelationId; address.classId = CollationRelationId;
address.objectId = get_collation_oid(castNode(List, object), missing_ok); address.objectId = get_collation_oid(castNode(List, object), missing_ok);
......
...@@ -1181,9 +1181,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt) ...@@ -1181,9 +1181,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock); rel = heap_open(ProcedureRelationId, RowExclusiveLock);
funcOid = LookupFuncNameTypeNames(stmt->func->objname, funcOid = LookupFuncWithArgs(stmt->func, false);
stmt->func->objargs,
false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid)); tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */ if (!HeapTupleIsValid(tup)) /* should not happen */
...@@ -1453,9 +1451,7 @@ CreateCast(CreateCastStmt *stmt) ...@@ -1453,9 +1451,7 @@ CreateCast(CreateCastStmt *stmt)
{ {
Form_pg_proc procstruct; Form_pg_proc procstruct;
funcid = LookupFuncNameTypeNames(stmt->func->objname, funcid = LookupFuncWithArgs(stmt->func, false);
stmt->func->objargs,
false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
...@@ -1836,7 +1832,7 @@ CreateTransform(CreateTransformStmt *stmt) ...@@ -1836,7 +1832,7 @@ CreateTransform(CreateTransformStmt *stmt)
*/ */
if (stmt->fromsql) if (stmt->fromsql)
{ {
fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->objname, stmt->fromsql->objargs, false); fromsqlfuncid = LookupFuncWithArgs(stmt->fromsql, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId())) if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname)); aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
...@@ -1862,7 +1858,7 @@ CreateTransform(CreateTransformStmt *stmt) ...@@ -1862,7 +1858,7 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql) if (stmt->tosql)
{ {
tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->objname, stmt->tosql->objargs, false); tosqlfuncid = LookupFuncWithArgs(stmt->tosql, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId())) if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->objname)); aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
......
...@@ -475,19 +475,12 @@ DefineOpClass(CreateOpClassStmt *stmt) ...@@ -475,19 +475,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid operator number %d," errmsg("invalid operator number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxOpNumber))); item->number, maxOpNumber)));
if (item->args != NIL) if (item->name->objargs != NIL)
{ operOid = LookupOperWithArgs(item->name, false);
TypeName *typeName1 = (TypeName *) linitial(item->args);
TypeName *typeName2 = (TypeName *) lsecond(item->args);
operOid = LookupOperNameTypeNames(NULL, item->name,
typeName1, typeName2,
false, -1);
}
else else
{ {
/* Default to binary op on input datatype */ /* Default to binary op on input datatype */
operOid = LookupOperName(NULL, item->name, operOid = LookupOperName(NULL, item->name->objname,
typeoid, typeoid, typeoid, typeoid,
false, -1); false, -1);
} }
...@@ -526,8 +519,7 @@ DefineOpClass(CreateOpClassStmt *stmt) ...@@ -526,8 +519,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid procedure number %d," errmsg("invalid procedure number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxProcNumber))); item->number, maxProcNumber)));
funcOid = LookupFuncNameTypeNames(item->name, item->args, funcOid = LookupFuncWithArgs(item->name, false);
false);
#ifdef NOT_USED #ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */ /* XXX this is unnecessary given the superuser check above */
/* Caller must own function */ /* Caller must own function */
...@@ -857,15 +849,8 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid, ...@@ -857,15 +849,8 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d," errmsg("invalid operator number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxOpNumber))); item->number, maxOpNumber)));
if (item->args != NIL) if (item->name->objargs != NIL)
{ operOid = LookupOperWithArgs(item->name, false);
TypeName *typeName1 = (TypeName *) linitial(item->args);
TypeName *typeName2 = (TypeName *) lsecond(item->args);
operOid = LookupOperNameTypeNames(NULL, item->name,
typeName1, typeName2,
false, -1);
}
else else
{ {
ereport(ERROR, ereport(ERROR,
...@@ -908,8 +893,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid, ...@@ -908,8 +893,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d," errmsg("invalid procedure number %d,"
" must be between 1 and %d", " must be between 1 and %d",
item->number, maxProcNumber))); item->number, maxProcNumber)));
funcOid = LookupFuncNameTypeNames(item->name, item->args, funcOid = LookupFuncWithArgs(item->name, false);
false);
#ifdef NOT_USED #ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */ /* XXX this is unnecessary given the superuser check above */
/* Caller must own function */ /* Caller must own function */
......
...@@ -402,10 +402,7 @@ AlterOperator(AlterOperatorStmt *stmt) ...@@ -402,10 +402,7 @@ AlterOperator(AlterOperatorStmt *stmt)
Oid joinOid; Oid joinOid;
/* Look up the operator */ /* Look up the operator */
oprId = LookupOperNameTypeNames(NULL, stmt->opername, oprId = LookupOperWithArgs(stmt->opername, false);
(TypeName *) linitial(stmt->operargs),
(TypeName *) lsecond(stmt->operargs),
false, -1);
catalog = heap_open(OperatorRelationId, RowExclusiveLock); catalog = heap_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId)); tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (tup == NULL) if (tup == NULL)
......
...@@ -3314,7 +3314,6 @@ _copyAlterOperatorStmt(const AlterOperatorStmt *from) ...@@ -3314,7 +3314,6 @@ _copyAlterOperatorStmt(const AlterOperatorStmt *from)
AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt); AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
COPY_NODE_FIELD(opername); COPY_NODE_FIELD(opername);
COPY_NODE_FIELD(operargs);
COPY_NODE_FIELD(options); COPY_NODE_FIELD(options);
return newnode; return newnode;
...@@ -3487,7 +3486,6 @@ _copyCreateOpClassItem(const CreateOpClassItem *from) ...@@ -3487,7 +3486,6 @@ _copyCreateOpClassItem(const CreateOpClassItem *from)
COPY_SCALAR_FIELD(itemtype); COPY_SCALAR_FIELD(itemtype);
COPY_NODE_FIELD(name); COPY_NODE_FIELD(name);
COPY_NODE_FIELD(args);
COPY_SCALAR_FIELD(number); COPY_SCALAR_FIELD(number);
COPY_NODE_FIELD(order_family); COPY_NODE_FIELD(order_family);
COPY_NODE_FIELD(class_args); COPY_NODE_FIELD(class_args);
......
...@@ -1390,7 +1390,6 @@ static bool ...@@ -1390,7 +1390,6 @@ static bool
_equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b) _equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b)
{ {
COMPARE_NODE_FIELD(opername); COMPARE_NODE_FIELD(opername);
COMPARE_NODE_FIELD(operargs);
COMPARE_NODE_FIELD(options); COMPARE_NODE_FIELD(options);
return true; return true;
...@@ -1535,7 +1534,6 @@ _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b) ...@@ -1535,7 +1534,6 @@ _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
{ {
COMPARE_SCALAR_FIELD(itemtype); COMPARE_SCALAR_FIELD(itemtype);
COMPARE_NODE_FIELD(name); COMPARE_NODE_FIELD(name);
COMPARE_NODE_FIELD(args);
COMPARE_SCALAR_FIELD(number); COMPARE_SCALAR_FIELD(number);
COMPARE_NODE_FIELD(order_family); COMPARE_NODE_FIELD(order_family);
COMPARE_NODE_FIELD(class_args); COMPARE_NODE_FIELD(class_args);
......
...@@ -5778,9 +5778,11 @@ opclass_item: ...@@ -5778,9 +5778,11 @@ opclass_item:
OPERATOR Iconst any_operator opclass_purpose opt_recheck OPERATOR Iconst any_operator opclass_purpose opt_recheck
{ {
CreateOpClassItem *n = makeNode(CreateOpClassItem); CreateOpClassItem *n = makeNode(CreateOpClassItem);
ObjectWithArgs *owa = makeNode(ObjectWithArgs);
owa->objname = $3;
owa->objargs = NIL;
n->itemtype = OPCLASS_ITEM_OPERATOR; n->itemtype = OPCLASS_ITEM_OPERATOR;
n->name = $3; n->name = owa;
n->args = NIL;
n->number = $2; n->number = $2;
n->order_family = $4; n->order_family = $4;
$$ = (Node *) n; $$ = (Node *) n;
...@@ -5790,8 +5792,7 @@ opclass_item: ...@@ -5790,8 +5792,7 @@ opclass_item:
{ {
CreateOpClassItem *n = makeNode(CreateOpClassItem); CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR; n->itemtype = OPCLASS_ITEM_OPERATOR;
n->name = $3->objname; n->name = $3;
n->args = $3->objargs;
n->number = $2; n->number = $2;
n->order_family = $4; n->order_family = $4;
$$ = (Node *) n; $$ = (Node *) n;
...@@ -5800,8 +5801,7 @@ opclass_item: ...@@ -5800,8 +5801,7 @@ opclass_item:
{ {
CreateOpClassItem *n = makeNode(CreateOpClassItem); CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION; n->itemtype = OPCLASS_ITEM_FUNCTION;
n->name = $3->objname; n->name = $3;
n->args = $3->objargs;
n->number = $2; n->number = $2;
$$ = (Node *) n; $$ = (Node *) n;
} }
...@@ -5809,8 +5809,7 @@ opclass_item: ...@@ -5809,8 +5809,7 @@ opclass_item:
{ {
CreateOpClassItem *n = makeNode(CreateOpClassItem); CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION; n->itemtype = OPCLASS_ITEM_FUNCTION;
n->name = $6->objname; n->name = $6;
n->args = $6->objargs;
n->number = $2; n->number = $2;
n->class_args = $4; n->class_args = $4;
$$ = (Node *) n; $$ = (Node *) n;
...@@ -8789,8 +8788,7 @@ AlterOperatorStmt: ...@@ -8789,8 +8788,7 @@ AlterOperatorStmt:
ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')' ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{ {
AlterOperatorStmt *n = makeNode(AlterOperatorStmt); AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
n->opername = $3->objname; n->opername = $3;
n->operargs = $3->objargs;
n->options = $6; n->options = $6;
$$ = (Node *)n; $$ = (Node *)n;
} }
......
...@@ -1932,19 +1932,19 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError) ...@@ -1932,19 +1932,19 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
} }
/* /*
* LookupFuncNameTypeNames * LookupFuncWithArgs
* Like LookupFuncName, but the argument types are specified by a * Like LookupFuncName, but the argument types are specified by a
* list of TypeName nodes. * ObjectWithArgs node.
*/ */
Oid Oid
LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError) LookupFuncWithArgs(ObjectWithArgs *func, bool noError)
{ {
Oid argoids[FUNC_MAX_ARGS]; Oid argoids[FUNC_MAX_ARGS];
int argcount; int argcount;
int i; int i;
ListCell *args_item; ListCell *args_item;
argcount = list_length(argtypes); argcount = list_length(func->objargs);
if (argcount > FUNC_MAX_ARGS) if (argcount > FUNC_MAX_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS), (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
...@@ -1953,7 +1953,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError) ...@@ -1953,7 +1953,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
FUNC_MAX_ARGS, FUNC_MAX_ARGS,
FUNC_MAX_ARGS))); FUNC_MAX_ARGS)));
args_item = list_head(argtypes); args_item = list_head(func->objargs);
for (i = 0; i < argcount; i++) for (i = 0; i < argcount; i++)
{ {
TypeName *t = (TypeName *) lfirst(args_item); TypeName *t = (TypeName *) lfirst(args_item);
...@@ -1962,19 +1962,19 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError) ...@@ -1962,19 +1962,19 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
args_item = lnext(args_item); args_item = lnext(args_item);
} }
return LookupFuncName(funcname, argcount, argoids, noError); return LookupFuncName(func->objname, argcount, argoids, noError);
} }
/* /*
* LookupAggNameTypeNames * LookupAggWithArgs
* Find an aggregate function given a name and list of TypeName nodes. * Find an aggregate function from a given ObjectWithArgs node.
* *
* This is almost like LookupFuncNameTypeNames, but the error messages refer * This is almost like LookupFuncWithArgs, but the error messages refer
* to aggregates rather than plain functions, and we verify that the found * to aggregates rather than plain functions, and we verify that the found
* function really is an aggregate. * function really is an aggregate.
*/ */
Oid Oid
LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) LookupAggWithArgs(ObjectWithArgs *agg, bool noError)
{ {
Oid argoids[FUNC_MAX_ARGS]; Oid argoids[FUNC_MAX_ARGS];
int argcount; int argcount;
...@@ -1984,7 +1984,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) ...@@ -1984,7 +1984,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
HeapTuple ftup; HeapTuple ftup;
Form_pg_proc pform; Form_pg_proc pform;
argcount = list_length(argtypes); argcount = list_length(agg->objargs);
if (argcount > FUNC_MAX_ARGS) if (argcount > FUNC_MAX_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS), (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
...@@ -1994,7 +1994,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) ...@@ -1994,7 +1994,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
FUNC_MAX_ARGS))); FUNC_MAX_ARGS)));
i = 0; i = 0;
foreach(lc, argtypes) foreach(lc, agg->objargs)
{ {
TypeName *t = (TypeName *) lfirst(lc); TypeName *t = (TypeName *) lfirst(lc);
...@@ -2002,7 +2002,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) ...@@ -2002,7 +2002,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
i++; i++;
} }
oid = LookupFuncName(aggname, argcount, argoids, true); oid = LookupFuncName(agg->objname, argcount, argoids, true);
if (!OidIsValid(oid)) if (!OidIsValid(oid))
{ {
...@@ -2012,12 +2012,12 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) ...@@ -2012,12 +2012,12 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s(*) does not exist", errmsg("aggregate %s(*) does not exist",
NameListToString(aggname)))); NameListToString(agg->objname))));
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s does not exist", errmsg("aggregate %s does not exist",
func_signature_string(aggname, argcount, func_signature_string(agg->objname, argcount,
NIL, argoids)))); NIL, argoids))));
} }
...@@ -2036,7 +2036,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError) ...@@ -2036,7 +2036,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("function %s is not an aggregate", errmsg("function %s is not an aggregate",
func_signature_string(aggname, argcount, func_signature_string(agg->objname, argcount,
NIL, argoids)))); NIL, argoids))));
} }
......
...@@ -132,32 +132,34 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, ...@@ -132,32 +132,34 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright,
} }
/* /*
* LookupOperNameTypeNames * LookupOperWithArgs
* Like LookupOperName, but the argument types are specified by * Like LookupOperName, but the argument types are specified by
* TypeName nodes. * a ObjectWithArg node.
*
* Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op.
*/ */
Oid Oid
LookupOperNameTypeNames(ParseState *pstate, List *opername, LookupOperWithArgs(ObjectWithArgs *oper, bool noError)
TypeName *oprleft, TypeName *oprright,
bool noError, int location)
{ {
TypeName *oprleft,
*oprright;
Oid leftoid, Oid leftoid,
rightoid; rightoid;
Assert(list_length(oper->objargs) == 2);
oprleft = linitial(oper->objargs);
oprright = lsecond(oper->objargs);
if (oprleft == NULL) if (oprleft == NULL)
leftoid = InvalidOid; leftoid = InvalidOid;
else else
leftoid = LookupTypeNameOid(pstate, oprleft, noError); leftoid = LookupTypeNameOid(NULL, oprleft, noError);
if (oprright == NULL) if (oprright == NULL)
rightoid = InvalidOid; rightoid = InvalidOid;
else else
rightoid = LookupTypeNameOid(pstate, oprright, noError); rightoid = LookupTypeNameOid(NULL, oprright, noError);
return LookupOperName(pstate, opername, leftoid, rightoid, return LookupOperName(NULL, oper->objname, leftoid, rightoid,
noError, location); noError, -1);
} }
/* /*
......
...@@ -2418,9 +2418,7 @@ typedef struct CreateOpClassItem ...@@ -2418,9 +2418,7 @@ typedef struct CreateOpClassItem
{ {
NodeTag type; NodeTag type;
int itemtype; /* see codes above */ int itemtype; /* see codes above */
/* fields used for an operator or function item: */ ObjectWithArgs *name; /* operator or function name and args */
List *name; /* operator or function name */
List *args; /* argument types */
int number; /* strategy num or support proc num */ int number; /* strategy num or support proc num */
List *order_family; /* only used for ordering operators */ List *order_family; /* only used for ordering operators */
List *class_args; /* amproclefttype/amprocrighttype or List *class_args; /* amproclefttype/amprocrighttype or
...@@ -2730,8 +2728,7 @@ typedef struct AlterOwnerStmt ...@@ -2730,8 +2728,7 @@ typedef struct AlterOwnerStmt
typedef struct AlterOperatorStmt typedef struct AlterOperatorStmt
{ {
NodeTag type; NodeTag type;
List *opername; /* operator name */ ObjectWithArgs *opername; /* operator name and argument types */
List *operargs; /* operator's argument TypeNames */
List *options; /* List of DefElem nodes */ List *options; /* List of DefElem nodes */
} AlterOperatorStmt; } AlterOperatorStmt;
......
...@@ -62,9 +62,9 @@ extern const char *func_signature_string(List *funcname, int nargs, ...@@ -62,9 +62,9 @@ extern const char *func_signature_string(List *funcname, int nargs,
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError); bool noError);
extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes, extern Oid LookupFuncWithArgs(ObjectWithArgs *func,
bool noError); bool noError);
extern Oid LookupAggNameTypeNames(List *aggname, List *argtypes, extern Oid LookupAggWithArgs(ObjectWithArgs *agg,
bool noError); bool noError);
extern void check_srf_call_placement(ParseState *pstate, int location); extern void check_srf_call_placement(ParseState *pstate, int location);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define PARSE_OPER_H #define PARSE_OPER_H
#include "access/htup.h" #include "access/htup.h"
#include "nodes/parsenodes.h"
#include "parser/parse_node.h" #include "parser/parse_node.h"
...@@ -24,9 +25,7 @@ typedef HeapTuple Operator; ...@@ -24,9 +25,7 @@ typedef HeapTuple Operator;
extern Oid LookupOperName(ParseState *pstate, List *opername, extern Oid LookupOperName(ParseState *pstate, List *opername,
Oid oprleft, Oid oprright, Oid oprleft, Oid oprright,
bool noError, int location); bool noError, int location);
extern Oid LookupOperNameTypeNames(ParseState *pstate, List *opername, extern Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError);
TypeName *oprleft, TypeName *oprright,
bool noError, int location);
/* Routines to find operators matching a name and given input types */ /* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */ /* NB: the selected operator may require coercion of the input types! */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment