DatabaseProcApplicationCreatedLinks
sybsystemprocssp_addextendedproc  14 déc. 14Defects Propagation Dependencies

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


exec sp_procxmode 'sp_addextendedproc', 'AnyMode'
go

Grant Execute on sp_addextendedproc to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_addextendedproc  
 MUCO 3 Useless Code Useless Brackets 34
 MUCO 3 Useless Code Useless Brackets 47
 MUCO 3 Useless Code Useless Brackets 66
 MUCO 3 Useless Code Useless Brackets 68
 MUCO 3 Useless Code Useless Brackets 76
 MUCO 3 Useless Code Useless Brackets 77
 MUCO 3 Useless Code Useless Brackets 86
 MUCO 3 Useless Code Useless Brackets 98
 MUCO 3 Useless Code Useless Brackets 104
 MUCO 3 Useless Code Useless Brackets 110
 MUCO 3 Useless Code Useless Brackets 113
 QISO 3 Set isolation level 52
 VNRD 3 Variable is not read @dummy 73
 MTR1 2 Metrics: Comments Ratio Comments: 47% 12
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 4 = 9dec - 7exi + 2 12
 MTR3 2 Metrics: Query Complexity Complexity: 40 12

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