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
f6923ff3
Commit
f6923ff3
authored
May 25, 2001
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Oops, only wanted python change in the last commit. Backing out.
parent
dffb6736
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
208 deletions
+15
-208
doc/src/sgml/ref/vacuum.sgml
doc/src/sgml/ref/vacuum.sgml
+2
-3
src/backend/access/transam/varsup.c
src/backend/access/transam/varsup.c
+1
-45
src/backend/commands/vacuum.c
src/backend/commands/vacuum.c
+1
-81
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+1
-54
src/backend/storage/file/fd.c
src/backend/storage/file/fd.c
+6
-14
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+1
-2
src/include/access/transam.h
src/include/access/transam.h
+1
-2
src/include/storage/fd.h
src/include/storage/fd.h
+1
-3
src/include/storage/proc.h
src/include/storage/proc.h
+1
-4
No files found.
doc/src/sgml/ref/vacuum.sgml
View file @
f6923ff3
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.1
5 2001/05/25 15:34:49
momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.1
6 2001/05/25 15:45:31
momjian Exp $
Postgres documentation
-->
...
...
@@ -154,8 +154,7 @@ NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
<para>
With no parameter, <command>VACUUM</command> processes every table in the
current database. It also detects any extraneous files in the
database directory. With a parameter, <command>VACUUM</command> processes
current database. With a parameter, <command>VACUUM</command> processes
only that table.
</para>
...
...
src/backend/access/transam/varsup.c
View file @
f6923ff3
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 2000, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.
39 2001/05/25 15:34:49
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.
40 2001/05/25 15:45:32
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,10 +16,7 @@
#include "access/transam.h"
#include "access/xlog.h"
#include "storage/proc.h"
#include "storage/sinval.h"
#include "storage/sinvaladt.h"
extern
SISeg
*
shmInvalBuffer
;
/* Number of XIDs and OIDs to prefetch (preallocate) per XLOG write */
#define VAR_XID_PREFETCH 1024
...
...
@@ -146,44 +143,3 @@ CheckMaxObjectId(Oid assigned_oid)
SpinRelease
(
OidGenLockId
);
}
/*
* GetMinBackendOid -- returns lowest oid stored on startup of
* each backend.
*/
Oid
GetMinStartupOid
(
void
)
{
SISeg
*
segP
=
shmInvalBuffer
;
ProcState
*
stateP
=
segP
->
procState
;
int
index
;
Oid
min_oid
;
/* prime with current oid, no need for lock */
min_oid
=
ShmemVariableCache
->
nextOid
;
SpinAcquire
(
SInvalLock
);
for
(
index
=
0
;
index
<
segP
->
lastBackend
;
index
++
)
{
SHMEM_OFFSET
pOffset
=
stateP
[
index
].
procStruct
;
if
(
pOffset
!=
INVALID_OFFSET
)
{
PROC
*
proc
=
(
PROC
*
)
MAKE_PTR
(
pOffset
);
Oid
proc_oid
;
proc_oid
=
proc
->
startOid
;
/* we don't use spin-locking in
* AbortTransaction() ! */
if
(
proc
==
MyProc
||
proc_oid
<=
BootstrapObjectIdData
)
continue
;
if
(
proc_oid
<
min_oid
)
min_oid
=
proc_oid
;
}
}
SpinRelease
(
SInvalLock
);
return
min_oid
;
}
src/backend/commands/vacuum.c
View file @
f6923ff3
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.19
4 2001/05/25 15:34:49
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.19
5 2001/05/25 15:45:32
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,12 +16,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/file.h>
#include <sys/stat.h>
...
...
@@ -33,7 +30,6 @@
#include "access/genam.h"
#include "access/heapam.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
#include "catalog/catname.h"
...
...
@@ -163,7 +159,6 @@ static int vac_cmp_vtlinks(const void *left, const void *right);
static
bool
enough_space
(
VacPage
vacpage
,
Size
len
);
static
void
init_rusage
(
VacRUsage
*
ru0
);
static
char
*
show_rusage
(
VacRUsage
*
ru0
);
static
void
report_orphans
(
void
);
/*
...
...
@@ -241,10 +236,6 @@ vacuum(VacuumStmt *vacstmt)
/* clean up */
vacuum_shutdown
();
if
(
VacRelName
==
NULL
)
report_orphans
();
}
/*
...
...
@@ -2655,74 +2646,3 @@ show_rusage(VacRUsage *ru0)
return
result
;
}
/*
* report_orphans
*
* Report files that are not referenced by any pg_class.relfilenode.
* Could be caused by backend crash no cleaning up.
*/
static
void
report_orphans
(
void
)
{
DIR
*
db_dir
;
struct
dirent
*
db_de
;
Relation
rel
;
TupleDesc
tupdesc
;
HeapScanDesc
scan
;
HeapTuple
tuple
;
Oid
dir_file_oid
;
Oid
rel_file_oid
;
Datum
d
;
bool
n
;
bool
match_found
;
char
cwd
[
MAXPGPATH
];
getcwd
(
cwd
,
MAXPGPATH
);
db_dir
=
opendir
(
"."
);
rel
=
heap_openr
(
RelationRelationName
,
AccessShareLock
);
Assert
(
db_dir
);
/*
* Cycle through directory and check each file against
* pg_class.relfilenode.
* XXX This is O(n^2). Is it too slow? bjm
*/
while
((
db_de
=
readdir
(
db_dir
))
!=
NULL
)
{
if
(
strspn
(
db_de
->
d_name
,
"0123456789"
)
==
strlen
(
db_de
->
d_name
))
{
dir_file_oid
=
(
Oid
)
strtoul
((
db_de
->
d_name
),
NULL
,
10
);
if
(
dir_file_oid
>=
GetMinStartupOid
()
||
dir_file_oid
<=
BootstrapObjectIdData
)
continue
;
tupdesc
=
RelationGetDescr
(
rel
);
match_found
=
false
;
scan
=
heap_beginscan
(
rel
,
false
,
SnapshotNow
,
0
,
(
ScanKey
)
NULL
);
while
(
HeapTupleIsValid
(
tuple
=
heap_getnext
(
scan
,
0
)))
{
d
=
heap_getattr
(
tuple
,
Anum_pg_class_relfilenode
,
tupdesc
,
&
n
);
rel_file_oid
=
DatumGetObjectId
(
d
);
if
(
dir_file_oid
==
rel_file_oid
)
{
match_found
=
true
;
break
;
}
}
heap_endscan
(
scan
);
/* make sure there was no oid wrap-around during the scan */
if
(
!
match_found
&&
dir_file_oid
<=
ShmemVariableCache
->
nextOid
)
elog
(
NOTICE
,
"Unreferenced file found in database directory:
\n\t
%s/%s"
,
cwd
,
db_de
->
d_name
);
/* Maybe one day we can unlink too. bjm 2001-05-24 */
}
}
heap_close
(
rel
,
AccessShareLock
);
closedir
(
db_dir
);
}
src/backend/postmaster/postmaster.c
View file @
f6923ff3
...
...
@@ -28,7 +28,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.21
3 2001/05/25 15:34:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.21
4 2001/05/25 15:45:33
momjian Exp $
*
* NOTES
*
...
...
@@ -58,7 +58,6 @@
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <errno.h>
...
...
@@ -244,7 +243,6 @@ static void RandomSalt(char *salt);
static
void
SignalChildren
(
int
signal
);
static
int
CountChildren
(
void
);
static
bool
CreateOptsFile
(
int
argc
,
char
*
argv
[]);
static
void
RemovePgSorttemp
(
void
);
static
pid_t
SSDataBase
(
int
xlop
);
...
...
@@ -597,9 +595,6 @@ PostmasterMain(int argc, char *argv[])
if
(
!
CreateDataDirLockFile
(
DataDir
,
true
))
ExitPostmaster
(
1
);
/* Remove old sort files */
RemovePgSorttemp
();
/*
* Establish input sockets.
*/
...
...
@@ -2455,51 +2450,3 @@ CreateOptsFile(int argc, char *argv[])
fclose
(
fp
);
return
true
;
}
/*
* Remove old sort files
*/
static
void
RemovePgSorttemp
(
void
)
{
char
db_path
[
MAXPGPATH
];
char
temp_path
[
MAXPGPATH
];
char
rm_path
[
MAXPGPATH
];
DIR
*
db_dir
;
DIR
*
temp_dir
;
struct
dirent
*
db_de
;
struct
dirent
*
temp_de
;
/*
* Cycle through pg_tempsort for all databases and
* and remove old sort files.
*/
/* trailing slash forces symlink following */
snprintf
(
db_path
,
sizeof
(
db_path
),
"%s/base/"
,
DataDir
);
if
((
db_dir
=
opendir
(
db_path
))
!=
NULL
)
{
while
((
db_de
=
readdir
(
db_dir
))
!=
NULL
)
{
snprintf
(
temp_path
,
sizeof
(
temp_path
),
"%s/%s/%s/"
,
db_path
,
db_de
->
d_name
,
SORT_TEMP_DIR
);
if
((
temp_dir
=
opendir
(
temp_path
))
!=
NULL
)
{
while
((
temp_de
=
readdir
(
temp_dir
))
!=
NULL
)
{
if
(
strspn
(
temp_de
->
d_name
,
"0123456789."
)
==
strlen
(
temp_de
->
d_name
))
{
snprintf
(
rm_path
,
sizeof
(
temp_path
),
"%s/%s/%s/%s"
,
db_path
,
db_de
->
d_name
,
SORT_TEMP_DIR
,
temp_de
->
d_name
);
unlink
(
rm_path
);
}
}
closedir
(
temp_dir
);
}
}
closedir
(
db_dir
);
}
}
src/backend/storage/file/fd.c
View file @
f6923ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.7
7 2001/05/25 15:34:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.7
8 2001/05/25 15:45:33
momjian Exp $
*
* NOTES:
*
...
...
@@ -742,29 +742,21 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode)
File
OpenTemporaryFile
(
void
)
{
char
tempfile
path
[
128
];
char
tempfile
name
[
64
];
File
file
;
/*
* Generate a tempfile name that's unique within the current
* transaction
*/
snprintf
(
tempfilepath
,
sizeof
(
tempfilepath
),
"%s%c%d.%ld"
,
SORT_TEMP_DIR
,
SEP_CHAR
,
MyProcPid
,
tempFileCounter
++
);
snprintf
(
tempfilename
,
sizeof
(
tempfilename
),
"pg_sorttemp%d.%ld"
,
MyProcPid
,
tempFileCounter
++
);
/* Open the file */
file
=
FileNameOpenFile
(
tempfile
path
,
file
=
FileNameOpenFile
(
tempfile
name
,
O_RDWR
|
O_CREAT
|
O_TRUNC
|
PG_BINARY
,
0600
);
if
(
file
<=
0
)
{
/* mkdir could fail if some one else already created it */
mkdir
(
SORT_TEMP_DIR
,
S_IRWXU
);
file
=
FileNameOpenFile
(
tempfilepath
,
O_RDWR
|
O_CREAT
|
O_TRUNC
|
PG_BINARY
,
0600
);
if
(
file
<=
0
)
elog
(
ERROR
,
"Failed to create temporary file %s"
,
tempfilepath
);
}
elog
(
ERROR
,
"Failed to create temporary file %s"
,
tempfilename
);
/* Mark it for deletion at close or EOXact */
VfdCache
[
file
].
fdstate
|=
FD_TEMPORARY
;
...
...
src/backend/storage/lmgr/proc.c
View file @
f6923ff3
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.10
1 2001/05/25 15:34:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.10
2 2001/05/25 15:45:33
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -261,7 +261,6 @@ InitProcess(void)
MyProc
->
databaseId
=
MyDatabaseId
;
MyProc
->
xid
=
InvalidTransactionId
;
MyProc
->
xmin
=
InvalidTransactionId
;
MyProc
->
startOid
=
ShmemVariableCache
->
nextOid
;
MyProc
->
waitLock
=
NULL
;
MyProc
->
waitHolder
=
NULL
;
SHMQueueInit
(
&
(
MyProc
->
procHolders
));
...
...
src/include/access/transam.h
View file @
f6923ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: transam.h,v 1.3
4 2001/05/25 15:34:50
momjian Exp $
* $Id: transam.h,v 1.3
5 2001/05/25 15:45:33
momjian Exp $
*
* NOTES
* Transaction System Version 101 now support proper oid
...
...
@@ -133,7 +133,6 @@ extern void GetNewTransactionId(TransactionId *xid);
extern
void
ReadNewTransactionId
(
TransactionId
*
xid
);
extern
void
GetNewObjectId
(
Oid
*
oid_return
);
extern
void
CheckMaxObjectId
(
Oid
assigned_oid
);
extern
Oid
GetMinStartupOid
(
void
);
/* ----------------
* global variable extern declarations
...
...
src/include/storage/fd.h
View file @
f6923ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: fd.h,v 1.2
8 2001/05/25 15:34:50
momjian Exp $
* $Id: fd.h,v 1.2
9 2001/05/25 15:45:34
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -39,8 +39,6 @@
* FileSeek uses the standard UNIX lseek(2) flags.
*/
#define SORT_TEMP_DIR "pg_sorttemp"
typedef
char
*
FileName
;
typedef
int
File
;
...
...
src/include/storage/proc.h
View file @
f6923ff3
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: proc.h,v 1.4
2 2001/05/25 15:34:50
momjian Exp $
* $Id: proc.h,v 1.4
3 2001/05/25 15:45:34
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -50,9 +50,6 @@ struct proc
* were starting our xact: vacuum must not
* remove tuples deleted by xid >= xmin ! */
Oid
startOid
;
/* oid at startup, used by vacuum to find
* orphaned files.
*/
/*
* XLOG location of first XLOG record written by this backend's
* current transaction. If backend is not in a transaction or hasn't
...
...
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