From: Robert Haas Date: Fri, 21 Oct 2011 13:10:46 +0000 (-0400) Subject: Fix DROP OPERATOR FAMILY IF EXISTS. X-Git-Tag: REL9_2_BETA1~949 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=980261929f2b8c40d6be1979ff81c943cad907b3;p=postgresql Fix DROP OPERATOR FAMILY IF EXISTS. Essentially, the "IF EXISTS" portion was being ignored, and an error thrown anyway if the opfamily did not exist. I broke this in commit fd1843ff8979c0461fb3f1a9eab61140c977e32d; so backpatch to 9.1.X. Report and diagnosis by KaiGai Kohei. --- diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 5dde78abc9..af0de05a03 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -1613,10 +1613,9 @@ RemoveOpFamily(RemoveOpFamilyStmt *stmt) tuple = OpFamilyCacheLookup(amID, stmt->opfamilyname, stmt->missing_ok); if (!HeapTupleIsValid(tuple)) { - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("operator family \"%s\" does not exist for access method \"%s\"", - NameListToString(stmt->opfamilyname), stmt->amname))); + ereport(NOTICE, + (errmsg("operator family \"%s\" does not exist for access method \"%s\", skipping", + NameListToString(stmt->opfamilyname), stmt->amname))); return; } diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out index d29077657f..85994016e1 100644 --- a/src/test/regress/expected/drop_if_exists.out +++ b/src/test/regress/expected/drop_if_exists.out @@ -214,7 +214,7 @@ ERROR: access method "no_such_am" does not exist DROP OPERATOR FAMILY test_operator_family USING btree; ERROR: operator family "test_operator_family" does not exist for access method "btree" DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree; -ERROR: operator family "test_operator_family" does not exist for access method "btree" +NOTICE: operator family "test_operator_family" does not exist for access method "btree", skipping DROP OPERATOR FAMILY test_operator_family USING no_such_am; ERROR: access method "no_such_am" does not exist DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am;