Re: function side effects

From: Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>
To: simon(at)2ndQuadrant(dot)com
Cc: ishii(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: function side effects
Date: 2010-02-24 00:56:29
Message-ID: 20100224.095629.00003185.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > I'm wondering if we could detect a funcion has a side effect,
> > i.e. does a write to database. This is neccessary for pgpool to decide
> > if a qeury should to be sent to all of databases or not. If a query
> > includes functions which do writes to database, it should send the
> > query to all of databases, otherwise the contents of databases go into
> > inconsistent state.
> >
> > Currently we have three properties of functions: IMMUTABLE, STABLE and
> > VOLATILE. According to docs IMMUTABLE or STABLE functions do not write
> > to database. VOLATILE functions *may* do writes to database. Maybe I
> > could regard VOLATILE functions always do write, but priblem is,
> > VOLATILE qfunctions such as random() and timeofday() apparently do not
> > write and sending those queries that include such functions is
> > overkill.
> >
> > Can we VOLATILE property divide into two categories, say, VOLATILE
> > without write, and VOLATILE with write?
>
> pgpool parses the query before deciding how to route it, yes?

Right.

> Why not mark random() and timeofday() as stable in the pgpool catalog,
> yet leave them as volatile on the database servers? It will "just work"
> then.

Please note that random() and timeofday() are just examples. What I'm
thinking about was, a function which directly or indirectly cause
write to database (thus lead writing to log).

Consider a function that calls those has-side-effect functions. We
need a property which is inherited to child function to parent
function.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2010-02-24 01:00:33 Re: function side effects
Previous Message Fujii Masao 2010-02-24 00:51:01 Re: pg_stop_backup does not complete