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
458a0770
Commit
458a0770
authored
May 15, 2015
by
Fujii Masao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support --verbose option in reindexdb.
Sawada Masahiko, reviewed by Fabrízio Mello
parent
35fcb1b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
17 deletions
+52
-17
doc/src/sgml/ref/reindexdb.sgml
doc/src/sgml/ref/reindexdb.sgml
+16
-1
src/bin/scripts/reindexdb.c
src/bin/scripts/reindexdb.c
+31
-15
src/bin/scripts/t/090_reindexdb.pl
src/bin/scripts/t/090_reindexdb.pl
+5
-1
No files found.
doc/src/sgml/ref/reindexdb.sgml
View file @
458a0770
...
@@ -23,7 +23,8 @@ PostgreSQL documentation
...
@@ -23,7 +23,8 @@ PostgreSQL documentation
<cmdsynopsis>
<cmdsynopsis>
<command>reindexdb</command>
<command>reindexdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>
<arg choice="plain" rep="repeat">
<arg choice="plain" rep="repeat">
<arg choice="opt">
<arg choice="opt">
<group choice="plain">
<group choice="plain">
...
@@ -60,6 +61,8 @@ PostgreSQL documentation
...
@@ -60,6 +61,8 @@ PostgreSQL documentation
<cmdsynopsis>
<cmdsynopsis>
<command>reindexdb</command>
<command>reindexdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>
<group choice="plain">
<group choice="plain">
<arg choice="plain"><option>--all</option></arg>
<arg choice="plain"><option>--all</option></arg>
<arg choice="plain"><option>-a</option></arg>
<arg choice="plain"><option>-a</option></arg>
...
@@ -69,6 +72,8 @@ PostgreSQL documentation
...
@@ -69,6 +72,8 @@ PostgreSQL documentation
<cmdsynopsis>
<cmdsynopsis>
<command>reindexdb</command>
<command>reindexdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>
<group choice="plain">
<group choice="plain">
<arg choice="plain"><option>--system</option></arg>
<arg choice="plain"><option>--system</option></arg>
<arg choice="plain"><option>-s</option></arg>
<arg choice="plain"><option>-s</option></arg>
...
@@ -195,6 +200,16 @@ PostgreSQL documentation
...
@@ -195,6 +200,16 @@ PostgreSQL documentation
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><option>-v</></term>
<term><option>--verbose</></term>
<listitem>
<para>
Print detailed information during processing.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><option>-V</></term>
<term><option>-V</></term>
<term><option>--version</></term>
<term><option>--version</></term>
...
...
src/bin/scripts/reindexdb.c
View file @
458a0770
...
@@ -18,16 +18,16 @@ static void reindex_one_database(const char *name, const char *dbname,
...
@@ -18,16 +18,16 @@ static void reindex_one_database(const char *name, const char *dbname,
const
char
*
type
,
const
char
*
host
,
const
char
*
type
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
);
bool
echo
,
bool
verbose
);
static
void
reindex_all_databases
(
const
char
*
maintenance_db
,
static
void
reindex_all_databases
(
const
char
*
maintenance_db
,
const
char
*
host
,
const
char
*
port
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
,
const
char
*
progname
,
bool
echo
,
bool
quiet
);
bool
quiet
,
bool
verbose
);
static
void
reindex_system_catalogs
(
const
char
*
dbname
,
static
void
reindex_system_catalogs
(
const
char
*
dbname
,
const
char
*
host
,
const
char
*
port
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
);
const
char
*
progname
,
bool
echo
,
bool
verbose
);
static
void
help
(
const
char
*
progname
);
static
void
help
(
const
char
*
progname
);
int
int
...
@@ -47,6 +47,7 @@ main(int argc, char *argv[])
...
@@ -47,6 +47,7 @@ main(int argc, char *argv[])
{
"system"
,
no_argument
,
NULL
,
's'
},
{
"system"
,
no_argument
,
NULL
,
's'
},
{
"table"
,
required_argument
,
NULL
,
't'
},
{
"table"
,
required_argument
,
NULL
,
't'
},
{
"index"
,
required_argument
,
NULL
,
'i'
},
{
"index"
,
required_argument
,
NULL
,
'i'
},
{
"verbose"
,
no_argument
,
NULL
,
'v'
},
{
"maintenance-db"
,
required_argument
,
NULL
,
2
},
{
"maintenance-db"
,
required_argument
,
NULL
,
2
},
{
NULL
,
0
,
NULL
,
0
}
{
NULL
,
0
,
NULL
,
0
}
};
};
...
@@ -65,6 +66,7 @@ main(int argc, char *argv[])
...
@@ -65,6 +66,7 @@ main(int argc, char *argv[])
bool
alldb
=
false
;
bool
alldb
=
false
;
bool
echo
=
false
;
bool
echo
=
false
;
bool
quiet
=
false
;
bool
quiet
=
false
;
bool
verbose
=
false
;
SimpleStringList
indexes
=
{
NULL
,
NULL
};
SimpleStringList
indexes
=
{
NULL
,
NULL
};
SimpleStringList
tables
=
{
NULL
,
NULL
};
SimpleStringList
tables
=
{
NULL
,
NULL
};
SimpleStringList
schemas
=
{
NULL
,
NULL
};
SimpleStringList
schemas
=
{
NULL
,
NULL
};
...
@@ -75,7 +77,7 @@ main(int argc, char *argv[])
...
@@ -75,7 +77,7 @@ main(int argc, char *argv[])
handle_help_version_opts
(
argc
,
argv
,
"reindexdb"
,
help
);
handle_help_version_opts
(
argc
,
argv
,
"reindexdb"
,
help
);
/* process command-line options */
/* process command-line options */
while
((
c
=
getopt_long
(
argc
,
argv
,
"h:p:U:wWeqS:d:ast:i:"
,
long_options
,
&
optindex
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
argv
,
"h:p:U:wWeqS:d:ast:i:
v
"
,
long_options
,
&
optindex
))
!=
-
1
)
{
{
switch
(
c
)
switch
(
c
)
{
{
...
@@ -118,6 +120,9 @@ main(int argc, char *argv[])
...
@@ -118,6 +120,9 @@ main(int argc, char *argv[])
case
'i'
:
case
'i'
:
simple_string_list_append
(
&
indexes
,
optarg
);
simple_string_list_append
(
&
indexes
,
optarg
);
break
;
break
;
case
'v'
:
verbose
=
true
;
break
;
case
2
:
case
2
:
maintenance_db
=
pg_strdup
(
optarg
);
maintenance_db
=
pg_strdup
(
optarg
);
break
;
break
;
...
@@ -176,7 +181,7 @@ main(int argc, char *argv[])
...
@@ -176,7 +181,7 @@ main(int argc, char *argv[])
}
}
reindex_all_databases
(
maintenance_db
,
host
,
port
,
username
,
reindex_all_databases
(
maintenance_db
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
,
quiet
);
prompt_password
,
progname
,
echo
,
quiet
,
verbose
);
}
}
else
if
(
syscatalog
)
else
if
(
syscatalog
)
{
{
...
@@ -207,7 +212,7 @@ main(int argc, char *argv[])
...
@@ -207,7 +212,7 @@ main(int argc, char *argv[])
}
}
reindex_system_catalogs
(
dbname
,
host
,
port
,
username
,
prompt_password
,
reindex_system_catalogs
(
dbname
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
progname
,
echo
,
verbose
);
}
}
else
else
{
{
...
@@ -228,7 +233,7 @@ main(int argc, char *argv[])
...
@@ -228,7 +233,7 @@ main(int argc, char *argv[])
for
(
cell
=
schemas
.
head
;
cell
;
cell
=
cell
->
next
)
for
(
cell
=
schemas
.
head
;
cell
;
cell
=
cell
->
next
)
{
{
reindex_one_database
(
cell
->
val
,
dbname
,
"SCHEMA"
,
host
,
port
,
reindex_one_database
(
cell
->
val
,
dbname
,
"SCHEMA"
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
username
,
prompt_password
,
progname
,
echo
,
verbose
);
}
}
}
}
...
@@ -239,7 +244,7 @@ main(int argc, char *argv[])
...
@@ -239,7 +244,7 @@ main(int argc, char *argv[])
for
(
cell
=
indexes
.
head
;
cell
;
cell
=
cell
->
next
)
for
(
cell
=
indexes
.
head
;
cell
;
cell
=
cell
->
next
)
{
{
reindex_one_database
(
cell
->
val
,
dbname
,
"INDEX"
,
host
,
port
,
reindex_one_database
(
cell
->
val
,
dbname
,
"INDEX"
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
username
,
prompt_password
,
progname
,
echo
,
verbose
);
}
}
}
}
if
(
tables
.
head
!=
NULL
)
if
(
tables
.
head
!=
NULL
)
...
@@ -249,13 +254,13 @@ main(int argc, char *argv[])
...
@@ -249,13 +254,13 @@ main(int argc, char *argv[])
for
(
cell
=
tables
.
head
;
cell
;
cell
=
cell
->
next
)
for
(
cell
=
tables
.
head
;
cell
;
cell
=
cell
->
next
)
{
{
reindex_one_database
(
cell
->
val
,
dbname
,
"TABLE"
,
host
,
port
,
reindex_one_database
(
cell
->
val
,
dbname
,
"TABLE"
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
username
,
prompt_password
,
progname
,
echo
,
verbose
);
}
}
}
}
/* reindex database only if neither index nor table nor schema is specified */
/* reindex database only if neither index nor table nor schema is specified */
if
(
indexes
.
head
==
NULL
&&
tables
.
head
==
NULL
&&
schemas
.
head
==
NULL
)
if
(
indexes
.
head
==
NULL
&&
tables
.
head
==
NULL
&&
schemas
.
head
==
NULL
)
reindex_one_database
(
dbname
,
dbname
,
"DATABASE"
,
host
,
port
,
reindex_one_database
(
dbname
,
dbname
,
"DATABASE"
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
username
,
prompt_password
,
progname
,
echo
,
verbose
);
}
}
exit
(
0
);
exit
(
0
);
...
@@ -264,7 +269,8 @@ main(int argc, char *argv[])
...
@@ -264,7 +269,8 @@ main(int argc, char *argv[])
static
void
static
void
reindex_one_database
(
const
char
*
name
,
const
char
*
dbname
,
const
char
*
type
,
reindex_one_database
(
const
char
*
name
,
const
char
*
dbname
,
const
char
*
type
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
)
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
,
bool
verbose
)
{
{
PQExpBufferData
sql
;
PQExpBufferData
sql
;
...
@@ -273,6 +279,10 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
...
@@ -273,6 +279,10 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
initPQExpBuffer
(
&
sql
);
initPQExpBuffer
(
&
sql
);
appendPQExpBufferStr
(
&
sql
,
"REINDEX"
);
appendPQExpBufferStr
(
&
sql
,
"REINDEX"
);
if
(
verbose
)
appendPQExpBufferStr
(
&
sql
,
" (VERBOSE)"
);
if
(
strcmp
(
type
,
"TABLE"
)
==
0
)
if
(
strcmp
(
type
,
"TABLE"
)
==
0
)
appendPQExpBuffer
(
&
sql
,
" TABLE %s"
,
name
);
appendPQExpBuffer
(
&
sql
,
" TABLE %s"
,
name
);
else
if
(
strcmp
(
type
,
"INDEX"
)
==
0
)
else
if
(
strcmp
(
type
,
"INDEX"
)
==
0
)
...
@@ -312,7 +322,7 @@ static void
...
@@ -312,7 +322,7 @@ static void
reindex_all_databases
(
const
char
*
maintenance_db
,
reindex_all_databases
(
const
char
*
maintenance_db
,
const
char
*
host
,
const
char
*
port
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
,
bool
quiet
)
const
char
*
progname
,
bool
echo
,
bool
quiet
,
bool
verbose
)
{
{
PGconn
*
conn
;
PGconn
*
conn
;
PGresult
*
result
;
PGresult
*
result
;
...
@@ -334,7 +344,7 @@ reindex_all_databases(const char *maintenance_db,
...
@@ -334,7 +344,7 @@ reindex_all_databases(const char *maintenance_db,
}
}
reindex_one_database
(
dbname
,
dbname
,
"DATABASE"
,
host
,
port
,
username
,
reindex_one_database
(
dbname
,
dbname
,
"DATABASE"
,
host
,
port
,
username
,
prompt_password
,
progname
,
echo
);
prompt_password
,
progname
,
echo
,
verbose
);
}
}
PQclear
(
result
);
PQclear
(
result
);
...
@@ -343,7 +353,7 @@ reindex_all_databases(const char *maintenance_db,
...
@@ -343,7 +353,7 @@ reindex_all_databases(const char *maintenance_db,
static
void
static
void
reindex_system_catalogs
(
const
char
*
dbname
,
const
char
*
host
,
const
char
*
port
,
reindex_system_catalogs
(
const
char
*
dbname
,
const
char
*
host
,
const
char
*
port
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
username
,
enum
trivalue
prompt_password
,
const
char
*
progname
,
bool
echo
)
const
char
*
progname
,
bool
echo
,
bool
verbose
)
{
{
PQExpBufferData
sql
;
PQExpBufferData
sql
;
...
@@ -351,7 +361,12 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port,
...
@@ -351,7 +361,12 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port,
initPQExpBuffer
(
&
sql
);
initPQExpBuffer
(
&
sql
);
appendPQExpBuffer
(
&
sql
,
"REINDEX SYSTEM %s;"
,
dbname
);
appendPQExpBuffer
(
&
sql
,
"REINDEX"
);
if
(
verbose
)
appendPQExpBuffer
(
&
sql
,
" (VERBOSE)"
);
appendPQExpBuffer
(
&
sql
,
" SYSTEM %s;"
,
dbname
);
conn
=
connectDatabase
(
dbname
,
host
,
port
,
username
,
prompt_password
,
conn
=
connectDatabase
(
dbname
,
host
,
port
,
username
,
prompt_password
,
progname
,
false
);
progname
,
false
);
...
@@ -381,6 +396,7 @@ help(const char *progname)
...
@@ -381,6 +396,7 @@ help(const char *progname)
printf
(
_
(
" -s, --system reindex system catalogs
\n
"
));
printf
(
_
(
" -s, --system reindex system catalogs
\n
"
));
printf
(
_
(
" -S, --schema=SCHEMA recreate specific schema(s) only
\n
"
));
printf
(
_
(
" -S, --schema=SCHEMA recreate specific schema(s) only
\n
"
));
printf
(
_
(
" -t, --table=TABLE reindex specific table(s) only
\n
"
));
printf
(
_
(
" -t, --table=TABLE reindex specific table(s) only
\n
"
));
printf
(
_
(
" -v, --verbose write a lot of output
\n
"
));
printf
(
_
(
" -V, --version output version information, then exit
\n
"
));
printf
(
_
(
" -V, --version output version information, then exit
\n
"
));
printf
(
_
(
" -?, --help show this help, then exit
\n
"
));
printf
(
_
(
" -?, --help show this help, then exit
\n
"
));
printf
(
_
(
"
\n
Connection options:
\n
"
));
printf
(
_
(
"
\n
Connection options:
\n
"
));
...
...
src/bin/scripts/t/090_reindexdb.pl
View file @
458a0770
use
strict
;
use
strict
;
use
warnings
;
use
warnings
;
use
TestLib
;
use
TestLib
;
use
Test::
More
tests
=>
18
;
use
Test::
More
tests
=>
20
;
program_help_ok
('
reindexdb
');
program_help_ok
('
reindexdb
');
program_version_ok
('
reindexdb
');
program_version_ok
('
reindexdb
');
...
@@ -35,3 +35,7 @@ issues_sql_like(
...
@@ -35,3 +35,7 @@ issues_sql_like(
[
'
reindexdb
',
'
-s
',
'
postgres
'
],
[
'
reindexdb
',
'
-s
',
'
postgres
'
],
qr/statement: REINDEX SYSTEM postgres;/
,
qr/statement: REINDEX SYSTEM postgres;/
,
'
reindex system tables
');
'
reindex system tables
');
issues_sql_like
(
[
'
reindexdb
',
'
-v
',
'
-t
',
'
test1
',
'
postgres
'
],
qr/statement: REINDEX \(VERBOSE\) TABLE test1;/
,
'
reindex with verbose output
');
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