]> granicus.if.org Git - postgresql/commitdiff
Fix DROP OPERATOR FAMILY IF EXISTS.
authorRobert Haas <rhaas@postgresql.org>
Fri, 21 Oct 2011 13:10:46 +0000 (09:10 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 21 Oct 2011 13:12:23 +0000 (09:12 -0400)
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.

src/backend/commands/opclasscmds.c
src/test/regress/expected/drop_if_exists.out

index 5dde78abc9a195add262c395287ca360d3661aff..af0de05a0320645610886cde5ac4fdcd4af058ea 100644 (file)
@@ -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;
        }
 
index d29077657f7a2a8c988c56ae53bca028b4334bb2..85994016e156d0824d9a2df61a85989575039393 100644 (file)
@@ -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;