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

Commit458a077

Browse files
committed
Support --verbose option in reindexdb.
Sawada Masahiko, reviewed by Fabrízio Mello
1 parent35fcb1b commit458a077

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

‎doc/src/sgml/ref/reindexdb.sgml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>reindexdb</command>
2525
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26-
26+
<arg rep="repeat"><replaceable>option</replaceable></arg>
27+
2728
<arg choice="plain" rep="repeat">
2829
<arg choice="opt">
2930
<group choice="plain">
@@ -60,6 +61,8 @@ PostgreSQL documentation
6061
<cmdsynopsis>
6162
<command>reindexdb</command>
6263
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
64+
<arg rep="repeat"><replaceable>option</replaceable></arg>
65+
6366
<group choice="plain">
6467
<arg choice="plain"><option>--all</option></arg>
6568
<arg choice="plain"><option>-a</option></arg>
@@ -69,6 +72,8 @@ PostgreSQL documentation
6972
<cmdsynopsis>
7073
<command>reindexdb</command>
7174
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
75+
<arg rep="repeat"><replaceable>option</replaceable></arg>
76+
7277
<group choice="plain">
7378
<arg choice="plain"><option>--system</option></arg>
7479
<arg choice="plain"><option>-s</option></arg>
@@ -195,6 +200,16 @@ PostgreSQL documentation
195200
</listitem>
196201
</varlistentry>
197202

203+
<varlistentry>
204+
<term><option>-v</></term>
205+
<term><option>--verbose</></term>
206+
<listitem>
207+
<para>
208+
Print detailed information during processing.
209+
</para>
210+
</listitem>
211+
</varlistentry>
212+
198213
<varlistentry>
199214
<term><option>-V</></term>
200215
<term><option>--version</></term>

‎src/bin/scripts/reindexdb.c

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ static void reindex_one_database(const char *name, const char *dbname,
1818
constchar*type,constchar*host,
1919
constchar*port,constchar*username,
2020
enumtrivalueprompt_password,constchar*progname,
21-
boolecho);
21+
boolecho,boolverbose);
2222
staticvoidreindex_all_databases(constchar*maintenance_db,
2323
constchar*host,constchar*port,
2424
constchar*username,enumtrivalueprompt_password,
2525
constchar*progname,boolecho,
26-
boolquiet);
26+
boolquiet,boolverbose);
2727
staticvoidreindex_system_catalogs(constchar*dbname,
2828
constchar*host,constchar*port,
2929
constchar*username,enumtrivalueprompt_password,
30-
constchar*progname,boolecho);
30+
constchar*progname,boolecho,boolverbose);
3131
staticvoidhelp(constchar*progname);
3232

3333
int
@@ -47,6 +47,7 @@ main(int argc, char *argv[])
4747
{"system",no_argument,NULL,'s'},
4848
{"table",required_argument,NULL,'t'},
4949
{"index",required_argument,NULL,'i'},
50+
{"verbose",no_argument,NULL,'v'},
5051
{"maintenance-db",required_argument,NULL,2},
5152
{NULL,0,NULL,0}
5253
};
@@ -65,6 +66,7 @@ main(int argc, char *argv[])
6566
boolalldb= false;
6667
boolecho= false;
6768
boolquiet= false;
69+
boolverbose= false;
6870
SimpleStringListindexes= {NULL,NULL};
6971
SimpleStringListtables= {NULL,NULL};
7072
SimpleStringListschemas= {NULL,NULL};
@@ -75,7 +77,7 @@ main(int argc, char *argv[])
7577
handle_help_version_opts(argc,argv,"reindexdb",help);
7678

7779
/* process command-line options */
78-
while ((c=getopt_long(argc,argv,"h:p:U:wWeqS:d:ast:i:",long_options,&optindex))!=-1)
80+
while ((c=getopt_long(argc,argv,"h:p:U:wWeqS:d:ast:i:v",long_options,&optindex))!=-1)
7981
{
8082
switch (c)
8183
{
@@ -118,6 +120,9 @@ main(int argc, char *argv[])
118120
case'i':
119121
simple_string_list_append(&indexes,optarg);
120122
break;
123+
case'v':
124+
verbose= true;
125+
break;
121126
case2:
122127
maintenance_db=pg_strdup(optarg);
123128
break;
@@ -176,7 +181,7 @@ main(int argc, char *argv[])
176181
}
177182

178183
reindex_all_databases(maintenance_db,host,port,username,
179-
prompt_password,progname,echo,quiet);
184+
prompt_password,progname,echo,quiet,verbose);
180185
}
181186
elseif (syscatalog)
182187
{
@@ -207,7 +212,7 @@ main(int argc, char *argv[])
207212
}
208213

209214
reindex_system_catalogs(dbname,host,port,username,prompt_password,
210-
progname,echo);
215+
progname,echo,verbose);
211216
}
212217
else
213218
{
@@ -228,7 +233,7 @@ main(int argc, char *argv[])
228233
for (cell=schemas.head;cell;cell=cell->next)
229234
{
230235
reindex_one_database(cell->val,dbname,"SCHEMA",host,port,
231-
username,prompt_password,progname,echo);
236+
username,prompt_password,progname,echo,verbose);
232237
}
233238
}
234239

