Re: Issue with pgstattuple on Sequences in PostgreSQL

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Issue with pgstattuple on Sequences in PostgreSQL
Date: 2024-06-24 13:35:54
Message-ID: CAKFQuwbWg51wrQCNYe8J6V_KXoK5wQR3SERWKhCFwx6jx2OuOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, June 24, 2024, Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com> wrote:
>
> I was recently exploring the pgstattuple code directory and found this
> piece of code: https://github.com/postgres/postgres/blob/master/contrib/
> pgstattuple/pgstattuple.c#L255-L259.
>
> It indicates that pgstattuple supports relations, toast tables,
> materialized views, and sequences.
> However, when I executed a query with a sequence, I encountered the
> following error:
>
> postgres=> CREATE SEQUENCE serial START 101;
> CREATE SEQUENCE
> postgres=> SELECT * FROM pgstattuple('serial');
> ERROR: only heap AM is supported
> postgres=>
>
> It got stuck in this if condition - https://github.com/postgres/
> postgres/blob/master/contrib/pgstattuple/pgstattuple.c#L326-L329
>
>
> How can one use pgstattuple on sequences?
>

As-is? Doesn’t look like you can. I agree it’s a documentation bug that
this is the case with a brief explanation of why - sequences do not produce
dead tuples and do not behave like real tables aside from being able to be
selected from (i.e., no SQL update/delete command).

The code should produce an explicit error for that relkind as well.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-06-24 14:32:45 Re: Issue with pgstattuple on Sequences in PostgreSQL
Previous Message Chris Travers 2024-06-24 13:30:44 Re: 2FA - - - was Re: Password complexity/history - credcheck?