1010 *
1111 *
1212 * IDENTIFICATION
13- * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.74 2006/04/15 17:45:34 tgl Exp $
13+ * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.75 2006/06/16 20:23:44 adunstan Exp $
1414 *
1515 * DESCRIPTION
1616 * These routines take the parse tree and pick out the
@@ -687,7 +687,16 @@ RemoveFunction(RemoveFuncStmt *stmt)
687687/*
688688 * Find the function, do permissions and validity checks
689689 */
690- funcOid = LookupFuncNameTypeNames (functionName ,argTypes , false);
690+ funcOid = LookupFuncNameTypeNames (functionName ,argTypes ,stmt -> missing_ok );
691+ if (stmt -> missing_ok && !OidIsValid (funcOid ))
692+ {
693+ ereport (NOTICE ,
694+ (errmsg ("function %s(%s) does not exist ... skipping" ,
695+ NameListToString (functionName ),
696+ NameListToString (argTypes ))));
697+ return ;
698+ }
699+
691700
692701tup = SearchSysCache (PROCOID ,
693702ObjectIdGetDatum (funcOid ),
@@ -1377,6 +1386,7 @@ DropCast(DropCastStmt *stmt)
13771386HeapTuple tuple ;
13781387ObjectAddress object ;
13791388
1389+ /* when dropping a cast, the types must exist even if you use IF EXISTS */
13801390sourcetypeid = typenameTypeId (NULL ,stmt -> sourcetype );
13811391targettypeid = typenameTypeId (NULL ,stmt -> targettype );
13821392
@@ -1385,11 +1395,23 @@ DropCast(DropCastStmt *stmt)
13851395ObjectIdGetDatum (targettypeid ),
138613960 ,0 );
13871397if (!HeapTupleIsValid (tuple ))
1388- ereport (ERROR ,
1389- (errcode (ERRCODE_UNDEFINED_OBJECT ),
1390- errmsg ("cast from type %s to type %s does not exist" ,
1391- TypeNameToString (stmt -> sourcetype ),
1392- TypeNameToString (stmt -> targettype ))));
1398+ {
1399+ if (!stmt -> missing_ok )
1400+ ereport (ERROR ,
1401+ (errcode (ERRCODE_UNDEFINED_OBJECT ),
1402+ errmsg ("cast from type %s to type %s does not exist" ,
1403+ TypeNameToString (stmt -> sourcetype ),
1404+ TypeNameToString (stmt -> targettype ))));
1405+ else
1406+ ereport (NOTICE ,
1407+ (errmsg ("cast from type %s to type %s does not exist ... skipping" ,
1408+ TypeNameToString (stmt -> sourcetype ),
1409+ TypeNameToString (stmt -> targettype ))));
1410+
1411+ return ;
1412+ }
1413+
1414+
13931415
13941416/* Permission check */
13951417if (!pg_type_ownercheck (sourcetypeid ,GetUserId ())