You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the label is already in the enum the statement becomes a no-op.
This will reduce the pain that comes from our not allowing this
operation inside a transaction block.
Andrew Dunstan, reviewed by Tom Lane and Magnus Hagander.
Copy file name to clipboardExpand all lines: doc/src/sgml/ref/alter_type.sgml
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab
28
28
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> RENAME ATTRIBUTE <replaceable class="PARAMETER">attribute_name</replaceable> TO <replaceable class="PARAMETER">new_attribute_name</replaceable>
29
29
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable> [ CASCADE | RESTRICT ]
30
30
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
31
-
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> ADD VALUE <replaceable class="PARAMETER">new_enum_value</replaceable> [ { BEFORE | AFTER } <replaceable class="PARAMETER">existing_enum_value</replaceable> ]
31
+
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> ADD VALUE [ IF NOT EXISTS ] <replaceable class="PARAMETER">new_enum_value</replaceable> [ { BEFORE | AFTER } <replaceable class="PARAMETER">existing_enum_value</replaceable> ]
32
32
33
33
<phrase>where <replaceable class="PARAMETER">action</replaceable> is one of:</phrase>
34
34
@@ -106,14 +106,19 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> ADD VALUE <replacea
106
106
</varlistentry>
107
107
108
108
<varlistentry>
109
-
<term><literal>ADD VALUE [ BEFORE | AFTER ]</literal></term>
109
+
<term><literal>ADD VALUE [ IF NOT EXISTS ] [ BEFORE | AFTER ]</literal></term>
110
110
<listitem>
111
111
<para>
112
112
This form adds a new value to an enum type. If the new value's place in
113
113
the enum's ordering is not specified using <literal>BEFORE</literal> or
114
114
<literal>AFTER</literal>, then the new item is placed at the end of the
115
115
list of values.
116
116
</para>
117
+
<para>
118
+
If <literal>IF NOT EXISTS</literal is used, it is not an error if the
119
+
type already contains the new value, and no action is taken. Otherwise,
120
+
an error will occur if the new value is already present.
0 commit comments