Neil Conway wrote:
> On Sun, 2008-01-27 at 12:36 -0500, Tom Lane wrote:
>> Both of the above arguments hold water only if we implement
>> compatible *semantics*, not merely syntax, so I find them
>> unconvincing at this stage.
>
> How are the semantics of the proposed patch incompatible with the SQL
> spec or the implementations in other systems? The proposed patch is
> a *subset* of the functionality in the SQL spec, but it isn't
> incompatible with it as far as I know (recursive and non-recursive
> WITH are distinct features).
An implementation of WITH that inlines the subquery instead of executing
it only once (if appropriate) might not be incompatible with the SQL
spec, but it might very well turn out to be incompatible with other
major DBMSes from a practical point of view. If people use non-recursive
WITH as a replacement for constructs like
CREATE TEMPORARY TABLE temp AS SELECT ... ;
SELECT ... FROM temp, ... ;
, and not merely to increase readability, they won't gain anything from
an inlining WITH implementation.
This, BTW, is the reason that the C++ standard specifies the runtime
complexity (in big-O-notation) for things like vector/list/hash lookups,
instead of just specifying the interface.
regards, Florian Pflug