Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise Developer Center
Viewing all articles
Browse latest Browse all 1240

Re: Analyze Capture fails in Workload Analyzer

$
0
0

Hello Niksa, long time no see!

 

Looks like str_replace locates the string to replace but then offsets the start/end positions by -1; so in your test case instead of replacing 'p_test' it's replacing ' p_tes' ("Duh, Mark!" ?):

 

======================================

-- original

create procedure p_test as select * from publishers

-- should be

create procedure p_test_v22 as select * from publishers

-- actual

create procedurep_test_v22t as select * from publishers

======================================


I'm not finding anything in the published CR lists of PL03 and PL04 so you'll likely need to contact tech support to see if they already know about this.


------------------


I'm wondering if this issue shows up in other string functions, is different for @variables vs literals, and/or is related to utf-8, eg:


======================================

-- some sample tests to run against a utf-8 dataserver and a non/utf-8 dataserver ...


-- str_replace() with literal


select str_replace("create procedure p_test as select * from publishers", "p_test", "p_test_v22")

go


-- str_replace() with literal and multi-string search/replace;

-- all 3x correct? all 3x wrong? mix of correct/wrong?


select "create procedure p_test as select * from publishers"

union all

select str_replace("create procedure p_test as select * from publishers", " p", "XY")

go


/* correct result:


---------------------------------------------------

create procedure p_test as select * from publishers

createXYrocedureXY_test as select * fromXYublishers


*/

 

-- stuff() with @variable


declare @proctext varchar(100)

select @proctext = "create procedure p_test as select * from publishers"

select stuff(@proctext, 18, 6, "p_test_v22")

go


-- stuff() with literal


select stuff("create procedure p_test as select * from publishers", 18, 6, "p_test_v22")

go


-- charindex() with @variable; returns 17 (wrong) or 18 (right)?


declare @proctext varchar(100)

select @proctext = "create procedure p_test as select * from publishers"

select charindex("p_test", @proctext)

go


-- charindex() with literal; returns 17 (wrong) or 18 (right)?


select charindex("p_test", "create procedure p_test as select * from publishers")

go


-- patindex() with @variable; returns 17 (wrong) or 18 (right)?


declare @proctext varchar(100)

select @proctext = "create procedure p_test as select * from publishers"

select patindex("%p_test%", @proctext)

go


-- patindex() with literal; returns 17 (wrong) or 18 (right)?


select patindex("%p_test%", "create procedure p_test as select * from publishers")

go


-- substring() with @variable: returns "p_test" or " p_tes"?


declare @proctext varchar(100)

select @proctext = "create procedure p_test as select * from publishers"

select substring(@proctext, 18, 6)

go


-- substring() with literal; returns "p_test" or " p_tes"?


select substring("create procedure p_test as select * from publishers", 18, 6)

go

======================================


Viewing all articles
Browse latest Browse all 1240


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>