DatabaseProcApplicationCreatedLinks
sybsystemprocssp_spaceusage_processusing  14 déc. 14Defects Propagation Dependencies

1     
2     /*
3     ** Generated by spgenmsgs.pl on Tue Oct 31 23:35:58 2006 
4     */
5     /*
6     ** raiserror Messages for spaceusage_processusing [Total 0]
7     */
8     /*
9     ** sp_getmessage Messages for spaceusage_processusing [Total 0]
10    */
11    /*
12    ** End spgenmsgs.pl output.
13    */
14    /*
15    **	SP_SPACEUSAGE_PROCESSUSING
16    **
17    **	The sub-procedure that processes the USING clause that is supplied as
18    **	input to the sp_spaceusage procedure and extracts and returns the 
19    **	database name and the prefix string and the unit specifier from it. 
20    **	Called by sp_spaceusage.
21    **
22    **	Parameters
23    **		@using_clause	- The USING clause string.
24    **	
25    **	NOTE: 	The procedure assumes that the USING clause is valid and in one
26    **		of the following forms:
27    **		using[ ]+dbname[ ]+=%
28    **		using[ ]+prefix[ ]+=%
29    **		using[ ]+unit[ ]+=%
30    **		using[ ]+dbname[ ]+=%,prefix[ ]+=%
31    **		using[ ]+dbname[ ]+=%,unit[ ]+=%
32    **		using[ ]+prefix[ ]+=%,dbname[ ]+=%
33    **		using[ ]+prefix[ ]+=%,unit[ ]+=%
34    **		using[ ]+unit[ ]+=%,dbname[ ]+=%
35    **		using[ ]+unit[ ]+=%,prefix[ ]+=%
36    **		using[ ]+dbname[ ]+=%,prefix[ ]+=%,unit[ ]+=%
37    **		using[ ]+dbname[ ]+=%,unit[ ]+=%,prefix[ ]+=%
38    **		using[ ]+prefix[ ]+=%,dbname[ ]+=%,unit[ ]+=%
39    **		using[ ]+prefix[ ]+=%,unit[ ]+=%,dbname[ ]+=%
40    **		using[ ]+unit[ ]+=%,dbname[ ]+=%,prefix[ ]+=%
41    **		using[ ]+unit[ ]+=%,prefix[ ]+=%,dbname[ ]+=%
42    **		
43    **	Returns
44    **		- The database name.
45    **		- The prefix string.
46    **		- The unit for page counts.
47    {
48    */
49    create or replace procedure sp_spaceusage_processusing
50    (
51        @using_clause varchar(350)
52        , @database varchar(30) output
53        , @prefixstring varchar(255) output
54        , @unit varchar(6) output
55    )
56    as
57        begin -- {	-- Procedure begins! 
58    
59            declare
60                @left_substr varchar(350)
61                , @right_substr varchar(350)
62                , @rest varchar(350)
63                , @firstpart varchar(350)
64                , @secondpart varchar(350)
65                , @thirdpart varchar(350)
66                , @dbnamekeyword varchar(7)
67                , @prefixkeyword varchar(7)
68                , @unitkeyword varchar(5)
69                , @savedRsubstr varchar(350)
70                , @returnStatus int
71    
72            select @database = NULL
73                , @prefixstring = NULL
74                , @unit = NULL
75                , @dbnamekeyword = "dbname"
76                , @prefixkeyword = "prefix"
77                , @unitkeyword = "unit"
78    
79            exec @returnStatus = sp_split_string @using_clause, ",", 1
80                , @firstpart out, @rest out
81    
82            if @returnStatus = 1
83            begin -- {
84    
85                /*
86                ** Comma not found. It's either dbname, or prefix, or unit,
87                ** keyword, not a combination. 
88                */
89                exec sp_split_string @using_clause, "=", 1, @left_substr out
90                    , @right_substr out
91    
92                select @left_substr = ltrim(rtrim(lower(@left_substr)))
93                    , @right_substr = ltrim(rtrim(@right_substr))
94    
95                if @left_substr = @dbnamekeyword
96                    select @database = @right_substr
97                else if @left_substr = @prefixkeyword
98                    select @prefixstring = @right_substr
99                else
100                   select @unit = @right_substr
101   
102               return (0)
103   
104           end -- }	-- End of if 
105           else
106           begin -- {
107   
108               /* 
109               ** Comma found. It's a combination of 2 or more of dbanme,
110               ** prefix, unit keywords. 
111               */
112               exec @returnStatus = sp_split_string @rest, ",", 1
113                   , @secondpart out, @thirdpart out
114   
115               if @returnStatus = 1 -- Second comma not found
116               begin
117                   select @secondpart = @rest
118                       , @thirdpart = NULL
119               end
120   
121               select @firstpart = ltrim(rtrim(@firstpart))
122                   , @secondpart = ltrim(rtrim(@secondpart))
123                   , @thirdpart = ltrim(rtrim(@thirdpart))
124   
125               exec sp_split_string @firstpart, "=", 1, @left_substr out
126                   , @right_substr out
127   
128               select @left_substr = ltrim(rtrim(lower(@left_substr)))
129                   , @right_substr = ltrim(rtrim(@right_substr))
130   
131               if @left_substr = @dbnamekeyword
132               begin -- {
133   
134                   select @database = @right_substr
135   
136                   exec sp_split_string @secondpart, "=", 1
137                       , @left_substr out, @right_substr out
138   
139                   select @left_substr = ltrim(rtrim(lower(@left_substr)))
140                       , @right_substr = ltrim(rtrim(@right_substr))
141   
142                   if @left_substr = @prefixkeyword
143                   begin -- {
144   
145                       select @prefixstring = @right_substr
146   
147                       if @thirdpart is not NULL
148                       begin
149                           exec sp_split_string @thirdpart, "=", 1
150                               , @left_substr out
151                               , @right_substr out
152   
153                           select @unit =
154                               ltrim(rtrim(@right_substr))
155                       end
156   
157                   end -- }
158                   else
159                   begin -- {
160   
161                       select @unit = @right_substr
162   
163                       if @thirdpart is not NULL
164                       begin
165                           exec sp_split_string @thirdpart, "=", 1
166                               , @left_substr out
167                               , @right_substr out
168   
169                           select @prefixstring =
170                               ltrim(rtrim(@right_substr))
171                       end
172   
173                   end -- }
174   
175               end -- }
176               else if @left_substr = @prefixkeyword
177               begin -- {
178   
179                   select @prefixstring = @right_substr
180   
181                   exec sp_split_string @secondpart, "=", 1
182                       , @left_substr out, @right_substr out
183   
184                   select @left_substr = ltrim(rtrim(lower(@left_substr)))
185                       , @right_substr = ltrim(rtrim(@right_substr))
186   
187                   if @left_substr = @dbnamekeyword
188                   begin -- {
189   
190                       select @database = @right_substr
191   
192                       if @thirdpart is not NULL
193                       begin
194                           exec sp_split_string @thirdpart, "=", 1
195                               , @left_substr out
196                               , @right_substr out
197   
198                           select @unit =
199                               ltrim(rtrim(@right_substr))
200                       end
201   
202                   end -- }
203                   else
204                   begin -- {
205   
206                       select @unit = @right_substr
207   
208                       if @thirdpart is not NULL
209                       begin
210                           exec sp_split_string @thirdpart, "=", 1
211                               , @left_substr out
212                               , @right_substr out
213   
214                           select @database =
215                               ltrim(rtrim(@right_substr))
216                       end
217   
218                   end -- }
219   
220               end -- }
221               else
222               begin -- {
223   
224                   select @unit = @right_substr
225   
226                   exec sp_split_string @secondpart, "=", 1
227                       , @left_substr out, @right_substr out
228   
229                   select @left_substr = ltrim(rtrim(lower(@left_substr)))
230                       , @right_substr = ltrim(rtrim(@right_substr))
231   
232                   if @left_substr = @prefixkeyword
233                   begin -- {
234   
235                       select @prefixstring = @right_substr
236   
237                       if @thirdpart is not NULL
238                       begin
239                           exec sp_split_string @thirdpart, "=", 1
240                               , @left_substr out
241                               , @right_substr out
242   
243                           select @database =
244                               ltrim(rtrim(@right_substr))
245                       end
246   
247                   end -- }
248                   else
249                   begin -- {
250   
251                       select @database = @right_substr
252   
253                       if @thirdpart is not NULL
254                       begin
255                           exec sp_split_string @thirdpart, "=", 1
256                               , @left_substr out
257                               , @right_substr out
258   
259                           select @prefixstring =
260                               ltrim(rtrim(@right_substr))
261                       end
262   
263                   end -- }
264   
265               end -- }
266   
267               return (0)
268   
269           end -- }	-- End of else
270   
271       end --}	-- }
272   


