10
10
*
11
11
*
12
12
* 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 $
14
14
*
15
15
* DESCRIPTION
16
16
* These routines take the parse tree and pick out the
@@ -687,7 +687,16 @@ RemoveFunction(RemoveFuncStmt *stmt)
687
687
/*
688
688
* Find the function, do permissions and validity checks
689
689
*/
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
+
691
700
692
701
tup = SearchSysCache (PROCOID ,
693
702
ObjectIdGetDatum (funcOid ),
@@ -1377,6 +1386,7 @@ DropCast(DropCastStmt *stmt)
1377
1386
HeapTuple tuple ;
1378
1387
ObjectAddress object ;
1379
1388
1389
+ /* when dropping a cast, the types must exist even if you use IF EXISTS */
1380
1390
sourcetypeid = typenameTypeId (NULL , stmt -> sourcetype );
1381
1391
targettypeid = typenameTypeId (NULL , stmt -> targettype );
1382
1392
@@ -1385,11 +1395,23 @@ DropCast(DropCastStmt *stmt)
1385
1395
ObjectIdGetDatum (targettypeid ),
1386
1396
0 , 0 );
1387
1397
if (!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
+
1393
1415
1394
1416
/* Permission check */
1395
1417
if (!pg_type_ownercheck (sourcetypeid , GetUserId ())
0 commit comments