Re: Accessing schema data in information schema

Christopher Kings-Lynne <chris.kings-lynne@calorieking.com>

From: Christopher Kings-Lynne <chris.kings-lynne@calorieking.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>, darcy@wavefire.com, pgsql-hackers@postgresql.org, peter_e@gmx.net
Date: 2006-03-23T04:26:02Z
Lists: pgsql-hackers
> Hm, good point.  We could put 'em in pg_sequence, except that most of
> the operations on pg_sequence rows will be nontransactional, and that
> doesn't seem to square nicely with transactional updates on ACLs.
> Maybe we need two catalogs just to separate the transactional and
> nontransactional data for a sequence?  Ugh.

Is it possible to have an SRF that can peek into the lastval data and 
present it, and make no changes to our catalogs at all?

Or can't we use in the schema view something like:

CREATE VIEW sequences AS
   SELECT CAST(current_database() AS sql_identifier) AS sequence_catalog,
          CAST(nc.nspname AS sql_identifier) AS sequence_schema,
          CAST(c.relname AS sql_identifier) AS sequence_name,
          (SELECT seq_info('sequence_name', 'max')) AS maximum_value,
          (SELECT seq_info('sequence_name', 'min')) AS minimum_value,
          (SELECT seq_info('sequence_name', 'inc')) AS increment,
          (SELECT seq_info('sequence_name', 'cycle')) AS cycle_option
   FROM pg_namespace nc, pg_class c
   WHERE c.relnamespace = nc.oid
         AND c.relkind = 's';

Chris