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

Commit 3301c83

Browse files
committed
Add some more regression tests for DROP IF EXISTS.
KaiGai Kohei
1 parent 3716ab2 commit 3301c83

File tree

2 files changed

+264
-12
lines changed

2 files changed

+264
-12
lines changed

src/test/regress/expected/drop_if_exists.out

+142-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ CREATE domain test_domain_exists as int not null check (value > 0);
6161
DROP DOMAIN IF EXISTS test_domain_exists;
6262
DROP DOMAIN test_domain_exists;
6363
ERROR: type "test_domain_exists" does not exist
64-
-- drop the table
65-
DROP TABLE IF EXISTS test_exists;
66-
DROP TABLE test_exists;
67-
ERROR: table "test_exists" does not exist
6864
---
6965
--- role/user/group
7066
---
@@ -89,3 +85,145 @@ DROP GROUP IF EXISTS tg1, tg2;
8985
NOTICE: role "tg2" does not exist, skipping
9086
DROP GROUP tg1;
9187
ERROR: role "tg1" does not exist
88+
-- collation
89+
DROP COLLATION test_collation_exists;
90+
ERROR: collation "test_collation_exists" for encoding "UTF8" does not exist
91+
DROP COLLATION IF EXISTS test_collation_exists;
92+
NOTICE: collation "test_collation_exists" does not exist, skipping
93+
CREATE COLLATION test_collation_exists FROM "POSIX";
94+
DROP COLLATION test_collation_exists;
95+
-- conversion
96+
DROP CONVERSION test_conversion_exists;
97+
ERROR: conversion "test_conversion_exists" does not exist
98+
DROP CONVERSION IF EXISTS test_conversion_exists;
99+
NOTICE: conversion "test_conversion_exists" does not exist, skipping
100+
CREATE CONVERSION test_conversion_exists
101+
FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
102+
DROP CONVERSION test_conversion_exists;
103+
-- text search parser
104+
DROP TEXT SEARCH PARSER test_tsparser_exists;
105+
ERROR: text search parser "test_tsparser_exists" does not exist
106+
DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists;
107+
NOTICE: text search parser "test_tsparser_exists" does not exist, skipping
108+
-- text search dictionary
109+
DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
110+
ERROR: text search dictionary "test_tsdict_exists" does not exist
111+
DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists;
112+
NOTICE: text search dictionary "test_tsdict_exists" does not exist, skipping
113+
CREATE TEXT SEARCH DICTIONARY test_tsdict_exists (
114+
Template=ispell,
115+
DictFile=ispell_sample,
116+
AffFile=ispell_sample
117+
);
118+
DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
119+
-- test search template
120+
DROP TEXT SEARCH TEMPLATE test_tstemplate_exists;
121+
ERROR: text search template "test_tstemplate_exists" does not exist
122+
DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists;
123+
NOTICE: text search template "test_tstemplate_exists" does not exist, skipping
124+
-- text search configuration
125+
DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
126+
ERROR: text search configuration "test_tsconfig_exists" does not exist
127+
DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists;
128+
NOTICE: text search configuration "test_tsconfig_exists" does not exist, skipping
129+
CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english);
130+
DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
131+
-- extension
132+
DROP EXTENSION test_extension_exists;
133+
ERROR: extension "test_extension_exists" does not exist
134+
DROP EXTENSION IF EXISTS test_extension_exists;
135+
NOTICE: extension "test_extension_exists" does not exist, skipping
136+
-- functions
137+
DROP FUNCTION test_function_exists();
138+
ERROR: function test_function_exists() does not exist
139+
DROP FUNCTION IF EXISTS test_function_exists();
140+
NOTICE: function test_function_exists() does not exist, skipping
141+
DROP FUNCTION test_function_exists(int, text, int[]);
142+
ERROR: function test_function_exists(integer, text, integer[]) does not exist
143+
DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]);
144+
NOTICE: function test_function_exists(pg_catalog.int4,text,pg_catalog.int4[]) does not exist, skipping
145+
-- aggregate
146+
DROP AGGREGATE test_aggregate_exists(*);
147+
ERROR: aggregate test_aggregate_exists(*) does not exist
148+
DROP AGGREGATE IF EXISTS test_aggregate_exists(*);
149+
NOTICE: aggregate test_aggregate_exists() does not exist, skipping
150+
DROP AGGREGATE test_aggregate_exists(int);
151+
ERROR: aggregate test_aggregate_exists(integer) does not exist
152+
DROP AGGREGATE IF EXISTS test_aggregate_exists(int);
153+
NOTICE: aggregate test_aggregate_exists(pg_catalog.int4) does not exist, skipping
154+
-- operator
155+
DROP OPERATOR @#@ (int, int);
156+
ERROR: operator does not exist: integer @#@ integer
157+
DROP OPERATOR IF EXISTS @#@ (int, int);
158+
NOTICE: operator @#@ does not exist, skipping
159+
CREATE OPERATOR @#@
160+
(leftarg = int8, rightarg = int8, procedure = int8xor);
161+
DROP OPERATOR @#@ (int8, int8);
162+
-- language
163+
DROP LANGUAGE test_language_exists;
164+
ERROR: language "test_language_exists" does not exist
165+
DROP LANGUAGE IF EXISTS test_language_exists;
166+
NOTICE: language "test_language_exists" does not exist, skipping
167+
-- cast
168+
DROP CAST (text AS text);
169+
ERROR: cast from type text to type text does not exist
170+
DROP CAST IF EXISTS (text AS text);
171+
NOTICE: cast from type text to type text does not exist, skipping
172+
-- trigger
173+
DROP TRIGGER test_trigger_exists ON test_exists;
174+
ERROR: trigger "test_trigger_exists" for table "test_exists" does not exist
175+
DROP TRIGGER IF EXISTS test_trigger_exists ON test_exists;
176+
NOTICE: trigger "test_trigger_exists" for table "test_exists" does not exist, skipping
177+
DROP TRIGGER test_trigger_exists ON no_such_table;
178+
ERROR: relation "no_such_table" does not exist
179+
DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_table;
180+
ERROR: relation "no_such_table" does not exist
181+
CREATE TRIGGER test_trigger_exists
182+
BEFORE UPDATE ON test_exists
183+
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
184+
DROP TRIGGER test_trigger_exists ON test_exists;
185+
-- rule
186+
DROP RULE test_rule_exists ON test_exists;
187+
ERROR: rule "test_rule_exists" for relation "test_exists" does not exist
188+
DROP RULE IF EXISTS test_rule_exists ON test_exists;
189+
NOTICE: rule "test_rule_exists" for relation "test_exists" does not exist, skipping
190+
DROP RULE test_rule_exists ON no_such_table;
191+
ERROR: relation "no_such_table" does not exist
192+
DROP RULE IF EXISTS test_rule_exists ON no_such_table;
193+
ERROR: relation "no_such_table" does not exist
194+
CREATE RULE test_rule_exists AS ON INSERT TO test_exists
195+
DO INSTEAD
196+
INSERT INTO test_exists VALUES (NEW.a, NEW.b || NEW.a::text);
197+
DROP RULE test_rule_exists ON test_exists;
198+
-- foreign data wrapper
199+
DROP FOREIGN DATA WRAPPER test_fdw_exists;
200+
ERROR: foreign-data wrapper "test_fdw_exists" does not exist
201+
DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists;
202+
NOTICE: foreign-data wrapper "test_fdw_exists" does not exist, skipping
203+
-- foreign server
204+
DROP SERVER test_server_exists;
205+
ERROR: server "test_server_exists" does not exist
206+
DROP SERVER IF EXISTS test_server_exists;
207+
NOTICE: server "test_server_exists" does not exist, skipping
208+
-- operator class
209+
DROP OPERATOR CLASS test_operator_class USING btree;
210+
ERROR: operator class "test_operator_class" does not exist for access method "btree"
211+
DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree;
212+
NOTICE: operator class "test_operator_class" does not exist for access method "btree"
213+
DROP OPERATOR CLASS test_operator_class USING no_such_am;
214+
ERROR: access method "no_such_am" does not exist
215+
DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am;
216+
ERROR: access method "no_such_am" does not exist
217+
-- operator family
218+
DROP OPERATOR FAMILY test_operator_family USING btree;
219+
ERROR: operator family "test_operator_family" does not exist for access method "btree"
220+
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree;
221+
ERROR: operator family "test_operator_family" does not exist for access method "btree"
222+
DROP OPERATOR FAMILY test_operator_family USING no_such_am;
223+
ERROR: access method "no_such_am" does not exist
224+
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
225+
ERROR: access method "no_such_am" does not exist
226+
-- drop the table
227+
DROP TABLE IF EXISTS test_exists;
228+
DROP TABLE test_exists;
229+
ERROR: table "test_exists" does not exist

src/test/regress/sql/drop_if_exists.sql

+122-8
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ DROP DOMAIN IF EXISTS test_domain_exists;
8282

8383
DROP DOMAIN test_domain_exists;
8484

85-
-- drop the table
86-
87-
88-
DROP TABLE IF EXISTS test_exists;
89-
90-
DROP TABLE test_exists;
91-
92-
9385
---
9486
--- role/user/group
9587
---
@@ -115,3 +107,125 @@ DROP GROUP tg2;
115107
DROP GROUP IF EXISTS tg1, tg2;
116108

117109
DROP GROUP tg1;
110+
111+
-- collation
112+
DROP COLLATION test_collation_exists;
113+
DROP COLLATION IF EXISTS test_collation_exists;
114+
CREATE COLLATION test_collation_exists FROM "POSIX";
115+
DROP COLLATION test_collation_exists;
116+
117+
-- conversion
118+
DROP CONVERSION test_conversion_exists;
119+
DROP CONVERSION IF EXISTS test_conversion_exists;
120+
CREATE CONVERSION test_conversion_exists
121+
FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
122+
DROP CONVERSION test_conversion_exists;
123+
124+
-- text search parser
125+
DROP TEXT SEARCH PARSER test_tsparser_exists;
126+
DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists;
127+
128+
-- text search dictionary
129+
DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
130+
DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists;
131+
CREATE TEXT SEARCH DICTIONARY test_tsdict_exists (
132+
Template=ispell,
133+
DictFile=ispell_sample,
134+
AffFile=ispell_sample
135+
);
136+
DROP TEXT SEARCH DICTIONARY test_tsdict_exists;
137+
138+
-- test search template
139+
DROP TEXT SEARCH TEMPLATE test_tstemplate_exists;
140+
DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists;
141+
142+
-- text search configuration
143+
DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
144+
DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists;
145+
CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english);
146+
DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists;
147+
148+
-- extension
149+
DROP EXTENSION test_extension_exists;
150+
DROP EXTENSION IF EXISTS test_extension_exists;
151+
152+
-- functions
153+
DROP FUNCTION test_function_exists();
154+
DROP FUNCTION IF EXISTS test_function_exists();
155+
156+
DROP FUNCTION test_function_exists(int, text, int[]);
157+
DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]);
158+
159+
-- aggregate
160+
DROP AGGREGATE test_aggregate_exists(*);
161+
DROP AGGREGATE IF EXISTS test_aggregate_exists(*);
162+
163+
DROP AGGREGATE test_aggregate_exists(int);
164+
DROP AGGREGATE IF EXISTS test_aggregate_exists(int);
165+
166+
-- operator
167+
DROP OPERATOR @#@ (int, int);
168+
DROP OPERATOR IF EXISTS @#@ (int, int);
169+
CREATE OPERATOR @#@
170+
(leftarg = int8, rightarg = int8, procedure = int8xor);
171+
DROP OPERATOR @#@ (int8, int8);
172+
173+
-- language
174+
DROP LANGUAGE test_language_exists;
175+
DROP LANGUAGE IF EXISTS test_language_exists;
176+
177+
-- cast
178+
DROP CAST (text AS text);
179+
DROP CAST IF EXISTS (text AS text);
180+
181+
-- trigger
182+
DROP TRIGGER test_trigger_exists ON test_exists;
183+
DROP TRIGGER IF EXISTS test_trigger_exists ON test_exists;
184+
185+
DROP TRIGGER test_trigger_exists ON no_such_table;
186+
DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_table;
187+
188+
CREATE TRIGGER test_trigger_exists
189+
BEFORE UPDATE ON test_exists
190+
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();
191+
DROP TRIGGER test_trigger_exists ON test_exists;
192+
193+
-- rule
194+
DROP RULE test_rule_exists ON test_exists;
195+
DROP RULE IF EXISTS test_rule_exists ON test_exists;
196+
197+
DROP RULE test_rule_exists ON no_such_table;
198+
DROP RULE IF EXISTS test_rule_exists ON no_such_table;
199+
200+
CREATE RULE test_rule_exists AS ON INSERT TO test_exists
201+
DO INSTEAD
202+
INSERT INTO test_exists VALUES (NEW.a, NEW.b || NEW.a::text);
203+
DROP RULE test_rule_exists ON test_exists;
204+
205+
-- foreign data wrapper
206+
DROP FOREIGN DATA WRAPPER test_fdw_exists;
207+
DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists;
208+
209+
-- foreign server
210+
DROP SERVER test_server_exists;
211+
DROP SERVER IF EXISTS test_server_exists;
212+
213+
-- operator class
214+
DROP OPERATOR CLASS test_operator_class USING btree;
215+
DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree;
216+
217+
DROP OPERATOR CLASS test_operator_class USING no_such_am;
218+
DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am;
219+
220+
-- operator family
221+
DROP OPERATOR FAMILY test_operator_family USING btree;
222+
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree;
223+
224+
DROP OPERATOR FAMILY test_operator_family USING no_such_am;
225+
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
226+
227+
-- drop the table
228+
229+
DROP TABLE IF EXISTS test_exists;
230+
231+
DROP TABLE test_exists;

0 commit comments

Comments
 (0)