Re: Identifying user-created objects

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Identifying user-created objects
Date: 2020-02-13 07:31:48
Message-ID: CA+HiwqFTNbN-DSmUcqDWX3uCxL-LU0avkbg+4gjBExrkh=uYcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 13, 2020 at 10:30 AM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)com> wrote:
> At Mon, 10 Feb 2020 14:32:44 +0900, Amit Langote <amitlangote09(at)gmail(dot)com> wrote in
> > Agree that ObjectIsUserObject(oid) is easier to read than oid >=
> > FirstNormalObject. I would have not bothered, for example, if it was
> > something like oid >= FirstUserObjectId to begin with.
>
> Aside from the naming, I'm not sure it's sensible to use
> FirstNormalObjectId since I don't see a clear definition or required
> characteristics for "user created objects" is. If we did CREATE
> TABLE, FUNCTION or maybe any objects during single-user mode before
> the first object is created during normal multiuser operation, the
> "user-created(or not?)" object has an OID less than
> FirstNormalObjectId. If such objects are the "user created object", we
> need FirstUserObjectId defferent from FirstNormalObjectId.

Interesting observation. Connecting to database in --single mode,
whether done using initdb or directly, is always considered
"bootstrapping", so the OIDs from the bootstrapping range are
consumed.

$ postgres --single -D pgdata postgres

PostgreSQL stand-alone backend 13devel
backend> create table a (a int);
backend> select 'a'::regclass::oid;
1: oid (typeid = 26, len = 4, typmod = -1, byval = t)
----
1: oid = "14168" (typeid = 26, len = 4, typmod = -1, byval = t)

Here, FirstBootstrapObjectId < 14168 < FirstNormalObjectId

Maybe we could document that pg_is_user_object() and its internal
counterpart returns true only for objects that are created during
"normal" multi-user database operation.

Thanks,
Amit

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Haumacher, Bernhard 2020-02-13 07:38:18 Re: Error on failed COMMIT
Previous Message Michael Paquier 2020-02-13 07:30:35 Re: Wait event that should be reported while waiting for WAL archiving to finish