99 *
1010 *
1111 * IDENTIFICATION
12- * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.16 2002/08/05 03:29:16 tgl Exp $
12+ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.17 2002/08/11 17:44:12 petere Exp $
1313 *
1414 * DESCRIPTION
1515 * These routines take the parse tree and pick out the
@@ -621,6 +621,12 @@ CreateCast(CreateCastStmt *stmt)
621621if (sourcetypeid == targettypeid )
622622elog (ERROR ,"source data type and target data type are the same" );
623623
624+ if (!pg_type_ownercheck (sourcetypeid ,GetUserId ())
625+ && !pg_type_ownercheck (targettypeid ,GetUserId ()))
626+ elog (ERROR ,"must be owner of type %s or type %s" ,
627+ TypeNameToString (stmt -> sourcetype ),
628+ TypeNameToString (stmt -> targettype ));
629+
624630relation = heap_openr (CastRelationName ,RowExclusiveLock );
625631
626632tuple = SearchSysCache (CASTSOURCETARGET ,
@@ -639,10 +645,6 @@ CreateCast(CreateCastStmt *stmt)
639645 false,
640646"CreateCast" );
641647
642- if (!pg_proc_ownercheck (funcid ,GetUserId ()))
643- aclcheck_error (ACLCHECK_NOT_OWNER ,
644- NameListToString (stmt -> func -> funcname ));
645-
646648tuple = SearchSysCache (PROCOID ,ObjectIdGetDatum (funcid ),0 ,0 ,0 );
647649if (!HeapTupleIsValid (tuple ))
648650elog (ERROR ,"cache lookup of function %u failed" ,funcid );
@@ -666,12 +668,6 @@ CreateCast(CreateCastStmt *stmt)
666668else
667669{
668670/* indicates binary compatibility */
669- if (!pg_type_ownercheck (sourcetypeid ,GetUserId ()))
670- aclcheck_error (ACLCHECK_NOT_OWNER ,
671- TypeNameToString (stmt -> sourcetype ));
672- if (!pg_type_ownercheck (targettypeid ,GetUserId ()))
673- aclcheck_error (ACLCHECK_NOT_OWNER ,
674- TypeNameToString (stmt -> targettype ));
675671funcid = InvalidOid ;
676672}
677673
@@ -730,7 +726,6 @@ DropCast(DropCastStmt *stmt)
730726Oid sourcetypeid ;
731727Oid targettypeid ;
732728HeapTuple tuple ;
733- Form_pg_cast caststruct ;
734729ObjectAddress object ;
735730
736731sourcetypeid = LookupTypeName (stmt -> sourcetype );
@@ -753,22 +748,11 @@ DropCast(DropCastStmt *stmt)
753748TypeNameToString (stmt -> targettype ));
754749
755750/* Permission check */
756- caststruct = (Form_pg_cast )GETSTRUCT (tuple );
757- if (caststruct -> castfunc != InvalidOid )
758- {
759- if (!pg_proc_ownercheck (caststruct -> castfunc ,GetUserId ()))
760- aclcheck_error (ACLCHECK_NOT_OWNER ,
761- get_func_name (caststruct -> castfunc ));
762- }
763- else
764- {
765- if (!pg_type_ownercheck (sourcetypeid ,GetUserId ()))
766- aclcheck_error (ACLCHECK_NOT_OWNER ,
767- format_type_be (sourcetypeid ));
768- if (!pg_type_ownercheck (targettypeid ,GetUserId ()))
769- aclcheck_error (ACLCHECK_NOT_OWNER ,
770- format_type_be (targettypeid ));
771- }
751+ if (!pg_type_ownercheck (sourcetypeid ,GetUserId ())
752+ && !pg_type_ownercheck (targettypeid ,GetUserId ()))
753+ elog (ERROR ,"must be owner of type %s or type %s" ,
754+ TypeNameToString (stmt -> sourcetype ),
755+ TypeNameToString (stmt -> targettype ));
772756
773757/*
774758 * Do the deletion