From: Tom Lane <tgl@sss.pgh.pa.us>
To: ceharris@vt.edu
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: WITH RECURSIVE (Documentation section 7.8.1) Note
Date: Wed, 02 Oct 2019 12:41:44 -0400
Message-ID: <9803.1570034504@sss.pgh.pa.us> (raw)
In-Reply-To: <157002368762.1131.16941475162203318675@wrigleys.postgresql.org>
References: <157002368762.1131.16941475162203318675@wrigleys.postgresql.org>
PG Doc comments form <noreply@postgresql.org> writes:
> In section 7.8.1, the author comments "Note: Strictly speaking, this process
> is iteration not recursion, but RECURSIVE is the terminology chosen by the
> SQL standards committee."
I think I'm to blame for that wording.
> Example: R_2 = F(F(R_0))
> Example: R_5 = F(F(F(F(F(R_0))))
> This is textbook recursion, not just some folly of the ANSI standards
> committee as suggested by the note in the text.
No, it isn't. F() is being applied repeatedly (iteratively). If F()
called itself internally, that would be recursion.
Another way to look at this is that control of whether the repetition
is finished is external to the function/query. If the stop condition
were part of the query logic, it'd be more sensible to think of it as
recursion, IMO.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, ceharris@vt.edu, pgsql-docs@lists.postgresql.org
Subject: Re: WITH RECURSIVE (Documentation section 7.8.1) Note
In-Reply-To: <9803.1570034504@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox