Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 The Yak Corral
 Please Vote If You Can

Author  Topic 

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-08-03 : 12:27:00
https://connect.microsoft.com/SQLServer/feedback/details/337516/incorrect-syntax-does-not-throw-error

They closed another one as won't fix:

https://connect.microsoft.com/SQLServer/feedback/details/273348/trailing-comma-allowed-in-create-table

Don't mean to hijack the forum for this, it just bugs me that this is "valid" T-SQL:
create table #a (a int,)
And if anyone's interested, I found this while cleaning up our source control and trying to standardize it. Almost ready to write my own parser and then this crap comes up.

Kristen
Test

22859 Posts

Posted - 2010-08-03 : 13:09:15
I think they should fix it in next release.

I'd be pretty pissed if a Service Pack caused my code to break because I had included a benign trailing space comma.

What I mean is: I'd be very happy for the parser to complain when I wrote the code, and I'd be very happy to fix it at that time, but if a service pack tightened up the parser such that my code broke, and we had to fix the code before we could install the service pack, that would be bad news. We'd have to do a full QA cycle, and (who knows?) we might be desperate to get the service pack for some vulnerability.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-08-03 : 13:34:23
quote:
benign trailing space
Ahhh, but it's NOT a space, or any other whitespace character, it's the universal delimiter. Its presence not only suggests but practically demands that something come after it. In fact I don't think there is a single legal token in SQL that allows this.

What pisses me off the most is that they say "it does not comply with the grammar" but they won't fix it. I can understand schedule pressures but closing the item as won't fix, especially since it's inconsistent with the other syntax...arrrrgh. There's a lot of these kinds of bugs and they get ignored all the time.
quote:
but if a service pack tightened up the parser such that my code broke, and we had to fix the code before we could install the service pack
I agree a service pack might not be the best way to roll it out, but at the same time, YOUR CODE IS BROKEN REGARDLESS, the service pack didn't break it. It's also not particularly difficult to fix, even if someone had thousands of procedures/functions. (And IMHO, if they're that sloppy/lazy/stupid to make this kind of mistake in hundreds of procs, they deserve to fix them all by hand)

I guess I need to get a life if this kind of thing pisses me off.
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2010-08-03 : 14:28:10
Sorry, but I agree with them be cautious about fixing this in a service pack.

________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-08-03 : 16:08:49
It has been this way a long time. I'm fairly certain that by now it would break at least some of my code.



CODO ERGO SUM
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-04 : 02:52:13
maybe not fixing this at the Service Pack but at least at new version. It can be a compatibility level thingy just like the non ansi join style when moving from 2000 to 2005.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-04 : 02:54:19
"Ahhh, but it's NOT a space,"

Rob I'm sorry, I'm a prat. I genuinely meant to type, and meant, "comma". Please take my original discussion to be in that context.

"YOUR CODE IS BROKEN REGARDLESS, the service pack didn't break it."

FWIW I'm 99.999% certain that I have found a trailing comma in production code and thought it odd that the parser had not complained. And I took it out. I am fanatical about code consistency. If I write a simple one time SELECT statement it is correctly capitalised and indented as per in-house coding standards - one-time-throw-away statements have a habit of getting into long-life code. But even so I'm 99.999% sure I've seen a trailing comma in my code.

Its easy to do. Write the first column definition:

CREATE TABLE
(
MyColumn int NULL,

cut & paste the MyColumn row 10 times and change the name for each column your want to add. Then forget to remove the trailing comma on the last one. Or add a PRIMARY KEY or some other constraint ... and then remove it forgetting to also remove the final comma.

I make these sorts of typing mistakes all too often, the parser complains when I EXEC it, and I tidy it up.

Hence I think fixing it in Service Pack would be an issue!

"It's also not particularly difficult to fix, even if someone had thousands of procedures/functions."

I'd be very happy to fix it; I like my code to be clean. But I would not be happy with the cost of the QA we would have to run because change-control had caused one/many Sprocs to be changed. Full QA for us is a week's work .... that's a lot of cost to roll out a Service Pack.

I'll repeat a rant:

I want a STRICT mode, or LINT that will moan about code iffiness. Including SELECT statements with no ORDER BY which are silently relying on Clustered Index and order fine in DEV and 99% of the time in production too ...
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-04 : 02:55:40
quote:
Originally posted by khtan

maybe not fixing this at the Service Pack but at least at new version. It can be a compatibility level thingy just like the non ansi join style when moving from 2000 to 2005.


... and , hopefully, would be picked up by the Upgrade Advisor
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-04 : 02:56:32
not hopefully, MUST !


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -