diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 162b134faf00977f65c4b87c4dd28fea4b3ef6d8..c6af2c3213459f9d407757dbd484bc7a5c3de34c 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -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,
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index ad348bf6a5630d3bfbd6192d3d3faa476fed1bb5..678931ce97714f6c16654b456165acf9b993eb59 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -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;
 }
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index 4c09a40b1d74a2385d07ee7e05c93e8cfd6f8ab7..023f7ef2808f83c422a9bb1df2f705ff2274041d 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -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;
diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c
index 860d490bd30c7938aff067fa79307b86cb821266..8006d71898750f0eab22509d807be8dce1023fa7 100644
--- a/src/backend/commands/aggregatecmds.c
+++ b/src/backend/commands/aggregatecmds.c
@@ -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),
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 53974f396b2ec2bb71deed34e9b62e2af29d7ab8..99b1fadbcf84e9705a59733e587d013622e2cd45 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -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()))
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index 2d2fd66c4b3daf67bb03511010d1ddd98517bc38..e490a852c408e5395368e896658eaedce5322637 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -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);
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 47ac67b9dcdf922f5a2481bd3fd147daf3986273..a7c7c47e1971ee870371af55a9c294b72cee0c5f 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -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),
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 9b90698a26ac8f184a354204446fa6d7cf12a991..84a01446d4d75683864b2b2656e73dd1fe93c62d 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -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);
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index bb82e0df56f504941df0161648f4beb487e5d410..6c902b643ce06f363a9b6f3045fddb70c4ea1093 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -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()) &&
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 1e93c07fec5f5068b6b0396a9fa454f974de8f06..65c82fbab8bbe36c45518e44735b3396402112ac 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -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
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index db30014bf9bef6048310844bdd9140ccb866ebe8..8e8d61d77b8d3ff36dfe9a19ad823cf45b5294a5 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -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)
 	{
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 5a16e53e983210c6259eb6354716cd63722978ae..94f25fb4be42bc75222af3b697db68363a3accda 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -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 */
 }
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 806138a25a5201510dceb0911afc792a3361d734..cb2da292a067fe778e2070fb4e29d0b6b49b8689 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -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);
 }
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 72327243310244d4fdc4fb23172d5e56d3790f3d..99b5a3078ca407ac17d139dac6acb239cb298bb7 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.68 2003/06/29 00:33:43 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.69 2003/07/04 02:51:33 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,6 +16,7 @@
 #include "postgres.h"
 
 #include "catalog/pg_operator.h"
+#include "lib/stringinfo.h"
 #include "parser/parse_coerce.h"
 #include "parser/parse_expr.h"
 #include "parser/parse_func.h"
@@ -29,25 +30,32 @@
 
 static Oid binary_oper_exact(Oid arg1, Oid arg2,
 				  FuncCandidateList candidates);
-static Oid oper_select_candidate(int nargs, Oid *input_typeids,
-					  FuncCandidateList candidates);
-static void op_error(List *op, Oid arg1, Oid arg2);
-static void unary_op_error(List *op, Oid arg, bool is_left_op);
+static FuncDetailCode oper_select_candidate(int nargs,
+											Oid *input_typeids,
+											FuncCandidateList candidates,
+											Oid *operOid);
+static const char *op_signature_string(List *op, char oprkind,
+									   Oid arg1, Oid arg2);
+static void op_error(List *op, char oprkind, Oid arg1, Oid arg2,
+					 FuncDetailCode fdresult);
 
 
 /*
  * LookupOperName
  *		Given a possibly-qualified operator name and exact input datatypes,
- *		look up the operator.  Returns InvalidOid if no such operator.
+ *		look up the operator.
  *
  * Pass oprleft = InvalidOid for a prefix op, oprright = InvalidOid for
  * a postfix op.
  *
  * If the operator name is not schema-qualified, it is sought in the current
  * namespace search path.
+ *
+ * If the operator is not found, we return InvalidOid if noError is true,
+ * else raise an error.
  */
 Oid
