1

If I create the following sequence in Postgres:

CREATE SEQUENCE test
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
GRANT ALL ON SEQUENCE test TO testuser;
GRANT SELECT ON SEQUENCE test TO testuser2;

And then select the sequence in pgAdmin, right mouse click -> CREATE script, I get:

CREATE SEQUENCE test
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
ALTER TABLE test
  OWNER TO testuser;
GRANT ALL ON TABLE test TO testuser;
GRANT SELECT ON TABLE test TO testuser2;

So in the GRANT statements I see the keyword "TABLE" and not "SEQUENCE"

  1. Why is that?
  2. How is pgAdmin generating the DDL extract?

This question is related to one of my other questions here:
Query GRANTS granted to a sequence in postgres

Cœur
  • 37,241
  • 25
  • 195
  • 267
markus
  • 6,258
  • 13
  • 41
  • 68

1 Answers1

1

In PostgreSQL, sequences are kind of like tables.

The catalog pg_class catalogs tables and most everything else that has columns or is otherwise similar to a table. This includes indexes (but see also pg_index), sequences, views, composite types, and TOAST tables; see relkind.

PostgreSQL docs for pg_class, one of the system catalogs (system tables)

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
  • But how does PgAdmin create staements like "GRANT ALL ON TABLE test TO testuser"? OK, the ACL information is available in column "relacl" of pg_class, but it takes some programming effort to tranform something like "{postgres=arwdDxt/postgres}" into "GRANT SELECT ...", nearly impossible to do this with pure SQL. Isn't there somewhere a table similar to information_schema.role_table_grants for sequences? – markus Sep 08 '11 at 08:04
  • @markus: Sorry for the delay; I overlooked your comment. I don't know how pgAdmin generates SQL for its SQL pane, but you can [download the source code](http://www.pgadmin.org/download/source.php). As far as I can tell, there's no information_schema view that exposes the privileges for sequences. – Mike Sherrill 'Cat Recall' May 07 '12 at 01:27