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

Commita378555

Browse files
committed
CLUSTER VERBOSE and corresponding clusterdb --verbose option
Jim Cox and Peter Eisentraut
1 parent6f6a6d8 commita378555

File tree

8 files changed

+71
-32
lines changed

8 files changed

+71
-32
lines changed

‎doc/src/sgml/ref/cluster.sgml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/cluster.sgml,v 1.45 2008/11/14 10:22:45 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/cluster.sgml,v 1.46 2008/11/24 08:46:03 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -21,8 +21,8 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
CLUSTER <replaceable class="PARAMETER">tablename</replaceable> [ USING <replaceable class="PARAMETER">indexname</replaceable> ]
25-
CLUSTER
24+
CLUSTER[VERBOSE]<replaceable class="PARAMETER">tablename</replaceable> [ USING <replaceable class="PARAMETER">indexname</replaceable> ]
25+
CLUSTER [VERBOSE]
2626
</synopsis>
2727
</refsynopsisdiv>
2828

@@ -95,6 +95,15 @@ CLUSTER
9595
</para>
9696
</listitem>
9797
</varlistentry>
98+
99+
<varlistentry>
100+
<term><literal>VERBOSE</literal></term>
101+
<listitem>
102+
<para>
103+
Prints a progress report as each table is clustered.
104+
</para>
105+
</listitem>
106+
</varlistentry>
98107
</variablelist>
99108
</refsect1>
100109

‎doc/src/sgml/ref/clusterdb.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/clusterdb.sgml,v 1.23 2007/12/11 19:57:32 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/clusterdb.sgml,v 1.24 2008/11/24 08:46:03 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -23,12 +23,14 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>clusterdb</command>
2525
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26+
<group><arg>--verbose</arg><arg>-v</arg></group>
2627
<arg>--table | -t <replaceable>table</replaceable> </arg>
2728
<arg><replaceable>dbname</replaceable></arg>
2829
<sbr>
2930
<command>clusterdb</command>
3031
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
3132
<group><arg>--all</arg><arg>-a</arg></group>
33+
<group><arg>--verbose</arg><arg>-v</arg></group>
3234
</cmdsynopsis>
3335
</refsynopsisdiv>
3436

@@ -117,6 +119,16 @@ PostgreSQL documentation
117119
</listitem>
118120
</varlistentry>
119121

122+
<varlistentry>
123+
<term><option>-v</></term>
124+
<term><option>--verbose</></term>
125+
<listitem>
126+
<para>
127+
Print detailed information during processing.
128+
</para>
129+
</listitem>
130+
</varlistentry>
131+
120132
</variablelist>
121133
</para>
122134

‎src/backend/commands/cluster.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.178 2008/10/14 17:19:50 alvherre Exp $
14+
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.179 2008/11/24 08:46:03 petere Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -61,7 +61,7 @@ typedef struct
6161
}RelToCluster;
6262

6363

64-
staticvoidcluster_rel(RelToCluster*rv,boolrecheck);
64+
staticvoidcluster_rel(RelToCluster*rv,boolrecheck,boolverbose);
6565
staticvoidrebuild_relation(RelationOldHeap,OidindexOid);
6666
staticTransactionIdcopy_heap_data(OidOIDNewHeap,OidOIDOldHeap,OidOIDOldIndex);
6767
staticList*get_tables_to_cluster(MemoryContextcluster_context);
@@ -177,7 +177,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
177177
heap_close(rel,NoLock);
178178