-LookupOperName(List *opername, Oid oprleft, Oid oprright)
+LookupOperName(List *opername, Oid oprleft, Oid oprright, bool noError)
 {
 	FuncCandidateList clist;
 	char		oprkind;
@@ -68,22 +76,28 @@ LookupOperName(List *opername, Oid oprleft, Oid oprright)
 		clist = clist->next;
 	}
 
+	/* we don't use op_error here because only an exact match is wanted */
+	if (!noError)
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_FUNCTION),
+				 errmsg("operator does not exist: %s",
+						op_signature_string(opername, oprkind,
+											oprleft, oprright))));
+
 	return InvalidOid;
 }
 
 /*
  * LookupOperNameTypeNames
  *		Like LookupOperName, but the argument types are specified by
- *		TypeName nodes.  Also, if we fail to find the operator
- *		and caller is not NULL, then an error is reported.
+ *		TypeName nodes.
  *
  * Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op.
  */
 Oid
 LookupOperNameTypeNames(List *opername, TypeName *oprleft,
-						TypeName *oprright, const char *caller)
+						TypeName *oprright, bool noError)
 {
-	Oid			operoid;
 	Oid			leftoid,
 				rightoid;
 
@@ -93,7 +107,7 @@ LookupOperNameTypeNames(List *opername, TypeName *oprleft,
 	{
 		leftoid = LookupTypeName(oprleft);
 		if (!OidIsValid(leftoid))
-			elog(ERROR, "Type \"%s\" does not exist",
+			elog(ERROR, "type %s does not exist",
 				 TypeNameToString(oprleft));
 	}
 	if (oprright == NULL)
@@ -102,30 +116,11 @@ LookupOperNameTypeNames(List *opername, TypeName *oprleft,
 	{
 		rightoid = LookupTypeName(oprright);
 		if (!OidIsValid(rightoid))
-			elog(ERROR, "Type \"%s\" does not exist",
-				 TypeNameToString(oprright));
-	}
-
-	operoid = LookupOperName(opername, leftoid, rightoid);
-
-	if (!OidIsValid(operoid) && caller != NULL)
-	{
-		if (oprleft == NULL)
-			elog(ERROR, "%s: Prefix operator '%s' for type '%s' does not exist",
-				 caller, NameListToString(opername),
-				 TypeNameToString(oprright));
-		else if (oprright == NULL)
-			elog(ERROR, "%s: Postfix operator '%s' for type '%s' does not exist",
-				 caller, NameListToString(opername),
-				 TypeNameToString(oprleft));
-		else
-			elog(ERROR, "%s: Operator '%s' for types '%s' and '%s' does not exist",
-				 caller, NameListToString(opername),
-				 TypeNameToString(oprleft),
+			elog(ERROR, "type %s does not exist",
 				 TypeNameToString(oprright));
 	}
 
-	return operoid;
+	return LookupOperName(opername, leftoid, rightoid, noError);
 }
 
 /*
@@ -183,7 +178,7 @@ equality_oper(Oid argtype, bool noError)
 		}
 	}
 	if (!noError)
-		elog(ERROR, "Unable to identify an equality operator for type %s",
+		elog(ERROR, "unable to identify an equality operator for type %s",
 			 format_type_be(argtype));
 	return NULL;
 }
@@ -244,7 +239,7 @@ ordering_oper(Oid argtype, bool noError)
 		}
 	}
 	if (!noError)
-		elog(ERROR, "Unable to identify an ordering operator for type %s"
+		elog(ERROR, "unable to identify an ordering operator for type %s"
 			 "\n\tUse an explicit ordering operator or modify the query",
 			 format_type_be(argtype));
 	return NULL;
@@ -347,17 +342,18 @@ binary_oper_exact(Oid arg1, Oid arg2,
  *		Given the input argtype array and one or more candidates
  *		for the operator, attempt to resolve the conflict.
  *
- * Returns the OID of the selected operator if the conflict can be resolved,
- * otherwise returns InvalidOid.
+ * Returns FUNCDETAIL_NOTFOUND, FUNCDETAIL_MULTIPLE, or FUNCDETAIL_NORMAL.
+ * In the success case the Oid of the best candidate is stored in *operOid.
  *
  * Note that the caller has already determined that there is no candidate
  * exactly matching the input argtype(s).  Incompatible candidates are not yet
  * pruned away, however.
  */
-static Oid
+static FuncDetailCode
 oper_select_candidate(int nargs,
 					  Oid *input_typeids,
-					  FuncCandidateList candidates)
+					  FuncCandidateList candidates,
+					  Oid *operOid)	/* output argument */
 {
 	int			ncandidates;
 
@@ -370,9 +366,15 @@ oper_select_candidate(int nargs,
 
 	/* Done if no candidate or only one candidate survives */
 	if (ncandidates == 0)
-		return InvalidOid;
+	{
+		*operOid = InvalidOid;
+		return FUNCDETAIL_NOTFOUND;
+	}
 	if (ncandidates == 1)
-		return candidates->oid;
+	{
+		*operOid = candidates->oid;
+		return FUNCDETAIL_NORMAL;
+	}
 
 	/*
 	 * Use the same heuristics as for ambiguous functions to resolve
@@ -381,10 +383,14 @@ oper_select_candidate(int nargs,
 	candidates = func_select_candidate(nargs, input_typeids, candidates);
 
 	if (candidates)
-		return candidates->oid;
+	{
+		*operOid = candidates->oid;
+		return FUNCDETAIL_NORMAL;
+	}
 
-	return InvalidOid;			/* failed to select a best candidate */
-}	/* oper_select_candidate() */
+	*operOid = InvalidOid;
+	return FUNCDETAIL_MULTIPLE;	/* failed to select a best candidate */
+}
 
 
 /* oper() -- search for a binary operator
@@ -404,8 +410,9 @@ Operator
 oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError)
 {
 	FuncCandidateList clist;
-	Oid			operOid;
 	Oid			inputOids[2];
+	Oid			operOid;
+	FuncDetailCode fdresult = FUNCDETAIL_NOTFOUND;
 	HeapTuple	tup = NULL;
 
 	/* Get binary operators of given name */
@@ -434,7 +441,7 @@ oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError)
 				ltypeId = rtypeId;
 			inputOids[0] = ltypeId;
 			inputOids[1] = rtypeId;
-			operOid = oper_select_candidate(2, inputOids, clist);
+			fdresult = oper_select_candidate(2, inputOids, clist, &operOid);
 		}
 		if (OidIsValid(operOid))
 			tup = SearchSysCache(OPEROID,
@@ -443,7 +450,7 @@ oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError)
 	}
 
 	if (!HeapTupleIsValid(tup) && !noError)
-		op_error(opname, ltypeId, rtypeId);
+		op_error(opname, 'b', ltypeId, rtypeId, fdresult);
 
 	return (Operator) tup;
 }
@@ -476,7 +483,8 @@ compatible_oper(List *op, Oid arg1, Oid arg2, bool noError)
 	ReleaseSysCache(optup);
 
 	if (!noError)
-		op_error(op, arg1, arg2);
+		elog(ERROR, "operator requires run-time type coercion: %s",
+			 op_signature_string(op, 'b', arg1, arg2));
 
 	return (Operator) NULL;
 }
@@ -504,7 +512,7 @@ compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError)
 }
 
 
-/* right_oper() -- search for a unary right operator (operator on right)
+/* right_oper() -- search for a unary right operator (postfix operator)
  * Given operator name and type of arg, return oper struct.
  *
  * IMPORTANT: the returned operator (if any) is only promised to be
@@ -522,6 +530,7 @@ right_oper(List *op, Oid arg, bool noError)
 {
 	FuncCandidateList clist;
 	Oid			operOid = InvalidOid;
+	FuncDetailCode fdresult = FUNCDETAIL_NOTFOUND;
 	HeapTuple	tup = NULL;
 
 	/* Find candidates */
@@ -551,7 +560,7 @@ right_oper(List *op, Oid arg, bool noError)
 			 * candidate, otherwise we may falsely return a
 			 * non-type-compatible operator.
 			 */
-			operOid = oper_select_candidate(1, &arg, clist);
+			fdresult = oper_select_candidate(1, &arg, clist, &operOid);
 		}
 		if (OidIsValid(operOid))
 			tup = SearchSysCache(OPEROID,
@@ -560,13 +569,13 @@ right_oper(List *op, Oid arg, bool noError)
 	}
 
 	if (!HeapTupleIsValid(tup) && !noError)
