pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: doug@oakstreetsoftware.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7786: select from view is computing columns not selected
Date: Fri, 04 Jan 2013 13:03:07 -0500
Message-ID: <22106.1357322587@sss.pgh.pa.us> (raw)
In-Reply-To: <E1Tr8Fz-00087d-MI@wrigleys.postgresql.org>
References: <E1Tr8Fz-00087d-MI@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

doug@oakstreetsoftware.com writes:
> in the interest of simplicity, I've got a view that calls a stored procedure
> to compute a value ...

> create view testv as select tt.field1, tt.intfield, compute_val(tt.field1)
> AS compute1 from tt;

> If compute_val() selects sum(intfield) from the testv view, compute_val() is
> called again when selecting records from testv (even though compute1 was not
> selected), resulting in infinite recursion (stack overflow).

> In retrospect, I realize this may have been a bad thing to do, but it worked
> in version 8.1.x.

I suspect that your function is declared VOLATILE, possibly by default.
PG versions later than 8.1 refrain from flattening views that contain
volatile functions in their SELECT list, on the grounds that such a
transformation might remove side-effects that the user expects to have
happen, or even cause the side-effects to happen more often than expected.

If you can declare the function STABLE then the view should continue to
work as before.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <22106.1357322587@sss.pgh.pa.us>
Permalink:  ../22106.1357322587@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22106.1357322587@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, doug@oakstreetsoftware.com
  Subject: Re: BUG #7786: select from view is computing columns not selected
  In-Reply-To: <22106.1357322587@sss.pgh.pa.us>
  References: <E1Tr8Fz-00087d-MI@wrigleys.postgresql.org> <22106.1357322587@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