You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GetSchema uses new connections instead of current #543
The fact that GetSchema is creating a new connection instead re-using the current connection is causing some headaches due to a specific configuration that my company is attempting to use.
Our connections are being established with one user, and then using "SET ROLE" to elevate the user to a different role that has access to more tables. The issue comes into play because since a new connection is created instead of re-using the current connection it is not receiving these elevated permissions and therefore GetSchema does not produce the expected results.
Is there a specific reason why GetSchema creates a new connection even if the current NpgsqlConnection instance on which the method is called is already connected to the database?
That's a pretty good question, I can't see any reason at all for this behavior. I checked SqlClient and trying to call GetSchema() while a reader is open fails, meaning that it doesn't open an additional connection.
@franciscojunior, any ideas why GetSchema() does this? If not I can change the behavior to use the current connection.
Activity
roji commentedon Mar 19, 2015
That's a pretty good question, I can't see any reason at all for this behavior. I checked SqlClient and trying to call GetSchema() while a reader is open fails, meaning that it doesn't open an additional connection.
@franciscojunior, any ideas why GetSchema() does this? If not I can change the behavior to use the current connection.
franciscojunior commentedon Mar 19, 2015
Hi, @roji !
When I started to implement GetSchema support in 2005 (https://github.com/npgsql/Npgsql1-From-CVS/commit/617081e939b38ba225de19650f5121cc11933e09) , I used a new NpgsqlConnection. I think I choose to create a new connection only to not have problems with the NpgsqlConnection currently in use. So, there was no specific reason for it to be like it is today :)
I think there wouldn't be any problems using the same connection, and it would fix this issue :)
roji commentedon Mar 19, 2015
OK, thanks @franciscojunior, I'll make the change.
No longer open separate conn in GetSchema()
roji commentedon Mar 19, 2015
Fixed and backported to 2.2