PG Bug reporting form <noreply@postgresql.org> writes:
> # select tablename,
> (pgstattuple_approx(tablename::regclass)).approx_free_space from pg_tables
> where schemaname = 'public' and
> (pgstattuple_approx(tablename::regclass)).approx_free_percent > 10;
> ERROR: relation "sql_implementation_info" does not exist
This is not a bug. We don't guarantee anything about the evaluation
order of WHERE clauses. Even if we did, this query has got bugs of
its own: it will fail on tablenames that would require quoting,
such as names containing spaces, dots, uppercase letters, etc.
You could write
(quote_ident(schemaname)||'.'||quote_ident(tablename))::regclass
to avoid both of those issues. There are still going to be some race
condition problems around just-dropped tables, though.
regards, tom lane