2
Vote

Ascmd.exe XMLA batch delimiter regex bug

description

I was running into issues trying to run an OLAP DB scripted out XMLA create (from management studio). The XMLA was valid and could be run fine in management studio, and AScmd would run simpler XMLA just fine.
 
It appears to be the "BatchRegex" pattern defined on line 316 in Ascmd.cs. It looks for "GO" statements within the xmla, however the pattern looked for any "go" text followed by a space. We had a dimension attribute of "Year Ago Today", and the ascmd would try to split the xmla into batches, and truncate the large CREATE statement at "Year Ago".
 
I've changed the regex to include and end string token and this seems to fix the problem, however I don't understand the batching properly to know if this is an adequate fix:
My Chagne: const string BatchRegex = @"^[\w\W]*?[\r\n]*go\s$";
 
Reproduction steps:
Create an olapdb/cube with a measure or dimension having "go" in the name, anything like "go time" or "year ago today" should work.
Script entire olap database as "CREATE" from Management studio
Try to run this create script to create the olapdb on a new server using Ascmd.exe.

comments

kosteckir wrote Jan 12, 2012 at 3:17 PM

We have faced the same issue and following some code debugging came up with the following bug fix: const string BatchRegex = @"^[\w\W]*?[\r\n]+go\s";

The second star before ‘go’ needs to be replaced with ‘+’

Justification:
“+” means 1 or more occurrences. This means that that ‘go’ must be preceded by at least one new line “\r\n” to form a new batch.

“*” means 0 or more occurrences therefore every string ending with “go”+ white space (such as “ringo “, “bingo “, “dingo “ etc.) created a new batch with a broken XML structure regardless whether it was preceded by [\r\n] or not.

kosteckir wrote Jan 12, 2012 at 3:19 PM

We have faced the same issue and following some code debugging came up with the following bug fix: const string BatchRegex = @"^[\w\W]*?[\r\n]+go\s";

The second star before ‘go’ needs to be replaced with ‘+’

Justification:
“+” means 1 or more occurrences. This means that that ‘go’ must be preceded by at least one new line “\r\n” to form a new batch.

“*” means 0 or more occurrences therefore every string ending with “go”+ white space (such as “ringo “, “bingo “, “dingo “ etc.) created a new batch with a broken XML structure regardless whether it was preceded by [\r\n] or not.

wrote Jan 14, 2012 at 4:59 AM

wrote Feb 21, 2013 at 10:34 PM