Did PostgreSQL not have stored procs before?
Did PostgreSQL not have stored procs before?
https://www.postgresql.org/docs/devel/static/sql-call.html
CALL executes a procedure.
If the procedure has output arguments, then a result row will be returned.
and from https://www.postgresql.org/docs/devel/static/sql-createproce... argmode
The mode of an argument: IN, INOUT, or VARIADIC. If omitted, the default is IN. (OUT arguments are currently not supported for procedures. Use INOUT instead.)If you want to have atomic transactions within a transaction you have to do hacks like make a distributed call back to yourself, in that new session creating another transaction.
It's an element of SQL Server that confuses people to this day.
From the announcement: "SQL Stored Procedures
PostgreSQL 11 introduces SQL stored procedures that allow users to use embedded transactions (i.e. BEGIN, COMMIT/ROLLBACK) within a procedure. Procedures can be created using the CREATE PROCEDURE command and executed using the CALL command."
It doesn't make sense to teach people how to create procedures if they already have them before. The docs[0] also don't have a section for CREATE PROCEDURE before 11[1].
It is a great tool anyway, better late than never.
[0] https://www.postgresql.org/docs/10/static/sql-commands.html
[1] https://www.postgresql.org/docs/11/static/sql-commands.html
It had functions, not procedure. You can emulate (most of) procedure using function that return void.
See also https://blog.2ndquadrant.com/postgresql-11-server-side-proce...
Having said that, the addition of transaction support is a great step forward.
I think you can get the equivalent behavior out of BEGIN/EXCEPT blocks in plpgsql functions. I think this behaves as if you used SAVEPOINT and ROLLBACK TO SAVEPOINT which have been directly supported in postgresql but not in functions.
Curious, what are those procedures which can't be emulated as functions. Maybe you have a chance to describe some example?