Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit daea4d8

Browse files
committed
DROP objecttype IF EXISTS for the following objects: table view index sequence schema type domain conversion
1 parent 8ef289d commit daea4d8

22 files changed

+436
-81
lines changed

doc/src/sgml/ref/drop_conversion.sgml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/drop_conversion.sgml,v 1.8 2003/11/29 19:51:38 pgsql Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/drop_conversion.sgml,v 1.9 2005/11/19 17:39:44 adunstan Exp $ -->
22

33
<refentry id="SQL-DROPCONVERSION">
44
<refmeta>
@@ -17,7 +17,7 @@
1717

1818
<refsynopsisdiv>
1919
<synopsis>
20-
DROP CONVERSION <replaceable>name</replaceable> [ CASCADE | RESTRICT ]
20+
DROP CONVERSION [ IF EXISTS ] <replaceable>name</replaceable> [ CASCADE | RESTRICT ]
2121
</synopsis>
2222
</refsynopsisdiv>
2323

@@ -34,6 +34,16 @@ DROP CONVERSION <replaceable>name</replaceable> [ CASCADE | RESTRICT ]
3434
<title>Parameters</title>
3535

3636
<variablelist>
37+
<varlistentry>
38+
<term><literal>IF EXISTS</literal></term>
39+
<listitem>
40+
<para>
41+
Do not throw an error if the conversion does not exist.
42+
A notice is issued in this case.
43+
</para>
44+
</listitem>
45+
</varlistentry>
46+
3747
<varlistentry>
3848
<term><replaceable>name</replaceable></term>
3949

