Skip to content

Commit fbcc0d6

Browse files
committed
Fix param handling of create* admin scripts as described months ago.
Properly handles default values.
1 parent c9361a7 commit fbcc0d6

File tree

8 files changed

+56
-17
lines changed

8 files changed

+56
-17
lines changed

doc/src/sgml/ref/vacuumdb.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.20 2001/12/08 03:24:40 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuumdb.sgml,v 1.21 2002/02/18 05:48:43 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -23,13 +23,13 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>vacuumdb</command>
2525
<arg rep="repeat"><replaceable>connection-options</replaceable></arg>
26-
<arg><arg>-d</arg> <replaceable>dbname</replaceable></arg>
2726
<group><arg>--full</arg><arg>-f</arg></group>
2827
<group><arg>--verbose</arg><arg>-v</arg></group>
2928
<group><arg>--analyze</arg><arg>-z</arg></group>
30-
<arg>--table '<replaceable>table</replaceable>
29+
<arg>--table | -t '<replaceable>table</replaceable>
3130
<arg>( <replaceable class="parameter">column</replaceable> [,...] )</arg>'
3231
</arg>
32+
<arg><replaceable>dbname</replaceable></arg>
3333
<sbr>
3434
<command>vacuumdb</command>
3535
<arg rep="repeat"><replaceable>connection-options</replaceable></arg>

src/bin/scripts/createdb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.18 2001/09/30 22:17:51 momjian Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.19 2002/02/18 05:48:44 momjian Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -104,11 +104,17 @@ do
104104
exit 1
105105
;;
106106
*)
107-
if [ -z "$dbname" ]; then
108-
dbname="$1"
109-
else
107+
dbname="$1"
108+
if [ "$2" ]
109+
then
110+
shift
110111
dbcomment="$1"
111112
fi
113+
if [ "$#" -ne 1 ]; then
114+
echo "$CMDNAME: invalid option: $2" 1>&2
115+
echo "Try '$CMDNAME --help' for more information." 1>&2
116+
exit 1
117+
fi
112118
;;
113119
esac
114120
shift
@@ -118,7 +124,7 @@ if [ "$usage" ]; then
118124
echo "$CMDNAME creates a PostgreSQL database."
119125
echo
120126
echo "Usage:"
121-
echo " $CMDNAME [options] dbname [description]"
127+
echo " $CMDNAME [options] [dbname] [description]"
122128
echo
123129
echo "Options:"
124130
echo " -D, --location=PATH Alternative place to store the database"

src/bin/scripts/createlang.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
# Portions Copyright (c) 1994, Regents of the University of California
99
#
10-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.32 2002/01/03 05:30:04 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.33 2002/02/18 05:48:44 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -116,6 +116,11 @@ do
116116
fi
117117
else dbname="$1"
118118
fi
119+
if [ "$#" -ne 1 ]; then
120+
echo "$CMDNAME: invalid option: $2" 1>&2
121+
echo "Try '$CMDNAME --help' for more information." 1>&2
122+
exit 1
123+
fi
119124
;;
120125
esac
121126
shift

src/bin/scripts/createuser

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.22 2001/09/30 22:17:51 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.23 2002/02/18 05:48:44 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -123,6 +123,11 @@ do
123123
;;
124124
*)
125125
NewUser="$1"
126+
if [ "$#" -ne 1 ]; then
127+
echo "$CMDNAME: invalid option: $2" 1>&2
128+
echo "Try '$CMDNAME --help' for more information." 1>&2
129+
exit 1
130+
fi
126131
;;
127132
esac
128133
shift;

src/bin/scripts/dropdb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.13 2001/09/30 22:17:51 momjian Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.14 2002/02/18 05:48:44 momjian Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -89,6 +89,11 @@ do
8989
;;
9090
*)
9191
dbname="$1"
92+
if [ "$#" -ne 1 ]; then
93+
echo "$CMDNAME: invalid option: $2" 1>&2
94+
echo "Try '$CMDNAME --help' for more information." 1>&2
95+
exit 1
96+
fi
9297
;;
9398
esac
9499
shift

src/bin/scripts/droplang

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
# Portions Copyright (c) 1994, Regents of the University of California
99
#
10-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.20 2002/01/03 08:53:00 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.21 2002/02/18 05:48:44 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -105,6 +105,11 @@ do
105105
fi
106106
else dbname="$1"
107107
fi
108+
if [ "$#" -ne 1 ]; then
109+
echo "$CMDNAME: invalid option: $2" 1>&2
110+
echo "Try '$CMDNAME --help' for more information." 1>&2
111+
exit 1
112+
fi
108113
;;
109114
esac
110115
shift

src/bin/scripts/dropuser

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.14 2001/09/30 22:17:51 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.15 2002/02/18 05:48:45 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -91,6 +91,11 @@ do
9191
;;
9292
*)
9393
DelUser="$1"
94+
if [ "$#" -ne 1 ]; then
95+
echo "$CMDNAME: invalid option: $2" 1>&2
96+
echo "Try '$CMDNAME --help' for more information." 1>&2
97+
exit 1
98+
fi
9499
;;
95100
esac
96101
shift;

src/bin/scripts/vacuumdb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.19 2001/09/30 22:17:51 momjian Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.20 2002/02/18 05:48:45 momjian Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -112,6 +112,11 @@ do
112112
;;
113113
*)
114114
dbname="$1"
115+
if [ "$#" -ne 1 ]; then
116+
echo "$CMDNAME: invalid option: $2" 1>&2
117+
echo "Try '$CMDNAME --help' for more information." 1>&2
118+
exit 1
119+
fi
115120
;;
116121
esac
117122
shift
@@ -151,9 +156,12 @@ if [ "$alldb" ]; then
151156
dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database WHERE datallowconn'`
152157

153158
elif [ -z "$dbname" ]; then
154-
echo "$CMDNAME: missing required argument: database name" 1>&2
155-
echo "Try '$CMDNAME -?' for help." 1>&2
156-
exit 1
159+
if [ "$PGUSER" ]; then
160+
dbname="$PGUSER"
161+
else
162+
dbname=`${PATHNAME}pg_id -u -n`
163+
fi
164+
[ "$?" -ne 0 ] && exit 1
157165
fi
158166

159167
for db in $dbname

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy