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

Commit 83dbde9

Browse files
committed
Fix DROP ACCESS METHOD IF EXISTS.
The IF EXISTS option was documented, and implemented in the grammar, but it didn't actually work for lack of support in does_not_exist_skipping(). Per bug #14160. Report and patch by Kouhei Sutou Report: <20160527070433.19424.81712@wrigleys.postgresql.org>
1 parent 9dd4178 commit 83dbde9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/backend/commands/dropcmds.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
262262

263263
switch (objtype)
264264
{
265+
case OBJECT_ACCESS_METHOD:
266+
msg = gettext_noop("access method \"%s\" does not exist, skipping");
267+
name = NameListToString(objname);
268+
break;
265269
case OBJECT_TYPE:
266270
case OBJECT_DOMAIN:
267271
{
@@ -438,7 +442,7 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
438442
}
439443
break;
440444
default:
441-
elog(ERROR, "unexpected object type (%d)", (int) objtype);
445+
elog(ERROR, "unrecognized object type: %d", (int) objtype);
442446
break;
443447
}
444448

src/test/regress/expected/drop_if_exists.out

+5
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ DROP OPERATOR FAMILY test_operator_family USING no_such_am;
227227
ERROR: access method "no_such_am" does not exist
228228
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
229229
ERROR: access method "no_such_am" does not exist
230+
-- access method
231+
DROP ACCESS METHOD no_such_am;
232+
ERROR: access method "no_such_am" does not exist
233+
DROP ACCESS METHOD IF EXISTS no_such_am;
234+
NOTICE: access method "no_such_am" does not exist, skipping
230235
-- drop the table
231236
DROP TABLE IF EXISTS test_exists;
232237
DROP TABLE test_exists;

src/test/regress/sql/drop_if_exists.sql

+4
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree;
227227
DROP OPERATOR FAMILY test_operator_family USING no_such_am;
228228
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
229229

230+
-- access method
231+
DROP ACCESS METHOD no_such_am;
232+
DROP ACCESS METHOD IF EXISTS no_such_am;
233+
230234
-- drop the table
231235

232236
DROP TABLE IF EXISTS test_exists;

0 commit comments

Comments
 (0)