DatabaseProcApplicationCreatedLinks
sybsystemprocssp_freedll  31 Aug 14Defects 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 procedure sp_freedll
13        @dll_name varchar(259) /* dll name (which may
14    						   include extension) */
15    as
16    
17    
18        /*
19        **  If we're in a transaction, disallow this since it might make recovery
20        **  impossible.
21        */
22        if @@trancount > 0
23        begin
24            /*
25            ** 17260, "Can't run %1! from within a transaction." 
26            */
27            raiserror 17260, "sp_freedll"
28            return (1)
29        end
30    
31        set chained off
32    
33        set transaction isolation level 1
34        /* check if user has sa role, proc_role will also do auditing
35        ** if required. proc_role will also print error message if required.
36        */
37    
38        if (proc_role("sa_role") = 0)
39            return (1)
40    
41        /* 
42        ** Remove optional . and extension (.dll or .so) from @dllname
43        */
44        declare @dotposition int
45        select @dotposition = patindex("%.%", @dll_name)
46        if (@dotposition > 0)
47            select @dll_name = substring(@dll_name, 1, @dotposition - 1)
48    
49        /*
50        **  Check to see that the @dll_name is valid.
51        */
52    
53        if valid_name(@dll_name, 255) = 0
54        begin
55            /*
56            ** 17240, "'%1!' is not a valid name." 
57            */
58            raiserror 17240, @dll_name
59            return (1)
60        end
61    
62        /*
63        **  Make sure the dll exists.
64        */
65        if (not exists (select *
66                    from sysobjects o
67                    where getdllname(o.id) = @dll_name
68                        and o.type = 'XP'
69                        and (o.sysstat & 15) = 4))
70        begin
71            /*
72            ** 18393, "DLL for the extended stored procedure '%1!' is not found."
73            */
74            raiserror 18393, @dll_name
75            return (1)
76        end
77    
78        /*
79        ** Now unload the DLL.
80        */
81        dbcc spfreedll(@dll_name)
82    
83        if (@@error != 0)
84        begin
85            /*
86            ** 18392, "sp_freedll failed."
87            */
88            raiserror 18392
89            return (1)
90        end
91    
92        return (0)
93    


exec sp_procxmode 'sp_freedll', 'AnyMode'
go

Grant Execute on sp_freedll to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_freedll  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MUCO 3 Useless Code Useless Brackets 28
 MUCO 3 Useless Code Useless Brackets 38
 MUCO 3 Useless Code Useless Brackets 39
 MUCO 3 Useless Code Useless Brackets 46
 MUCO 3 Useless Code Useless Brackets 59
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 75
 MUCO 3 Useless Code Useless Brackets 83
 MUCO 3 Useless Code Useless Brackets 89
 MUCO 3 Useless Code Useless Brackets 92
 QISO 3 Set isolation level 33
 MSUB 2 Subquery Marker 65
 MTR1 2 Metrics: Comments Ratio Comments: 53% 12
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 8dec - 5exi + 2 12
 MTR3 2 Metrics: Query Complexity Complexity: 33 12

DEPENDENCIES
PROCS AND TABLES USED
reads table sybsystemprocs..sysobjects