error messages where the type existence is established.
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.103 2008/06/19 00:46:04 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.104 2008/10/21 10:38:51 petere Exp $
*
*-------------------------------------------------------------------------
*/
if (!pg_type_ownercheck(oid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE,
- TypeNameToString(tname));
+ format_type_be(oid));
/* Call CreateComments() to create/drop the comments */
CreateComments(oid, TypeRelationId, 0, comment);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("cast from type %s to type %s does not exist",
- TypeNameToString(sourcetype),
- TypeNameToString(targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
/* Get the OID of the cast */
castOid = HeapTupleGetOid(tuple);
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be owner of type %s or type %s",
- TypeNameToString(sourcetype),
- TypeNameToString(targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
ReleaseSysCache(tuple);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.98 2008/07/18 03:32:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.99 2008/10/21 10:38:51 petere Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be owner of type %s or type %s",
- TypeNameToString(stmt->sourcetype),
- TypeNameToString(stmt->targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
if (stmt->func != NULL)
{
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("cast from type %s to type %s already exists",
- TypeNameToString(stmt->sourcetype),
- TypeNameToString(stmt->targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
/* ready to go */
values[Anum_pg_cast_castsource - 1] = ObjectIdGetDatum(sourcetypeid);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("cast from type %s to type %s does not exist",
- TypeNameToString(stmt->sourcetype),
- TypeNameToString(stmt->targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
else
ereport(NOTICE,
(errmsg("cast from type %s to type %s does not exist, skipping",
- TypeNameToString(stmt->sourcetype),
- TypeNameToString(stmt->targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
return;
}
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be owner of type %s or type %s",
- TypeNameToString(stmt->sourcetype),
- TypeNameToString(stmt->targettype))));
+ format_type_be(sourcetypeid),
+ format_type_be(targettypeid))));
/*
* Do the deletion
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.267 2008/10/07 11:15:41 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.268 2008/10/21 10:38:51 petere Exp $
*
*-------------------------------------------------------------------------
*/
if (transform == NULL)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("column \"%s\" cannot be cast to type \"%s\"",
- colName, TypeNameToString(typename))));
+ errmsg("column \"%s\" cannot be cast to type %s",
+ colName, format_type_be(targettype))));
/*
* Add a work queue item to make ATRewriteTable update the column
if (defaultexpr == NULL)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("default for column \"%s\" cannot be cast to type \"%s\"",
- colName, TypeNameToString(typename))));
+ errmsg("default for column \"%s\" cannot be cast to type %s",
+ colName, format_type_be(targettype))));
}
else
defaultexpr = NULL;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.124 2008/09/25 03:28:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.125 2008/10/21 10:38:51 petere Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
if (!pg_type_ownercheck(typeoid, GetUserId()) &&
!pg_namespace_ownercheck(typ->typnamespace, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE,
- TypeNameToString(typename));
+ format_type_be(typeoid));
if (drop->removeType == OBJECT_DOMAIN)
{
/* Permission check: must own type */
if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE,
- TypeNameToString(typename));
+ format_type_be(HeapTupleGetOid(tup)));
}
/*
/* Otherwise, must be owner of the existing object */
if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE,
- TypeNameToString(typename));
+ format_type_be(HeapTupleGetOid(tup)));
/* Must be able to become new owner */
check_is_member_of_role(GetUserId(), newOwnerId);
-- Simple tests for alter table column type
alter table foo alter f1 TYPE integer; -- fails
-ERROR: column "f1" cannot be cast to type "pg_catalog.int4"
+ERROR: column "f1" cannot be cast to type integer
alter table foo alter f1 TYPE varchar(10);
create table anothertab (atcol1 serial8, atcol2 boolean,
constraint anothertab_chk check (atcol1 <= 3));
(2 rows)
alter table anothertab alter column atcol1 type boolean; -- fails
-ERROR: column "atcol1" cannot be cast to type "pg_catalog.bool"
+ERROR: column "atcol1" cannot be cast to type boolean
alter table anothertab alter column atcol1 type integer;
select * from anothertab;
atcol1 | atcol2
alter table anothertab alter column atcol1 type boolean
using case when atcol1 % 2 = 0 then true else false end; -- fails
-ERROR: default for column "atcol1" cannot be cast to type "pg_catalog.bool"
+ERROR: default for column "atcol1" cannot be cast to type boolean
alter table anothertab alter column atcol1 drop default;
alter table anothertab alter column atcol1 type boolean
using case when atcol1 % 2 = 0 then true else false end; -- fails