Commit 550214a4 authored by Peter Eisentraut's avatar Peter Eisentraut

Add operator_with_argtypes grammar rule

This makes the handling of operators similar to that of functions and
aggregates.

Rename node FuncWithArgs to ObjectWithArgs, to reflect the expanded use.
Reviewed-by: default avatarJim Nasby <Jim.Nasby@BlueTreble.com>
Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
parent 63ebd377
......@@ -667,11 +667,11 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
case ACL_OBJECT_FUNCTION:
foreach(cell, objnames)
{
FuncWithArgs *func = (FuncWithArgs *) lfirst(cell);
ObjectWithArgs *func = (ObjectWithArgs *) lfirst(cell);
Oid funcid;
funcid = LookupFuncNameTypeNames(func->funcname,
func->funcargs, false);
funcid = LookupFuncNameTypeNames(func->objname,
func->objargs, false);
objects = lappend_oid(objects, funcid);
}
break;
......
......@@ -1181,8 +1181,8 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
stmt->func->funcargs,
funcOid = LookupFuncNameTypeNames(stmt->func->objname,
stmt->func->objargs,
false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
......@@ -1194,13 +1194,13 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
/* Permission check: must own function */
if (!pg_proc_ownercheck(funcOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
NameListToString(stmt->func->funcname));
NameListToString(stmt->func->objname));
if (procForm->proisagg)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an aggregate function",
NameListToString(stmt->func->funcname))));
NameListToString(stmt->func->objname))));
/* Examine requested actions. */
foreach(l, stmt->actions)
......@@ -1453,8 +1453,8 @@ CreateCast(CreateCastStmt *stmt)
{
Form_pg_proc procstruct;
funcid = LookupFuncNameTypeNames(stmt->func->funcname,
stmt->func->funcargs,
funcid = LookupFuncNameTypeNames(stmt->func->objname,
stmt->func->objargs,
false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
......@@ -1836,14 +1836,14 @@ CreateTransform(CreateTransformStmt *stmt)
*/
if (stmt->fromsql)
{
fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->funcname, stmt->fromsql->funcargs, false);
fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->objname, stmt->fromsql->objargs, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
aclresult = pg_proc_aclcheck(fromsqlfuncid, GetUserId(), ACL_EXECUTE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid));
if (!HeapTupleIsValid(tuple))
......@@ -1862,14 +1862,14 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql)
{
tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->funcname, stmt->tosql->funcargs, false);
tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->objname, stmt->tosql->objargs, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
aclresult = pg_proc_aclcheck(tosqlfuncid, GetUserId(), ACL_EXECUTE);
if (aclresult != ACLCHECK_OK)
aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid));
if (!HeapTupleIsValid(tuple))
......
......@@ -2954,13 +2954,13 @@ _copyGrantStmt(const GrantStmt *from)
return newnode;
}
static FuncWithArgs *
_copyFuncWithArgs(const FuncWithArgs *from)
static ObjectWithArgs *
_copyObjectWithArgs(const ObjectWithArgs *from)
{
FuncWithArgs *newnode = makeNode(FuncWithArgs);
ObjectWithArgs *newnode = makeNode(ObjectWithArgs);
COPY_NODE_FIELD(funcname);
COPY_NODE_FIELD(funcargs);
COPY_NODE_FIELD(objname);
COPY_NODE_FIELD(objargs);
return newnode;
}
......@@ -5274,8 +5274,8 @@ copyObject(const void *from)
case T_CommonTableExpr:
retval = _copyCommonTableExpr(from);
break;
case T_FuncWithArgs:
retval = _copyFuncWithArgs(from);
case T_ObjectWithArgs:
retval = _copyObjectWithArgs(from);
break;
case T_AccessPriv:
retval = _copyAccessPriv(from);
......
......@@ -1095,10 +1095,10 @@ _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
}
static bool
_equalFuncWithArgs(const FuncWithArgs *a, const FuncWithArgs *b)
_equalObjectWithArgs(const ObjectWithArgs *a, const ObjectWithArgs *b)
{
COMPARE_NODE_FIELD(funcname);
COMPARE_NODE_FIELD(funcargs);
COMPARE_NODE_FIELD(objname);
COMPARE_NODE_FIELD(objargs);
return true;
}
......@@ -3532,8 +3532,8 @@ equal(const void *a, const void *b)
case T_CommonTableExpr:
retval = _equalCommonTableExpr(a, b);
break;
case T_FuncWithArgs:
retval = _equalFuncWithArgs(a, b);
case T_ObjectWithArgs:
retval = _equalObjectWithArgs(a, b);
break;
case T_AccessPriv:
retval = _equalAccessPriv(a, b);
......
This diff is collapsed.
......@@ -451,7 +451,7 @@ typedef enum NodeTag
T_SortGroupClause,
T_GroupingSet,
T_WindowClause,
T_FuncWithArgs,
T_ObjectWithArgs,
T_AccessPriv,
T_CreateOpClassItem,
T_TableLikeClause,
......
......@@ -1753,7 +1753,7 @@ typedef struct GrantStmt
bool is_grant; /* true = GRANT, false = REVOKE */
GrantTargetType targtype; /* type of the grant target */
GrantObjectType objtype; /* kind of object being operated on */
List *objects; /* list of RangeVar nodes, FuncWithArgs nodes,
List *objects; /* list of RangeVar nodes, ObjectWithArgs nodes,
* or plain names (as Value strings) */
List *privileges; /* list of AccessPriv nodes */
/* privileges == NIL denotes ALL PRIVILEGES */
......@@ -1763,16 +1763,16 @@ typedef struct GrantStmt
} GrantStmt;
/*
* Note: FuncWithArgs carries only the types of the input parameters of the
* Note: ObjectWithArgs carries only the types of the input parameters of the
* function. So it is sufficient to identify an existing function, but it
* is not enough info to define a function nor to call it.
*/
typedef struct FuncWithArgs
typedef struct ObjectWithArgs
{
NodeTag type;
List *funcname; /* qualified name of function */
List *funcargs; /* list of Typename nodes */
} FuncWithArgs;
List *objname; /* qualified name of function/operator */
List *objargs; /* list of Typename nodes */
} ObjectWithArgs;
/*
* An access privilege, with optional list of column names
......@@ -2644,7 +2644,7 @@ typedef struct FunctionParameter
typedef struct AlterFunctionStmt
{
NodeTag type;
FuncWithArgs *func; /* name and args of function */
ObjectWithArgs *func; /* name and args of function */
List *actions; /* list of DefElem */
} AlterFunctionStmt;
......@@ -3138,7 +3138,7 @@ typedef struct CreateCastStmt
NodeTag type;
TypeName *sourcetype;
TypeName *targettype;
FuncWithArgs *func;
ObjectWithArgs *func;
CoercionContext context;
bool inout;
} CreateCastStmt;
......@@ -3153,8 +3153,8 @@ typedef struct CreateTransformStmt
bool replace;
TypeName *type_name;
char *lang;
FuncWithArgs *fromsql;
FuncWithArgs *tosql;
ObjectWithArgs *fromsql;
ObjectWithArgs *tosql;
} CreateTransformStmt;
/* ----------------------
......
......@@ -745,7 +745,6 @@ FuncDetailCode
FuncExpr
FuncExprState
FuncInfo
FuncWithArgs
FunctionCallInfo
FunctionCallInfoData
FunctionParameter
......@@ -1228,6 +1227,7 @@ ObjectAddresses
ObjectClass
ObjectPropertyType
ObjectType
ObjectWithArgs
Offset
OffsetNumber
OffsetVarNodes_context
......
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