1

Closed

Double hyphens following newline not treated properly

description

the string
N'Hello
--Janet'
 
is treated as an unterminated string followed by a comment. this should be treated as
N'Hello'+NCHAR(10)+NCHAR(13)+'Janet'

file attachments

Closed Mar 26, 2012 at 9:26 AM by ErikEJ
3.5.2.9 released

comments

ErikEJ wrote Dec 15, 2011 at 6:21 AM

That seems to be an edge case - and what about the 2 hyphens?

wrote Dec 15, 2011 at 10:00 AM

Fixed on changeset 83907

lostinplace wrote Dec 15, 2011 at 1:25 PM

the line should have been N'Hello'+NCHAR(10)+NCHAR(13)+'--Janet'

This is accounted for in the patch

Thanks.

mape1082 wrote Jan 6, 2012 at 2:54 PM

This patch is causing an issue when the SQL sentence is big enough:

Msg 191, Level 15, State 1, Line 1
Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.

The insert statement looks like the attachments, being 190+ lines long.

The solution I found was:
to replace "'+NCHAR(10)+NCHAR(13)+'" by ""..

A more long term solution may be neeed.

lostinplace wrote Jan 6, 2012 at 4:33 PM

Can you clarify please?

lostinplace wrote Jan 6, 2012 at 4:35 PM

I would imagine that this is occurring because of the large number of newlines (and hence extremely complex sql statement)

can you clarify your solution?

mape1082 wrote Jan 7, 2012 at 3:39 AM

Sorry for the delay. The issue was solved by removing the call to NCHAR(10) and NCHAR(13) and replacing the \n by an empty string "". This worked with my dataset by may not work for others. Since it is removing the functionality introduced by the patch I wouldnt say mine is a solution.

Maybe in the specific case of the issue addressed by the patch, the solution could be as follows:

if a string contains "\n" followed by "--", then it could be replaced by "\n-' + NCHAR(??)", where ?? is the ascii code for the '-' charcater. If this patch was like this it would work too with my dataset.

Thanks

ErikEJ wrote Jan 8, 2012 at 12:16 PM

Setting to active, and rollong back fix for now

wrote Feb 10, 2012 at 8:53 PM

Fixed on changeset 86293