Commit 79fafdf4 authored by Tom Lane's avatar Tom Lane

Some early work on error message editing. Operator-not-found and

function-not-found messages now distinguish the cases no-match and
ambiguous-match, and they follow the style guidelines too.
parent cdb8a844
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.82 2003/06/27 14:45:26 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.83 2003/07/04 02:51:33 tgl Exp $
*
* NOTES
* See acl.h.
......@@ -397,8 +397,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
char nulls[Natts_pg_proc];
char replaces[Natts_pg_proc];
oid = LookupFuncNameTypeNames(func->funcname, func->funcargs,
stmt->is_grant ? "GRANT" : "REVOKE");
oid = LookupFuncNameTypeNames(func->funcname, func->funcargs, false);
relation = heap_openr(ProcedureRelationName, RowExclusiveLock);
tuple = SearchSysCache(PROCOID,
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.59 2003/07/01 19:10:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.60 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -109,8 +109,7 @@ AggregateCreate(const char *aggName,
ObjectIdGetDatum(transfn),
0, 0, 0);
if (!HeapTupleIsValid(tup))
func_error("AggregateCreate", aggtransfnName,
nargs_transfn, fnArgs, NULL);
elog(ERROR, "cache lookup of function %u failed", transfn);
proc = (Form_pg_proc) GETSTRUCT(tup);
/*
......@@ -264,10 +263,12 @@ lookup_agg_function(List *fnName,
&true_oid_array);
/* only valid case is a normal function not returning a set */
if (fdresult != FUNCDETAIL_NORMAL ||
!OidIsValid(fnOid) ||
retset)
func_error("AggregateCreate", fnName, nargs, input_types, NULL);
if (fdresult != FUNCDETAIL_NORMAL || !OidIsValid(fnOid))
elog(ERROR, "function %s does not exist",
func_signature_string(fnName, nargs, input_types));
if (retset)
elog(ERROR, "function %s returns a set",
func_signature_string(fnName, nargs, input_types));
/*
* If the given type(s) are all polymorphic, there's nothing we
......@@ -295,13 +296,15 @@ lookup_agg_function(List *fnName,
if (true_oid_array[0] != ANYARRAYOID &&
true_oid_array[0] != ANYELEMENTOID &&
!IsBinaryCoercible(input_types[0], true_oid_array[0]))
func_error("AggregateCreate", fnName, nargs, input_types, NULL);
elog(ERROR, "function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array));
if (nargs == 2 &&
true_oid_array[1] != ANYARRAYOID &&
true_oid_array[1] != ANYELEMENTOID &&
!IsBinaryCoercible(input_types[1], true_oid_array[1]))
func_error("AggregateCreate", fnName, nargs, input_types, NULL);
elog(ERROR, "function %s requires run-time type coercion",
func_signature_string(fnName, nargs, true_oid_array));
return fnOid;
}
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.78 2003/01/28 22:13:25 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.79 2003/07/04 02:51:33 tgl Exp $
*
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
......@@ -175,7 +175,7 @@ OperatorLookup(List *operatorName,
RegProcedure oprcode;
operatorObjectId = LookupOperName(operatorName, leftObjectId,
rightObjectId);
rightObjectId, true);
if (!OidIsValid(operatorObjectId))
{
*defined = false;
......@@ -453,9 +453,7 @@ OperatorCreate(const char *operatorName,
typeId[1] = rightTypeId;
nargs = 2;
}
procOid = LookupFuncName(procedureName, nargs, typeId);
if (!OidIsValid(procOid))
func_error("OperatorDef", procedureName, nargs, typeId, NULL);
procOid = LookupFuncName(procedureName, nargs, typeId, false);
operResultType = get_func_rettype(procOid);
/*
......@@ -469,9 +467,7 @@ OperatorCreate(const char *operatorName,
typeId[2] = INTERNALOID; /* args list */
typeId[3] = INT4OID; /* varRelid */
restOid = LookupFuncName(restrictionName, 4, typeId);
if (!OidIsValid(restOid))
func_error("OperatorDef", restrictionName, 4, typeId, NULL);
restOid = LookupFuncName(restrictionName, 4, typeId, false);
}
else
restOid = InvalidOid;
......@@ -487,9 +483,7 @@ OperatorCreate(const char *operatorName,
typeId[2] = INTERNALOID; /* args list */
typeId[3] = INT2OID; /* jointype */
joinOid = LookupFuncName(joinName, 4, typeId);
if (!OidIsValid(joinOid))
func_error("OperatorDef", joinName, 4, typeId, NULL);
joinOid = LookupFuncName(joinName, 4, typeId, false);
}
else
joinOid = InvalidOid;
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.9 2003/07/01 19:10:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.10 2003/07/04 02:51:33 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -165,7 +165,7 @@ RemoveAggregate(RemoveAggrStmt *stmt)
else
basetypeID = ANYOID;
procOid = find_aggregate_func("RemoveAggregate", aggName, basetypeID);
procOid = find_aggregate_func(aggName, basetypeID, false);
/*
* Find the function tuple, do permissions and validity checks
......@@ -223,7 +223,7 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname)
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
procOid = find_aggregate_func("RenameAggregate", name, basetypeOid);
procOid = find_aggregate_func(name, basetypeOid, false);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(procOid),
......
......@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.63 2003/06/27 14:45:27 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.64 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -629,7 +629,7 @@ CommentAggregate(List *aggregate, List *arguments, char *comment)
/* Now, attempt to find the actual tuple in pg_proc */
oid = find_aggregate_func("CommentAggregate", aggregate, baseoid);
oid = find_aggregate_func(aggregate, baseoid, false);
/* Next, validate the user's attempt to comment */
......@@ -657,8 +657,7 @@ CommentProc(List *function, List *arguments, char *comment)
/* Look up the procedure */
oid = LookupFuncNameTypeNames(function, arguments,
"CommentProc");
oid = LookupFuncNameTypeNames(function, arguments, false);
/* Now, validate the user's ability to comment on this function */
......@@ -689,8 +688,7 @@ CommentOperator(List *opername, List *arguments, char *comment)
Oid classoid;
/* Look up the operator */
oid = LookupOperNameTypeNames(opername, typenode1, typenode2,
"CommentOperator");
oid = LookupOperNameTypeNames(opername, typenode1, typenode2, false);
/* Valid user's ability to comment on this operator */
if (!pg_oper_ownercheck(oid, GetUserId()))
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.6 2003/06/27 14:45:27 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.7 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -70,10 +70,8 @@ CreateConversionCommand(CreateConversionStmt *stmt)
* Check the existence of the conversion function. Function name could
* be a qualified name.
*/
funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid), funcargs);
if (!OidIsValid(funcoid))
func_error("CreateConversion", func_name,
sizeof(funcargs) / sizeof(Oid), funcargs, NULL);
funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid),
funcargs, false);
/* Check we have EXECUTE rights for the function */
aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.26 2003/06/27 14:45:27 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.27 2003/07/04 02:51:33 tgl Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
......@@ -495,8 +495,7 @@ RemoveFunction(RemoveFuncStmt *stmt)
/*
* Find the function, do permissions and validity checks
*/
funcOid = LookupFuncNameTypeNames(functionName, argTypes,
"RemoveFunction");
funcOid = LookupFuncNameTypeNames(functionName, argTypes, false);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcOid),
......@@ -607,7 +606,7 @@ RenameFunction(List *name, List *argtypes, const char *newname)
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
procOid = LookupFuncNameTypeNames(name, argtypes, "RenameFunction");
procOid = LookupFuncNameTypeNames(name, argtypes, false);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(procOid),
......@@ -796,7 +795,7 @@ CreateCast(CreateCastStmt *stmt)
funcid = LookupFuncNameTypeNames(stmt->func->funcname,
stmt->func->funcargs,
"CreateCast");
false);
tuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcid),
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.10 2003/06/27 14:45:27 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.11 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -155,19 +155,15 @@ DefineOpClass(CreateOpClassStmt *stmt)
TypeName *typeName2 = (TypeName *) lsecond(item->args);
operOid = LookupOperNameTypeNames(item->name,
typeName1, typeName2,
"DefineOpClass");
/* No need to check for error */
typeName1,
typeName2,
false);
}
else
{
/* Default to binary op on input datatype */
operOid = LookupOperName(item->name, typeoid, typeoid);
if (!OidIsValid(operOid))
elog(ERROR, "DefineOpClass: Operator '%s' for types '%s' and '%s' does not exist",
NameListToString(item->name),
format_type_be(typeoid),
format_type_be(typeoid));
operOid = LookupOperName(item->name, typeoid, typeoid,
false);
}
/* Caller must have execute permission on operators */
funcOid = get_opcode(operOid);
......@@ -187,7 +183,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
elog(ERROR, "DefineOpClass: procedure number %d appears more than once",
item->number);
funcOid = LookupFuncNameTypeNames(item->name, item->args,
"DefineOpClass");
false);
/* Caller must have execute permission on functions */
aclresult = pg_proc_aclcheck(funcOid, GetUserId(),
ACL_EXECUTE);
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.7 2002/09/04 20:31:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.8 2003/07/04 02:51:33 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -206,14 +206,13 @@ RemoveOperator(RemoveOperStmt *stmt)
ObjectAddress object;
operOid = LookupOperNameTypeNames(operatorName, typeName1, typeName2,
"RemoveOperator");
false);
tup = SearchSysCache(OPEROID,
ObjectIdGetDatum(operOid),
0, 0, 0);
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "RemoveOperator: failed to find tuple for operator '%s'",
NameListToString(operatorName));
elog(ERROR, "cache lookup of operator %u failed", operOid);
/* Permission check: must own operator or its namespace */
if (!pg_oper_ownercheck(operOid, GetUserId()) &&
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.44 2003/06/27 14:45:27 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.45 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -77,10 +77,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
* return type
*/
MemSet(typev, 0, sizeof(typev));
procOid = LookupFuncName(stmt->plhandler, 0, typev);
if (!OidIsValid(procOid))
elog(ERROR, "function %s() doesn't exist",
NameListToString(stmt->plhandler));
procOid = LookupFuncName(stmt->plhandler, 0, typev, false);
funcrettype = get_func_rettype(procOid);
if (funcrettype != LANGUAGE_HANDLEROID)
{
......@@ -104,10 +101,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
if (stmt->plvalidator)
{
typev[0] = OIDOID;
valProcOid = LookupFuncName(stmt->plvalidator, 1, typev);
if (!OidIsValid(valProcOid))
elog(ERROR, "function %s(oid) doesn't exist",
NameListToString(stmt->plvalidator));
valProcOid = LookupFuncName(stmt->plvalidator, 1, typev, false);
/* return value is ignored, so we don't check the type */
}
else
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.149 2003/06/24 23:25:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.150 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -257,10 +257,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
* Find and validate the trigger function.
*/
MemSet(fargtypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
funcoid = LookupFuncName(stmt->funcname, 0, fargtypes);
if (!OidIsValid(funcoid))
elog(ERROR, "CreateTrigger: function %s() does not exist",
NameListToString(stmt->funcname));
funcoid = LookupFuncName(stmt->funcname, 0, fargtypes, false);
funcrettype = get_func_rettype(funcoid);
if (funcrettype != TRIGGEROID)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.37 2003/06/06 15:04:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.38 2003/07/04 02:51:33 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -789,14 +789,14 @@ findTypeInputFunction(List *procname, Oid typeOid)
argList[0] = CSTRINGOID;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
argList[2] = INT4OID;
procOid = LookupFuncName(procname, 3, argList);
procOid = LookupFuncName(procname, 3, argList, true);
if (OidIsValid(procOid))
return procOid;
......@@ -805,14 +805,14 @@ findTypeInputFunction(List *procname, Oid typeOid)
argList[0] = OPAQUEOID;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (!OidIsValid(procOid))
{
argList[1] = OIDOID;
argList[2] = INT4OID;
procOid = LookupFuncName(procname, 3, argList);
procOid = LookupFuncName(procname, 3, argList, true);
}
if (OidIsValid(procOid))
......@@ -834,7 +834,8 @@ findTypeInputFunction(List *procname, Oid typeOid)
/* Use CSTRING (preferred) in the error message */
argList[0] = CSTRINGOID;
func_error("TypeCreate", procname, 1, argList, NULL);
elog(ERROR, "function %s does not exist",
func_signature_string(procname, 1, argList));
return InvalidOid; /* keep compiler quiet */
}
......@@ -857,13 +858,13 @@ findTypeOutputFunction(List *procname, Oid typeOid)
argList[0] = typeOid;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList);
procOid = LookupFuncName(procname, 2, argList, true);
if (OidIsValid(procOid))
return procOid;
......@@ -872,13 +873,13 @@ findTypeOutputFunction(List *procname, Oid typeOid)
argList[0] = OPAQUEOID;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (!OidIsValid(procOid))
{
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList);
procOid = LookupFuncName(procname, 2, argList, true);
}
if (OidIsValid(procOid))
......@@ -899,7 +900,8 @@ findTypeOutputFunction(List *procname, Oid typeOid)
/* Use type name, not OPAQUE, in the failure message. */
argList[0] = typeOid;
func_error("TypeCreate", procname, 1, argList, NULL);
elog(ERROR, "function %s does not exist",
func_signature_string(procname, 1, argList));
return InvalidOid; /* keep compiler quiet */
}
......@@ -918,17 +920,18 @@ findTypeReceiveFunction(List *procname, Oid typeOid)
argList[0] = INTERNALOID;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList);
procOid = LookupFuncName(procname, 2, argList, true);
if (OidIsValid(procOid))
return procOid;
func_error("TypeCreate", procname, 1, argList, NULL);
elog(ERROR, "function %s does not exist",
func_signature_string(procname, 1, argList));
return InvalidOid; /* keep compiler quiet */
}
......@@ -947,17 +950,18 @@ findTypeSendFunction(List *procname, Oid typeOid)
argList[0] = typeOid;
procOid = LookupFuncName(procname, 1, argList);
procOid = LookupFuncName(procname, 1, argList, true);
if (OidIsValid(procOid))
return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList);
procOid = LookupFuncName(procname, 2, argList, true);
if (OidIsValid(procOid))
return procOid;
func_error("TypeCreate", procname, 1, argList, NULL);
elog(ERROR, "function %s does not exist",
func_signature_string(procname, 1, argList));
return InvalidOid; /* keep compiler quiet */
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.152 2003/06/25 21:30:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.153 2003/07/04 02:51:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -294,10 +294,23 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
/*
* Else generate a detailed complaint for a function
*/
func_error(NULL, funcname, nargs, actual_arg_types,
"Unable to identify a function that satisfies the "
"given argument types"
"\n\tYou may need to add explicit typecasts");
if (fdresult == FUNCDETAIL_MULTIPLE)
ereport(ERROR,
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
errmsg("function %s is not unique",
func_signature_string(funcname, nargs,
actual_arg_types)),
errhint("Unable to choose a best candidate function. "
"You may need to add explicit typecasts.")));
else
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function %s does not exist",
func_signature_string(funcname, nargs,
actual_arg_types)),
errhint("No function matches the given name and argument types. "
"You may need to add explicit typecasts.")));
}
/*
......@@ -874,11 +887,11 @@ func_get_detail(List *funcname,
/*
* If we were able to choose a best candidate, we're
* done. Otherwise, ambiguous function call, so fail
* by exiting loop with best_candidate still NULL.
* Either way, we're outta here.
* done. Otherwise, ambiguous function call.
*/
break;
if (best_candidate)
break;
return FUNCDETAIL_MULTIPLE;
}
/*
......@@ -908,7 +921,8 @@ func_get_detail(List *funcname,
ObjectIdGetDatum(best_candidate->oid),
0, 0, 0);
if (!HeapTupleIsValid(ftup)) /* should not happen */
elog(ERROR, "function %u not found", best_candidate->oid);
elog(ERROR, "cache lookup of function %u failed",
best_candidate->oid);
pform = (Form_pg_proc) GETSTRUCT(ftup);
*rettype = pform->prorettype;
*retset = pform->proretset;
......@@ -918,7 +932,7 @@ func_get_detail(List *funcname,
}
return FUNCDETAIL_NOTFOUND;
} /* func_get_detail() */
}
/*
* argtype_inherit() -- Construct an argtype vector reflecting the
......@@ -1324,19 +1338,23 @@ unknown_attribute(const char *schemaname, const char *relname,
}
/*
* Error message when function lookup fails that gives details of the
* argument types
* func_signature_string
* Build a string representing a function name, including arg types.
* The result is something like "foo(integer)".
*
* This is typically used in the construction of function-not-found error
* messages.
*/
void
func_error(const char *caller, List *funcname,
int nargs, const Oid *argtypes,
const char *msg)
const char *
func_signature_string(List *funcname, int nargs, const Oid *argtypes)
{
StringInfoData argbuf;
int i;
initStringInfo(&argbuf);
appendStringInfo(&argbuf, "%s(", NameListToString(funcname));
for (i = 0; i < nargs; i++)
{
if (i)
......@@ -1344,18 +1362,9 @@ func_error(const char *caller, List *funcname,
appendStringInfoString(&argbuf, format_type_be(argtypes[i]));
}
if (caller == NULL)
{
elog(ERROR, "Function %s(%s) does not exist%s%s",
NameListToString(funcname), argbuf.data,
((msg != NULL) ? "\n\t" : ""), ((msg != NULL) ? msg : ""));
}
else
{
elog(ERROR, "%s: function %s(%s) does not exist%s%s",
caller, NameListToString(funcname), argbuf.data,
((msg != NULL) ? "\n\t" : ""), ((msg != NULL) ? msg : ""));
}
appendStringInfoChar(&argbuf, ')');
return argbuf.data; /* return palloc'd string buffer */
}
/*
......@@ -1367,23 +1376,24 @@ func_error(const char *caller, List *funcname,
* all types.
*/
Oid
find_aggregate_func(const char *caller, List *aggname, Oid basetype)
find_aggregate_func(List *aggname, Oid basetype, bool noError)
{
Oid oid;
HeapTuple ftup;
Form_pg_proc pform;
oid = LookupFuncName(aggname, 1, &basetype);
oid = LookupFuncName(aggname, 1, &basetype, true);
if (!OidIsValid(oid))
{
if (noError)
return InvalidOid;
if (basetype == ANYOID)
elog(ERROR, "%s: aggregate %s(*) does not exist",
caller, NameListToString(aggname));
elog(ERROR, "aggregate %s(*) does not exist",
NameListToString(aggname));
else
elog(ERROR, "%s: aggregate %s(%s) does not exist",
caller, NameListToString(aggname),
format_type_be(basetype));
elog(ERROR, "aggregate %s(%s) does not exist",
NameListToString(aggname), format_type_be(basetype));
}
/* Make sure it's an aggregate */
......@@ -1396,13 +1406,12 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
if (!pform->proisagg)
{
if (basetype == ANYOID)
elog(ERROR, "%s: function %s(*) is not an aggregate",
caller, NameListToString(aggname));
else
elog(ERROR, "%s: function %s(%s) is not an aggregate",
caller, NameListToString(aggname),
format_type_be(basetype));
ReleaseSysCache(ftup);
if (noError)
return InvalidOid;
/* we do not use the (*) notation for functions... */
elog(ERROR, "function %s(%s) is not an aggregate",
NameListToString(aggname), format_type_be(basetype));
}
ReleaseSysCache(ftup);
......@@ -1413,13 +1422,16 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
/*
* LookupFuncName
* Given a possibly-qualified function name and a set of argument types,
* look up the function. Returns InvalidOid if no such function.
* look up the function.
*
* If the function name is not schema-qualified, it is sought in the current
* namespace search path.
*
* If the function is not found, we return InvalidOid if noError is true,
* else raise an error.
*/
Oid
LookupFuncName(List *funcname, int nargs, const Oid *argtypes)
LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
{
FuncCandidateList clist;
......@@ -1432,19 +1444,21 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes)
clist = clist->next;
}
if (!noError)
elog(ERROR, "function %s does not exist",
func_signature_string(funcname, nargs, argtypes));
return InvalidOid;
}
/*
* LookupFuncNameTypeNames
* Like LookupFuncName, but the argument types are specified by a
* list of TypeName nodes. Also, if we fail to find the function
* and caller is not NULL, then an error is reported via func_error.
* list of TypeName nodes.
*/
Oid
LookupFuncNameTypeNames(List *funcname, List *argtypes, const char *caller)
LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
{
Oid funcoid;
Oid argoids[FUNC_MAX_ARGS];
int argcount;
int i;
......@@ -1468,10 +1482,5 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, const char *caller)
argtypes = lnext(argtypes);
}
funcoid = LookupFuncName(funcname, argcount, argoids);
if (!OidIsValid(funcoid) && caller != NULL)
func_error(caller, funcname, argcount, argoids, NULL);
return funcoid;
return LookupFuncName(funcname, argcount, argoids, noError);
}
This diff is collapsed.
......@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.144 2003/07/03 16:34:25 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.145 2003/07/04 02:51:34 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -3539,7 +3539,8 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes)
NIL, nargs, argtypes,
&p_funcid, &p_rettype,
&p_retset, &p_true_typeids);
if (p_result != FUNCDETAIL_NOTFOUND && p_funcid == funcid)
if ((p_result == FUNCDETAIL_NORMAL || p_result == FUNCDETAIL_AGGREGATE) &&
p_funcid == funcid)
nspname = NULL;
else
nspname = get_namespace_name(procform->pronamespace);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_func.h,v 1.46 2003/05/26 00:11:28 tgl Exp $
* $Id: parse_func.h,v 1.47 2003/07/04 02:51:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -33,7 +33,8 @@ typedef struct _InhPaths
/* Result codes for func_get_detail */
typedef enum
{
FUNCDETAIL_NOTFOUND, /* no suitable interpretation */
FUNCDETAIL_NOTFOUND, /* no matching function */
FUNCDETAIL_MULTIPLE, /* too many matching functions */
FUNCDETAIL_NORMAL, /* found a matching regular function */
FUNCDETAIL_AGGREGATE, /* found a matching aggregate function */
FUNCDETAIL_COERCION /* it's a type coercion request */
......@@ -65,15 +66,14 @@ extern void make_fn_arguments(ParseState *pstate,
Oid *actual_arg_types,
Oid *declared_arg_types);
extern void func_error(const char *caller, List *funcname,
int nargs, const Oid *argtypes,
const char *msg);
extern const char *func_signature_string(List *funcname,
int nargs, const Oid *argtypes);
extern Oid find_aggregate_func(const char *caller, List *aggname,
Oid basetype);
extern Oid find_aggregate_func(List *aggname, Oid basetype, bool noError);
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes);
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError);
extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes,
const char *caller);
bool noError);
#endif /* PARSE_FUNC_H */
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_oper.h,v 1.29 2003/06/29 00:33:44 tgl Exp $
* $Id: parse_oper.h,v 1.30 2003/07/04 02:51:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -21,9 +21,10 @@
typedef HeapTuple Operator;
/* Routines to look up an operator given name and exact input type(s) */
extern Oid LookupOperName(List *opername, Oid oprleft, Oid oprright);
extern Oid LookupOperName(List *opername, Oid oprleft, Oid oprright,
bool noError);
extern Oid LookupOperNameTypeNames(List *opername, TypeName *oprleft,
TypeName *oprright, const char *caller);
TypeName *oprright, bool noError);
/* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: elog.h,v 1.45 2003/06/30 16:47:02 tgl Exp $
* $Id: elog.h,v 1.46 2003/07/04 02:51:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -175,7 +175,35 @@
#define ERRCODE_WITH_CHECK_OPTION_VIOLATION MAKE_SQLSTATE('4','4', '0','0','0')
/* Implementation-defined error codes for PostgreSQL */
/* Where appropriate, we borrow SQLSTATE values from DB2 */
#define ERRCODE_INTERNAL_ERROR MAKE_SQLSTATE('X','X', '0','0','0')
#define ERRCODE_INSUFFICIENT_PRIVILEGE MAKE_SQLSTATE('4','2', '5','0','1')
#define ERRCODE_SYNTAX_ERROR MAKE_SQLSTATE('4','2', '6','0','1')
#define ERRCODE_UNTERMINATED_LITERAL MAKE_SQLSTATE('4','2', '6','0','3')
#define ERRCODE_INVALID_LITERAL MAKE_SQLSTATE('4','2', '6','0','6')
#define ERRCODE_TOO_MANY_ARGUMENTS MAKE_SQLSTATE('4','2', '6','0','5')
#define ERRCODE_UNDEFINED_COLUMN MAKE_SQLSTATE('4','2', '7','0','3')
/*
* Note: use the above SQL-standard error codes for undefined catalog, schema,
* prepared statement, or cursor names. Curiously, they don't define error
* codes for any other kinds of objects. We choose to define an errcode for
* undefined tables, as well as one for functions (also used for operators);
* all other names (rules, triggers, etc) are lumped as UNDEFINED_OBJECT.
* The same breakdown is used for "ambiguous" and "duplicate" complaints.
*/
#define ERRCODE_UNDEFINED_TABLE MAKE_SQLSTATE('4','2', '7','0','4')
#define ERRCODE_UNDEFINED_FUNCTION MAKE_SQLSTATE('4','2', '8','8','3')
#define ERRCODE_UNDEFINED_OBJECT MAKE_SQLSTATE('4','2', '7','0','5')
#define ERRCODE_AMBIGUOUS_COLUMN MAKE_SQLSTATE('4','2', '7','0','2')
#define ERRCODE_AMBIGUOUS_FUNCTION MAKE_SQLSTATE('4','2', '7','2','5')
#define ERRCODE_DUPLICATE_COLUMN MAKE_SQLSTATE('4','2', '7','1','1')
#define ERRCODE_DUPLICATE_TABLE MAKE_SQLSTATE('4','2', '7','2','2')
#define ERRCODE_DUPLICATE_FUNCTION MAKE_SQLSTATE('4','2', '7','2','3')
#define ERRCODE_DUPLICATE_OBJECT MAKE_SQLSTATE('4','2', '7','1','0')
#define ERRCODE_GROUPING_ERROR MAKE_SQLSTATE('4','2', '8','0','3')
#define ERRCODE_TYPE_MISMATCH MAKE_SQLSTATE('4','2', '8','0','4')
#define ERRCODE_CANNOT_COERCE MAKE_SQLSTATE('4','2', '8','4','6')
#define ERRCODE_INVALID_FOREIGN_KEY MAKE_SQLSTATE('4','2', '8','3','0')
/* Which __func__ symbol do we have, if any? */
......
......@@ -340,14 +340,14 @@ CREATE TEMP TABLE FKTABLE (ftest1 inet);
-- This next should fail, because inet=int does not exist
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'inet' and 'integer'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: inet = integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- This should also fail for the same reason, but here we
-- give the column name
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'inet' and 'integer'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: inet = integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- This should succeed, even though they are different types
-- because varchar=int does exist
DROP TABLE FKTABLE;
......@@ -368,30 +368,30 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' fo
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'cidr' and 'integer'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: cidr = integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
DROP TABLE FKTABLE;
-- Again, so should this...
CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
references pktable(ptest1, ptest2);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'cidr' and 'integer'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: cidr = integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
DROP TABLE FKTABLE;
-- This fails because we mixed up the column ordering
CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
references pktable(ptest2, ptest1);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'integer' and 'inet'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: integer = inet
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- As does this...
ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1)
references pktable(ptest1, ptest2);
NOTICE: ALTER TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
ERROR: Unable to identify an operator '=' for types 'inet' and 'integer'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: inet = integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- temp tables should go away by themselves, need not drop them.
-- test check constraint adding
create table atacc1 ( test int );
......
......@@ -111,7 +111,7 @@ create aggregate newavg2 (sfunc = int4pl,
stype = int4,
finalfunc = int2um,
initcond = '0');
ERROR: AggregateCreate: function int2um(integer) does not exist
ERROR: function int2um(integer) does not exist
-- left out basetype
create aggregate newcnt1 (sfunc = int4inc,
stype = int4,
......@@ -146,10 +146,10 @@ drop aggregate newcnt (nonesuch);
ERROR: Type "nonesuch" does not exist
-- no such aggregate
drop aggregate nonesuch (int4);
ERROR: RemoveAggregate: aggregate nonesuch(integer) does not exist
ERROR: aggregate nonesuch(integer) does not exist
-- no such aggregate for type
drop aggregate newcnt (float4);
ERROR: RemoveAggregate: aggregate newcnt(real) does not exist
ERROR: aggregate newcnt(real) does not exist
--
-- DROP FUNCTION
......@@ -161,7 +161,7 @@ drop function 314159();
ERROR: syntax error at or near "314159" at character 15
-- no such function
drop function nonesuch();
ERROR: RemoveFunction: function nonesuch() does not exist
ERROR: function nonesuch() does not exist
--
-- DROP TYPE
......@@ -200,7 +200,7 @@ drop operator === (int4);
ERROR: parser: argument type missing (use NONE for unary operators)
-- no such operator by that name
drop operator === (int4, int4);
ERROR: RemoveOperator: Operator '===' for types 'int4' and 'int4' does not exist
ERROR: operator does not exist: integer === integer
-- no such type1
drop operator = (nonesuch);
ERROR: parser: argument type missing (use NONE for unary operators)
......@@ -209,10 +209,10 @@ drop operator = ( , int4);
ERROR: syntax error at or near "," at character 19
-- no such type1
drop operator = (nonesuch, int4);
ERROR: Type "nonesuch" does not exist
ERROR: type nonesuch does not exist
-- no such type2
drop operator = (int4, nonesuch);
ERROR: Type "nonesuch" does not exist
ERROR: type nonesuch does not exist
-- no such type2
drop operator = (int4, );
ERROR: syntax error at or near ")" at character 24
......
This diff is collapsed.
......@@ -104,8 +104,8 @@ SELECT '' AS one, p1.f1
-- intersection
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
FROM LSEG_TBL l, POINT_TBL p;
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: lseg # point
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- closest point
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
FROM LSEG_TBL l, POINT_TBL p;
......
......@@ -104,8 +104,8 @@ SELECT '' AS one, p1.f1
-- intersection
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
FROM LSEG_TBL l, POINT_TBL p;
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: lseg # point
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
-- closest point
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
FROM LSEG_TBL l, POINT_TBL p;
......
......@@ -299,8 +299,8 @@ SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time";
(1 row)
SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC";
ERROR: Unable to identify an operator '-' for types 'date' and 'time with time zone'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: date - time with time zone
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
--
-- timestamp, interval arithmetic
--
......@@ -332,20 +332,20 @@ SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days'
Feb 23, 285506
----------------------------
Fri Feb 23 00:00:00 285506
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244";
Jan 20, 288244
----------------------------
Sat Jan 20 00:00:00 288244
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276";
Dec 31, 294276
----------------------------
Sun Dec 31 00:00:00 294276
(1 row)
(1 row)
SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days";
106751991 Days
------------------
......
......@@ -299,8 +299,8 @@ SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time";
(1 row)
SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC";
ERROR: Unable to identify an operator '-' for types 'date' and 'time with time zone'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: date - time with time zone
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
--
-- timestamp, interval arithmetic
--
......@@ -332,20 +332,20 @@ SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days'
Feb 23, 285506
----------------------------
Fri Feb 23 00:00:00 285506
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244";
Jan 20, 288244
----------------------------
Sat Jan 20 00:00:00 288244
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276";
Dec 31, 294276
----------------------------
Sun Dec 31 00:00:00 294276
(1 row)
(1 row)
SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days";
106751991 Days
------------------
......
......@@ -299,8 +299,8 @@ SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time";
(1 row)
SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC";
ERROR: Unable to identify an operator '-' for types 'date' and 'time with time zone'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: date - time with time zone
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
--
-- timestamp, interval arithmetic
--
......@@ -332,20 +332,20 @@ SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days'
Feb 23, 285506
----------------------------
Fri Feb 23 00:00:00 285506
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244";
Jan 20, 288244
----------------------------
Sat Jan 20 00:00:00 288244
(1 row)
(1 row)
SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276";
Dec 31, 294276
----------------------------
Sun Dec 31 00:00:00 294276
(1 row)
(1 row)
SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days";
106751991 Days
------------------
......
......@@ -107,7 +107,7 @@ CREATE AGGREGATE myaggp06a(BASETYPE = int, SFUNC = tf2p, STYPE = int[],
-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int)
CREATE AGGREGATE myaggp07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[],
FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(integer[], anyelement) does not exist
ERROR: function tfnp(integer[], anyelement) does not exist
-- N N P P
-- should CREATE
CREATE AGGREGATE myaggp08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[],
......@@ -128,18 +128,18 @@ CREATE AGGREGATE myaggp10b(BASETYPE = int, SFUNC = tfp, STYPE = int[],
-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int)
CREATE AGGREGATE myaggp11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[],
FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(integer[], anyelement) does not exist
ERROR: function tf1p(integer[], anyelement) does not exist
CREATE AGGREGATE myaggp11b(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[],
INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(integer[], anyelement) does not exist
ERROR: function tf1p(integer[], anyelement) does not exist
-- N P P P
-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement)
CREATE AGGREGATE myaggp12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[],
FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tfp(integer[], anyelement) does not exist
ERROR: function tfp(integer[], anyelement) does not exist
CREATE AGGREGATE myaggp12b(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[],
INITCOND = '{}');
ERROR: AggregateCreate: function tfp(integer[], anyelement) does not exist
ERROR: function tfp(integer[], anyelement) does not exist
-- P N N N
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
......@@ -154,12 +154,12 @@ ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have o
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp,
STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(anyarray, anyelement) does not exist
ERROR: function tfnp(anyarray, anyelement) does not exist
-- P N P P
-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggp16a(BASETYPE = anyelement, SFUNC = tf2p,
STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tf2p(anyarray, anyelement) does not exist
ERROR: function tf2p(anyarray, anyelement) does not exist
-- P P N N
-- should ERROR: we have no way to resolve S
CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
......@@ -180,10 +180,10 @@ ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have o
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p,
STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(anyarray, anyelement) does not exist
ERROR: function tf1p(anyarray, anyelement) does not exist
CREATE AGGREGATE myaggp19b(BASETYPE = anyelement, SFUNC = tf1p,
STYPE = anyarray, INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(anyarray, anyelement) does not exist
ERROR: function tf1p(anyarray, anyelement) does not exist
-- P P P P
-- should CREATE
CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp,
......@@ -237,10 +237,10 @@ CREATE AGGREGATE myaggn06b(BASETYPE = int, SFUNC = tf2p, STYPE = int[],
-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int)
CREATE AGGREGATE myaggn07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[],
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(integer[], anyelement) does not exist
ERROR: function tfnp(integer[], anyelement) does not exist
CREATE AGGREGATE myaggn07b(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[],
INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(integer[], anyelement) does not exist
ERROR: function tfnp(integer[], anyelement) does not exist
-- N N P P
-- should CREATE
CREATE AGGREGATE myaggn08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[],
......@@ -259,12 +259,12 @@ CREATE AGGREGATE myaggn10a(BASETYPE = int, SFUNC = tfp, STYPE = int[],
-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int)
CREATE AGGREGATE myaggn11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[],
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(integer[], anyelement) does not exist
ERROR: function tf1p(integer[], anyelement) does not exist
-- N P P P
-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement)
CREATE AGGREGATE myaggn12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[],
FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tfp(integer[], anyelement) does not exist
ERROR: function tfp(integer[], anyelement) does not exist
-- P N N N
-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray,
......@@ -285,18 +285,18 @@ ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have o
-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int)
CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp,
STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(anyarray, anyelement) does not exist
ERROR: function tfnp(anyarray, anyelement) does not exist
CREATE AGGREGATE myaggn15b(BASETYPE = anyelement, SFUNC = tfnp,
STYPE = anyarray, INITCOND = '{}');
ERROR: AggregateCreate: function tfnp(anyarray, anyelement) does not exist
ERROR: function tfnp(anyarray, anyelement) does not exist
-- P N P P
-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement)
CREATE AGGREGATE myaggn16a(BASETYPE = anyelement, SFUNC = tf2p,
STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tf2p(anyarray, anyelement) does not exist
ERROR: function tf2p(anyarray, anyelement) does not exist
CREATE AGGREGATE myaggn16b(BASETYPE = anyelement, SFUNC = tf2p,
STYPE = anyarray, INITCOND = '{}');
ERROR: AggregateCreate: function tf2p(anyarray, anyelement) does not exist
ERROR: function tf2p(anyarray, anyelement) does not exist
-- P P N N
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray,
......@@ -311,12 +311,12 @@ ERROR: an aggregate using ANYARRAY or ANYELEMENT as trans type must also have o
-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int)
CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p,
STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function tf1p(anyarray, anyelement) does not exist
ERROR: function tf1p(anyarray, anyelement) does not exist
-- P P P P
-- should ERROR: ffnp(anyarray) not matched by ffnp(int[])
CREATE AGGREGATE myaggn20a(BASETYPE = anyelement, SFUNC = tfp,
STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}');
ERROR: AggregateCreate: function ffnp(anyarray) does not exist
ERROR: function ffnp(anyarray) does not exist
-- create test data for polymorphic aggregates
create temp table t(f1 int, f2 int[], f3 text);
insert into t values(1,array[1],'a');
......
......@@ -235,7 +235,7 @@ GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error
ERROR: invalid privilege type USAGE for function object
GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4;
GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4;
ERROR: GRANT: function testfunc_nosuch(integer) does not exist
ERROR: function testfunc_nosuch(integer) does not exist
CREATE FUNCTION testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
LANGUAGE sql SECURITY DEFINER;
......
......@@ -69,5 +69,5 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
-- and do the rest of the testing in horology.sql
-- where we do mixed-type arithmetic. - thomas 2000-12-02
SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
ERROR: Unable to identify an operator '+' for types 'time without time zone' and 'time without time zone'
You will have to retype this query using an explicit cast
ERROR: operator is not unique: time without time zone + time without time zone
HINT: Unable to choose a best candidate operator. You may need to add explicit typecasts.
......@@ -76,5 +76,5 @@ SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00-07';
-- and do the rest of the testing in horology.sql
-- where we do mixed-type arithmetic. - thomas 2000-12-02
SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
ERROR: Unable to identify an operator '+' for types 'time with time zone' and 'time with time zone'
You will have to retype this query using an explicit cast
ERROR: operator does not exist: time with time zone + time with time zone
HINT: No operator matches the given name and argument type(s). You may need to add explicit typecasts.
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