Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d1b02e76
Commit
d1b02e76
authored
Oct 21, 2008
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use format_type_be() instead of TypeNameToString() for some more user-facing
error messages where the type existence is established.
parent
1471e384
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
29 deletions
+29
-29
src/backend/commands/comment.c
src/backend/commands/comment.c
+6
-6
src/backend/commands/functioncmds.c
src/backend/commands/functioncmds.c
+11
-11
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+5
-5
src/backend/commands/typecmds.c
src/backend/commands/typecmds.c
+4
-4
src/test/regress/expected/alter_table.out
src/test/regress/expected/alter_table.out
+3
-3
No files found.
src/backend/commands/comment.c
View file @
d1b02e76
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Copyright (c) 1996-2008, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.10
3 2008/06/19 00:46:04 alvher
re Exp $
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.10
4 2008/10/21 10:38:51 pete
re Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -882,7 +882,7 @@ CommentType(List *typename, char *comment)
...
@@ -882,7 +882,7 @@ CommentType(List *typename, char *comment)
if
(
!
pg_type_ownercheck
(
oid
,
GetUserId
()))
if
(
!
pg_type_ownercheck
(
oid
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
TypeNameToString
(
tname
));
format_type_be
(
oid
));
/* Call CreateComments() to create/drop the comments */
/* Call CreateComments() to create/drop the comments */
CreateComments
(
oid
,
TypeRelationId
,
0
,
comment
);
CreateComments
(
oid
,
TypeRelationId
,
0
,
comment
);
...
@@ -1464,8 +1464,8 @@ CommentCast(List *qualname, List *arguments, char *comment)
...
@@ -1464,8 +1464,8 @@ CommentCast(List *qualname, List *arguments, char *comment)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"cast from type %s to type %s does not exist"
,
errmsg
(
"cast from type %s to type %s does not exist"
,
TypeNameToString
(
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
targettype
))));
format_type_be
(
targettypeid
))));
/* Get the OID of the cast */
/* Get the OID of the cast */
castOid
=
HeapTupleGetOid
(
tuple
);
castOid
=
HeapTupleGetOid
(
tuple
);
...
@@ -1476,8 +1476,8 @@ CommentCast(List *qualname, List *arguments, char *comment)
...
@@ -1476,8 +1476,8 @@ CommentCast(List *qualname, List *arguments, char *comment)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be owner of type %s or type %s"
,
errmsg
(
"must be owner of type %s or type %s"
,
TypeNameToString
(
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
targettype
))));
format_type_be
(
targettypeid
))));
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
...
...
src/backend/commands/functioncmds.c
View file @
d1b02e76
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.9
8 2008/07/18 03:32:52 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.9
9 2008/10/21 10:38:51 petere
Exp $
*
*
* DESCRIPTION
* DESCRIPTION
* These routines take the parse tree and pick out the
* These routines take the parse tree and pick out the
...
@@ -1412,8 +1412,8 @@ CreateCast(CreateCastStmt *stmt)
...
@@ -1412,8 +1412,8 @@ CreateCast(CreateCastStmt *stmt)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be owner of type %s or type %s"
,
errmsg
(
"must be owner of type %s or type %s"
,
TypeNameToString
(
stmt
->
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
stmt
->
targettype
))));
format_type_be
(
targettypeid
))));
if
(
stmt
->
func
!=
NULL
)
if
(
stmt
->
func
!=
NULL
)
{
{
...
@@ -1554,8 +1554,8 @@ CreateCast(CreateCastStmt *stmt)
...
@@ -1554,8 +1554,8 @@ CreateCast(CreateCastStmt *stmt)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
(
errcode
(
ERRCODE_DUPLICATE_OBJECT
),
errmsg
(
"cast from type %s to type %s already exists"
,
errmsg
(
"cast from type %s to type %s already exists"
,
TypeNameToString
(
stmt
->
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
stmt
->
targettype
))));
format_type_be
(
targettypeid
))));
/* ready to go */
/* ready to go */
values
[
Anum_pg_cast_castsource
-
1
]
=
ObjectIdGetDatum
(
sourcetypeid
);
values
[
Anum_pg_cast_castsource
-
1
]
=
ObjectIdGetDatum
(
sourcetypeid
);
...
@@ -1629,13 +1629,13 @@ DropCast(DropCastStmt *stmt)
...
@@ -1629,13 +1629,13 @@ DropCast(DropCastStmt *stmt)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"cast from type %s to type %s does not exist"
,
errmsg
(
"cast from type %s to type %s does not exist"
,
TypeNameToString
(
stmt
->
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
stmt
->
targettype
))));
format_type_be
(
targettypeid
))));
else
else
ereport
(
NOTICE
,
ereport
(
NOTICE
,
(
errmsg
(
"cast from type %s to type %s does not exist, skipping"
,
(
errmsg
(
"cast from type %s to type %s does not exist, skipping"
,
TypeNameToString
(
stmt
->
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
stmt
->
targettype
))));
format_type_be
(
targettypeid
))));
return
;
return
;
}
}
...
@@ -1646,8 +1646,8 @@ DropCast(DropCastStmt *stmt)
...
@@ -1646,8 +1646,8 @@ DropCast(DropCastStmt *stmt)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
(
errcode
(
ERRCODE_INSUFFICIENT_PRIVILEGE
),
errmsg
(
"must be owner of type %s or type %s"
,
errmsg
(
"must be owner of type %s or type %s"
,
TypeNameToString
(
stmt
->
sourcetype
),
format_type_be
(
sourcetypeid
),
TypeNameToString
(
stmt
->
targettype
))));
format_type_be
(
targettypeid
))));
/*
/*
* Do the deletion
* Do the deletion
...
...
src/backend/commands/tablecmds.c
View file @
d1b02e76
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.26
7 2008/10/07 11:15:41 heikki
Exp $
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.26
8 2008/10/21 10:38:51 petere
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -5520,8 +5520,8 @@ ATPrepAlterColumnType(List **wqueue,
...
@@ -5520,8 +5520,8 @@ ATPrepAlterColumnType(List **wqueue,
if
(
transform
==
NULL
)
if
(
transform
==
NULL
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"column
\"
%s
\"
cannot be cast to type
\"
%s
\"
"
,
errmsg
(
"column
\"
%s
\"
cannot be cast to type
%s
"
,
colName
,
TypeNameToString
(
typenam
e
))));
colName
,
format_type_be
(
targettyp
e
))));
/*
/*
* Add a work queue item to make ATRewriteTable update the column
* Add a work queue item to make ATRewriteTable update the column
...
@@ -5619,8 +5619,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
...
@@ -5619,8 +5619,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
if
(
defaultexpr
==
NULL
)
if
(
defaultexpr
==
NULL
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
(
errcode
(
ERRCODE_DATATYPE_MISMATCH
),
errmsg
(
"default for column
\"
%s
\"
cannot be cast to type
\"
%s
\"
"
,
errmsg
(
"default for column
\"
%s
\"
cannot be cast to type
%s
"
,
colName
,
TypeNameToString
(
typenam
e
))));
colName
,
format_type_be
(
targettyp
e
))));
}
}
else
else
defaultexpr
=
NULL
;
defaultexpr
=
NULL
;
...
...
src/backend/commands/typecmds.c
View file @
d1b02e76
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.12
4 2008/09/25 03:28:56 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.12
5 2008/10/21 10:38:51 petere
Exp $
*
*
* DESCRIPTION
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
* The "DefineFoo" routines take the parse tree and pick out the
...
@@ -581,7 +581,7 @@ RemoveTypes(DropStmt *drop)
...
@@ -581,7 +581,7 @@ RemoveTypes(DropStmt *drop)
if
(
!
pg_type_ownercheck
(
typeoid
,
GetUserId
())
&&
if
(
!
pg_type_ownercheck
(
typeoid
,
GetUserId
())
&&
!
pg_namespace_ownercheck
(
typ
->
typnamespace
,
GetUserId
()))
!
pg_namespace_ownercheck
(
typ
->
typnamespace
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
TypeNameToString
(
typename
));
format_type_be
(
typeoid
));
if
(
drop
->
removeType
==
OBJECT_DOMAIN
)
if
(
drop
->
removeType
==
OBJECT_DOMAIN
)
{
{
...
@@ -2082,7 +2082,7 @@ checkDomainOwner(HeapTuple tup, TypeName *typename)
...
@@ -2082,7 +2082,7 @@ checkDomainOwner(HeapTuple tup, TypeName *typename)
/* Permission check: must own type */
/* Permission check: must own type */
if
(
!
pg_type_ownercheck
(
HeapTupleGetOid
(
tup
),
GetUserId
()))
if
(
!
pg_type_ownercheck
(
HeapTupleGetOid
(
tup
),
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
TypeNameToString
(
typename
));
format_type_be
(
HeapTupleGetOid
(
tup
)
));
}
}
/*
/*
...
@@ -2487,7 +2487,7 @@ AlterTypeOwner(List *names, Oid newOwnerId)
...
@@ -2487,7 +2487,7 @@ AlterTypeOwner(List *names, Oid newOwnerId)
/* Otherwise, must be owner of the existing object */
/* Otherwise, must be owner of the existing object */
if
(
!
pg_type_ownercheck
(
HeapTupleGetOid
(
tup
),
GetUserId
()))
if
(
!
pg_type_ownercheck
(
HeapTupleGetOid
(
tup
),
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_TYPE
,
TypeNameToString
(
typename
));
format_type_be
(
HeapTupleGetOid
(
tup
)
));
/* Must be able to become new owner */
/* Must be able to become new owner */
check_is_member_of_role
(
GetUserId
(),
newOwnerId
);
check_is_member_of_role
(
GetUserId
(),
newOwnerId
);
...
...
src/test/regress/expected/alter_table.out
View file @
d1b02e76
...
@@ -1301,7 +1301,7 @@ select f3,max(f1) from foo group by f3;
...
@@ -1301,7 +1301,7 @@ select f3,max(f1) from foo group by f3;
-- Simple tests for alter table column type
-- Simple tests for alter table column type
alter table foo alter f1 TYPE integer; -- fails
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);
alter table foo alter f1 TYPE varchar(10);
create table anothertab (atcol1 serial8, atcol2 boolean,
create table anothertab (atcol1 serial8, atcol2 boolean,
constraint anothertab_chk check (atcol1 <= 3));
constraint anothertab_chk check (atcol1 <= 3));
...
@@ -1316,7 +1316,7 @@ select * from anothertab;
...
@@ -1316,7 +1316,7 @@ select * from anothertab;
(2 rows)
(2 rows)
alter table anothertab alter column atcol1 type boolean; -- fails
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;
alter table anothertab alter column atcol1 type integer;
select * from anothertab;
select * from anothertab;
atcol1 | atcol2
atcol1 | atcol2
...
@@ -1350,7 +1350,7 @@ select * from anothertab;
...
@@ -1350,7 +1350,7 @@ select * from anothertab;
alter table anothertab alter column atcol1 type boolean
alter table anothertab alter column atcol1 type boolean
using case when atcol1 % 2 = 0 then true else false end; -- fails
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 drop default;
alter table anothertab alter column atcol1 type boolean
alter table anothertab alter column atcol1 type boolean
using case when atcol1 % 2 = 0 then true else false end; -- fails
using case when atcol1 % 2 = 0 then true else false end; -- fails
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment