Re: pg_relation_size / could not open relation with OID #

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_relation_size / could not open relation with OID #
Дата
Msg-id 28488.1286461610@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pg_relation_size / could not open relation with OID #  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: pg_relation_size / could not open relation with OID #  (Greg Smith <greg@2ndquadrant.com>)
Список pgsql-general
I wrote:
> Greg Smith <greg@2ndquadrant.com> writes:
>> I've struggled with scripts using pg_relation_size doing strange things
>> because of this more than once.  How about a) return NULL and b) log at
>> NOTICE that you just asked for something undefined?

> I don't care for the NOTICE at all; it's just useless log bloat (that
> likely will never be seen by a human) in most use-cases.  Either we
> think this is an expected case, or not.

It strikes me that if we were willing to throw code at the problem,
we could make it work like this:

1. Try to open the relation.  If successful, proceed as normal.

2. Try to fetch the pg_class row by OID, using SnapshotDirty (or perhaps
the surrounding query's snapshot).  If we can find it under a
non-current snapshot, return NULL.

3. Else throw error.

This would properly throw error for cases where you'd passed the wrong
catalog's OID column to pg_relation_size.  Depending on how tense we
were about the snapshot selection, it might sometimes return NULL in
cases where an error would be more appropriate (because the relation
had been dead for some time).

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: VACUUM FULL for performance
Следующее
От: Juan Sueiro
Дата:
Сообщение: Re: PostgreSQL 7.4.16 is creating strange files under /var/lib/pgsql