DatabaseProcApplicationCreatedLinks
sybsystemprocssp_listener  31 Aug 14Defects Dependencies

1     
2     
3     /*
4     ** Messages for "sp_listener"
5     **
6     ** 17260, "Can't run %1! from within a transaction."
7     ** 19862, "Invalid input: Server name '%1!' matches the remote instance." 
8     ** 18899, "Invalid value supplied to parameter %1!."
9     ** 17325, "The length of input parameter '%1!' is longer than the permissible %2! characters."
10    */
11    
12    /*
13    **	sp_listener cmd, addr, eng
14    **
15    ** This stored procedure is the interface to the
16    ** Dynamic Listener Daemon functionality. It allows
17    ** the sa to start, stop, suspend, resume, reserve,
18    ** network listeners on selected ports and engines.
19    ** The command will execute atomically unless the command
20    ** is reserve or the engine parameter has been specified
21    ** via the keyword remaining.
22    **
23    ** Parameters:
24    **	cmd can be any of the following:
25    **		"start", "stop", "suspend", "resume", "status",
26    **		"reserve", "activate", "unreserve"
27    **	addr can be the name of the running ASE server
28    **		or a "proto:host:port" combination.
29    **		length of addr is at the most MAXDLADDR
30    **
31    **	eng can be any list of engines including ranges such
32    **		as "1-3,5,7,10-12", or the word "remaining"
33    **
34    ** Return Value:
35    **	0 in case of success, 1 in case of error
36    */
37    create procedure sp_listener
38        @cmd varchar(30) = null,
39        @addr varchar(612) = null,
40        @eng varchar(30) = null
41    as
42    
43        if @@trancount > 0
44        begin
45            /* 17260, "Can't run %1! from within a transaction." */
46            raiserror 17260, "sp_listener"
47            return (1)
48        end
49        else
50        begin
51            set chained off
52        end
53    
54        set transaction isolation level 1
55        set nocount on
56    
57        /* Must have sa_role as this stored procedure is related to config */
58        if (proc_role("sa_role") < 1)
59            return (1)
60    
61        /* Restrict listener command to local instance */
62        if (@@clustermode = "shared disk cluster"
63                and (instance_id(@addr) is not NULL)
64                and (instance_id(@addr) != instance_id()))
65        begin
66            /* 19862, "Invalid input: Server name '%1!' matches the remote instance." */
67            raiserror 19862, @addr
68            return (1)
69        end
70    
71        if (@cmd in ("start", "stop", "suspend", "resume", "status"))
72        begin
73            if (char_length(@addr) > 611)
74            begin
75                /*
76                ** 17325, "The length of input parameter '%1!' is longer than the permissible %2! characters."
77                */
78                raiserror 17325, @addr, 611
79                return (1)
80            end
81            dbcc listener(@cmd, @addr, @eng)
82            if (@@error != 0)
83            begin
84                return (1)
85            end
86        end
87        else
88        begin
89            print "Usage: sp_listener command [,'protocol:machine:port'[,engine]] "
90            print "sp_listener commands:"
91            print "start"
92            print "stop"
93            print "suspend"
94            print "resume"
95            print "status"
96            print "help"
97            print "The type of protocol can be one of the following: "
98            print "tcp, tli, ssltcp, ssltli, winsock, sslnlwnsck, sslwinsock"
99            print "IPV6 addresses should be enclosed in brackets, for ex 'tcp:[2001:ec8:4008:1::123]:80'"
100           print "Note: 'engine' parameter is valid only in process kernel mode"
101       end
102       return (0)
103   
104   


exec sp_procxmode 'sp_listener', 'AnyMode'
go

Grant Execute on sp_listener to public
go
DEFECTS
 MGTP 3 Grant to public sybsystemprocs..sp_listener  
 MUCO 3 Useless Code Useless Brackets 47
 MUCO 3 Useless Code Useless Brackets 58
 MUCO 3 Useless Code Useless Brackets 59
 MUCO 3 Useless Code Useless Brackets 62
 MUCO 3 Useless Code Useless Brackets 68
 MUCO 3 Useless Code Useless Brackets 71
 MUCO 3 Useless Code Useless Brackets 73
 MUCO 3 Useless Code Useless Brackets 79
 MUCO 3 Useless Code Useless Brackets 82
 MUCO 3 Useless Code Useless Brackets 84
 MUCO 3 Useless Code Useless Brackets 102
 QISO 3 Set isolation level 54
 MTR1 2 Metrics: Comments Ratio Comments: 49% 37
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 5 = 8dec - 5exi + 2 37
 MTR3 2 Metrics: Query Complexity Complexity: 40 37

DEPENDENCIES