-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX | Adding support for sharedInstances to managed SNI #1237
FIX | Adding support for sharedInstances to managed SNI #1237
Conversation
Regex is much faster in 5 but this is a really trivial case and what you really want is just to split the string and then count the number of resulting strings. Regex isn't needed or much easier here. |
Ok. seems fair. It was an over kill. I've changed it. |
Is |
Is case important in the output instanceName? because if it isn't I think I've got a version of the function which only allocates the output string. If i have to lower case it then I'll need to allocate a stringbuilder. |
Have a look, see what you think: https://gist.github.com/Wraith2/b2dbcf6af7d21c48620dc00eb0879364 |
I like the idea, but I was thinking about this, what is preventing us from getting the very last index of the array? |
You can simply replace the range expressions with Slice, they're all start offset only so the single arg version works. We can get the last index if the split works but then what happens if a user passes us a string with 4 slashes in? Invalid yes but will it behave the same? More importantly I was trying to avoid the allocation that the split causes, it's an array and 3 strings all of them on the heap and we know that 2 of the strings are going to get thrown away instantly. The split version is fine if you want to stick with that. It's not a hot path so it's not going to cause anyone a problem. I just like to see if there are efficient ways to implement things like this, as I did with the azure endpoint parsing. |
@Wraith2, FYI ReadOnlySpan is not supported in |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs
Show resolved
Hide resolved
…haredInstance-to-localdb
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Johnny Pham <[email protected]>
fixes #1231
Manged SNI did not have sharedInstances support for lcoaldb.
localdb
the assumption is that when we split the connection string by\\
it always returns an array with length of 2 however when the connection string is set for a shared instance we get an array with a length of 3 since it is in a format of(localdb)\.\shared Instance name
Based on MS Docs all shared instances connection strings should be in a format of
(localdb)\.\ "shared instance's name"
a shared instance could be created as below:
Make sure you have installed SqlLocalDB
SqlLocalDB create "" (you can choose any name)
SqlLocalDB share " your instance name " "provide a name for shared instance"
SqlLocalDB start "name your instance"
Create LOGIN [Domain\User];
(run this if the login is not created by default for the user otherwise it fails)GRANT LOGIN TO [Domain\User]
in the same format one can unshare and delete a shared instance.
One can log into shared instances using ssms with the format mentioned above. Also, Visual studio provides the connection string when you go to View > SQL Server Object Explorer and select local. (It only shows localdb and shared isntances if you have already created one and it is running).
Added:
(localdb)\.
will login the user into the defaultlocaldb
.