mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
All works on linux now by my tests and regression(with patch below).
ALTER TABLE RENAME with extents. Ole Gjerde
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.23 1999/05/10 00:44:59 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -201,10 +201,13 @@ renameatt(char *relname,
|
|||||||
void
|
void
|
||||||
renamerel(char *oldrelname, char *newrelname)
|
renamerel(char *oldrelname, char *newrelname)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Relation relrelation; /* for RELATION relation */
|
Relation relrelation; /* for RELATION relation */
|
||||||
HeapTuple oldreltup;
|
HeapTuple oldreltup;
|
||||||
char oldpath[MAXPGPATH],
|
char oldpath[MAXPGPATH],
|
||||||
newpath[MAXPGPATH];
|
newpath[MAXPGPATH],
|
||||||
|
toldpath[MAXPGPATH + 10],
|
||||||
|
tnewpath[MAXPGPATH + 10];
|
||||||
Relation irelations[Num_pg_class_indices];
|
Relation irelations[Num_pg_class_indices];
|
||||||
|
|
||||||
if (!allowSystemTableMods && IsSystemRelationName(oldrelname))
|
if (!allowSystemTableMods && IsSystemRelationName(oldrelname))
|
||||||
@ -230,6 +233,14 @@ renamerel(char *oldrelname, char *newrelname)
|
|||||||
if (rename(oldpath, newpath) < 0)
|
if (rename(oldpath, newpath) < 0)
|
||||||
elog(ERROR, "renamerel: unable to rename file: %s", oldpath);
|
elog(ERROR, "renamerel: unable to rename file: %s", oldpath);
|
||||||
|
|
||||||
|
for (i = 1;; i++)
|
||||||
|
{
|
||||||
|
sprintf(toldpath, "%s.%d", oldpath, i);
|
||||||
|
sprintf(tnewpath, "%s.%d", newpath, i);
|
||||||
|
if(rename(toldpath, tnewpath) < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
StrNCpy((((Form_pg_class) GETSTRUCT(oldreltup))->relname.data),
|
StrNCpy((((Form_pg_class) GETSTRUCT(oldreltup))->relname.data),
|
||||||
newrelname, NAMEDATALEN);
|
newrelname, NAMEDATALEN);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user