Re: Quick patch: Display sequence owner - Mailing list pgsql-hackers

From David Rowley
Subject Re: Quick patch: Display sequence owner
Date
Msg-id 3411ADE41B794AC093384CD61B81575E@amd64
Whole thread Raw
In response to Quick patch: Display sequence owner  (Josh Williams <joshwilliams@ij.net>)
List pgsql-hackers

Josh Williams wrote:
> Hi folks,
>
> Was recently poked and reminded that this patch may be of interest to
> the community.  It was mostly done as an academic exercise, just to see
> how it works, and so it has a rather hackish feel.  The patch adds the
> sequence owner, if available, to psql's \d <sequence> output, as
> suggested in a recent thread:
>
> http://archives.postgresql.org/pgsql-general/2008-11/msg01300.php
>
> The patch adds a query against pg_depend, then fakes an extra column
> "owned_by" in the output:
>
> # \d tablename_columnname_seq
>      Sequence "public.tablename_columnname_seq"
>     Column     |   Type   |          Value
> ---------------+----------+--------------------------
>  sequence_name | name     | tablename_columnname_seq
>  last_value    | bigint   | 1
>  start_value   | bigint   | 1
>  increment_by  | bigint   | 1
>  max_value     | bigint   | 9223372036854775807
>  min_value     | bigint   | 1
>  cache_value   | bigint   | 1
>  log_cnt       | bigint   | 1
>  is_cycled     | boolean  | f
>  is_called     | boolean  | f
>  owned_by      | regclass | tablename
>
>
> Now for the snags and additional thoughts:
>
> The query against pg_depend looks for relations for which the sequence
> is auto-dependent.  It wouldn't make any sense, but is it at all
> possible for a sequence to auto-depend on something else?
>
> An earlier version of the patch pulled the owning table and schema names
> directly, rather than casting to regclass, so the schema name was always
> shown.  Would this be preferable, in case there's some ambiguity in
> similarly named tables between schemas?
>
> I'd pondered briefly whether there should be a real attribute to
> represent the sequence owner, just for display purposes.  But I'm
> assuming that would present a big concurrency issue, as other
> transactions would see the change on the sequence immediately while
> pg_depend wouldn't be seen to change until committed.  That, and
> ROLLBACK wouldn't work at all...
>
> The column info query is getting messy.  Could probably clean that up a
> bit if anyone thinks it'd be worth it?
>
> - Josh Williams

Josh,

We've just gone into a feature freeze for the 8.4 release. So I've added a
link to your patch in the first Commitfest for 8.5 here:

http://wiki.postgresql.org/wiki/CommitFest_2009-First#Pending_patches

This Commitfest is scheduled to start March 2009. Though it's possible that
it may be later. Hopefully not though.

Much of the community is quite busy reviewing current patches and doing last
minute changes to their own patches for 8.4. If you don't get much response
then that's probably why. Please don't mistakenly assume we're not
interested. If you make changes to the patch please post it back to the list
and you can update the CommitFest page too if you like.

David.






pgsql-hackers by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: new vacuum is slower for small tables
Next
From: Simon Riggs
Date:
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches (r1268)