DatabaseProcApplicationCreatedLinks
sybsystemprocssp_freedll  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /* 
4     ** Messages from freedll
5     **
6     ** 17260, "Can't run %1! from within a transaction." 
7     ** 17240, "'%1!' is not a valid name." 
8     ** 18393, "DLL for the extended stored procedure '%1!' is not found." 
9     ** 18392, "sp_freedll failed."
10    */
11    
12    create or replace procedure sp_freedll
13        @dll_name varchar(259) /* dll name (which may
14    						   include extension) */
15    as
16    
17        declare @nullarg char(1)
18        declare @dummy int
19        declare @status int
20        declare @gp_enabled int
21    
22    
23    
24    
25        /*
26        **  If we're in a transaction, disallow this since it might make recovery
27        **  impossible.
28        */
29        if @@trancount > 0
30        begin
31            /*
32            ** 17260, "Can't run %1! from within a transaction." 
33            */
34            raiserror 17260, "sp_freedll"
35            return (1)
36        end
37    
38        set chained off
39    
40        set transaction isolation level 1
41    
42        /* 
43        ** If granular permissions is not enabled then sa_role is required.
44        ** If granular permissions is enabled then the permission manage any ESP is
45        ** required.  proc_role and proc_auditperm will also do auditing
46        ** if required. Both will also print error message if required.
47        */
48    
49        select @nullarg = NULL
50        execute @status = sp_aux_checkroleperm "sa_role",
51            "manage any ESP", @nullarg, @gp_enabled output
52    
53        /* For Auditing */
54        if (@gp_enabled = 0)
55        begin
56            if (proc_role("sa_role") = 0)
57                return 1
58        end
59        else
60        begin
61            select @dummy = proc_auditperm("manage any ESP", @status)
62        end
63    
64        if (@status != 0)
65            return 1
66        /* 
67        ** Remove optional . and extension (.dll or .so) from @dllname
68        */
69        declare @dotposition int
70        select @dotposition = patindex("%.%", @dll_name)
71        if (@dotposition > 0)
72            select @dll_name = substring(@dll_name, 1, @dotposition - 1)
73    
74        /*
75        **  Check to see that the @dll_name is valid.
76        */
77    
78        if valid_name(@dll_name, 255) = 0
79        begin
80            /*
81            ** 17240, "'%1!' is not a valid name." 
82            */
83            raiserror 17240, @dll_name
84            return (1)
85        end
86    
87        /*
88        **  Make sure the dll exists.
89        */
90        if (not exists (select *
91                    from sysobjects o
92                    where getdllname(o.id) = @dll_name
93                        and o.type = 'XP'
94                        and (o.sysstat & 15) = 4))
95        begin
96            /*
97            ** 18393, "DLL for the extended stored procedure '%1!' is not found."
98            */
99            raiserror 18393, @dll_name
100           return (1)
101       end
102   
103       /*
104       ** Now unload the DLL.
105       */
106       dbcc spfreedll(@dll_name)
107   
108       if (@@error != 0)
109       begin
110           /*
111           ** 18392, "sp_freedll failed."
112           */
113           raiserror 18392
114           return (1)
115       end
116   
117       return (0)
118   


exec sp_procxmode 'sp_freedll', 'AnyMode'
go

Grant Execute on sp_freedll to public
go
DEFECTS
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 92
 MGTP 3 Grant to public sybsystemprocs..sp_freedll  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MUCO 3 Useless Code Useless Brackets 35
 MUCO 3 Useless Code Useless Brackets 54
 MUCO 3 Useless Code Useless Brackets 56
 MUCO 3 Useless Code Useless Brackets 64
 MUCO 3 Useless Code Useless Brackets 71
 MUCO 3 Useless Code Useless Brackets 84
 MUCO 3 Useless Code Useless Brackets 90
 MUCO 3 Useless Code Useless Brackets 100
 MUCO 3 Useless Code Useless Brackets 108
 MUCO 3 Useless Code Useless Brackets 114
 MUCO 3 Useless Code Useless Brackets 117
 QISO 3 Set isolation level 40
 VNRD 3 Variable is not read @dummy 61
 MSUB 2 Subquery Marker 90
 MTR1 2 Metrics: Comments Ratio Comments: 47% 12
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 7 = 11dec - 6exi + 2 12
 MTR3 2 Metrics: Query Complexity Complexity: 45 12

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