9
9
*
10
10
*
11
11
* IDENTIFICATION
12
- * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.14 2002/07/29 20:45 :44 tgl Exp $
12
+ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.15 2002/07/29 23:44 :44 tgl Exp $
13
13
*
14
14
* DESCRIPTION
15
15
* These routines take the parse tree and pick out the
47
47
#include "parser/parse_func.h"
48
48
#include "parser/parse_type.h"
49
49
#include "utils/acl.h"
50
+ #include "utils/builtins.h"
50
51
#include "utils/fmgroids.h"
51
52
#include "utils/lsyscache.h"
52
53
#include "utils/syscache.h"
@@ -633,10 +634,14 @@ CreateCast(CreateCastStmt *stmt)
633
634
634
635
if (stmt -> func != NULL )
635
636
{
636
- funcid = LookupFuncNameTypeNames (stmt -> func -> funcname , stmt -> func -> funcargs , false, "CreateCast" );
637
+ funcid = LookupFuncNameTypeNames (stmt -> func -> funcname ,
638
+ stmt -> func -> funcargs ,
639
+ false,
640
+ "CreateCast" );
637
641
638
- if (!pg_proc_ownercheck (funcid , GetUserId ()))
639
- elog (ERROR , "permission denied" );
642
+ if (!pg_proc_ownercheck (funcid , GetUserId ()))
643
+ aclcheck_error (ACLCHECK_NOT_OWNER ,
644
+ NameListToString (stmt -> func -> funcname ));
640
645
641
646
tuple = SearchSysCache (PROCOID , ObjectIdGetDatum (funcid ), 0 , 0 , 0 );
642
647
if (!HeapTupleIsValid (tuple ))
@@ -661,10 +666,13 @@ CreateCast(CreateCastStmt *stmt)
661
666
else
662
667
{
663
668
/* indicates binary compatibility */
664
- if (!pg_type_ownercheck (sourcetypeid , GetUserId ())
665
- || !pg_type_ownercheck (targettypeid , GetUserId ()))
666
- elog (ERROR , "permission denied" );
667
- funcid = 0 ;
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 ));
675
+ funcid = InvalidOid ;
668
676
}
669
677
670
678
/* ready to go */
@@ -754,14 +762,18 @@ DropCast(DropCastStmt *stmt)
754
762
caststruct = (Form_pg_cast ) GETSTRUCT (tuple );
755
763
if (caststruct -> castfunc != InvalidOid )
756
764
{
757
- if (!pg_proc_ownercheck (caststruct -> castfunc , GetUserId ()))
758
- elog (ERROR , "permission denied" );
765
+ if (!pg_proc_ownercheck (caststruct -> castfunc , GetUserId ()))
766
+ aclcheck_error (ACLCHECK_NOT_OWNER ,
767
+ get_func_name (caststruct -> castfunc ));
759
768
}
760
769
else
761
770
{
762
- if (!pg_type_ownercheck (sourcetypeid , GetUserId ())
763
- || !pg_type_ownercheck (targettypeid , GetUserId ()))
764
- elog (ERROR , "permission denied" );
771
+ if (!pg_type_ownercheck (sourcetypeid , GetUserId ()))
772
+ aclcheck_error (ACLCHECK_NOT_OWNER ,
773
+ format_type_be (sourcetypeid ));
774
+ if (!pg_type_ownercheck (targettypeid , GetUserId ()))
775
+ aclcheck_error (ACLCHECK_NOT_OWNER ,
776
+ format_type_be (targettypeid ));
765
777
}
766
778
767
779
/*
0 commit comments