8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1943,6 +1943,7 @@ renameatt(Oid myrelid,
1943
1943
HeapTuple atttup ;
1944
1944
Form_pg_attribute attform ;
1945
1945
int attnum ;
1946
+ char relkind ;
1946
1947
1947
1948
/*
1948
1949
* Grab an exclusive lock on the target table, which we will NOT release
@@ -1955,6 +1956,23 @@ renameatt(Oid myrelid,
1955
1956
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
1956
1957
errmsg ("cannot rename column of typed table" )));
1957
1958
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
+
1958
1976
/*
1959
1977
* permissions checking. only the owner of a class can change its schema.
1960
1978
*/
0 commit comments