-		unary_op_error(op, arg, FALSE);
+		op_error(op, 'r', arg, InvalidOid, fdresult);
 
 	return (Operator) tup;
 }
 
 
-/* left_oper() -- search for a unary left operator (operator on left)
+/* left_oper() -- search for a unary left operator (prefix operator)
  * Given operator name and type of arg, return oper struct.
  *
  * IMPORTANT: the returned operator (if any) is only promised to be
@@ -584,6 +593,7 @@ left_oper(List *op, Oid arg, bool noError)
 {
 	FuncCandidateList clist;
 	Oid			operOid = InvalidOid;
+	FuncDetailCode fdresult = FUNCDETAIL_NOTFOUND;
 	HeapTuple	tup = NULL;
 
 	/* Find candidates */
@@ -618,7 +628,7 @@ left_oper(List *op, Oid arg, bool noError)
 			 * candidate, otherwise we may falsely return a
 			 * non-type-compatible operator.
 			 */
-			operOid = oper_select_candidate(1, &arg, clist);
+			fdresult = oper_select_candidate(1, &arg, clist, &operOid);
 		}
 		if (OidIsValid(operOid))
 			tup = SearchSysCache(OPEROID,
@@ -627,67 +637,59 @@ left_oper(List *op, Oid arg, bool noError)
 	}
 
 	if (!HeapTupleIsValid(tup) && !noError)
-		unary_op_error(op, arg, TRUE);
+		op_error(op, 'l', InvalidOid, arg, fdresult);
 
 	return (Operator) tup;
 }
 
-
-/* op_error()
- * Give a somewhat useful error message when the operator for two types
- * is not found.
+/*
+ * op_signature_string
+ *		Build a string representing an operator name, including arg type(s).
+ *		The result is something like "integer + integer".
+ *
+ * This is typically used in the construction of operator-not-found error
+ * messages.
  */
-static void
-op_error(List *op, Oid arg1, Oid arg2)
+static const char *
+op_signature_string(List *op, char oprkind, Oid arg1, Oid arg2)
 {
-	if (!typeidIsValid(arg1))
-		elog(ERROR, "Left hand side of operator '%s' has an unknown type"
-			 "\n\tProbably a bad attribute name",
-			 NameListToString(op));
-
-	if (!typeidIsValid(arg2))
-		elog(ERROR, "Right hand side of operator %s has an unknown type"
-			 "\n\tProbably a bad attribute name",
-			 NameListToString(op));
-
-	elog(ERROR, "Unable to identify an operator '%s' for types '%s' and '%s'"
-		 "\n\tYou will have to retype this query using an explicit cast",
-		 NameListToString(op),
-		 format_type_be(arg1), format_type_be(arg2));
+	StringInfoData argbuf;
+
+	initStringInfo(&argbuf);
+
+	if (oprkind != 'l')
+		appendStringInfo(&argbuf, "%s ", format_type_be(arg1));
+
+	appendStringInfoString(&argbuf, NameListToString(op));
+
+	if (oprkind != 'r')
+		appendStringInfo(&argbuf, " %s", format_type_be(arg2));
+
+	return argbuf.data;			/* return palloc'd string buffer */
 }
 
-/* unary_op_error()
- * Give a somewhat useful error message when the operator for one type
- * is not found.
+/*
+ * op_error - utility routine to complain about an unresolvable operator
  */
 static void
