1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Get rid of the last few uses of typeidTypeName() rather than

format_type_be() in error messages.
This commit is contained in:
Tom Lane
2002-05-17 22:35:13 +00:00
parent 940f772a29
commit 22d641a7d4
13 changed files with 73 additions and 97 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.72 2002/05/12 23:43:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.73 2002/05/17 22:35:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -133,7 +133,7 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
InvalidOid,
isExplicit);
if (!OidIsValid(funcId))
elog(ERROR, "coerce_type: no conversion function from %s to %s",
elog(ERROR, "coerce_type: no conversion function from '%s' to '%s'",
format_type_be(inputTypeId), format_type_be(targetTypeId));
result = build_func_call(funcId, baseTypeId, makeList1(node));
@@ -392,8 +392,8 @@ select_common_type(List *typeids, const char *context)
* both types in different categories? then not much
* hope...
*/
elog(ERROR, "%s types \"%s\" and \"%s\" not matched",
context, typeidTypeName(ptype), typeidTypeName(ntype));
elog(ERROR, "%s types '%s' and '%s' not matched",
context, format_type_be(ptype), format_type_be(ntype));
}
else if (IsPreferredType(pcategory, ntype)
&& !IsPreferredType(pcategory, ptype)
@@ -448,8 +448,8 @@ coerce_to_common_type(ParseState *pstate, Node *node,
false);
else
{
elog(ERROR, "%s unable to convert to type \"%s\"",
context, typeidTypeName(targetTypeId));
elog(ERROR, "%s unable to convert to type %s",
context, format_type_be(targetTypeId));
}
return node;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.117 2002/05/12 23:43:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.118 2002/05/17 22:35:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -366,7 +366,7 @@ transformExpr(ParseState *pstate, Node *expr)
/* Combining operators other than =/<> is dubious... */
if (length(left_list) != 1 &&
strcmp(opname, "=") != 0 && strcmp(opname, "<>") != 0)
elog(ERROR, "Row comparison cannot use '%s'",
elog(ERROR, "Row comparison cannot use operator %s",
opname);
/*
@@ -405,13 +405,13 @@ transformExpr(ParseState *pstate, Node *expr)
opform = (Form_pg_operator) GETSTRUCT(optup);
if (opform->oprresult != BOOLOID)
elog(ERROR, "'%s' result type of '%s' must return '%s'"
elog(ERROR, "%s has result type of %s, but must return %s"
" to be used with quantified predicate subquery",
opname, typeidTypeName(opform->oprresult),
typeidTypeName(BOOLOID));
opname, format_type_be(opform->oprresult),
format_type_be(BOOLOID));
if (get_func_retset(opform->oprcode))
elog(ERROR, "'%s' must not return a set"
elog(ERROR, "%s must not return a set"
" to be used with quantified predicate subquery",
opname);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.129 2002/05/12 23:43:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.130 2002/05/17 22:35:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,6 +19,7 @@
#include "catalog/namespace.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_proc.h"
#include "lib/stringinfo.h"
#include "nodes/makefuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
@@ -261,9 +262,25 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
* give an error message that is appropriate for that case.
*/
if (is_column)
elog(ERROR, "Attribute \"%s\" not found",
strVal(lfirst(funcname)));
/* Else generate a detailed complaint */
{
char *colname = strVal(lfirst(funcname));
Oid relTypeId;
Assert(nargs == 1);
if (IsA(first_arg, RangeVar))
elog(ERROR, "No such attribute %s.%s",
((RangeVar *) first_arg)->relname, colname);
relTypeId = exprType(first_arg);
if (!ISCOMPLEX(relTypeId))
elog(ERROR, "Attribute notation .%s applied to type %s, which is not a complex type",
colname, format_type_be(relTypeId));
else
elog(ERROR, "Attribute \"%s\" not found in datatype %s",
colname, format_type_be(relTypeId));
}
/*
* Else generate a detailed complaint for a function
*/
func_error(NULL, funcname, nargs, oid_array,
"Unable to identify a function that satisfies the "
"given argument types"
@@ -1214,39 +1231,31 @@ func_error(const char *caller, List *funcname,
int nargs, const Oid *argtypes,
const char *msg)
{
char p[(NAMEDATALEN + 2) * FUNC_MAX_ARGS],
*ptr;
StringInfoData argbuf;
int i;
ptr = p;
*ptr = '\0';
initStringInfo(&argbuf);
for (i = 0; i < nargs; i++)
{
if (i)
{
*ptr++ = ',';
*ptr++ = ' ';
}
appendStringInfo(&argbuf, ", ");
if (OidIsValid(argtypes[i]))
{
strncpy(ptr, typeidTypeName(argtypes[i]), NAMEDATALEN);
*(ptr + NAMEDATALEN) = '\0';
}
appendStringInfo(&argbuf, format_type_be(argtypes[i]));
else
strcpy(ptr, "opaque");
ptr += strlen(ptr);
appendStringInfo(&argbuf, "opaque");
}
if (caller == NULL)
{
elog(ERROR, "Function '%s(%s)' does not exist%s%s",
NameListToString(funcname), p,
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), p,
elog(ERROR, "%s: function %s(%s) does not exist%s%s",
caller, NameListToString(funcname), argbuf.data,
((msg != NULL) ? "\n\t" : ""), ((msg != NULL) ? msg : ""));
}
}
@@ -1271,10 +1280,10 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
if (!OidIsValid(oid))
{
if (basetype == InvalidOid)
elog(ERROR, "%s: aggregate '%s' for all types does not exist",
elog(ERROR, "%s: aggregate %s(*) does not exist",
caller, NameListToString(aggname));
else
elog(ERROR, "%s: aggregate '%s' for type %s does not exist",
elog(ERROR, "%s: aggregate %s(%s) does not exist",
caller, NameListToString(aggname),
format_type_be(basetype));
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.41 2002/05/12 20:10:04 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.42 2002/05/17 22:35:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,6 +23,7 @@
#include "parser/parser.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
@@ -93,7 +94,7 @@ LookupTypeName(const TypeName *typename)
/* emit nuisance warning */
elog(NOTICE, "%s converted to %s",
TypeNameToString(typename), typeidTypeName(restype));
TypeNameToString(typename), format_type_be(restype));
}
else
{
@@ -187,7 +188,7 @@ TypeNameToString(const TypeName *typename)
else
{
/* Look up internally-specified type */
appendStringInfo(&string, "%s", typeidTypeName(typename->typeid));
appendStringInfo(&string, "%s", format_type_be(typename->typeid));
}
/*
@@ -252,12 +253,7 @@ typenameType(const TypeName *typename)
return (Type) tup;
}
/* check to see if a type id is valid,
* returns true if it is. By using this call before calling
* typeidType or typeidTypeName, more meaningful error messages
* can be produced because the caller typically has more context of
* what's going on - jolly
*/
/* check to see if a type id is valid, returns true if it is */
bool
typeidIsValid(Oid id)
{
@@ -418,32 +414,6 @@ typeidOutfunc(Oid type_id)
}
#endif
/* return a type name, given a typeid */
/* nb: type name is NOT unique; use this only for error messages */
char *
typeidTypeName(Oid id)
{
HeapTuple tup;
Form_pg_type typetuple;
char *result;
tup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(id),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "Unable to locate type oid %u in catalog", id);
typetuple = (Form_pg_type) GETSTRUCT(tup);
/*
* pstrdup here because result may need to outlive the syscache entry
* (eg, it might end up as part of a parse tree that will outlive the
* current transaction...)
*/
result = pstrdup(NameStr(typetuple->typname));
ReleaseSysCache(tup);
return result;
}
/* given a typeid, return the type's typrelid (associated relation, if any) */
Oid
typeidTypeRelid(Oid type_id)