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
41fde546
Commit
41fde546
authored
Jan 06, 2001
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish help output. Allow --help to work with BSD getopts.
parent
24a4aff6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
104 deletions
+125
-104
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+42
-39
src/bin/pg_dump/pg_restore.c
src/bin/pg_dump/pg_restore.c
+83
-65
No files found.
src/bin/pg_dump/pg_dump.c
View file @
41fde546
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.18
4 2001/01/04 01:23:47 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.18
5 2001/01/06 20:57:26 petere
Exp $
*
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
*
...
@@ -193,24 +193,27 @@ help(const char *progname)
...
@@ -193,24 +193,27 @@ help(const char *progname)
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_GETOPT_LONG
puts
(
puts
(
" -a, --data-only dump out only the data, not the schema
\n
"
" -a, --data-only dump out only the data, not the schema
\n
"
" -b, --blobs
dump out blob data
\n
"
" -b, --blobs
dump out blob data
\n
"
" -c, --clean clean (drop) schema prior to create
\n
"
" -c, --clean clean (drop) schema prior to create
\n
"
" -C, --create output commands to create database
\n
"
" -C, --create output commands to create database
\n
"
" -d, --inserts dump data as INSERT, rather than COPY, commands
\n
"
" -d, --inserts dump data as INSERT, rather than COPY, commands
\n
"
" -D, --attribute-inserts dump data as INSERT commands with attribute names
\n
"
" -D, --attribute-inserts dump data as INSERT commands with attribute names
\n
"
" -f, --file
specify output file name
\n
"
" -f, --file
=FILENAME
specify output file name
\n
"
" -F, --format {c|f|p} output file format (custom, files, plain text)
\n
"
" -F, --format {c|f|p} output file format (custom, files, plain text)
\n
"
" -h, --host
<hostname>
server host name
\n
"
" -h, --host
=HOSTNAME
server host name
\n
"
" -i, --ignore-version proceed when database version != pg_dump version
\n
"
" -i, --ignore-version proceed when database version != pg_dump version
\n
"
" -n, --no-quotes suppress most quotes around identifiers
\n
"
" -n, --no-quotes suppress most quotes around identifiers
\n
"
" -N, --quotes enable most quotes around identifiers
\n
"
" -N, --quotes enable most quotes around identifiers
\n
"
" -o, --oids dump object ids (oids)
\n
"
" -o, --oids dump object ids (oids)
\n
"
" -O, --no-owner don't output
\\
connect commands in plain text format
\n
"
" -O, --no-owner do not output
\\
connect commands in plain text
\n
"
" -p, --port <port> server port number
\n
"
" format
\n
"
" -R, --no-reconnect disable ALL reconnections to the database in plain text format
\n
"
" -p, --port=PORT server port number
\n
"
" -R, --no-reconnect disable ALL reconnections to the database in
\n
"
" plain text format
\n
"
" -s, --schema-only dump out only the schema, no data
\n
"
" -s, --schema-only dump out only the schema, no data
\n
"
" -S, --superuser <name> specify the superuser username to use in plain text format
\n
"
" -S, --superuser=NAME specify the superuser user name to use in plain
\n
"
" -t, --table <table> dump for this table only
\n
"
" text format
\n
"
" -t, --table=TABLE dump for this table only
\n
"
" -u, --password use password authentication
\n
"
" -u, --password use password authentication
\n
"
" -v, --verbose verbose
\n
"
" -v, --verbose verbose
\n
"
" -x, --no-acl do not dump ACL's (grant/revoke)
\n
"
" -x, --no-acl do not dump ACL's (grant/revoke)
\n
"
...
@@ -224,19 +227,22 @@ help(const char *progname)
...
@@ -224,19 +227,22 @@ help(const char *progname)
" -C output commands to create database
\n
"
" -C output commands to create database
\n
"
" -d dump data as INSERT, rather than COPY, commands
\n
"
" -d dump data as INSERT, rather than COPY, commands
\n
"
" -D dump data as INSERT commands with attribute names
\n
"
" -D dump data as INSERT commands with attribute names
\n
"
" -f
specify output file name
\n
"
" -f
FILENAME
specify output file name
\n
"
" -F {c|f|p} output file format (custom, files, plain text)
\n
"
" -F {c|f|p} output file format (custom, files, plain text)
\n
"
" -h
<hostname>
server host name
\n
"
" -h
HOSTNAME
server host name
\n
"
" -i proceed when database version != pg_dump version
\n
"
" -i proceed when database version != pg_dump version
\n
"
" -n suppress most quotes around identifiers
\n
"
" -n suppress most quotes around identifiers
\n
"
" -N enable most quotes around identifiers
\n
"
" -N enable most quotes around identifiers
\n
"
" -o dump object ids (oids)
\n
"
" -o dump object ids (oids)
\n
"
" -O don't output
\\
connect commands in plain text format
\n
"
" -O do not output
\\
connect commands in plain text
\n
"
" -p <port> server port number
\n
"
" format
\n
"
" -R disable ALL reconnections to the database in plain text format
\n
"
" -p PORT server port number
\n
"
" -R disable ALL reconnections to the database in
\n
"
" plain text format
\n
"
" -s dump out only the schema, no data
\n
"
" -s dump out only the schema, no data
\n
"
" -S <name> specify the superuser username to use in plain text format
\n
"
" -S NAME specify the superuser user name to use in plain
\n
"
" -t <table> dump for this table only
\n
"
" text format
\n
"
" -t TABLE dump for this table only
\n
"
" -u use password authentication
\n
"
" -u use password authentication
\n
"
" -v verbose
\n
"
" -v verbose
\n
"
" -x do not dump ACL's (grant/revoke)
\n
"
" -x do not dump ACL's (grant/revoke)
\n
"
...
@@ -253,7 +259,7 @@ version(void)
...
@@ -253,7 +259,7 @@ version(void)
{
{
puts
(
"pg_dump (PostgreSQL) "
PG_VERSION
);
puts
(
"pg_dump (PostgreSQL) "
PG_VERSION
);
puts
(
"Portions Copyright (c) 1996-2000, PostgreSQL, Inc"
);
puts
(
"Portions Copyright (c) 1996-2000, PostgreSQL, Inc"
);
puts
(
"Portions Copyright (
C
) 1996 Regents of the University of California"
);
puts
(
"Portions Copyright (
c
) 1996 Regents of the University of California"
);
puts
(
"Read the file COPYRIGHT to see the usage and distribution terms."
);
puts
(
"Read the file COPYRIGHT to see the usage and distribution terms."
);
}
}
...
@@ -718,10 +724,24 @@ main(int argc, char **argv)
...
@@ -718,10 +724,24 @@ main(int argc, char **argv)
outputBlobs
=
true
;
outputBlobs
=
true
;
}
}
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-?"
)
==
0
)
{
help
(
progname
);
exit
(
0
);
}
if
(
strcmp
(
argv
[
1
],
"--version"
)
==
0
||
strcmp
(
argv
[
1
],
"-V"
)
==
0
)
{
version
();
exit
(
0
);
}
}
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_GETOPT_LONG
while
((
c
=
getopt_long
(
argc
,
argv
,
"abcCdDf:F:h:inNoOp:sS:t:uvxzZ:V?"
,
long_options
,
&
optindex
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
argv
,
"abcCdDf:F:h:inNoOp:
R
sS:t:uvxzZ:V?"
,
long_options
,
&
optindex
))
!=
-
1
)
#else
#else
while
((
c
=
getopt
(
argc
,
argv
,
"abcCdDf:F:h:inNoOp:sS:t:uvxzZ:V?-"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"abcCdDf:F:h:inNoOp:
R
sS:t:uvxzZ:V?-"
))
!=
-
1
)
#endif
#endif
{
{
...
@@ -852,32 +872,15 @@ main(int argc, char **argv)
...
@@ -852,32 +872,15 @@ main(int argc, char **argv)
exit
(
0
);
exit
(
0
);
break
;
break
;
case
'?'
:
/*
* getopt returns '?' on unknown argument. That's not
* quite what we want
*/
if
(
strcmp
(
argv
[
optind
-
1
],
"-?"
)
==
0
||
strcmp
(
argv
[
optind
-
1
],
"--help"
)
==
0
)
{
help
(
progname
);
exit
(
1
);
}
else
{
fputs
(
"Try -? for help.
\n
"
,
stderr
);
exit
(
1
);
}
break
;
#ifndef HAVE_GETOPT_LONG
#ifndef HAVE_GETOPT_LONG
case
'-'
:
case
'-'
:
fprintf
(
stderr
,
"%s was compiled without support for long options.
\n
"
fprintf
(
stderr
,
"%s was compiled without support for long options.
\n
"
"Use -
?
for help on invocation options.
\n
"
,
progname
);
"Use -
-help
for help on invocation options.
\n
"
,
progname
);
exit
(
1
);
exit
(
1
);
break
;
break
;
#endif
#endif
default:
default:
fprintf
(
stderr
,
"
%s: unknown option -%c
\n
Try -? for help.
\n
"
,
progname
,
c
);
fprintf
(
stderr
,
"
Try '%s --help' for more information.
\n
"
,
progname
);
exit
(
1
);
exit
(
1
);
}
}
}
}
...
@@ -885,7 +888,7 @@ main(int argc, char **argv)
...
@@ -885,7 +888,7 @@ main(int argc, char **argv)
if
(
optind
<
(
argc
-
1
))
{
if
(
optind
<
(
argc
-
1
))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"%s: extra parameters found on command line after '%s' (first is '%s').
\n
"
"%s: extra parameters found on command line after '%s' (first is '%s').
\n
"
"Please respecify command.
\n
Use -
?
for help on invocation options.
\n
"
,
"Please respecify command.
\n
Use -
-help
for help on invocation options.
\n
"
,
progname
,
argv
[
optind
],
argv
[
optind
+
1
]);
progname
,
argv
[
optind
],
argv
[
optind
+
1
]);
exit
(
1
);
exit
(
1
);
}
}
...
...
src/bin/pg_dump/pg_restore.c
View file @
41fde546
...
@@ -129,7 +129,21 @@ int main(int argc, char **argv)
...
@@ -129,7 +129,21 @@ int main(int argc, char **argv)
opts
=
NewRestoreOptions
();
opts
=
NewRestoreOptions
();
progname
=
*
argv
;
progname
=
argv
[
0
];
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-?"
)
==
0
)
{
usage
(
progname
);
exit
(
0
);
}
if
(
strcmp
(
argv
[
1
],
"--version"
)
==
0
||
strcmp
(
argv
[
1
],
"-V"
)
==
0
)
{
puts
(
"pg_restore (PostgreSQL) "
PG_VERSION
);
exit
(
0
);
}
}
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_GETOPT_LONG
while
((
c
=
getopt_long
(
argc
,
argv
,
"acCd:f:F:h:i:lNoOp:P:rRsS:t:T:uU:vx"
,
cmdopts
,
NULL
))
!=
EOF
)
while
((
c
=
getopt_long
(
argc
,
argv
,
"acCd:f:F:h:i:lNoOp:P:rRsS:t:T:uU:vx"
,
cmdopts
,
NULL
))
!=
EOF
)
...
@@ -235,8 +249,8 @@ int main(int argc, char **argv)
...
@@ -235,8 +249,8 @@ int main(int argc, char **argv)
opts
->
aclsSkip
=
1
;
opts
->
aclsSkip
=
1
;
break
;
break
;
default:
default:
usage
(
progname
);
fprintf
(
stderr
,
"Try '%s --help' for more information.
\n
"
,
progname
);
break
;
exit
(
1
)
;
}
}
}
}
...
@@ -311,72 +325,76 @@ int main(int argc, char **argv)
...
@@ -311,72 +325,76 @@ int main(int argc, char **argv)
static
void
usage
(
const
char
*
progname
)
static
void
usage
(
const
char
*
progname
)
{
{
printf
(
"%s restores a PostgreSQL database from an archive created by pg_dump.
\n\n
"
"Usage:
\n
%s [options] [backup file]
\n\n
"
"Options:
\n
"
,
progname
,
progname
);
#ifdef HAVE_GETOPT_LONG
#ifdef HAVE_GETOPT_LONG
fprintf
(
stderr
,
puts
(
"usage: %s [options] [backup file]
\n
"
" -a, --data-only dump out only the data, no schema
\n
"
" -a, --data-only
\t
dump out only the data, no schema
\n
"
" -c, --clean clean (drop) schema prior to create
\n
"
" -d, --dbname <name>
\t
specify database name
\n
"
" -C, --create output commands to create the database
\n
"
" -c, --clean
\t
clean(drop) schema prior to create
\n
"
" -d, --dbname=NAME specify database name
\n
"
" -C, --create
\t
output commands to create the database
\n
"
" -f, --file=FILENAME script output file name
\n
"
" -f filename
\t
script output filename
\n
"
" -F, --format {c|f} specify backup file format
\n
"
" -F, --format {c|f}
\t
specify backup file format
\n
"
" -h, --host HOSTNAME server host name
\n
"
" -h, --host <hostname>
\t
server host name
\n
"
" -i, --index[=NAME] dump indexes or named index
\n
"
" -i, --index[=name]
\t
dump indexes or named index
\n
"
" -l, --list dump summarized TOC for this file
\n
"
" -l, --list
\t
dump summarized TOC for this file
\n
"
" -N, --orig-order dump in original dump order
\n
"
" -N, --orig-order
\t
dump in original dump order
\n
"
" -o, --oid-order dump in oid order
\n
"
" -o, --oid-order
\t
dump in oid order
\n
"
" -O, --no-owner do not output reconnect to database to match
\n
"
" -O, --no-owner
\t
don't output reconnect to database to match object owner
\n
"
" object owner
\n
"
" -p, --port <port>
\t
server port number
\n
"
" -p, --port PORT server port number
\n
"
" -P, --function[=name]
\t
dump functions or named function
\n
"
" -P, --function[=NAME] dump functions or named function
\n
"
" -r, --rearrange
\t
rearrange output to put indexes etc at end
\n
"
" -r, --rearrange rearrange output to put indexes etc. at end
\n
"
" -R, --no-reconnect
\t
disallow ALL reconnections to the database
\n
"
" -R, --no-reconnect disallow ALL reconnections to the database
\n
"
" -s, --schema-only
\t
dump out only the schema, no data
\n
"
" -s, --schema-only dump out only the schema, no data
\n
"
" -S, --superuser <name>
\t
specify the superuser username to use in disabling triggers
\n
"
" -S, --superuser=NAME specify the superuser user name to use for
\n
"
" -t [table], --table[=table]
\t
dump for this table only
\n
"
" disabling triggers
\n
"
" -T, --trigger[=name]
\t
dump triggers or named trigger
\n
"
" -t [TABLE], --table[=TABLE] dump for this table only
\n
"
" -u, --password
\t
use password authentication
\n
"
" -T, --trigger[=NAME] dump triggers or named trigger
\n
"
" -U, --use-list filename
\t
use specified TOC for ordering output from this file
\n
"
" -u, --password use password authentication
\n
"
" -v, --verbose
\t
verbose
\n
"
" -U, --use-list=FILENAME use specified table of contents for ordering
\n
"
" -x, --no-acl
\t
skip dumping of ACLs (grant/revoke)
\n
"
" output from this file
\n
"
,
progname
);
" -v, --verbose verbose
\n
"
" -x, --no-acl skip dumping of ACLs (grant/revoke)
\n
"
);
#else
fprintf
(
stderr
,
#else
/* not HAVE_GETOPT_LONG */
"usage: %s [options] [backup file]
\n
"
" -a
\t
dump out only the data, no schema
\n
"
puts
(
" -d <name>
\t
specify database name
\n
"
" -a dump out only the data, no schema
\n
"
" -c
\t
clean(drop) schema prior to create
\n
"
" -c clean (drop) schema prior to create
\n
"
" -C
\t
output commands to create the database
\n
"
" -C output commands to create the database
\n
"
" -f filename
\t
script output filename
\n
"
" -d NAME specify database name
\n
"
" -F {c|f}
\t
specify backup file format
\n
"
" -f FILENAME script output file name
\n
"
" -h <hostname>
\t
server host name
\n
"
" -F {c|f} specify backup file format
\n
"
" -i name
\t
dump indexes or named index
\n
"
" -h HOSTNAME server host name
\n
"
" -l
\t
dump summarized TOC for this file
\n
"
" -i NAME dump indexes or named index
\n
"
" -N
\t
dump in original dump order
\n
"
" -l dump summarized TOC for this file
\n
"
" -o
\t
dump in oid order
\n
"
" -N dump in original dump order
\n
"
" -O
\t
don't output reconnect to database to match object owner
\n
"
" -o dump in oid order
\n
"
" -p <port>
\t
server port number
\n
"
" -O do not output reconnect to database to match
\n
"
" -P name
\t
dump functions or named function
\n
"
" object owner
\n
"
" -r
\t
rearrange output to put indexes etc at end
\n
"
" -p PORT server port number
\n
"
" -R
\t
disallow ALL reconnections to the database
\n
"
" -P NAME dump functions or named function
\n
"
" -s
\t
dump out only the schema, no data
\n
"
" -r rearrange output to put indexes etc at end
\n
"
" -S <name>
\t
specify the superuser username to use in disabling triggers
\n
"
" -R disallow ALL reconnections to the database
\n
"
" -t name
\t
dump for this table only
\n
"
" -s dump out only the schema, no data
\n
"
" -T name
\t
dump triggers or named trigger
\n
"
" -S NAME specify the superuser user name to use for
\n
"
" -u
\t
use password authentication
\n
"
" disabling triggers
\n
"
" -U filename
\t
use specified TOC for ordering output from this file
\n
"
" -t NAME dump for this table only
\n
"
" -v
\t
verbose
\n
"
" -T NAME dump triggers or named trigger
\n
"
" -x
\t
skip dumping of ACLs (grant/revoke)
\n
"
" -u use password authentication
\n
"
,
progname
);
" -U FILENAME use specified table of contents for ordering
\n
"
" output from this file
\n
"
" -v verbose
\n
"
" -x skip dumping of ACLs (grant/revoke)
\n
"
);
#endif
#endif
fprintf
(
stderr
,
puts
(
"If [backup file] is not supplied, then standard input is used.
\n
"
);
"
\n
If [backup file] is not supplied, then standard input "
puts
(
"Report bugs to <pgsql-bugs@postgresql.org>."
);
"is used.
\n
"
);
fprintf
(
stderr
,
"
\n
"
);
exit
(
1
);
}
}
static
char
*
_cleanupName
(
char
*
name
)
static
char
*
_cleanupName
(
char
*
name
)
{
{
int
i
;
int
i
;
...
...
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