exec sp_procxmode 'sp_spaceusage_processusing', 'AnyMode'
go

Grant Execute on sp_spaceusage_processusing to public
go
DEFECTS
 MTYP 4 Assignment type mismatch @database: varchar(30) = varchar(350) 96
 MTYP 4 Assignment type mismatch @prefixstring: varchar(255) = varchar(350) 98
 MTYP 4 Assignment type mismatch @unit: varchar(6) = varchar(350) 100
 MTYP 4 Assignment type mismatch @database: varchar(30) = varchar(350) 134
 MTYP 4 Assignment type mismatch @prefixstring: varchar(255) = varchar(350) 145
 MTYP 4 Assignment type mismatch @unit: varchar(6) = varchar(350) 161
 MTYP 4 Assignment type mismatch @prefixstring: varchar(255) = varchar(350) 179
 MTYP 4 Assignment type mismatch @database: varchar(30) = varchar(350) 190
 MTYP 4 Assignment type mismatch @unit: varchar(6) = varchar(350) 206
 MTYP 4 Assignment type mismatch @unit: varchar(6) = varchar(350) 224
 MTYP 4 Assignment type mismatch @prefixstring: varchar(255) = varchar(350) 235
 MTYP 4 Assignment type mismatch @database: varchar(30) = varchar(350) 251
 MGTP 3 Grant to public sybsystemprocs..sp_spaceusage_processusing  
 MNER 3 No Error Check should check return value of exec 89
 MNER 3 No Error Check should check return value of exec 125
 MNER 3 No Error Check should check return value of exec 136
 MNER 3 No Error Check should check return value of exec 149
 MNER 3 No Error Check should check return value of exec 165
 MNER 3 No Error Check should check return value of exec 181
 MNER 3 No Error Check should check return value of exec 194
 MNER 3 No Error Check should check return value of exec 210
 MNER 3 No Error Check should check return value of exec 226
 MNER 3 No Error Check should check return value of exec 239
 MNER 3 No Error Check should check return value of exec 255
 MUCO 3 Useless Code Useless Brackets in create proc 50
 MUCO 3 Useless Code Useless Begin-End Pair 57
 MUCO 3 Useless Code Useless Brackets 102
 MUCO 3 Useless Code Useless Brackets 267
 VNRD 3 Variable is not read @unitkeyword 77
 VNRD 3 Variable is not read @left_substr 256
 VUNU 3 Variable is not used @savedRsubstr 69
 MTR1 2 Metrics: Comments Ratio Comments: 27% 49
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 15 = 16dec - 3exi + 2 49
 MTR3 2 Metrics: Query Complexity Complexity: 73 49

DEPENDENCIES
PROCS AND TABLES USED
calls proc sybsystemprocs..sp_split_string  

CALLERS
called by proc sybsystemprocs..sp_spaceusage  
called by proc sybsystemprocs..sp_monitor_parse_archive_cmd  
   called by proc sybsystemprocs..sp_monitor_archive  
      called by proc sybsystemprocs..sp_monitor_deadlock  
         called by proc sybsystemprocs..sp_monitor  
   called by proc sybsystemprocs..sp_monitor_deadlock