aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/opclasscmds.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2014-01-23 14:40:29 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2014-01-23 14:40:29 -0300
commitb152c6cd0de1827ba58756e24e18110cf902182a (patch)
tree82d0ced551764509a60014e9996f3b4d634b4071 /src/backend/commands/opclasscmds.c
parent9f80f4835a55a1cbffcda5d23a617917f3286c14 (diff)
downloadpostgresql-b152c6cd0de1827ba58756e24e18110cf902182a.tar.gz
postgresql-b152c6cd0de1827ba58756e24e18110cf902182a.zip
Make DROP IF EXISTS more consistently not fail
Some cases were still reporting errors and aborting, instead of a NOTICE that the object was being skipped. This makes it more difficult to cleanly handle pg_dump --clean, so change that to instead skip missing objects properly. Per bug #7873 reported by Dave Rolsky; apparently this affects a large number of users. Authors: Pavel Stehule and Dean Rasheed. Some tweaks by Álvaro Herrera
Diffstat (limited to 'src/backend/commands/opclasscmds.c')
-rw-r--r--src/backend/commands/opclasscmds.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index c910c3964c6..5d7b37c674a 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -103,11 +103,14 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
/* Look in specific schema only */
Oid namespaceId;
- namespaceId = LookupExplicitNamespace(schemaname, false);
- htup = SearchSysCache3(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amID),
- PointerGetDatum(opfname),
- ObjectIdGetDatum(namespaceId));
+ namespaceId = LookupExplicitNamespace(schemaname, missing_ok);
+ if (!OidIsValid(namespaceId))
+ htup = NULL;
+ else
+ htup = SearchSysCache3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amID),
+ PointerGetDatum(opfname),
+ ObjectIdGetDatum(namespaceId));
}
else
{
@@ -179,11 +182,14 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
/* Look in specific schema only */
Oid namespaceId;
- namespaceId = LookupExplicitNamespace(schemaname, false);
- htup = SearchSysCache3(CLAAMNAMENSP,
- ObjectIdGetDatum(amID),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceId));
+ namespaceId = LookupExplicitNamespace(schemaname, missing_ok);
+ if (!OidIsValid(namespaceId))
+ htup = NULL;
+ else
+ htup = SearchSysCache3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amID),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceId));
}
else
{