Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZH86Y-0000OZ-CW for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2015 10:15:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZH86X-00061l-8f for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2015 10:15:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZH85s-0004Zo-UG; Mon, 20 Jul 2015 10:14:44 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZH85m-0002Op-PJ; Mon, 20 Jul 2015 10:14:43 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [89.176.99.192]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 97B29400633; Mon, 20 Jul 2015 03:14:33 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 4916C361C; Mon, 20 Jul 2015 14:14:31 +0400 (SAMT) Date: Mon, 20 Jul 2015 12:14:31 +0200 From: Alvaro Herrera To: Robert Haas , Jim Nasby , Jaimin Pan , Michael Paquier Cc: "pgsql-hackers@postgresql.org" , pgsql-bugs@postgresql.org Subject: Re: [HACKERS] object_classes array is broken, again Message-ID: <20150720101431.GJ2301@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150718151434.GX2301@postgresql.org> <20150718153859.GY2301@postgresql.org> <558DD0BF.1000407@BlueTreble.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Any opinions on this idea? I don't like it all that much, but it's plenty effective. Alvaro Herrera wrote: > The problem is that there aren't enough callers of add_object_address: > there are many indexes of that array that aren't ever accessed and so > it's not obvious when the array is broken. If we were to put > OCLASS_CLASS at the end instead of at the beginning, that would fix the > problem by making it immediately obvious when things get broken this > way, because the value used in the most common case would shift around > every time we add another value. (Of course, we'd have to instruct > people to not add new members after the pg_class entry.) > diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c > index c1212e9..0107c53 100644 > --- a/src/backend/catalog/dependency.c > +++ b/src/backend/catalog/dependency.c > @@ -127,7 +127,6 @@ typedef struct > * See also getObjectClass(). > */ > static const Oid object_classes[MAX_OCLASS] = { > - RelationRelationId, /* OCLASS_CLASS */ > ProcedureRelationId, /* OCLASS_PROC */ > TypeRelationId, /* OCLASS_TYPE */ > CastRelationId, /* OCLASS_CAST */ > @@ -158,7 +157,9 @@ static const Oid object_classes[MAX_OCLASS] = { > DefaultAclRelationId, /* OCLASS_DEFACL */ > ExtensionRelationId, /* OCLASS_EXTENSION */ > EventTriggerRelationId, /* OCLASS_EVENT_TRIGGER */ > - PolicyRelationId /* OCLASS_POLICY */ > + PolicyRelationId, /* OCLASS_POLICY */ > + TransformRelationId, /* OCLASS_POLICY */ > + RelationRelationId /* OCLASS_CLASS */ > }; > > > diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h > index 5da18c2..6f4802d 100644 > --- a/src/include/catalog/dependency.h > +++ b/src/include/catalog/dependency.h > @@ -112,11 +112,10 @@ typedef struct ObjectAddresses ObjectAddresses; > > /* > * This enum covers all system catalogs whose OIDs can appear in > - * pg_depend.classId or pg_shdepend.classId. > + * pg_depend.classId or pg_shdepend.classId. See also object_classes[]. > */ > typedef enum ObjectClass > { > - OCLASS_CLASS, /* pg_class */ > OCLASS_PROC, /* pg_proc */ > OCLASS_TYPE, /* pg_type */ > OCLASS_CAST, /* pg_cast */ > @@ -149,6 +148,11 @@ typedef enum ObjectClass > OCLASS_EVENT_TRIGGER, /* pg_event_trigger */ > OCLASS_POLICY, /* pg_policy */ > OCLASS_TRANSFORM, /* pg_transform */ > + /* > + * Keep this previous-to-last, see > + * https://www.postgresql.org/message-id/ > + */ > + OCLASS_CLASS, /* pg_class */ > MAX_OCLASS /* MUST BE LAST */ > } ObjectClass; > -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs