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

Commit9f07f8f

Browse files
author
Thomas G. Lockhart
committed
Add "vacuumdb" utility to make it easier to clean databases.
Also supports the "analyze" mode, with or without specifying tables and columns.
1 parent69ff5b9 commit9f07f8f

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

‎src/bin/vacuumdb/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile--
4+
# Makefile for bin/vacuumdb
5+
#
6+
# Copyright (c) 1994, Regents of the University of California
7+
#
8+
#
9+
# IDENTIFICATION
10+
# $Header: /cvsroot/pgsql/src/bin/vacuumdb/Attic/Makefile,v 1.1 1998/11/14 01:58:14 thomas Exp $
11+
#
12+
#-------------------------------------------------------------------------
13+
14+
SRCDIR= ../..
15+
include ../../Makefile.global
16+
17+
all: vacuumdb
18+
19+
install: vacuumdb
20+
$(INSTALL)$(INSTL_EXE_OPTS)$<$(BINDIR)/$<
21+
22+
clean:
23+
24+
depdepend:

‎src/bin/vacuumdb/vacuumdb

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/sh
2+
#-------------------------------------------------------------------------
3+
#
4+
# vacuumdb--
5+
# vacuum a postgres database
6+
#
7+
# this program runs the monitor with the "-c" option to vacuum
8+
# the requested database.
9+
#
10+
# Copyright (c) 1994, Regents of the University of California
11+
#
12+
#
13+
# IDENTIFICATION
14+
# $Header: /cvsroot/pgsql/src/bin/vacuumdb/Attic/vacuumdb,v 1.1 1998/11/14 01:58:15 thomas Exp $
15+
#
16+
#-------------------------------------------------------------------------
17+
18+
CMDNAME=`basename$0`
19+
20+
if [-z"$USER" ];then
21+
if [-z"$LOGNAME" ];then
22+
if [-z"`whoami`" ];then
23+
echo"$CMDNAME: cannot determine user name"
24+
exit 1
25+
fi
26+
else
27+
USER=$LOGNAME
28+
export USER
29+
fi
30+
fi
31+
32+
dbname=$USER
33+
34+
PASSWDOPT="";
35+
36+
whiletest -n"$1"
37+
do
38+
case$1in
39+
--help) usage=1;;
40+
--analyze) analyze="analyze";;
41+
--table) table=$2;shift;;
42+
--verbose) verbose="verbose";;
43+
44+
-a) AUTHSYS=$2;shift;;
45+
-h) PGHOST=$2;shift;;
46+
-p) PGPORT=$2;shift;;
47+
-t) table=$2;shift;;
48+
-u) PASSWDOPT=$1;;
49+
-v) verbose="verbose";;
50+
-z) analyze="analyze";;
51+
-*)echo"$CMDNAME: unrecognized parameter$1"; usage=1;;
52+
*) dbname=$1;;
53+
esac
54+
shift;
55+
done
56+
57+
if ["$usage" ];then
58+
echo"Usage:$CMDNAME -a <authtype> -h <server> -p <portnumber> --analyze --verbose [--table 'table[(cols)]'] [dbname]"
59+
exit 1
60+
fi
61+
62+
if [-z"$AUTHSYS" ];then
63+
AUTHOPT=""
64+
else
65+
AUTHOPT="-a$AUTHSYS"
66+
fi
67+
68+
if [-z"$PGHOST" ];then
69+
PGHOSTOPT=""
70+
else
71+
PGHOSTOPT="-h$PGHOST"
72+
fi
73+
74+
if [-z"$PGPORT" ];then
75+
PGPORTOPT=""
76+
else
77+
PGPORTOPT="-p$PGPORT"
78+
fi
79+
80+
if [-z"$dbpath" ];then
81+
location=""
82+
else
83+
#if [ ! -d "$dbpath"/base ]; then
84+
#echo "$CMDNAME: database creation failed on $dbname."
85+
#echo "directory $dbpath/base not found."
86+
#exit 1
87+
#fi
88+
location="with location = '$dbpath'"
89+
fi
90+
91+
psql$PASSWDOPT -tq$AUTHOPT$PGHOSTOPT$PGPORTOPT -c"vacuum$verbose$analyze$table"$dbname
92+
93+
if [$?-ne 0 ];then
94+
echo"$CMDNAME: database vacuum failed on$dbname."
95+
exit 1
96+
fi
97+
98+
exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp