question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change CommandType.StoredProcedure to execute procedures instead of functions

See original GitHub issue

PostgreSQL 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).

/cc @vonzshik @NinoFloris @Brar

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Sep 1, 2021

@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…

1reaction
NinoFloriscommented, Sep 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found