179179
/* Do the job */
180-
cluster_rel(&rvtc, false);
180+
cluster_rel(&rvtc, false,stmt->verbose);
181181
}
182182
else
183183
{
@@ -226,7 +226,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
226226
StartTransactionCommand();
227227
/* functions in indexes may want a snapshot set */
228228
PushActiveSnapshot(GetTransactionSnapshot());
229-
cluster_rel(rvtc, true);
229+
cluster_rel(rvtc, true,stmt->verbose);
230230
PopActiveSnapshot();
231231
CommitTransactionCommand();
232232
}
@@ -254,7 +254,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
254254
* them incrementally while we load the table.
255255
*/
256256
staticvoid
257-
cluster_rel(RelToCluster*rvtc,boolrecheck)
257+
cluster_rel(RelToCluster*rvtc,boolrecheck,boolverbose)
258258
{
259259
RelationOldHeap;
260260

@@ -344,6 +344,10 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
344344
check_index_is_clusterable(OldHeap,rvtc->indexOid,recheck);
345345

346346
/* rebuild_relation does all the dirty work */
347+
ereport(verbose ?INFO :DEBUG2,
348+
(errmsg("clustering \"%s.%s\"",
349+
get_namespace_name(RelationGetNamespace(OldHeap)),
350+
RelationGetRelationName(OldHeap))));
347351
rebuild_relation(OldHeap,rvtc->indexOid);
348352

349353
/* NB: rebuild_relation does heap_close() on OldHeap */

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.412 2008/11/15 19:43:46 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.413 2008/11/24 08:46:03 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -2293,6 +2293,7 @@ _copyClusterStmt(ClusterStmt *from)
22932293

22942294
COPY_NODE_FIELD(relation);
22952295
COPY_STRING_FIELD(indexname);
2296+
COPY_SCALAR_FIELD(verbose) ;
22962297

22972298
returnnewnode;
22982299
}

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
2424
* IDENTIFICATION
25-
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.337 2008/11/15 19:43:46 tgl Exp $
25+
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.338 2008/11/24 08:46:03 petere Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -1032,6 +1032,7 @@ _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
10321032
{
10331033
COMPARE_NODE_FIELD(relation);
10341034
COMPARE_STRING_FIELD(indexname);
1035+
COMPARE_SCALAR_FIELD(verbose);
10351036

10361037
return true;
10371038
}

‎src/backend/parser/gram.y

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.639 2008/11/21 11:47:55 petere Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.640 2008/11/24 08:46:03 petere Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -5781,33 +5781,36 @@ CreateConversionStmt:
57815781
/*****************************************************************************
57825782
*
57835783
*QUERY:
5784-
*CLUSTER <qualified_name> [ USING <index_name> ]
5785-
*CLUSTER
5786-
*CLUSTER <index_name> ON <qualified_name> (for pre-8.3)
5784+
*CLUSTER[VERBOSE]<qualified_name> [ USING <index_name> ]
5785+
*CLUSTER [VERBOSE]
5786+
*CLUSTER[VERBOSE]<index_name> ON <qualified_name> (for pre-8.3)
57875787
*
57885788
*****************************************************************************/
57895789

57905790
ClusterStmt:
5791-
CLUSTER qualified_name cluster_index_specification
5791+
CLUSTERopt_verbosequalified_name cluster_index_specification
57925792
{
57935793
ClusterStmt *n = makeNode(ClusterStmt);
5794-
n->relation =$2;
5795-
n->indexname =$3;
5794+
n->relation =$3;
5795+
n->indexname =$4;
5796+
n->verbose =$2;
57965797
$$ = (Node*)n;
57975798
}
5798-
| CLUSTER
5799+
| CLUSTER opt_verbose
57995800
{
58005801
ClusterStmt *n = makeNode(ClusterStmt);
58015802
n->relation =NULL;
58025803
n->indexname =NULL;
5804+
n->verbose =$2;
58035805
$$ = (Node*)n;
58045806
}
58055807
/* kept for pre-8.3 compatibility*/
5806-
| CLUSTER index_name ON qualified_name
5808+
| CLUSTERopt_verboseindex_name ON qualified_name
58075809
{
58085810
ClusterStmt *n = makeNode(ClusterStmt);
5809-
n->relation =$4;
5810-
n->indexname =$2;
5811+
n->relation =$5;
5812+
n->indexname =$3;
5813+
n->verbose =$2;
58115814
$$ = (Node*)n;
58125815
}
58135816
;

‎src/bin/scripts/clusterdb.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2008, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.20 2008/01/01 19:45:56 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.21 2008/11/24 08:46:04 petere Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -14,11 +14,11 @@
1414
#include"dumputils.h"
1515

1616

