Database | Proc | Application | Created | Links |
sybsystemprocs | sp_errorlog | 31 Aug 14 | Defects Dependencies |
1 2 3 /* 4 ** SP_ERRORLOG 5 ** 6 ** Driver interface to error logging functionality. 7 ** For each feature the underlying driver function/built-in/sub-ordinate stored 8 ** procedure is called. 9 ** 10 ** Syntax 11 ** sp_errorlog ["command" [,"parameter"]] 12 ** 13 ** Parameters 14 ** @cmd - This is the command or action to be performed. 15 ** @subcommand - This is the parameter supplied for executing the comman 16 ** @param_value - This is the require parameter to be passed for subcommand. 17 ** 18 ** Returns 19 ** 0 - success 20 ** other - errors while execution 21 */ 22 23 create procedure sp_errorlog 24 ( 25 @cmd varchar(30) = NULL, 26 @subcommand varchar(1024) = NULL, 27 @param_value varchar(30) = NULL 28 ) 29 as 30 begin 31 declare @retval int, 32 @msg varchar(256), 33 @flag int, 34 @retstatus int 35 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 /* 17260, "Can't run %1! from within a transaction." */ 44 raiserror 17260, "sp_errorlog" 45 return (1) 46 end 47 else 48 begin 49 set chained off 50 end 51 52 set transaction isolation level 1 53 set nocount on 54 55 /* Begin command processing. */ 56 57 select @cmd = lower(@cmd) 58 select @param_value = lower(@param_value) 59 60 If (@cmd is null or @cmd = 'help') 61 begin 62 exec sp_errorlog_showhelp @cmd, @subcommand, @param_value 63 return (0) 64 end 65 66 if (@cmd = 'change log') 67 begin 68 /* Must have sa_role for this command */ 69 if (proc_role("sa_role") < 1) 70 begin 71 return (1) 72 end 73 74 /* Check if subcommand or param_value entered is valid */ 75 if (@subcommand is null or 76 (@param_value not in ('jslog true', 'jslog false', null))) 77 begin 78 /* 17932, "You entered an invalid value. No change was made." */ 79 raiserror 17932 80 return (1) 81 end 82 83 select @flag = 1 84 if (@param_value = 'jslog false') 85 begin 86 select @flag = 0 87 end 88 89 select @retval = errorlog_admin(@cmd, @subcommand) 90 if (@retval = 0) 91 begin 92 /* 19845, "Change in errorlog path complete. New file: '%1!'" */ 93 exec sp_getmessage 19845, @msg output 94 print @msg, @subcommand 95 /* 96 ** 19846, "Update the -e argument in the Runserver file with 97 ** the new errorlog path to reflect the errorlog change. 98 */ 99 exec sp_getmessage 19846, @msg output 100 print @msg 101 end 102 else if (@retval = 2) 103 begin 104 /* 19848,"Command already in use by another user or session." */ 105 raiserror 19848 106 end 107 else if (@retval = 4) 108 begin 109 /* 19847, "File '%1!' did not open for writing." */ 110 raiserror 19847, @subcommand 111 end 112 else if (@retval = 8) 113 begin 114 /* 19845, "Change in errorlog path complete. New file: '%1!'" */ 115 exec sp_getmessage 19845, @msg output 116 print @msg, @subcommand 117 /* 118 ** 19846, "Update the -e argument in the Runserver file with 119 ** the new errorlog path to reflect the errorlog change. 120 */ 121 exec sp_getmessage 19846, @msg output 122 print @msg 123 124 /* 19851, "Warning:Previous errorlog file could not be closed."*/ 125 exec sp_getmessage 19851, @msg output 126 print @msg 127 end 128 else 129 begin 130 /* 131 ** 19850, "Internal error encountered in opening new errorlog. 132 ** Check current ASE errorlog for details." 133 */ 134 raiserror 19850 135 136 end 137 138 if ((@retval = 0 or @retval = 8) and @flag = 1) 139 begin 140 /* 141 ** Errorlog change was successful. Now change the Job Scheduler 142 ** errorlog directory from its current directory to the 143 ** directory where new errorlog resides. 144 */ 145 146 select @retstatus = js_wakeup('jsagent_log', @flag) 147 148 if (@retstatus = 1) 149 begin 150 /* 151 ** 19852, "Attempting to change the Job Scheduler Agent 152 ** log from its current directory to the directory 153 ** where new ASE errorlog is residing. Check the 154 ** JS Agent log and/or ASE errorlog for details." 155 */ 156 exec sp_getmessage 19852, @msg output 157 print @msg 158 end 159 else 160 begin 161 select @retstatus = js_wakeup('start_js', 0) 162 if (@retstatus = 1 and @param_value = 'jslog true') 163 begin 164 /* 165 ** 19853, "The Job Scheduler is not running; 166 ** therefore, no attempt amde to change 167 ** location of JS Agent log. 168 */ 169 raiserror 19853 170 end 171 else 172 begin 173 if (@retstatus = 0) /* Indicates JS is running */ 174 begin 175 /* print error when moving to JS agent log */ 176 /* 177 ** 19856, "Error encountered when moving the 178 ** Job Scheduler Agent log from its 179 ** current directory to the directory 180 ** where new errorlog is residing. 181 ** Check the previous JS Agent log and/or 182 ** ASE errorlog for details." 183 */ 184 raiserror 19856 185 end 186 end 187 end 188 end 189 return (@retval) 190 end 191 else 192 begin 193 194 /* 19213, "Invalid argument or unsupported command: %1!." */ 195 raiserror 19213, @cmd 196 return (1) 197 end 198 end 199
exec sp_procxmode 'sp_errorlog', 'AnyMode' go Grant Execute on sp_errorlog to public go
DEFECTS | |
MTYP 4 Assignment type mismatch @command: varchar(30) = varchar(1024) | 62 |
MGTP 3 Grant to public sybsystemprocs..sp_errorlog | |
MNER 3 No Error Check should check return value of exec | 62 |
MNER 3 No Error Check should check return value of exec | 93 |
MNER 3 No Error Check should check return value of exec | 99 |
MNER 3 No Error Check should check return value of exec | 115 |
MNER 3 No Error Check should check return value of exec | 121 |
MNER 3 No Error Check should check return value of exec | 125 |
MNER 3 No Error Check should check return value of exec | 156 |
MUCO 3 Useless Code Useless Brackets in create proc | 24 |
MUCO 3 Useless Code Useless Begin-End Pair | 30 |
MUCO 3 Useless Code Useless Brackets | 45 |
MUCO 3 Useless Code Useless Brackets | 60 |
MUCO 3 Useless Code Useless Brackets | 63 |
MUCO 3 Useless Code Useless Brackets | 66 |
MUCO 3 Useless Code Useless Brackets | 69 |
MUCO 3 Useless Code Useless Brackets | 71 |
MUCO 3 Useless Code Useless Brackets | 75 |
MUCO 3 Useless Code Useless Brackets | 80 |
MUCO 3 Useless Code Useless Brackets | 84 |
MUCO 3 Useless Code Useless Brackets | 90 |
MUCO 3 Useless Code Useless Brackets | 102 |
MUCO 3 Useless Code Useless Brackets | 107 |
MUCO 3 Useless Code Useless Brackets | 112 |
MUCO 3 Useless Code Useless Brackets | 138 |
MUCO 3 Useless Code Useless Brackets | 148 |
MUCO 3 Useless Code Useless Brackets | 162 |
MUCO 3 Useless Code Useless Brackets | 173 |
MUCO 3 Useless Code Useless Brackets | 189 |
MUCO 3 Useless Code Useless Brackets | 196 |
QISO 3 Set isolation level | 52 |
MTR1 2 Metrics: Comments Ratio Comments: 48% | 23 |
MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 14 = 19dec - 7exi + 2 | 23 |
MTR3 2 Metrics: Query Complexity Complexity: 72 | 23 |
DEPENDENCIES |
PROCS AND TABLES USED calls proc sybsystemprocs..sp_getmessage reads table sybsystemprocs..sysusermessages reads table master..sysmessages (1) reads table master..syslanguages (1) calls proc sybsystemprocs..sp_validlang reads table master..syslanguages (1) calls proc sybsystemprocs..sp_errorlog_showhelp calls proc sybsystemprocs..sp_getmessage |