@@ -239,7 +244,7 @@ main(int argc, char *argv[])
239244
for (cell=indexes.head;cell;cell=cell->next)
240245
{
241246
reindex_one_database(cell->val,dbname,"INDEX",host,port,
242-
username,prompt_password,progname,echo);
247+
username,prompt_password,progname,echo,verbose);
243248
}
244249
}
245250
if (tables.head!=NULL)
@@ -249,13 +254,13 @@ main(int argc, char *argv[])
249254
for (cell=tables.head;cell;cell=cell->next)
250255
{
251256
reindex_one_database(cell->val,dbname,"TABLE",host,port,
252-
username,prompt_password,progname,echo);
257+
username,prompt_password,progname,echo,verbose);
253258
}
254259
}
255260
/* reindex database only if neither index nor table nor schema is specified */
256261
if (indexes.head==NULL&&tables.head==NULL&&schemas.head==NULL)
257262
reindex_one_database(dbname,dbname,"DATABASE",host,port,
258-
username,prompt_password,progname,echo);
263+
username,prompt_password,progname,echo,verbose);
259264
}
260265

261266
exit(0);
@@ -264,7 +269,8 @@ main(int argc, char *argv[])
264269
staticvoid
265270
reindex_one_database(constchar*name,constchar*dbname,constchar*type,
266271
constchar*host,constchar*port,constchar*username,
267-
enumtrivalueprompt_password,constchar*progname,boolecho)
272+
enumtrivalueprompt_password,constchar*progname,boolecho,
273+
boolverbose)
268274
{
269275
PQExpBufferDatasql;
270276

@@ -273,6 +279,10 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
273279
initPQExpBuffer(&sql);
274280

275281
appendPQExpBufferStr(&sql,"REINDEX");
282+
283+
if (verbose)
284+
appendPQExpBufferStr(&sql," (VERBOSE)");
285+
276286
if (strcmp(type,"TABLE")==0)
277287
appendPQExpBuffer(&sql," TABLE %s",name);
278288
elseif (strcmp(type,"INDEX")==0)
@@ -312,7 +322,7 @@ static void
312322
reindex_all_databases(constchar*maintenance_db,
313323
constchar*host,constchar*port,
314324
constchar*username,enumtrivalueprompt_password,
315-
constchar*progname,boolecho,boolquiet)
325+
constchar*progname,boolecho,boolquiet,boolverbose)
316326
{
317327
PGconn*conn;
318328
PGresult*result;
@@ -334,7 +344,7 @@ reindex_all_databases(const char *maintenance_db,
334344
}
335345

336346
reindex_one_database(dbname,dbname,"DATABASE",host,port,username,
337-
prompt_password,progname,echo);
347+
prompt_password,progname,echo,verbose);
338348
}
339349

340350
PQclear(result);
@@ -343,15 +353,20 @@ reindex_all_databases(const char *maintenance_db,
343353
staticvoid
344354
reindex_system_catalogs(constchar*dbname,constchar*host,constchar*port,
345355
constchar*username,enumtrivalueprompt_password,
346-
constchar*progname,boolecho)
356+
constchar*progname,boolecho,boolverbose)
347357
{
348358
PQExpBufferDatasql;
349359

350360
PGconn*conn;
351361

352362
initPQExpBuffer(&sql);
353363

354-
appendPQExpBuffer(&sql,"REINDEX SYSTEM %s;",dbname);
364+
appendPQExpBuffer(&sql,"REINDEX");
365+
366+
if (verbose)
367+
appendPQExpBuffer(&sql," (VERBOSE)");
368+
369+
appendPQExpBuffer(&sql," SYSTEM %s;",dbname);
355370

356371
conn=connectDatabase(dbname,host,port,username,prompt_password,
357372
progname, false);
@@ -381,6 +396,7 @@ help(const char *progname)
381396
printf(_(" -s, --system reindex system catalogs\n"));
382397
printf(_(" -S, --schema=SCHEMA recreate specific schema(s) only\n"));
383398
printf(_(" -t, --table=TABLE reindex specific table(s) only\n"));
399+
printf(_(" -v, --verbose write a lot of output\n"));
384400
printf(_(" -V, --version output version information, then exit\n"));
385401
printf(_(" -?, --help show this help, then exit\n"));
386402
printf(_("\nConnection options:\n"));

‎src/bin/scripts/t/090_reindexdb.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33
use TestLib;
4-
use Test::Moretests=>18;
4+
use Test::Moretests=>20;
55

66
program_help_ok('reindexdb');
77
program_version_ok('reindexdb');
@@ -35,3 +35,7 @@
3535
['reindexdb','-s','postgres' ],
3636
qr/statement: REINDEX SYSTEM postgres;/,
3737
'reindex system tables');
38+
issues_sql_like(
39+
['reindexdb','-v','-t','test1','postgres' ],
40+
qr/statement: REINDEX\(VERBOSE\) TABLE test1;/,
41+
'reindex with verbose output');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp