Change CommandType.StoredProcedure to execute procedures instead of functions
See original GitHub issuePostgreSQL originally only had functions - procedures were introduced in PG 11 - so specifying CommandType.StoredProcedure makes Npgsql generate function invocation syntax (SELECT * FROM func(...)
. We can consider changing StoredProcedure to generate procedure invocation syntax instead (CALL ...
). The current situation is inconsistent/terminologically confusing - I assume newcomers justifiably expect CommandType.StoredProcedure to invoke PostgreSQL stored procedures.
This would be quite a breaking change - any code using CommandType.StoredProcedure to invoke functions would stop working. Options:
- Make the breaking change, and have an AppContext switch for the old behavior. This is breaking, but anyone upgrading to Npgsql would simply have to turn on the switch and everything would work as before.
- Have an AppContext switch for the new behavior. This would make the behavior opt-in, but this may not have much value: the main value in changing the meaning of CommandType.StoredProcedure is to make things clearer/more consistent for new people etc.
- Not do anything. Users can invoke both functions and procedures with SQL themselves (i.e. not use CommandType.StoredProcedure at all).
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Setting CommandType to StoredPRocedure when invoking ...
I know that the purpose of this enum is to specify a stored procedure; for functions CommandType.Text should be used. But I don't...
Read more >Modify a Stored Procedure - SQL Server
This article describes how to modify a stored procedure in SQL Server by using SQL Server Management Studio or Transact-SQL.
Read more >Functions vs stored procedures in SQL Server
This article gives a comparison between Functions and Stored Procedure in SQL Server.
Read more >Stored Procedure in SQL: Benefits And How to Create It
A stored procedure in SQL is a group of SQL statements that are stored together in a database. Based on the statements in...
Read more >Working with Stored Procedures
Stored procedures allow an optional COMMENT that can be specified with the CREATE PROCEDURE or ALTER PROCEDURE statement. Other people can read this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Wraith2 I agree, but that’s a bit tricky… since CommandType.StoredProcedure is currently used to invoke functions (
SELECT * FROM func()
, code upgrading to Npgsql 6.0 would simply start failing, since Npgsql will start producing SQL for invoking procedures (CALL foo()
)… I actually tried to suggest to PostgreSQL that they allow invoking functions with CALL, so that the transition could be backwards compatible, but they didn’t go this way…There is also the matter of all the different pg compatible databases failing the backend version check. I’m in favor for doing this at a specific npgsql version.