1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

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
This commit is contained in:
Alvaro Herrera
2014-01-23 14:40:29 -03:00
parent 9f80f4835a
commit b152c6cd0d
17 changed files with 523 additions and 145 deletions

View File

@ -1259,7 +1259,8 @@ func_get_detail(List *funcname,
/* Get list of possible candidates from namespace search */
raw_candidates = FuncnameGetCandidates(funcname, nargs, fargnames,
expand_variadic, expand_defaults);
expand_variadic, expand_defaults,
false);
/*
* Quickly check if there is an exact match to the input datatypes (there
@ -1714,7 +1715,7 @@ FuncNameAsType(List *funcname)
Oid result;
Type typtup;
typtup = LookupTypeName(NULL, makeTypeNameFromNameList(funcname), NULL);
typtup = LookupTypeName(NULL, makeTypeNameFromNameList(funcname), NULL, false);
if (typtup == NULL)
return InvalidOid;
@ -1873,7 +1874,7 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
{
FuncCandidateList clist;
clist = FuncnameGetCandidates(funcname, nargs, NIL, false, false);
clist = FuncnameGetCandidates(funcname, nargs, NIL, false, false, noError);
while (clist)
{
@ -1892,27 +1893,6 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
return InvalidOid;
}
/*
* LookupTypeNameOid
* Convenience routine to look up a type, silently accepting shell types
*/
static Oid
LookupTypeNameOid(const TypeName *typename)
{
Oid result;
Type typtup;
typtup = LookupTypeName(NULL, typename, NULL);
if (typtup == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("type \"%s\" does not exist",
TypeNameToString(typename))));
result = typeTypeId(typtup);
ReleaseSysCache(typtup);
return result;
}
/*
* LookupFuncNameTypeNames
* Like LookupFuncName, but the argument types are specified by a
@ -1940,7 +1920,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
{
TypeName *t = (TypeName *) lfirst(args_item);
argoids[i] = LookupTypeNameOid(t);
argoids[i] = LookupTypeNameOid(NULL, t, noError);
args_item = lnext(args_item);
}
@ -1980,7 +1960,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
{
TypeName *t = (TypeName *) lfirst(lc);
argoids[i] = LookupTypeNameOid(t);
argoids[i] = LookupTypeNameOid(NULL, t, noError);
i++;
}