17-
staticvoidcluster_one_database(constchar*dbname,constchar*table,
17+
staticvoidcluster_one_database(constchar*dbname,boolverbose,constchar*table,
1818
constchar*host,constchar*port,
1919
constchar*username,boolpassword,
2020
constchar*progname,boolecho);
21-
staticvoidcluster_all_databases(constchar*host,constchar*port,
21+
staticvoidcluster_all_databases(boolverbose,constchar*host,constchar*port,
2222
constchar*username,boolpassword,
2323
constchar*progname,boolecho,boolquiet);
2424

@@ -38,6 +38,7 @@ main(int argc, char *argv[])
3838
{"dbname",required_argument,NULL,'d'},
3939
{"all",no_argument,NULL,'a'},
4040
{"table",required_argument,NULL,'t'},
41+
{"verbose",no_argument,NULL,'v'},
4142
{NULL,0,NULL,0}
4243
};
4344

@@ -54,13 +55,14 @@ main(int argc, char *argv[])
5455
boolquiet= false;
5556
boolalldb= false;
5657
char*table=NULL;
58+
boolverbose= false;
5759

5860
progname=get_progname(argv[0]);
5961
set_pglocale_pgservice(argv[0],"pgscripts");
6062

6163
handle_help_version_opts(argc,argv,"clusterdb",help);
6264

63-
while ((c=getopt_long(argc,argv,"h:p:U:Weqd:at:",long_options,&optindex))!=-1)
65+
while ((c=getopt_long(argc,argv,"h:p:U:Weqd:at:v",long_options,&optindex))!=-1)
6466
{
6567
switch (c)
6668
{
@@ -91,6 +93,9 @@ main(int argc, char *argv[])
9193
case't':
9294
table=optarg;
9395
break;
96+
case'v':
97+
verbose= true;
98+
break;
9499
default:
95100
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
96101
exit(1);
@@ -128,7 +133,7 @@ main(int argc, char *argv[])
128133
exit(1);
129134
}
130135

131-
cluster_all_databases(host,port,username,password,
136+
cluster_all_databases(verbose,host,port,username,password,
132137
progname,echo,quiet);
133138
}
134139
else
@@ -143,7 +148,7 @@ main(int argc, char *argv[])
143148
dbname=get_user_name(progname);
144149
}
145150

146-
cluster_one_database(dbname,table,
151+
cluster_one_database(dbname,verbose,table,
147152
host,port,username,password,
148153
progname,echo);
149154
}
@@ -153,7 +158,7 @@ main(int argc, char *argv[])
153158

154159

155160
staticvoid
156-
cluster_one_database(constchar*dbname,constchar*table,
161+
cluster_one_database(constchar*dbname,boolverbose,constchar*table,
157162
constchar*host,constchar*port,
158163
constchar*username,boolpassword,
159164
constchar*progname,boolecho)
@@ -165,6 +170,8 @@ cluster_one_database(const char *dbname, const char *table,
165170
initPQExpBuffer(&sql);
166171

167172
appendPQExpBuffer(&sql,"CLUSTER");
173+
if (verbose)
174+
appendPQExpBuffer(&sql," VERBOSE");
168175
if (table)
169176
appendPQExpBuffer(&sql," %s",fmtId(table));
170177
appendPQExpBuffer(&sql,";\n");
@@ -187,7 +194,7 @@ cluster_one_database(const char *dbname, const char *table,
187194

188195

189196
staticvoid
190-
cluster_all_databases(constchar*host,constchar*port,
197+
cluster_all_databases(boolverbose,constchar*host,constchar*port,
191198
constchar*username,boolpassword,
192199
constchar*progname,boolecho,boolquiet)
193200
{
@@ -209,7 +216,7 @@ cluster_all_databases(const char *host, const char *port,
209216
fflush(stdout);
210217
}
211218

212-
cluster_one_database(dbname,NULL,
219+
cluster_one_database(dbname,verbose,NULL,
213220
host,port,username,password,
214221
progname,echo);
215222
}
@@ -230,6 +237,7 @@ help(const char *progname)
230237
printf(_(" -t, --table=TABLE cluster specific table only\n"));
231238
printf(_(" -e, --echo show the commands being sent to the server\n"));
232239
printf(_(" -q, --quiet don't write any messages\n"));
240+
printf(_(" -v, --verbose write a lot of output\n"));
233241
printf(_(" --help show this help, then exit\n"));
234242
printf(_(" --version output version information, then exit\n"));
235243
printf(_("\nConnection options:\n"));

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.378 2008/11/15 19:43:46 tgl Exp $
16+
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.379 2008/11/24 08:46:04 petere Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -1949,6 +1949,7 @@ typedef struct ClusterStmt
19491949
NodeTagtype;
19501950
RangeVar*relation;/* relation being indexed, or NULL if all */
19511951
char*indexname;/* original index defined */
1952+
boolverbose;/* print progress info */
19521953
}ClusterStmt;
19531954

19541955
/* ----------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp