Database | Proc | Application | Created | Links |
sybsystemprocs | sp_monitor_parse_archive_cmd ![]() | ![]() | 31 Aug 14 | Defects Dependencies |
1 2 create procedure sp_monitor_parse_archive_cmd( 3 @archivecmd varchar(255) 4 , @archive_str varchar(7) 5 , @archive_syntax varchar(40) 6 , @arch_prefix varchar(8) output 7 , @trace int = NULL 8 ) as 9 begin 10 declare @whoami varchar(30) 11 , @indent varchar(32) 12 , @msg varchar(200) 13 , @retval int 14 , @option_found int 15 16 , @opt_sep char(1) 17 , @charindex tinyint 18 , @usingIndex int 19 , @using_clause varchar(30) 20 , @prefix_str varchar(30) 21 , @option_item varchar(30) 22 , @left_substr varchar(30) 23 24 -- We restrict this to a short string for 125.x due to the 25 -- limited tablename length. 26 -- 27 , @arch_prefix_dflt varchar(8) 28 , @arch_prefix_maxlen int 29 , @arch_prefix_lcl varchar(30) -- Parsed value. 30 31 -- [Currently] unused output variables that are returned by the 32 -- common parsing routine sp_spaceusage_processusing. 33 -- 34 , @archive_db_unused varchar(30) 35 , @unit_unused varchar(30) 36 , @unit_found tinyint 37 38 select @whoami = 'sp_monitor_parse_archive_cmd' 39 , @indent = char(10) + space(2 * @@nestlevel) 40 , @prefix_str = 'prefix' 41 , @arch_prefix_dflt = 'archive_' 42 , @arch_prefix_lcl = NULL 43 , @using_clause = NULL 44 , @retval = 1 -- expect failure till we know otherwise 45 , @usingIndex = 0 46 47 -- Initialize to aid in error checking for inapplicable syntax. 48 , @archive_db_unused = NULL 49 , @unit_unused = NULL 50 , @unit_found = 0 51 52 -- This is the max prefix name length, as the identifiers are 53 -- restricted to be 30 bytes. This prefix allows for the possibility 54 -- to archive data from the MDA table with the longest name, if at 55 -- all we want to add that funcationality. 56 -- 57 select @arch_prefix_maxlen = datalength(@arch_prefix_dflt) 58 59 if (@trace = 1) 60 begin 61 print "%1!---- Start Trace %2! archivecmd='%3!'" 62 , @indent, @whoami 63 , @archivecmd 64 end 65 66 -- ================================================================= 67 -- If the archivecmd has a "USING prefix=" argument, parse 68 -- that out and validate it. (Note we allow mixed-case for keywords 69 -- like USING, PREFIX etc.) 70 -- 71 72 -- Check whether the user has specified a USING clause. 73 select @usingIndex = charindex("USING", upper(@archivecmd)) 74 75 if (@usingIndex != 0) 76 begin 77 -- 0 => case insensitive 78 exec sp_split_string @archivecmd, "USING", 0 79 , @left_substr out 80 , @using_clause out 81 select @using_clause = ltrim(rtrim(@using_clause)) 82 end 83 84 else if (@archivecmd != @archive_str) 85 begin 86 -- Reuse @whoami to build command-specific help. 87 select @whoami = "'@" + @archive_str + "'" 88 raiserror 18640, @whoami, @archivecmd, @archive_syntax 89 90 -- print "@archivecmd: '%1!', @archive_str: '%2!'", 91 -- @archivecmd, @archive_str 92 goto error_exit 93 end 94 95 if (@using_clause IS NOT NULL) 96 begin 97 exec @retval = sp_spaceusage_processusing 98 @using_clause 99 , @archive_db_unused out 100 , @arch_prefix_lcl out 101 , @unit_unused out 102 , @unit_found out 103 104 -- Check for cases that user might have provided sub-args 105 -- to USING clause that are valid for other interfaces (and 106 -- are hence legal per sp_spaceusage_processusing logic) 107 -- but are not legal here. Error out in such cases. 108 -- Expected: "archive[ USING prefix=]" 109 -- Expected: "report[ USING prefix=]" 110 -- 111 if ((@retval != 0) 112 or (@archive_db_unused IS NOT NULL) 113 or ((@unit_unused IS NOT NULL) and (@unit_found = 1))) 114 begin 115 -- Reuse @whoami to build command-specific help. 116 select @whoami = "'@" + @archive_str + "'" 117 118 raiserror 18640, @whoami, @archivecmd, @archive_syntax 119 120 if (@trace = 1) 121 begin 122 print "@retval: %1! @archive_db_unused: %2! @unit_unused: %3! @unit_found: %4!" 123 , @retval 124 , @archive_db_unused 125 , @unit_unused 126 , @unit_found 127 end 128 129 -- Reset to indicate an error condition. 130 select @retval = 1 131 goto error_exit 132 end 133 end 134 135 -- Validate that the length of the prefix is what we can support 136 -- in 12.5.x 137 -- 138 if (@arch_prefix_lcl IS NULL) or (@arch_prefix_lcl = "") 139 begin 140 -- Allow user to create archives named simply 'monDeadLock'. 141 select @arch_prefix = NULL -- @arch_prefix_dflt 142 end 143 144 else if (valid_name(@arch_prefix_lcl) = 0) 145 begin 146 raiserror 17284, @arch_prefix_lcl 147 goto error_exit 148 end 149 150 else if (datalength(@arch_prefix_lcl) > @arch_prefix_maxlen) 151 begin 152 raiserror 19491, @arch_prefix_lcl, @arch_prefix_maxlen 153 goto error_exit 154 end 155 else 156 begin 157 select @arch_prefix = @arch_prefix_lcl 158 end 159 160 -- All ok; @arch_prefix is a valid prefix for archive tables. 161 select @retval = 0 162 163 error_exit: 164 if (@trace = 1) 165 begin 166 print "%1!---- End Trace %2! archivecmd='%3!' arch_prefix='%4!' (retval=%5!)" 167 , @indent, @whoami 168 , @archivecmd 169 , @arch_prefix 170 , @retval 171 end 172 173 return @retval 174 end -- } 175
DEPENDENCIES |
PROCS AND TABLES USED calls proc sybsystemprocs..sp_spaceusage_processusing ![]() calls proc sybsystemprocs..sp_split_string ![]() calls proc sybsystemprocs..sp_split_string ![]() CALLERS called by proc sybsystemprocs..sp_monitor_deadlock ![]() called by proc sybsystemprocs..sp_monitor ![]() called by proc sybsystemprocs..sp_monitor_archive ![]() called by proc sybsystemprocs..sp_monitor_deadlock ![]() |