doc/src/sgml/ref/drop_domain.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.15 2005/05/02 01:52:50 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.16 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP DOMAIN <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP DOMAIN [IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -37,6 +37,16 @@ DROP DOMAIN <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE
3737
<title>Parameters</title>
3838

3939
<variablelist>
40+
<varlistentry>
41+
<term><literal>IF EXISTS</literal></term>
42+
<listitem>
43+
<para>
44+
Do not throw an error if the domain does not exist. A notice is issued
45+
in this case.
46+
</para>
47+
</listitem>
48+
</varlistentry>
49+
4050
<varlistentry>
4151
<term><replaceable class="PARAMETER">name</replaceable></term>
4252
<listitem>
@@ -84,7 +94,9 @@ DROP DOMAIN box;
8494
<title>Compatibility</title>
8595

8696
<para>
87-
This command conforms to the SQL standard.
97+
This command conforms to the SQL standard, except for the
98+
<literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
99+
extension.
88100
</para>
89101
</refsect1>
90102

doc/src/sgml/ref/drop_index.sgml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_index.sgml,v 1.21 2003/11/29 19:51:38 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_index.sgml,v 1.22 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP INDEX <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP INDEX [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -38,6 +38,16 @@ DROP INDEX <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE |
3838
<title>Parameters</title>
3939

4040
<variablelist>
41+
<varlistentry>
42+
<term><literal>IF EXISTS</literal></term>
43+
<listitem>
44+
<para>
45+
Do not throw an error if the index does not exist. A notice is issued
46+
in this case.
47+
</para>
48+
</listitem>
49+
</varlistentry>
50+
4151
<varlistentry>
4252
<term><replaceable class="PARAMETER">name</replaceable></term>
4353
<listitem>

doc/src/sgml/ref/drop_schema.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_schema.sgml,v 1.6 2003/11/29 19:51:38 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_schema.sgml,v 1.7 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP SCHEMA <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP SCHEMA [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -42,6 +42,16 @@ DROP SCHEMA <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE
4242
<title>Parameters</title>
4343

4444
<variablelist>
45+
<varlistentry>
46+
<term><literal>IF EXISTS</literal></term>
47+
<listitem>
48+
<para>
49+
Do not throw an error if the schema does not exist. A notice is issued
50+
in this case.
51+
</para>
52+
</listitem>
53+
</varlistentry>
54+
4555
<varlistentry>
4656
<term><replaceable class="PARAMETER">name</replaceable></term>
4757
<listitem>
@@ -92,7 +102,9 @@ DROP SCHEMA mystuff CASCADE;
92102
<para>
93103
<command>DROP SCHEMA</command> is fully conforming with the SQL
94104
standard, except that the standard only allows one schema to be
95-
dropped per command.
105+
dropped per command, and apart from the
106+
<literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
107+
extension.
96108
</para>
97109
</refsect1>
98110

doc/src/sgml/ref/drop_sequence.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_sequence.sgml,v 1.23 2005/11/01 21:09:50 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_sequence.sgml,v 1.24 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP SEQUENCE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP SEQUENCE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -36,6 +36,16 @@ DROP SEQUENCE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCAD
3636
<title>Parameters</title>
3737

3838
<variablelist>
39+
<varlistentry>
40+
<term><literal>IF EXISTS</literal></term>
41+
<listitem>
42+
<para>
43+
Do not throw an error if the sequence does not exist. A notice is issued
44+
in this case.
45+
</para>
46+
</listitem>
47+
</varlistentry>
48+
3949
<varlistentry>
4050
<term><replaceable class="PARAMETER">name</replaceable></term>
4151
<listitem>
@@ -84,7 +94,9 @@ DROP SEQUENCE serial;
8494
<para>
8595
<command>DROP SEQUENCE</command> conforms to the <acronym>SQL</acronym>
8696
standard, except that the standard only allows one
87-
sequence to be dropped per command.
97+
sequence to be dropped per command, and apart from the
98+
<literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
99+
extension.
88100
</para>
89101
</refsect1>
90102

doc/src/sgml/ref/drop_table.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_table.sgml,v 1.22 2005/01/04 00:39:53 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_table.sgml,v 1.23 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -48,6 +48,16 @@ DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE |
4848
<title>Parameters</title>
4949

5050
<variablelist>
51+
<varlistentry>
52+
<term><literal>IF EXISTS</literal></term>
53+
<listitem>
54+
<para>
55+
Do not throw an error if the table does not exist. A notice is issued
56+
in this case.
57+
</para>
58+
</listitem>
59+
</varlistentry>
60+
5161
<varlistentry>
5262
<term><replaceable class="PARAMETER">name</replaceable></term>
5363
<listitem>
@@ -97,7 +107,9 @@ DROP TABLE films, distributors;
97107

98108
<para>
99109
This command conforms to the SQL standard, except that the standard only
100-
allows one table to be dropped per command.
110+
allows one table to be dropped per command, and apart from the
111+
<literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
112+
extension.
101113
</para>
102114
</refsect1>
103115

doc/src/sgml/ref/drop_type.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.26 2004/06/25 21:55:50 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.27 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP TYPE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP TYPE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -37,6 +37,16 @@ DROP TYPE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE |
3737
<title>Parameters</title>
3838

3939
<variablelist>
40+
<varlistentry>
41+
<term><literal>IF EXISTS</literal></term>
42+
<listitem>
43+
<para>
44+
Do not throw an error if the type does not exist. A notice is issued
45+
in this case.
46+
</para>
47+
</listitem>
48+
</varlistentry>
49+
4050
<varlistentry>
4151
<term><replaceable class="PARAMETER">name</replaceable></term>
4252
<listitem>
@@ -84,7 +94,9 @@ DROP TYPE box;
8494

8595
<para>
8696
This command is similar to the corresponding command in the SQL
87-
standard, but note that the <command>CREATE TYPE</command> command
97+
standard, aapart from the <literal>IF EXISTS</>
98+
option, which is a <productname>PostgreSQL</> extension.
99+
But note that the <command>CREATE TYPE</command> command
88100
and the data type extension mechanisms in
89101
<productname>PostgreSQL</productname> differ from the SQL standard.
90102
</para>

doc/src/sgml/ref/drop_view.sgml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.21 2005/01/04 00:39:53 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.22 2005/11/19 17:39:44 adunstan Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,7 +20,7 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23-
DROP VIEW <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
23+
DROP VIEW [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
2424
</synopsis>
2525
</refsynopsisdiv>
2626

@@ -37,6 +37,16 @@ DROP VIEW <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE |
3737
<title>Parameters</title>
3838

3939
<variablelist>
40+
<varlistentry>
41+
<term><literal>IF EXISTS</literal></term>
42+
<listitem>
43+
<para>
44+
Do not throw an error if the view does not exist. A notice is issued
45+
in this case.
46+
</para>
47+
</listitem>
48+
</varlistentry>
49+
4050
<varlistentry>
4151
<term><replaceable class="PARAMETER">name</replaceable></term>
4252
<listitem>
@@ -84,7 +94,9 @@ DROP VIEW kinds;
8494

8595
<para>
8696
This command conforms to the SQL standard, except that the standard only
87-
allows one view to be dropped per command.
97+
allows one view to be dropped per command, and apart from the
98+
<literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
99+
extension.
88100
</para>
89101
</refsect1>
90102

src/backend/commands/conversioncmds.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.23 2005/10/15 02:49:15 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.24 2005/11/19 17:39:44 adunstan Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -98,16 +98,29 @@ CreateConversionCommand(CreateConversionStmt *stmt)
9898
* DROP CONVERSION
9999
*/
100100
void
101-
DropConversionCommand(List *name, DropBehavior behavior)
101+
DropConversionCommand(List *name, DropBehavior behavior, bool missing_ok)
102102
{
103103
Oid conversionOid;
104104

105105
conversionOid = FindConversionByName(name);
106106
if (!OidIsValid(conversionOid))
107-
ereport(ERROR,
108-
(errcode(ERRCODE_UNDEFINED_OBJECT),
109-
errmsg("conversion \"%s\" does not exist",
110-
NameListToString(name))));
107+
{
108+
if (! missing_ok)
109+
{
110+
ereport(ERROR,
111+
(errcode(ERRCODE_UNDEFINED_OBJECT),
112+
errmsg("conversion \"%s\" does not exist",
113+
NameListToString(name))));
114+
}
115+
else
116+
{
117+
ereport(NOTICE,
118+
(errmsg("conversion \"%s\" does not exist, skipping",
119+
NameListToString(name))));
120+
}
121+
122+
return;
123+
}
111124

112125
ConversionDrop(conversionOid, behavior);
113126
}

0 commit comments

Comments
 (0)