Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0591bbd5
Commit
0591bbd5
authored
Jun 18, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch to allow vacuum on multi-segment tables, from Hiroshi Inoue
parent
8c3a7963
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
12 deletions
+46
-12
src/backend/storage/smgr/md.c
src/backend/storage/smgr/md.c
+46
-12
No files found.
src/backend/storage/smgr/md.c
View file @
0591bbd5
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.4
5 1999/06/11 02:39:4
3 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.4
6 1999/06/18 16:47:2
3 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -674,11 +674,12 @@ mdnblocks(Relation reln)
...
@@ -674,11 +674,12 @@ mdnblocks(Relation reln)
segno
=
0
;
segno
=
0
;
for
(;;)
for
(;;)
{
{
if
(
v
->
mdfd_lstbcnt
==
RELSEG_SIZE
nblocks
=
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
);
||
(
nblocks
=
_mdnblocks
(
v
->
mdfd_vfd
,
BLCKSZ
))
==
RELSEG_SIZE
)
if
(
nblocks
>
RELSEG_SIZE
)
elog
(
FATAL
,
"segment too big in mdnblocks!"
);
v
->
mdfd_lstbcnt
=
nblocks
;
if
(
nblocks
==
RELSEG_SIZE
)
{
{
v
->
mdfd_lstbcnt
=
RELSEG_SIZE
;
segno
++
;
segno
++
;
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
if
(
v
->
mdfd_chain
==
(
MdfdVec
*
)
NULL
)
...
@@ -711,22 +712,55 @@ mdtruncate(Relation reln, int nblocks)
...
@@ -711,22 +712,55 @@ mdtruncate(Relation reln, int nblocks)
MdfdVec
*
v
;
MdfdVec
*
v
;
#ifndef LET_OS_MANAGE_FILESIZE
#ifndef LET_OS_MANAGE_FILESIZE
int
curnblk
;
int
curnblk
,
i
,
oldsegno
,
newsegno
,
lastsegblocks
;
MdfdVec
**
varray
;
curnblk
=
mdnblocks
(
reln
);
curnblk
=
mdnblocks
(
reln
);
if
(
curnblk
/
RELSEG_SIZE
>
0
)
if
(
nblocks
>
curnblk
)
{
return
-
1
;
elog
(
NOTICE
,
"Can't truncate multi-segments relation %s"
,
oldsegno
=
curnblk
/
RELSEG_SIZE
;
reln
->
rd_rel
->
relname
.
data
);
newsegno
=
nblocks
/
RELSEG_SIZE
;
return
curnblk
;
}
#endif
#endif
fd
=
RelationGetFile
(
reln
);
fd
=
RelationGetFile
(
reln
);
v
=
&
Md_fdvec
[
fd
];
v
=
&
Md_fdvec
[
fd
];
#ifndef LET_OS_MANAGE_FILESIZE
varray
=
(
MdfdVec
**
)
palloc
((
oldsegno
+
1
)
*
sizeof
(
MdfdVec
*
));
for
(
i
=
0
;
i
<=
oldsegno
;
i
++
)
{
if
(
!
v
)
elog
(
ERROR
,
"segment isn't open in mdtruncate!"
);
varray
[
i
]
=
v
;
v
=
v
->
mdfd_chain
;
}
for
(
i
=
oldsegno
;
i
>
newsegno
;
i
--
)
{
v
=
varray
[
i
];
if
(
FileTruncate
(
v
->
mdfd_vfd
,
0
)
<
0
)
{
pfree
(
varray
);
return
-
1
;
}
v
->
mdfd_lstbcnt
=
0
;
}
/* Calculate the # of blocks in the last segment */
lastsegblocks
=
nblocks
-
(
newsegno
*
RELSEG_SIZE
);
v
=
varray
[
i
];
pfree
(
varray
);
if
(
FileTruncate
(
v
->
mdfd_vfd
,
lastsegblocks
*
BLCKSZ
)
<
0
)
return
-
1
;
v
->
mdfd_lstbcnt
=
lastsegblocks
;
#else
if
(
FileTruncate
(
v
->
mdfd_vfd
,
nblocks
*
BLCKSZ
)
<
0
)
if
(
FileTruncate
(
v
->
mdfd_vfd
,
nblocks
*
BLCKSZ
)
<
0
)
return
-
1
;
return
-
1
;
v
->
mdfd_lstbcnt
=
nblocks
;
#endif
return
nblocks
;
return
nblocks
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment