Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitacdd6ea

Browse files
committed
Forbid renaming columns of objects whose column names are system-generated.
KaiGai Kohei, with adjustments to the comments.
1 parenta836abe commitacdd6ea

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.328 2010/03/10 19:48:39 rhaas Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.329 2010/03/20 00:43:42 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1943,6 +1943,7 @@ renameatt(Oid myrelid,
19431943
HeapTupleatttup;
19441944
Form_pg_attributeattform;
19451945
intattnum;
1946+
charrelkind;
19461947

19471948
/*
19481949
* Grab an exclusive lock on the target table, which we will NOT release
@@ -1955,6 +1956,23 @@ renameatt(Oid myrelid,
19551956
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
19561957
errmsg("cannot rename column of typed table")));
19571958

1959+
/*
1960+
* Renaming the columns of sequences or toast tables doesn't actually
1961+
* break anything from the system's point of view, since internal
1962+
* references are by attnum. But it doesn't seem right to allow users
1963+
* to change names that are hardcoded into the system, hence the following
1964+
* restriction.
1965+
*/
1966+
relkind=RelationGetForm(targetrelation)->relkind;
1967+
if (relkind!=RELKIND_RELATION&&
1968+
relkind!=RELKIND_VIEW&&
1969+
relkind!=RELKIND_COMPOSITE_TYPE&&
1970+
relkind!=RELKIND_INDEX)
1971+
ereport(ERROR,
1972+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
1973+
errmsg("\"%s\" is not a table, view, composite type or index",
1974+
RelationGetRelationName(targetrelation))));
1975+
19581976
/*
19591977
* permissions checking. only the owner of a class can change its schema.
19601978
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp