pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Scheffer <pg2401k@pinkwin.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #15060: Row in table not found when using pg function in an expression
Date: Mon, 12 Feb 2018 06:37:47 -0700 (MST)
Message-ID: <1518442667671-0.post@n3.nabble.com> (raw)
In-Reply-To: <151844034484.1446.1721073839109092583@wrigleys.postgresql.org>
References: <151844034484.1446.1721073839109092583@wrigleys.postgresql.org>

PG Bug reporting form wrote
> I tested this in postgresql versions 9.1, 10.1 and 10.2 on centOS. 
> 
> In short this is what happens (in a plpgsql function):
> 1.) An insert is done into 'bug' table
> 2.) A SELECT is done to make sure the INSERT was successful
> 3.) Another function (get_bug_id) is called which returns id based on
> value.
> When the function is called directly, it returns the id correctly. When
> it's
> called in an expression, it does not find the inserted row and an
> exception
> is raised.

Significant is that function get_bug_id() being STABLE is necessary for the
bug to occur. 
It appears to be not a bug, since documentation reads:

> For functions written in SQL or in any of the standard procedural
> languages, there is a second important property determined by the
> volatility category, 
*
> namely the visibility of any data changes that have been made by the SQL
> command that is calling the function. A VOLATILE function will see such
> changes, a STABLE or IMMUTABLE function will not
*
> . This behavior is implemented using the snapshotting behavior of MVCC
> (see Chapter 13): STABLE and IMMUTABLE functions use a snapshot
> established as of the start of the calling query, whereas VOLATILE
> functions obtain a fresh snapshot at the start of each query they execute.

Although i.m.o. it is strange that one produces the proper result and the
other call does not.




--
Sent from: http://www.postgresql-archive.org/PostgreSQL-bugs-f2117394.html




view thread (11+ messages)  latest in thread

Message-ID: <1518442667671-0.post@n3.nabble.com>
Permalink:  ../1518442667671-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1518442667671-0.post@n3.nabble.com

 · 

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: pg2401k@pinkwin.com
  Subject: Re: BUG #15060: Row in table not found when using pg function in an expression
  In-Reply-To: <1518442667671-0.post@n3.nabble.com>
  References: <151844034484.1446.1721073839109092583@wrigleys.postgresql.org> <1518442667671-0.post@n3.nabble.com>

* 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