-unary_op_error(List *op, Oid arg, bool is_left_op)
+op_error(List *op, char oprkind, Oid arg1, Oid arg2, FuncDetailCode fdresult)
 {
-	if (!typeidIsValid(arg))
-	{
-		if (is_left_op)
-			elog(ERROR, "operand of prefix operator '%s' has an unknown type"
-				 "\n\t(probably an invalid column reference)",
-				 NameListToString(op));
-		else
-			elog(ERROR, "operand of postfix operator '%s' has an unknown type"
-				 "\n\t(probably an invalid column reference)",
-				 NameListToString(op));
-	}
+	if (fdresult == FUNCDETAIL_MULTIPLE)
+		ereport(ERROR,
+				(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
+				 errmsg("operator is not unique: %s",
+						op_signature_string(op, oprkind, arg1, arg2)),
+				 errhint("Unable to choose a best candidate operator. "
+						 "You may need to add explicit typecasts.")));
 	else
-	{
-		if (is_left_op)
-			elog(ERROR, "Unable to identify a prefix operator '%s' for type '%s'"
-			   "\n\tYou may need to add parentheses or an explicit cast",
-				 NameListToString(op), format_type_be(arg));
-		else
-			elog(ERROR, "Unable to identify a postfix operator '%s' for type '%s'"
-			   "\n\tYou may need to add parentheses or an explicit cast",
-				 NameListToString(op), format_type_be(arg));
-	}
+		ereport(ERROR,
+				(errcode(ERRCODE_UNDEFINED_FUNCTION),
+				 errmsg("operator does not exist: %s",
+						op_signature_string(op, oprkind, arg1, arg2)),
+				 errhint("No operator matches the given name and argument type(s). "
+						 "You may need to add explicit typecasts.")));
 }
 
-
 /*
  * make_op()
  *		Operator expression construction.
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 6ff458b91ffcb05d12fca680f4cd5886079e6d81..63d5fee0af19a65837053a8189b461aff3685a90 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -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);
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index 5f2adf5c4a1d9b15c3239878a46a9cdd6e84923e..a5beb2368d2d1e5562e84d7c41ac23993a4c0284 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/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_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 */
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index 3fd5eea2a8a8f60197b3660bfd8148d758d58b76..a53b1a5a23e15793cfc72864e02da7dff9197d02 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.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! */
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index b92bc8393374048ef0c1a3ed294c4af3e97cd460..f58a032527830c0e88fd4fb7fdebd8a335c0190a 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.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: 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? */
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 06a5bec15e02c2ea17ca88e98cee6e8952c1780a..cdd6c88831553d516da6c343efb5ffea30f1157c 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -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 );
diff --git a/src/test/regress/expected/errors.out b/src/test/regress/expected/errors.out
index c97b8346b147890c951dd48adf712f14c5b05ebc..071ad9cd40faf792bdc55126815c100943661777 100644
--- a/src/test/regress/expected/errors.out
+++ b/src/test/regress/expected/errors.out
@@ -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
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index 580762f93bdb33b54296f71f5acdc8a2bab8e323..d44b5203a541e6dcea26c456beeee582184f2c22 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -716,14 +716,14 @@ NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' fo
 -- This next should fail, because inet=int does not exist
 CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable);
 NOTICE:  CREATE 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
 CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1));
 NOTICE:  CREATE 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
 CREATE TABLE FKTABLE (ftest1 varchar REFERENCES pktable);
@@ -740,28 +740,28 @@ NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' fo
 -- This should fail, because we just chose really odd types
 CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable);
 NOTICE:  CREATE 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.
 -- Again, so should this...
 CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2));
 NOTICE:  CREATE 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.
 -- This fails because we mixed up the column ordering
 CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable);
 NOTICE:  CREATE 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.
 -- As does this...
 CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2));
 NOTICE:  CREATE 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.
 -- And again..
 CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1));
 NOTICE:  CREATE 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.
 -- This works...
 CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1));
 NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
@@ -789,22 +789,22 @@ CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY
 ptest4) REFERENCES pktable(ptest2, ptest1));
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 -- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types
 CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
 ptest3) REFERENCES pktable(ptest1, ptest2));
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 -- Not this one either... Same as the last one except we didn't defined the columns being referenced.
 CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4,
 ptest3) REFERENCES pktable);
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 --
 -- Now some cases with inheritance
 -- Basic 2 table case: 1 column of matching types.
@@ -895,25 +895,25 @@ NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' fo
 -- just generally bad types (with and without column references on the referenced table)
 create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable);
 NOTICE:  CREATE 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.
 create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1));
 NOTICE:  CREATE 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.
 -- let's mix up which columns reference which
 create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable);
 NOTICE:  CREATE 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.
 create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1));
 NOTICE:  CREATE 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.
 create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1));
 NOTICE:  CREATE 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.
 drop table pktable;
 drop table pktable_base;
 -- 2 columns (1 table), mismatched types
