BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Now here's a nice gotcha (MSSQL2000)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Arthur Hoornweg
Guest





PostPosted: Wed Mar 01, 2006 9:03 am    Post subject: Now here's a nice gotcha (MSSQL2000) Reply with quote



I ran into the weirdest thing yesterday.

I added a new field to an existing table called "tracks" in my database:

ALTER TABLE tracks ADD nlfbcode NVARCHAR(50) NOT NULL Default 'No ID
entered'

The database already contained a view "tracks_view".

The purpose of this view is to implement row-level security, i.e. all users
only get to see a subset of the records depending on their credentials.
Table "tracks" itself is not accessible directly to normal database users.


It was defined as:

CREATE VIEW tracks_view WITH VIEW_METADATA AS
SELECT T.* FROM (tracks T inner join sec_rights R on t.tracknr=r.objectid)
WHERE r.uname=system_user WITH CHECK OPTION


To my amazement, the new column "nlfbcode" doesn't show up at all when I
perform "select * from tracks_view", but it does show up when I do a
"select * from tracks".


I had to delete the view and re-create it to get things working again!



--
Arthur Hoornweg

(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
Back to top
Oliver Townshend
Guest





PostPosted: Wed Mar 01, 2006 9:03 am    Post subject: Re: Now here's a nice gotcha (MSSQL2000) Reply with quote



Quote:
The purpose of this view is to implement row-level security, i.e. all
users
only get to see a subset of the records depending on their credentials.
Table "tracks" itself is not accessible directly to normal database users.

Well in this case I think you'd could say that SQL-Server was working the
way you wanted.

Oliver Townshend
Back to top
Arthur Hoornweg
Guest





PostPosted: Wed Mar 01, 2006 9:03 am    Post subject: Re: Now here's a nice gotcha (MSSQL2000) Reply with quote



Oliver Townshend wrote:

Quote:
Well in this case I think you'd could say that SQL-Server was working the
way you wanted.

er, you mean by giving me column-level security when I wanted only row-level
security? Please explain...


--
Arthur Hoornweg

(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
Back to top
Bob Dawson
Guest





PostPosted: Wed Mar 01, 2006 10:03 am    Post subject: Re: Now here's a nice gotcha (MSSQL2000) Reply with quote

"Arthur Hoornweg" wrote
Quote:

I had to delete the view and re-create it to get things working again!

It would appear that SQLServer prepares and stores

Quote:
SELECT T.* FROM [...]

as a set of literal field references, and that altering the table did not
trigger a reanalysis of (ie, did not invalidate) this stored evaluation of
T.*. I can see why that could be an issue for maintaining a database design
that makes extensive use of views. I can also see why silently updating the
view could be an issue.

bobD
Back to top
Oliver Townshend
Guest





PostPosted: Wed Mar 01, 2006 10:03 am    Post subject: Re: Now here's a nice gotcha (MSSQL2000) Reply with quote

Quote:
er, you mean by giving me column-level security when I wanted only
row-level
security? Please explain...

Bonus! :)

Oliver Townshend
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.