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