Re: erroneous restore into pg_catalog schema - Mailing list pgsql-hackers

From Andres Freund
Subject Re: erroneous restore into pg_catalog schema
Date
Msg-id 20130513175032.GD1066@awork2.anarazel.de
Whole thread Raw
In response to Re: erroneous restore into pg_catalog schema  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: erroneous restore into pg_catalog schema  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2013-05-13 13:40:57 -0400, Tom Lane wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > On Mon, May 13, 2013 at 1:03 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> >> Why don't we just prohibit deletion/modification for anything below
> >> FirstNormalObjectId instead of using the schema as a restriction? Then
> >> we can allow creation for tables as well.
> 
> > We currently do, but that led to problems with $SUBJECT.

> AFAIR there are no code restrictions based on OID value.  We've got
> restrictions based on things being in pg_catalog or not, and we've got
> restrictions based on things being marked pinned in pg_depend.

> Looking at the OID range might be a reasonable proxy for pinned-ness,
> though, and it would certainly be a lot cheaper than a lookup in
> pg_depend.

It might need a slight change in GetNewObjectId() though:    if (IsPostmasterEnvironment)    {        /* wraparound in
normalenvironment */        ShmemVariableCache->nextOid = FirstNormalObjectId;        ShmemVariableCache->oidCount = 0;
  }    else    {        /* we may be bootstrapping, so don't enforce the full range */        if
(ShmemVariableCache->nextOid< ((Oid) FirstBootstrapObjectId))        {            /* wraparound in standalone
environment?*/            ShmemVariableCache->nextOid = FirstBootstrapObjectId;            ShmemVariableCache->oidCount
=0;        }    }
 

I think we shouldn't check IsPostmasterEnvironment here but instead
IsBootstrapProcessingMode() since we otherwise can generate oids below
FirstNormalObjectId in --single mode. Imo that should be fixed
independently though, given the comment it looks like either an
oversight or the check predating the existance of
IsBootstrapProcessingMode().


Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: erroneous restore into pg_catalog schema
Next
From: Noah Misch
Date:
Subject: Re: Parallel Sort