Re: pg_relation_size / could not open relation with OID #

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tomas Vondra <tv(at)fuzzy(dot)cz>, pgsql-general(at)postgresql(dot)org
Subject: Re: pg_relation_size / could not open relation with OID #
Date: 2010-10-07 13:42:22
Message-ID: 4CADCE3E.60705@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> We could prevent your query from failing if we did something like having
> pg_relation_size() return NULL, rather than throwing an error, if the
> OID it's given doesn't turn out to correspond to a live table. I'm not
> sure if that'd be a net improvement or not --- it certainly seems to
> reduce the system's ability to detect simple errors

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? That would let
scripts run without interruption in some of these race condition cases,
while still generating some clue the user was likely to see that there
was a problem when people were just using the thing blatantly wrong--the
biggest subset of cases that produce errors now I suspect.

--
Greg Smith, 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services and Support www.2ndQuadrant.us

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-10-07 13:43:06 Re: stuck spinlock detected at dynahash.c
Previous Message Bill Moran 2010-10-07 13:39:58 Re: VACUUM FULL for performance