On Wed, 22 Sep 2004, Jaroslaw J. Pyszny wrote:
> W liście z sro, 22-09-2004, godz. 00:50, Dave Cramer pisze:
> > Sorry, missed one more where clause.
> >
> > select column_default from information_schema.columns where table_name =
> > 'xyz' and column_name = 'id';
> >
> > This assumes a table defined like create table xyz (id serial);
> It's works but only for the owner of the table
> or I do something wrong ;)
>
The information_schema takes into account permissions on objects and
doesn't show things you can't access. So in this case a GRANT SELECT ON
<table> TO <user> would make it show up. This seems OK because to get a
ResultSet you clearly have to be able to query the table.
The problem I came across was that if you only grant access to the table
it doesn't propagate to the underlying sequence. So if a user doesn't
have permissions to use the sequence it doesn't show up as the default in
the information_schema view. I'm leaning towards believing this is a bug
in the information_schema, but it just seems safer to use the direct
catalog access method you wrote.
Kris Jurka