@@ -922,26 +922,26 @@ create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), for
                                              pktable(base1, ptest1)) inherits (pktable_base);
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
-ERROR:  Unable to identify an operator '=' for types 'inet[]' and 'inet'
-	You will have to retype this query using an explicit cast
+ERROR:  operator does not exist: inet[] = inet
+HINT:  No operator matches the given name and argument type(s). You may need to add explicit typecasts.
 create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references
                                              pktable(ptest1, base1)) inherits (pktable_base);
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
                                              pktable(base1, ptest1)) inherits (pktable_base);
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references
                                              pktable(base1, ptest1)) inherits (pktable_base);
 NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'pktable_pkey' for table 'pktable'
 NOTICE:  CREATE 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.
 drop table pktable;
 ERROR:  table "pktable" does not exist
 drop table pktable_base;
diff --git a/src/test/regress/expected/geometry.out b/src/test/regress/expected/geometry.out
index fa16f72c9e59ac10d870ce312b2959f3939f4aa6..69118725f4a857d55628a91a16eb77fdc2b183b3 100644
--- a/src/test/regress/expected/geometry.out
+++ b/src/test/regress/expected/geometry.out
@@ -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;
diff --git a/src/test/regress/expected/geometry_1.out b/src/test/regress/expected/geometry_1.out
index 4fc3d4c3bb2b34470c88fea36e59f603bc76ee4b..76b621fede615b6ac817914cd152ac3d1ccdcfaa 100644
--- a/src/test/regress/expected/geometry_1.out
+++ b/src/test/regress/expected/geometry_1.out
@@ -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;
diff --git a/src/test/regress/expected/horology-no-DST-before-1970.out b/src/test/regress/expected/horology-no-DST-before-1970.out
index 269c169c62345d64d7a10180836f4a4e809e4333..a5edd6103f1537d59665497bc483fa7b35e86d6b 100644
--- a/src/test/regress/expected/horology-no-DST-before-1970.out
+++ b/src/test/regress/expected/horology-no-DST-before-1970.out
@@ -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  
 ------------------
diff --git a/src/test/regress/expected/horology-solaris-1947.out b/src/test/regress/expected/horology-solaris-1947.out
index 73402c1ead4ef4271aa2025ef36f2e9d97c48a0e..ea64e96beed10cfa1d4e073b9b17e7da0a5e940b 100644
--- a/src/test/regress/expected/horology-solaris-1947.out
+++ b/src/test/regress/expected/horology-solaris-1947.out
@@ -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  
 ------------------
diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out
index 831806c992b3b2970f4263e33ce8e3b0ccf46c39..084f9fe2a64104319afb5f1124700398d1476383 100644
--- a/src/test/regress/expected/horology.out
+++ b/src/test/regress/expected/horology.out
@@ -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  
 ------------------
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 63dfdb694f1ff13fc61f0b3154782b65f8f0e134..08bed53de74619d618c4a5d2280170cb7ca5bdfa 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -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');
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
index 1c63dfcc8292b0a6131f21b7d8c5895174bc1e0e..1114f688655644ed5de248cacc299d65904daa37 100644
--- a/src/test/regress/expected/privileges.out
+++ b/src/test/regress/expected/privileges.out
@@ -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;
diff --git a/src/test/regress/expected/time.out b/src/test/regress/expected/time.out
index e8b2b6de3371b8c4997bc0a41519cff0ce37c055..5604c9a452d7e34b8ebf8272eda137c0f00c1bcf 100644
--- a/src/test/regress/expected/time.out
+++ b/src/test/regress/expected/time.out
@@ -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.
diff --git a/src/test/regress/expected/timetz.out b/src/test/regress/expected/timetz.out
index 62e5c19f0032268fff3689381639e0c9632d617d..540d5e091a84a1c9013ce4c23e14644f7c6170c9 100644
--- a/src/test/regress/expected/timetz.out
+++ b/src/test/regress/expected/timetz.out
@@ -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.