DatabaseProcApplicationCreatedLinks
sybsystemprocssp_helpthread  31 Aug 14Defects Dependencies

1     
2     /*
3     ** Messages for "sp_helpthread"
4     ** 18365, "The kernel mode that is currently in use does not support thread pools."
5     ** 18367, "The specified thread pool does not exist."
6     **
7     */
8     create procedure sp_helpthread
9         @threadpool varchar(30) = NULL /* thread pool name */
10    as
11    
12        declare @msg varchar(1024)
13    
14        begin
15    
16            if @@trancount = 0
17            begin
18                set chained off
19            end
20    
21            set transaction isolation level 1
22    
23            set nocount on
24    
25            IF @@kernelmode = 'process'
26            begin
27                /* 18365, "The kernel mode that is currently in use does not support thread pools." */
28                raiserror 18365
29                return (1)
30            end
31    
32            /*
33            **  If threadpool name not given, get them all.
34            */
35            if @threadpool is null
36            begin
37                select @threadpool = "%"
38            end
39    
40            /*
41            **  Does the threadpool exist?
42            */
43            if not exists (select *
44                    from master.dbo.monThreadPool
45                    where ThreadPoolName like @threadpool)
46            begin
47                /* 18367, "The specified thread pool does not exist." */
48                raiserror 18367
49                return (1)
50            end
51    
52            /*
53            **  Display threadpool information.
54            */
55    
56            create table #spt_thread
57            (
58                thread_id int,
59                osthread_id int,
60                state varchar(30),
61                affinity int NULL,
62                instance_id tinyint
63            )
64    
65            /*
66            **  Initialize #spt_threadpool from monThreadPool.
67            */
68            select ThreadPoolName "Name", Type, Size "CurrentSize",
69                TargetSize "TargetSize", IdleTimeout,
70                ThreadPoolDescription "Description"
71            into #spt_threadpool
72            from master.dbo.monThreadPool
73            where ThreadPoolName like @threadpool
74    
75            exec sp_autoformat @fulltabname = #spt_threadpool,
76                @selectlist = "Name, Type, CurrentSize, TargetSize, IdleTimeout, Description",
77                @orderby = "order by Name"
78    
79            print ""
80            /*
81            ** Display thread info when @threadpool is specified.
82            */
83            if @threadpool != "%"
84            begin
85                insert into #spt_thread
86                select ThreadID, OSThreadID, State, ThreadAffinity, InstanceID
87                from master.dbo.monThread
88                where ThreadPoolName like @threadpool
89    
90                exec sp_autoformat @fulltabname = #spt_thread,
91                    @selectlist = "thread_id, osthread_id, state, affinity, instance_id",
92                    @orderby = "order by thread_id"
93            end
94    
95            drop table #spt_threadpool
96            drop table #spt_thread
97    
98            return (0)
99        end
100   
101   


exec sp_procxmode 'sp_helpthread', 'AnyMode'
go

Grant Execute on sp_helpthread to public
go
DEFECTS
 MEST 4 Empty String will be replaced by Single Space 79
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 75
 MUSP 4 Unquoted String Parameter sybsystemprocs..sp_autoformat: @fulltabname 90
 TNOI 4 Table with no index master..monThread master..monThread
 TNOI 4 Table with no index master..monThreadPool master..monThreadPool
 MGTP 3 Grant to public master..monThread  
 MGTP 3 Grant to public master..monThreadPool  
 MGTP 3 Grant to public sybsystemprocs..sp_helpthread  
 MNER 3 No Error Check should check @@error after select into 68
 MNER 3 No Error Check should check return value of exec 75
 MNER 3 No Error Check should check @@error after insert 85
 MNER 3 No Error Check should check return value of exec 90
 MUCO 3 Useless Code Useless Begin-End Pair 14
 MUCO 3 Useless Code Useless Brackets 29
 MUCO 3 Useless Code Useless Brackets 49
 MUCO 3 Useless Code Useless Brackets 98
 MUIN 3 Column created using implicit nullability 56
 QAPT 3 Access to Proxy Table master..monThreadPool 44
 QAPT 3 Access to Proxy Table master..monThreadPool 72
 QAPT 3 Access to Proxy Table master..monThread 87
 QISO 3 Set isolation level 21
 VUNU 3 Variable is not used @msg 12
 MSUB 2 Subquery Marker 43
 MTR1 2 Metrics: Comments Ratio Comments: 27% 8
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 4 = 5dec - 3exi + 2 8
 MTR3 2 Metrics: Query Complexity Complexity: 38 8

DEPENDENCIES
PROCS AND TABLES USED
reads table master..monThread (1)  
reads table master..monThreadPool (1)  
calls proc sybsystemprocs..sp_autoformat  
   reads table tempdb..syscolumns (1)  
   read_writes table tempdb..#colinfo_af (1) 
   calls proc sybsystemprocs..sp_autoformat  
   reads table master..syscolumns (1)  
   reads table tempdb..systypes (1)  
   reads table master..systypes (1)  
   calls proc sybsystemprocs..sp_namecrack  
writes table tempdb..#spt_threadpool (1) 
writes table tempdb..#spt_thread (1)