Commit 83dbde94 authored by Tom Lane's avatar Tom Lane

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>
parent 9dd4178c
...@@ -262,6 +262,10 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs) ...@@ -262,6 +262,10 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
switch (objtype) switch (objtype)
{ {
case OBJECT_ACCESS_METHOD:
msg = gettext_noop("access method \"%s\" does not exist, skipping");
name = NameListToString(objname);
break;
case OBJECT_TYPE: case OBJECT_TYPE:
case OBJECT_DOMAIN: case OBJECT_DOMAIN:
{ {
...@@ -438,7 +442,7 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs) ...@@ -438,7 +442,7 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
} }
break; break;
default: default:
elog(ERROR, "unexpected object type (%d)", (int) objtype); elog(ERROR, "unrecognized object type: %d", (int) objtype);
break; break;
} }
......
...@@ -227,6 +227,11 @@ DROP OPERATOR FAMILY test_operator_family USING no_such_am; ...@@ -227,6 +227,11 @@ DROP OPERATOR FAMILY test_operator_family USING no_such_am;
ERROR: access method "no_such_am" does not exist ERROR: access method "no_such_am" does not exist
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am; DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
ERROR: access method "no_such_am" does not exist ERROR: access method "no_such_am" does not exist
-- access method
DROP ACCESS METHOD no_such_am;
ERROR: access method "no_such_am" does not exist
DROP ACCESS METHOD IF EXISTS no_such_am;
NOTICE: access method "no_such_am" does not exist, skipping
-- drop the table -- drop the table
DROP TABLE IF EXISTS test_exists; DROP TABLE IF EXISTS test_exists;
DROP TABLE test_exists; DROP TABLE test_exists;
......
...@@ -227,6 +227,10 @@ DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree; ...@@ -227,6 +227,10 @@ DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree;
DROP OPERATOR FAMILY test_operator_family USING no_such_am; DROP OPERATOR FAMILY test_operator_family USING no_such_am;
DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am; DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;
-- access method
DROP ACCESS METHOD no_such_am;
DROP ACCESS METHOD IF EXISTS no_such_am;
-- drop the table -- drop the table
DROP TABLE IF EXISTS test_exists; DROP TABLE IF EXISTS test_exists;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment