Re: "stored procedures" - use cases?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Christopher Browne <cbbrowne(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: "stored procedures" - use cases?
Date: 2011-05-10 12:55:54
Message-ID: BANLkTi=UK4auvB-7Xo09812jw0FZm_kHPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 9, 2011 at 11:58 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> no - you are little bit confused :). CALL and function execution
> shares nothing. There is significant differences between function and
> procedure. Function is called only from executor - from some plan, and
> you have to know a structure of result before run. The execution of
> CALL is much simple - you just execute code - without plan and waiting
> for any result - if there is.

Now I'm a little confused, or you are. Surely any SQL has to be
planned and executed, regardless of whether it appears in a function,
a stored procedure, or anywhere else. Non-SQL statements within a
stored procedure don't need to go through the planner and executor,
but that's true in PL/python or PL/pgsql or whatever today.

I think people are using the term "stored procedures" to refer to
approximately whatever it is that they're unhappy that functions don't
allow, and that's leading to a lot of people talking across each
other. The main features seem to be (1) explicit transaction control
and/or execution of commands like VACUUM that can't be invoked from
within a transaction, (2) autonomous transactions, and (3) returning
multiple result sets. But I don't think anybody would be desperately
unhappy if it magically became possible to do those things from
regular functions, unlikely as that may seem.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2011-05-10 13:18:16 Re: "stored procedures" - use cases?
Previous Message Robert Haas 2011-05-10 12:49:12 Re: switch UNLOGGED to LOGGED