8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.129 2002/05/12 23:43:03 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.130 2002/05/17 22:35:13 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
19
19
#include "catalog/namespace.h"
20
20
#include "catalog/pg_inherits.h"
21
21
#include "catalog/pg_proc.h"
22
+ #include "lib/stringinfo.h"
22
23
#include "nodes/makefuncs.h"
23
24
#include "parser/parse_coerce.h"
24
25
#include "parser/parse_expr.h"
@@ -261,9 +262,25 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
261
262
* give an error message that is appropriate for that case.
262
263
*/
263
264
if (is_column )
264
- elog (ERROR ,"Attribute \"%s\" not found" ,
265
- strVal (lfirst (funcname )));
266
- /* Else generate a detailed complaint */
265
+ {
266
+ char * colname = strVal (lfirst (funcname ));
267
+ Oid relTypeId ;
268
+
269
+ Assert (nargs == 1 );
270
+ if (IsA (first_arg ,RangeVar ))
271
+ elog (ERROR ,"No such attribute %s.%s" ,
272
+ ((RangeVar * )first_arg )-> relname ,colname );
273
+ relTypeId = exprType (first_arg );
274
+ if (!ISCOMPLEX (relTypeId ))
275
+ elog (ERROR ,"Attribute notation .%s applied to type %s, which is not a complex type" ,
276
+ colname ,format_type_be (relTypeId ));
277
+ else
278
+ elog (ERROR ,"Attribute \"%s\" not found in datatype %s" ,
279
+ colname ,format_type_be (relTypeId ));
280
+ }
281
+ /*
282
+ * Else generate a detailed complaint for a function
283
+ */
267
284
func_error (NULL ,funcname ,nargs ,oid_array ,
268
285
"Unable to identify a function that satisfies the "
269
286
"given argument types"
@@ -1214,39 +1231,31 @@ func_error(const char *caller, List *funcname,
1214
1231
int nargs ,const Oid * argtypes ,
1215
1232
const char * msg )
1216
1233
{
1217
- char p [(NAMEDATALEN + 2 )* FUNC_MAX_ARGS ],
1218
- * ptr ;
1234
+ StringInfoData argbuf ;
1219
1235
int i ;
1220
1236
1221
- ptr = p ;
1222
- * ptr = '\0' ;
1237
+ initStringInfo ( & argbuf ) ;
1238
+
1223
1239
for (i = 0 ;i < nargs ;i ++ )
1224
1240
{
1225
1241
if (i )
1226
- {
1227
- * ptr ++ = ',' ;
1228
- * ptr ++ = ' ' ;
1229
- }
1242
+ appendStringInfo (& argbuf ,", " );
1230
1243
if (OidIsValid (argtypes [i ]))
1231
- {
1232
- strncpy (ptr ,typeidTypeName (argtypes [i ]),NAMEDATALEN );
1233
- * (ptr + NAMEDATALEN )= '\0' ;
1234
- }
1244
+ appendStringInfo (& argbuf ,format_type_be (argtypes [i ]));
1235
1245
else
1236
- strcpy (ptr ,"opaque" );
1237
- ptr += strlen (ptr );
1246
+ appendStringInfo (& argbuf ,"opaque" );
1238
1247
}
1239
1248
1240
1249
if (caller == NULL )
1241
1250
{
1242
- elog (ERROR ,"Function' %s(%s)' does not exist%s%s" ,
1243
- NameListToString (funcname ),p ,
1251
+ elog (ERROR ,"Function %s(%s) does not exist%s%s" ,
1252
+ NameListToString (funcname ),argbuf . data ,
1244
1253
((msg != NULL ) ?"\n\t" :"" ), ((msg != NULL ) ?msg :"" ));
1245
1254
}
1246
1255
else
1247
1256
{
1248
- elog (ERROR ,"%s: function' %s(%s)' does not exist%s%s" ,
1249
- caller ,NameListToString (funcname ),p ,
1257
+ elog (ERROR ,"%s: function %s(%s) does not exist%s%s" ,
1258
+ caller ,NameListToString (funcname ),argbuf . data ,
1250
1259
((msg != NULL ) ?"\n\t" :"" ), ((msg != NULL ) ?msg :"" ));
1251
1260
}
1252
1261
}
@@ -1271,10 +1280,10 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype)
1271
1280
if (!OidIsValid (oid ))
1272
1281
{
1273
1282
if (basetype == InvalidOid )
1274
- elog (ERROR ,"%s: aggregate'%s' for all types does not exist" ,
1283
+ elog (ERROR ,"%s: aggregate%s(*) does not exist" ,
1275
1284
caller ,NameListToString (aggname ));
1276
1285
else
1277
- elog (ERROR ,"%s: aggregate'%s' for type %s does not exist" ,
1286
+ elog (ERROR ,"%s: aggregate%s(%s) does not exist" ,
1278
1287
caller ,NameListToString (aggname ),
1279
1288
format_type_be (basetype ));
1280
1289
}