Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8819213

Browse files
committed
Now that the CLUSTER ALL machinery is in place, the clusterdb script can
be simplified (I'd thought that it can even be removed). This patch does that. Alvaro Herrera
1 parent 432b9b0 commit 8819213

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

doc/src/sgml/ref/clusterdb.sgml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/clusterdb.sgml,v 1.7 2003/02/19 04:06:28 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/clusterdb.sgml,v 1.8 2003/03/20 18:53:18 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -43,7 +43,7 @@ PostgreSQL documentation
4343
<para>
4444
<application>clusterdb</application> is a shell script wrapper around the
4545
backend command
46-
<xref linkend="SQL-CLUSTER" endterm="SQL-CLUSTER-title"> via
46+
<xref linkend="SQL-CLUSTER" endterm="sql-cluster-title"> via
4747
the <productname>PostgreSQL</productname> interactive terminal
4848
<xref linkend="APP-PSQL">. There is no effective
4949
difference between clustering databases via this or other methods.
@@ -53,13 +53,6 @@ PostgreSQL documentation
5353
and the <application>libpq</application> front-end library do apply.
5454
</para>
5555

56-
<para>
57-
<application>clusterdb</application> might need to connect several
58-
times to the <productname>PostgreSQL</productname> server, asking for
59-
a password each time. It is convenient to have a
60-
<filename>$HOME/.pgpass</> file in such cases.
61-
</para>
62-
6356
</refsect1>
6457

6558

@@ -202,10 +195,9 @@ PostgreSQL documentation
202195
<listitem>
203196
<para>
204197
Something went wrong. <application>clusterdb</application> is only a wrapper
205-
script. See <xref linkend="SQL-CLUSTER" endterm="SQL-CLUSTER-title">
198+
script. See <xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
206199
and <xref linkend="APP-PSQL"> for a detailed
207-
discussion of error messages and potential problems. Note that this message
208-
may appear once per table to be clustered.
200+
discussion of error messages and potential problems.
209201
</para>
210202
</listitem>
211203
</varlistentry>

src/bin/scripts/clusterdb

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/clusterdb,v 1.9 2003/02/13 05:37:44 momjian Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/clusterdb,v 1.10 2003/03/20 18:53:18 momjian Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -156,34 +156,12 @@ fi
156156
for db in $dbname
157157
do
158158
[ "$alldb" ] && echo "Clustering $db"
159-
query="SELECT nspname, pg_class.relname, pg_class_2.relname FROM pg_class, pg_class AS pg_class_2 JOIN pg_namespace ON (pg_namespace.oid=relnamespace), pg_index WHERE pg_class.oid=pg_index.indrelid AND pg_class_2.oid=pg_index.indexrelid AND pg_index.indisclustered AND pg_class.relowner=(SELECT usesysid FROM pg_user WHERE usename=current_user)"
160159
if [ -z "$table" ]; then
161-
tables=`${PATHNAME}psql $db $PSQLOPT -F: -P format=unaligned -t -c "$query"`
160+
${PATHNAME}psql $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';CLUSTER" -d $db
162161
[ "$?" -ne 0 ] && exit 1
163162
else
164-
# if tablename has a dot, use it as namespace separator
165-
if echo $table | grep -s '\.' 2>&1 >/dev/null
166-
then
167-
tbl=`echo $table | cut -d. -f2`
168-
nspc=`echo $table | cut -d. -f1`
169-
tables=`${PATHNAME}psql $db $PSQLOPT -F: -P format=unaligned -t -c "$query AND pg_class.relname='$tbl' AND nspname='$nspc'"`
170-
echo $tables
171-
else
172-
tables=`${PATHNAME}psql $db $PSQLOPT -F: -P format=unaligned -t -c "$query AND pg_class.relname='$table'"`
173-
fi
174-
fi
175-
query=
176-
for tabs in $tables
177-
do
178-
nspc=`echo $tabs | cut -d: -f1`
179-
tab=`echo $tabs | cut -d: -f2`
180-
idx=`echo $tabs | cut -d: -f3`
181-
query="$query CLUSTER $idx ON $nspc.$tab;"
182-
done
183-
${PATHNAME}psql $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';$query" -d $db
184-
if [ "$?" -ne 0 ]
185-
then
186-
echo "$CMDNAME: While clustering $db, the following failed: $query" 1>&2
163+
${PATHNAME}psql $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';CLUSTER $table" -d $db
164+
[ "$?" -ne 0 ] && exit 1
187165
fi
188166
done
189167

0 commit comments

Comments
 (0)