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
7fe33a51
Commit
7fe33a51
authored
Aug 30, 2011
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --if-exists option to dropdb and dropuser.
Josh Kupershmidt, with some further editing by me.
parent
94478aa8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
doc/src/sgml/ref/dropdb.sgml
doc/src/sgml/ref/dropdb.sgml
+10
-0
doc/src/sgml/ref/dropuser.sgml
doc/src/sgml/ref/dropuser.sgml
+10
-0
src/bin/scripts/dropdb.c
src/bin/scripts/dropdb.c
+9
-2
src/bin/scripts/dropuser.c
src/bin/scripts/dropuser.c
+9
-1
No files found.
doc/src/sgml/ref/dropdb.sgml
View file @
7fe33a51
...
...
@@ -86,6 +86,16 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--if-exists</></term>
<listitem>
<para>
Do not throw an error if the database does not exist. A notice is issued
in this case.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</></term>
<term><option>--version</></term>
...
...
doc/src/sgml/ref/dropuser.sgml
View file @
7fe33a51
...
...
@@ -88,6 +88,16 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--if-exists</></term>
<listitem>
<para>
Do not throw an error if the database does not exist. A notice is
issued in this case.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</></term>
<term><option>--version</></term>
...
...
src/bin/scripts/dropdb.c
View file @
7fe33a51
...
...
@@ -21,6 +21,8 @@ static void help(const char *progname);
int
main
(
int
argc
,
char
*
argv
[])
{
static
int
if_exists
=
0
;
static
struct
option
long_options
[]
=
{
{
"host"
,
required_argument
,
NULL
,
'h'
},
{
"port"
,
required_argument
,
NULL
,
'p'
},
...
...
@@ -29,6 +31,7 @@ main(int argc, char *argv[])
{
"password"
,
no_argument
,
NULL
,
'W'
},
{
"echo"
,
no_argument
,
NULL
,
'e'
},
{
"interactive"
,
no_argument
,
NULL
,
'i'
},
{
"if-exists"
,
no_argument
,
&
if_exists
,
1
},
{
NULL
,
0
,
NULL
,
0
}
};
...
...
@@ -79,6 +82,9 @@ main(int argc, char *argv[])
case
'i'
:
interactive
=
true
;
break
;
case
0
:
/* this covers the long options */
break
;
default:
fprintf
(
stderr
,
_
(
"Try
\"
%s --help
\"
for more information.
\n
"
),
progname
);
exit
(
1
);
...
...
@@ -110,8 +116,8 @@ main(int argc, char *argv[])
initPQExpBuffer
(
&
sql
);
appendPQExpBuffer
(
&
sql
,
"DROP DATABASE %s;
\n
"
,
fmtId
(
dbname
));
appendPQExpBuffer
(
&
sql
,
"DROP DATABASE %s
%s
;
\n
"
,
(
if_exists
?
"IF EXISTS "
:
""
),
fmtId
(
dbname
));
/*
* Connect to the 'postgres' database by default, except have the
...
...
@@ -146,6 +152,7 @@ help(const char *progname)
printf
(
_
(
"
\n
Options:
\n
"
));
printf
(
_
(
" -e, --echo show the commands being sent to the server
\n
"
));
printf
(
_
(
" -i, --interactive prompt before deleting anything
\n
"
));
printf
(
_
(
" --if-exists don't report error if database doesn't exist
\n
"
));
printf
(
_
(
" --help show this help, then exit
\n
"
));
printf
(
_
(
" --version output version information, then exit
\n
"
));
printf
(
_
(
"
\n
Connection options:
\n
"
));
...
...
src/bin/scripts/dropuser.c
View file @
7fe33a51
...
...
@@ -21,6 +21,8 @@ static void help(const char *progname);
int
main
(
int
argc
,
char
*
argv
[])
{
static
int
if_exists
=
0
;
static
struct
option
long_options
[]
=
{
{
"host"
,
required_argument
,
NULL
,
'h'
},
{
"port"
,
required_argument
,
NULL
,
'p'
},
...
...
@@ -29,6 +31,7 @@ main(int argc, char *argv[])
{
"password"
,
no_argument
,
NULL
,
'W'
},
{
"echo"
,
no_argument
,
NULL
,
'e'
},
{
"interactive"
,
no_argument
,
NULL
,
'i'
},
{
"if-exists"
,
no_argument
,
&
if_exists
,
1
},
{
NULL
,
0
,
NULL
,
0
}
};
...
...
@@ -79,6 +82,9 @@ main(int argc, char *argv[])
case
'i'
:
interactive
=
true
;
break
;
case
0
:
/* this covers the long options */
break
;
default:
fprintf
(
stderr
,
_
(
"Try
\"
%s --help
\"
for more information.
\n
"
),
progname
);
exit
(
1
);
...
...
@@ -110,7 +116,8 @@ main(int argc, char *argv[])
}
initPQExpBuffer
(
&
sql
);
appendPQExpBuffer
(
&
sql
,
"DROP ROLE %s;
\n
"
,
fmtId
(
dropuser
));
appendPQExpBuffer
(
&
sql
,
"DROP ROLE %s%s;
\n
"
,
(
if_exists
?
"IF EXISTS "
:
""
),
fmtId
(
dropuser
));
conn
=
connectDatabase
(
"postgres"
,
host
,
port
,
username
,
prompt_password
,
progname
);
...
...
@@ -141,6 +148,7 @@ help(const char *progname)
printf
(
_
(
"
\n
Options:
\n
"
));
printf
(
_
(
" -e, --echo show the commands being sent to the server
\n
"
));
printf
(
_
(
" -i, --interactive prompt before deleting anything
\n
"
));
printf
(
_
(
" --if-exists don't report error if user doesn't exist
\n
"
));
printf
(
_
(
" --help show this help, then exit
\n
"
));
printf
(
_
(
" --version output version information, then exit
\n
"
));
printf
(
_
(
"
\n
Connection options:
\n
"
));
...
...
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