pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Jaimin Pan <jaimin.pan@gmail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: pgsql-bugs@postgresql.org
Subject: Re: [HACKERS] object_classes array is broken, again
Date: Mon, 20 Jul 2015 12:14:31 +0200
Message-ID: <20150720101431.GJ2301@postgresql.org> (raw)
In-Reply-To: <20150718151434.GX2301@postgresql.org> <CAB7nPqRKL34RMAxgQ3MhjGEVPZhVRM2oHXgiTf+Wmt4JZ1+-3w@mail.gmail.com> <CABP8UDS4jf4t6hjNF_g=4e=X=BA_EC2P+AL+Q4y5ESU2E4-Uag@mail.gmail.com> <20150718153859.GY2301@postgresql.org> <558DD0BF.1000407@BlueTreble.com> <CA+Tgmoa6SgDaxW_n_7SEhwBAc=mniYga+obUj5fmw4rU9_mLvA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (9+ messages)  latest in thread

Message-ID: <20150720101431.GJ2301@postgresql.org>
Permalink:  ../20150720101431.GJ2301@postgresql.org/
Also on:    postgresql.org/message-id/20150720101431.GJ2301@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, robertmhaas@gmail.com, Jim.Nasby@BlueTreble.com, jaimin.pan@gmail.com, michael.paquier@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] object_classes array is broken, again
  In-Reply-To: <20150720101431.GJ2301@postgresql.org>
  References: <20150720101431.GJ2301@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox