Re: key = currval('tab_key_seq') choses SEQSCAN?! - Mailing list pgsql-general

From Joe Conway
Subject Re: key = currval('tab_key_seq') choses SEQSCAN?!
Date
Msg-id 403D7412.8090509@joeconway.com
Whole thread Raw
In response to Re: key = currval('tab_key_seq') choses SEQSCAN?!  (Eric B.Ridge <ebr@tcdi.com>)
Responses Re: key = currval('tab_key_seq') choses SEQSCAN?!  (Greg Stark <gsstark@mit.edu>)
List pgsql-general
Eric B. Ridge wrote:
> gotcha.  Stated differently, it's not volatile because, by design, it
> doesn't always produce the same output for the same input.

Right. But further, it doesn't even produce the same result within a
single scan. Here's from pg_proc.h:

/*
  * Symbolic values for provolatile column: these indicate whether the
  * result of a function is dependent *only* on the values of its
  * explicit arguments, or can change due to outside factors (such as
  * parameter variables or table contents).  NOTE: functions having
  * side-effects, such as setval(), must be labeled volatile to ensure
  * they will not get optimized away, even if the actual return value is
  * not changeable.
  */
#define PROVOLATILE_IMMUTABLE    'i' /* never changes for given input */
#define PROVOLATILE_STABLE    's' /* does not change within a scan */
#define PROVOLATILE_VOLATILE    'v' /* can change even within a scan */

> OT:  generate_series looks useful.  Is this only in 7.5?

Yes, new in 7.5.

Joe

pgsql-general by date:

Previous
From: Shelby Cain
Date:
Subject: Re: select statement against pg_stats returns inconsistent data
Next
From: "Tiptur, Sathish (MED)"
Date:
Subject: postgreSQL licenseing