Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2b75c8

Browse files
committed
All works on linux now by my tests and regression(with patch below).
ALTER TABLE RENAME with extents. Ole Gjerde
1 parent 19c4e86 commit c2b75c8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/backend/commands/rename.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.23 1999/05/10 00:44:59 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -201,10 +201,13 @@ renameatt(char *relname,
201201
void
202202
renamerel(char *oldrelname, char *newrelname)
203203
{
204+
int i;
204205
Relation relrelation; /* for RELATION relation */
205206
HeapTuple oldreltup;
206207
char oldpath[MAXPGPATH],
207-
newpath[MAXPGPATH];
208+
newpath[MAXPGPATH],
209+
toldpath[MAXPGPATH + 10],
210+
tnewpath[MAXPGPATH + 10];
208211
Relation irelations[Num_pg_class_indices];
209212

210213
if (!allowSystemTableMods && IsSystemRelationName(oldrelname))
@@ -230,6 +233,14 @@ renamerel(char *oldrelname, char *newrelname)
230233
if (rename(oldpath, newpath) < 0)
231234
elog(ERROR, "renamerel: unable to rename file: %s", oldpath);
232235

236+
for (i = 1;; i++)
237+
{
238+
sprintf(toldpath, "%s.%d", oldpath, i);
239+
sprintf(tnewpath, "%s.%d", newpath, i);
240+
if(rename(toldpath, tnewpath) < 0)
241+
break;
242+
}
243+
233244
StrNCpy((((Form_pg_class) GETSTRUCT(oldreltup))->relname.data),
234245
newrelname, NAMEDATALEN);
235246

0 commit comments

Comments
 (0)