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

Commit184dd28

Browse files
committed
This is actually more of a fundamental problem with mdtruncate. It
lookslike someone just didn't add support for multiple segments fortruncation.The following patch seems to do the right thing, for me at least.It passed my tests, my data looks right(no data that shouldn't be inthere) and regression is ok.Ole Gjerde
1 parent1125c5e commit184dd28

File tree

1 file changed

+19
-8
lines changed
  • src/backend/storage/smgr

1 file changed

+19
-8
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.42 1999/04/05 22:25:11 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.43 1999/05/17 06:38:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -711,15 +711,26 @@ mdtruncate(Relation reln, int nblocks)
711711
MdfdVec*v;
712712

713713
#ifndefLET_OS_MANAGE_FILESIZE
714-
intcurnblk;
714+
intcurnblk,
715+
i,
716+
oldsegno,
717+
newsegno;
718+
charfname[NAMEDATALEN];
719+
chartname[NAMEDATALEN+10];
715720

716721
curnblk=mdnblocks(reln);
717-
if (curnblk /RELSEG_SIZE>0)
718-
{
719-
elog(NOTICE,"Can't truncate multi-segments relation %s",
720-
reln->rd_rel->relname.data);
721-
returncurnblk;
722-
}
722+
oldsegno=curnblk /RELSEG_SIZE;
723+
newsegno=nblocks /RELSEG_SIZE;
724+
725+
StrNCpy(fname,RelationGetRelationName(reln)->data,NAMEDATALEN);
726+
727+
if (newsegno<oldsegno) {
728+
for (i= (newsegno+1);;i++) {
729+
sprintf(tname,"%s.%d",fname,i);
730+
if (FileNameUnlink(tname)<0)
731+
break;
732+
}
733+
}
723734
#endif
724735

725736
fd=RelationGetFile(reln);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp