DatabaseProcApplicationCreatedLinks
sybsystemprocssp_dropextendedproc  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /*
4     ** Messages from dropextendedproc
5     **
6     ** 17260, "Can't run %1! from within a transaction." 
7     ** 18388, "You must be in the 'master' database in order to run %1!
8     ** 17240, "'%1!' is not a valid name."
9     ** 18389, "sp_dropextendedproc failed."
10    */
11    create or replace procedure sp_dropextendedproc
12        @esp_name varchar(255)
13    as
14    
15        declare @maxlen int
16        declare @nullarg char(1)
17        declare @dummy int
18        declare @status int
19        declare @gp_enabled int
20    
21    
22    
23    
24        /* If we're not in master, disallow this */
25    
26        if db_name() != "master"
27        begin
28            /*
29            ** 18388, "You must be in the 'master' database in order to run %1!
30            */
31            raiserror 18388, "sp_dropextendedproc"
32            return (1)
33        end
34    
35        /*
36        **  If we're in a transaction, disallow this since it might make recovery
37        **  impossible.
38        */
39        if @@trancount > 0
40        begin
41            /*
42            ** 17260, "Can't run %1! from within a transaction." 
43            */
44            raiserror 17260, "sp_dropextendedproc"
45            return (1)
46        end
47    
48        set chained off
49    
50        set transaction isolation level 1
51    
52        /* 
53        ** If granular permissions is not enabled then sa_role is required.
54        ** If granular permissions is enabled then the permission 'manage any ESP' is
55        ** required.  proc_role and proc_auditperm will also do auditing
56        ** if required. Both will also print error message if required.
57        */
58    
59        select @nullarg = NULL
60        execute @status = sp_aux_checkroleperm "sa_role",
61            "manage any ESP", @nullarg, @gp_enabled output
62    
63        /* For Auditing */
64        if (@gp_enabled = 0)
65        begin
66            if (proc_role("sa_role") = 0)
67                return 1
68        end
69        else
70        begin
71            select @dummy = proc_auditperm("manage any ESP", @status)
72        end
73    
74        if (@status != 0)
75            return (1)
76    
77        /* check that esp_name is a valid identifier */
78        select @maxlen = length from syscolumns
79        where id = object_id("sysobjects") and name = "name"
80    
81        if valid_name(@esp_name, @maxlen) = 0
82        begin
83            /*
84            ** 17240, "'%1!' is not a valid name."
85            */
86            raiserror 17240, @esp_name
87            return (1)
88        end
89    
90        dbcc dropextendedproc(@esp_name)
91    
92        if (@@error != 0)
93        begin
94            /*
95            ** 18389, "sp_dropextendedproc failed."
96            */
97            raiserror 18389
98            return (1)
99        end
100   
101       return (0)
102   


exec sp_procxmode 'sp_dropextendedproc', 'AnyMode'
go

Grant Execute on sp_dropextendedproc to public
go
DEFECTS
 MAW1 3 Warning message on %name% sybsystemprocs..syscolumns.id: Warning message on syscolumns 79
 MGTP 3 Grant to public sybsystemprocs..sp_dropextendedproc  
 MGTP 3 Grant to public sybsystemprocs..syscolumns  
 MUCO 3 Useless Code Useless Brackets 32
 MUCO 3 Useless Code Useless Brackets 45
 MUCO 3 Useless Code Useless Brackets 64
 MUCO 3 Useless Code Useless Brackets 66
 MUCO 3 Useless Code Useless Brackets 74
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 87
 MUCO 3 Useless Code Useless Brackets 92
 MUCO 3 Useless Code Useless Brackets 98
 MUCO 3 Useless Code Useless Brackets 101
 QAFM 3 Var Assignment from potentially many rows 78
 QISO 3 Set isolation level 50
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: syscolumns.csyscolumns unique clustered
(id, number, colid)
Intersection: {id}
79
 VNRD 3 Variable is not read @dummy 71
 MTR1 2 Metrics: Comments Ratio Comments: 47% 11
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 9dec - 6exi + 2 11
 MTR3 2 Metrics: Query Complexity Complexity: 41 11

DEPENDENCIES
PROCS AND TABLES USED
reads table sybsystemprocs..syscolumns  
calls proc sybsystemprocs..sp_aux_checkroleperm  
   reads table master..syscurconfigs (1)  
   reads table master..sysconfigures (1)