DatabaseProcApplicationCreatedLinks
sybsystemprocssp_role  14 déc. 14Defects Propagation Dependencies

1     
2     /* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */
3     /*	5.0	1.0	10/22/91	sproc/src/role */
4     
5     /*
6     ** Generated by spgenmsgs.pl on Thu Feb  2 00:39:19 2006 
7     */
8     /*
9     ** raiserror Messages for role [Total 3]
10    **
11    ** 17260, "Can't run %1! from within a transaction."
12    ** 17756, "The execution of the stored procedure '%1!' in database '%2!' was aborted because there was an error in writing the replication log record."
13    ** 17884, "Neither 'grant' or 'revoke' is specified -- nothing changed."
14    */
15    /*
16    ** sp_getmessage Messages for role [Total 1]
17    **
18    ** 17885, "Authorization updated."
19    */
20    /*
21    ** End spgenmsgs.pl output.
22    */
23    
24    create or replace procedure sp_role
25        @action varchar(30), /* "grant" or "revoke"	*/
26        @rolename varchar(255), /* role name		*/
27        @grantee varchar(255) /* user/role name	*/
28    as
29        declare @msg varchar(1024) /* Message text */
30    
31        /*
32        ** Do not allow this system procedure to be run from within a transaction
33        ** to avoid creating a multi-database transaction where the 'master'
34        ** database is not the co-ordinating database.
35        */
36        if @@trancount > 0
37        begin
38            /* 17260, "Can't run %1! from within a transaction." */
39            raiserror 17260, "sp_role"
40            return (1)
41        end
42    
43        /*
44        **  Invoke the grant/revoke role command to perform the grant/revoke.
45        */
46        if @action = "grant"
47        begin
48            grant role @rolename to @grantee
49        end
50        else if @action = "revoke"
51        begin
52            revoke role @rolename from @grantee
53        end
54        else
55        begin
56            /*
57            ** 17884, "Neither 'grant' or 'revoke' is specified -- nothing changed."
58            */
59            raiserror 17884
60        end
61    
62        if @@error != 0
63        begin
64            return (1)
65        end
66    
67        /*
68        ** If the 'master' database is marked for replication, the T-SQL built-in
69        ** 'logexec()' will log for replication the execution instance of this
70        ** system procedure.  Otherwise, the T-SQL built-in 'logexec()' is a no-op.
71        */
72        if (logexec(1) != 1)
73        begin
74            raiserror 17756, "sp_role", "master"
75            return (1)
76        end
77    
78        /*
79        ** 17885, "Role updated."
80        */
81        exec sp_getmessage 17885, @msg output
82        print @msg
83        return (0)
84    


exec sp_procxmode 'sp_role', 'AnyMode'
go

Grant Execute on sp_role to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_role  
 MNER 3 No Error Check should check return value of exec 81
 MUCO 3 Useless Code Useless Brackets 40
 MUCO 3 Useless Code Useless Brackets 64
 MUCO 3 Useless Code Useless Brackets 72
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 83
 MTR1 2 Metrics: Comments Ratio Comments: 63% 24
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 4 = 6dec - 4exi + 2 24
 MTR3 2 Metrics: Query Complexity Complexity: 23 24

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_getmessage  
   reads table master..syslanguages (1)  
   reads table sybsystemprocs..sysusermessages  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  

CALLERS
called by proc master..mon_authorize_non_sa