Commit a2a33e13 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

New mdtruncate() func for single segment relations (< 2Gb).

parent 3643248a
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.9 1996/11/25 06:33:51 bryanh Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.10 1996/11/27 07:24:02 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -528,6 +528,36 @@ mdnblocks(Relation reln) ...@@ -528,6 +528,36 @@ mdnblocks(Relation reln)
} }
} }
/*
* mdtruncate() -- Truncate relation to specified number of blocks.
*
* Returns # of blocks or -1 on error.
*/
int
mdtruncate (Relation reln, int nblocks)
{
int fd;
MdfdVec *v;
int curnblk;
curnblk = mdnblocks (reln);
if ( curnblk / RELSEG_SIZE > 0 )
{
elog (NOTICE, "Can't truncate multi-segments relation %.*s",
NAMEDATALEN, &(reln->rd_rel->relname.data[0]));
return (curnblk);
}
fd = RelationGetFile(reln);
v = &Md_fdvec[fd];
if ( FileTruncate (v->mdfd_vfd, nblocks * BLCKSZ) < 0 )
return (-1);
return (nblocks);
} /* mdtruncate */
/* /*
* mdcommit() -- Commit a transaction. * mdcommit() -- Commit a transaction.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment