Re: Identifying user-created objects

2020-07-30 Thread Daniel Gustafsson
> On 1 Jul 2020, at 14:15, Daniel Gustafsson wrote: > >> On 4 Mar 2020, at 12:06, Masahiko Sawada >> wrote: > >> Attached updated patch that incorporated comments from Amit and Vignesh. > > This patch fails to compile due to an Oid collision in pg_proc.dat. Please > submit a new version with

Re: Identifying user-created objects

2020-07-01 Thread Daniel Gustafsson
> On 4 Mar 2020, at 12:06, Masahiko Sawada > wrote: > Attached updated patch that incorporated comments from Amit and Vignesh. This patch fails to compile due to an Oid collision in pg_proc.dat. Please submit a new version with an Oid from the recommended range for new patches: 8000-. See

Re: Identifying user-created objects

2020-03-09 Thread Kyotaro Horiguchi
At Sun, 8 Mar 2020 11:55:06 +0900, Masahiko Sawada wrote in > On Thu, 5 Mar 2020 at 18:39, Kyotaro Horiguchi > wrote: > > > > At Thu, 5 Mar 2020 18:06:26 +0900, Masahiko Sawada > > wrote in > > > On Thu, 5 Mar 2020 at 16:36, Kyotaro Horiguchi > > > wrote: > > > I think normally users don't

Re: Identifying user-created objects

2020-03-07 Thread Masahiko Sawada
On Thu, 5 Mar 2020 at 18:39, Kyotaro Horiguchi wrote: > > At Thu, 5 Mar 2020 18:06:26 +0900, Masahiko Sawada > wrote in > > On Thu, 5 Mar 2020 at 16:36, Kyotaro Horiguchi > > wrote: > > > > > > At Thu, 5 Mar 2020 15:21:49 +0900, Masahiko Sawada > > > wrote in > > > > > > I don't come up with

Re: Identifying user-created objects

2020-03-05 Thread Kyotaro Horiguchi
At Thu, 5 Mar 2020 18:06:26 +0900, Masahiko Sawada wrote in > On Thu, 5 Mar 2020 at 16:36, Kyotaro Horiguchi > wrote: > > > > At Thu, 5 Mar 2020 15:21:49 +0900, Masahiko Sawada > > wrote in > > > > > I don't come up with another use cases but, anyway, I think we need to > > > > > clarify the

Re: Identifying user-created objects

2020-03-05 Thread Masahiko Sawada
On Thu, 5 Mar 2020 at 16:36, Kyotaro Horiguchi wrote: > > At Thu, 5 Mar 2020 15:21:49 +0900, Masahiko Sawada > wrote in > > > > I don't come up with another use cases but, anyway, I think we need to > > > > clarify the scope of the feature. > > > > > > Agreed. Also we would need to consider that

Re: Identifying user-created objects

2020-03-04 Thread Kyotaro Horiguchi
At Thu, 5 Mar 2020 15:21:49 +0900, Masahiko Sawada wrote in > > > I don't come up with another use cases but, anyway, I think we need to > > > clarify the scope of the feature. > > > > Agreed. Also we would need to consider that the existing approach > > (e.g., checking whether the object is def

Re: Identifying user-created objects

2020-03-04 Thread Masahiko Sawada
On Thu, 5 Mar 2020 at 13:23, Fujii Masao wrote: > > > > On 2020/03/05 12:32, Kyotaro Horiguchi wrote: > > At Wed, 4 Mar 2020 21:07:05 +0900, Fujii Masao > > wrote in > The function that you are proposing is really enough for this use > case? > What if malicious users d

Re: Identifying user-created objects

2020-03-04 Thread Michael Paquier
On Wed, Mar 04, 2020 at 06:57:00PM +0900, Fujii Masao wrote: > Yes. But I'm sure that DBA has already considered the measures > againt such threads. Otherwise malicious users can do anything > more malicious rather than changing oid. A superuser is by definition able to do anything on the system u

Re: Identifying user-created objects

2020-03-04 Thread Fujii Masao
On 2020/03/05 12:32, Kyotaro Horiguchi wrote: At Wed, 4 Mar 2020 21:07:05 +0900, Fujii Masao wrote in The function that you are proposing is really enough for this use case? What if malicious users directly change the oid of function to < FirstNormalObjectId? Or you're assuming that malicio

Re: Identifying user-created objects

2020-03-04 Thread Kyotaro Horiguchi
At Wed, 4 Mar 2020 21:07:05 +0900, Fujii Masao wrote in > >> The function that you are proposing is really enough for this use > >> case? > >> What if malicious users directly change the oid of function > >> to < FirstNormalObjectId? Or you're assuming that malicious users will >

Re: Identifying user-created objects

2020-03-04 Thread Fujii Masao
On 2020/03/04 19:14, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 18:57, Fujii Masao wrote: On 2020/03/04 18:36, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 18:02, Fujii Masao wrote: On 2020/03/04 17:05, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 16:43, Fujii Masao wrote: O

Re: Identifying user-created objects

2020-03-04 Thread Masahiko Sawada
On Wed, 4 Mar 2020 at 15:28, vignesh C wrote: > > On Wed, Mar 4, 2020 at 9:02 AM Masahiko Sawada > wrote: > > > > On Tue, 3 Mar 2020 at 23:33, vignesh C wrote: > > > > > > Should we add some check if object exists or not here: > > > +Datum > > > +pg_is_user_object(PG_FUNCTION_ARGS) > > > +{ > >

Re: Identifying user-created objects

2020-03-04 Thread Masahiko Sawada
On Wed, 4 Mar 2020 at 18:57, Fujii Masao wrote: > > > > On 2020/03/04 18:36, Masahiko Sawada wrote: > > On Wed, 4 Mar 2020 at 18:02, Fujii Masao > > wrote: > >> > >> > >> > >> On 2020/03/04 17:05, Masahiko Sawada wrote: > >>> On Wed, 4 Mar 2020 at 16:43, Fujii Masao > >>> wrote: > >

Re: Identifying user-created objects

2020-03-04 Thread Fujii Masao
On 2020/03/04 18:36, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 18:02, Fujii Masao wrote: On 2020/03/04 17:05, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 16:43, Fujii Masao wrote: On 2020/02/05 20:26, Masahiko Sawada wrote: Hi, User can create database objects such as function

Re: Identifying user-created objects

2020-03-04 Thread Masahiko Sawada
On Wed, 4 Mar 2020 at 18:02, Fujii Masao wrote: > > > > On 2020/03/04 17:05, Masahiko Sawada wrote: > > On Wed, 4 Mar 2020 at 16:43, Fujii Masao > > wrote: > >> > >> > >> > >> On 2020/02/05 20:26, Masahiko Sawada wrote: > >>> Hi, > >>> > >>> User can create database objects such as functions int

Re: Identifying user-created objects

2020-03-04 Thread Fujii Masao
On 2020/03/04 17:05, Masahiko Sawada wrote: On Wed, 4 Mar 2020 at 16:43, Fujii Masao wrote: On 2020/02/05 20:26, Masahiko Sawada wrote: Hi, User can create database objects such as functions into pg_catalog. But if I'm not missing something, currently there is no straightforward way to

Re: Identifying user-created objects

2020-03-04 Thread Masahiko Sawada
On Wed, 4 Mar 2020 at 16:43, Fujii Masao wrote: > > > > On 2020/02/05 20:26, Masahiko Sawada wrote: > > Hi, > > > > User can create database objects such as functions into pg_catalog. > > But if I'm not missing something, currently there is no > > straightforward way to identify if the object is a

Re: Identifying user-created objects

2020-03-03 Thread Fujii Masao
On 2020/02/05 20:26, Masahiko Sawada wrote: Hi, User can create database objects such as functions into pg_catalog. But if I'm not missing something, currently there is no straightforward way to identify if the object is a user created object or a system object which is created during initdb.

Re: Identifying user-created objects

2020-03-03 Thread vignesh C
On Wed, Mar 4, 2020 at 9:02 AM Masahiko Sawada wrote: > > On Tue, 3 Mar 2020 at 23:33, vignesh C wrote: > > > > Should we add some check if object exists or not here: > > +Datum > > +pg_is_user_object(PG_FUNCTION_ARGS) > > +{ > > +Oid oid = PG_GETARG_OID(0); > > + > > +PG_RETURN_BOOL(Obje

Re: Identifying user-created objects

2020-03-03 Thread Masahiko Sawada
On Tue, 3 Mar 2020 at 23:33, vignesh C wrote: > > Should we add some check if object exists or not here: > +Datum > +pg_is_user_object(PG_FUNCTION_ARGS) > +{ > +Oid oid = PG_GETARG_OID(0); > + > +PG_RETURN_BOOL(ObjectIsUserObject(oid)); > +} > > I was trying some scenarios where we pass an

Re: Identifying user-created objects

2020-03-03 Thread vignesh C
On Wed, Feb 26, 2020 at 1:18 PM Masahiko Sawada wrote: > > On Thu, 13 Feb 2020 at 17:13, Julien Rouhaud wrote: > > > > On Thu, Feb 13, 2020 at 8:32 AM Amit Langote > > wrote: > > > > > > On Thu, Feb 13, 2020 at 10:30 AM Kyotaro Horiguchi > > > wrote: > > > > At Mon, 10 Feb 2020 14:32:44 +0900,

Re: Identifying user-created objects

2020-02-27 Thread Amit Langote
On Wed, Feb 26, 2020 at 4:48 PM Masahiko Sawada wrote: > On Thu, 13 Feb 2020 at 17:13, Julien Rouhaud wrote: > > On Thu, Feb 13, 2020 at 8:32 AM Amit Langote > > wrote: > > > Maybe we could document that pg_is_user_object() and its internal > > > counterpart returns true only for objects that a

Re: Identifying user-created objects

2020-02-25 Thread Masahiko Sawada
On Thu, 13 Feb 2020 at 17:13, Julien Rouhaud wrote: > > On Thu, Feb 13, 2020 at 8:32 AM Amit Langote wrote: > > > > On Thu, Feb 13, 2020 at 10:30 AM Kyotaro Horiguchi > > wrote: > > > At Mon, 10 Feb 2020 14:32:44 +0900, Amit Langote > > > wrote in > > > > Agree that ObjectIsUserObject(oid) is

Re: Identifying user-created objects

2020-02-13 Thread Julien Rouhaud
On Thu, Feb 13, 2020 at 8:32 AM Amit Langote wrote: > > On Thu, Feb 13, 2020 at 10:30 AM Kyotaro Horiguchi > wrote: > > At Mon, 10 Feb 2020 14:32:44 +0900, Amit Langote > > wrote in > > > Agree that ObjectIsUserObject(oid) is easier to read than oid >= > > > FirstNormalObject. I would have not

Re: Identifying user-created objects

2020-02-12 Thread Amit Langote
On Thu, Feb 13, 2020 at 10:30 AM Kyotaro Horiguchi wrote: > At Mon, 10 Feb 2020 14:32:44 +0900, Amit Langote > 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 >= FirstUs

Re: Identifying user-created objects

2020-02-12 Thread Kyotaro Horiguchi
At Mon, 10 Feb 2020 14:32:44 +0900, Amit Langote wrote in > On Mon, Feb 10, 2020 at 2:23 PM Masahiko Sawada > wrote: > > On Mon, 10 Feb 2020 at 14:09, Michael Paquier wrote: > > > > > > On Mon, Feb 10, 2020 at 01:16:30PM +0900, Amit Langote wrote: > > > > On Mon, Feb 10, 2020 at 1:06 PM Masahi

Re: Identifying user-created objects

2020-02-09 Thread Amit Langote
On Mon, Feb 10, 2020 at 2:23 PM Masahiko Sawada wrote: > On Mon, 10 Feb 2020 at 14:09, Michael Paquier wrote: > > > > On Mon, Feb 10, 2020 at 01:16:30PM +0900, Amit Langote wrote: > > > On Mon, Feb 10, 2020 at 1:06 PM Masahiko Sawada > > > wrote: > > >> How about having it as a macro like: > > >

Re: Identifying user-created objects

2020-02-09 Thread Masahiko Sawada
On Mon, 10 Feb 2020 at 14:09, Michael Paquier wrote: > > On Mon, Feb 10, 2020 at 01:16:30PM +0900, Amit Langote wrote: > > On Mon, Feb 10, 2020 at 1:06 PM Masahiko Sawada > > wrote: > >> How about having it as a macro like: > >> > >> #define ObjectIdIsUserObject(oid) ((Oid)(oid) >= FirstNormalObj

Re: Identifying user-created objects

2020-02-09 Thread Michael Paquier
On Mon, Feb 10, 2020 at 01:16:30PM +0900, Amit Langote wrote: > On Mon, Feb 10, 2020 at 1:06 PM Masahiko Sawada > wrote: >> How about having it as a macro like: >> >> #define ObjectIdIsUserObject(oid) ((Oid)(oid) >= FirstNormalObjectId) > > I'm fine with a macro. I am not sure that it is worth h

Re: Identifying user-created objects

2020-02-09 Thread Amit Langote
On Mon, Feb 10, 2020 at 1:06 PM Masahiko Sawada wrote: > On Mon, 10 Feb 2020 at 12:54, Amit Langote wrote: > > > > Sawada-san, > > > > On Mon, Feb 10, 2020 at 12:25 PM Masahiko Sawada > > wrote: > > > > > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > > > > > About the imp

Re: Identifying user-created objects

2020-02-09 Thread Masahiko Sawada
On Mon, 10 Feb 2020 at 12:54, Amit Langote wrote: > > Sawada-san, > > On Mon, Feb 10, 2020 at 12:25 PM Masahiko Sawada > wrote: > > > > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > > > > About the implementation, how about defining a static inline > > > > > > function, >

Re: Identifying user-created objects

2020-02-09 Thread Amit Langote
Sawada-san, On Mon, Feb 10, 2020 at 12:25 PM Masahiko Sawada wrote: > > > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > > > About the implementation, how about defining a static inline function, > > > > > say is_user_object(), next to FirstNormalObjectId's definition and >

Re: Identifying user-created objects

2020-02-09 Thread Masahiko Sawada
On Thu, 6 Feb 2020 at 17:18, Masahiko Sawada wrote: > > On Thu, 6 Feb 2020 at 16:53, Amit Langote wrote: > > > > On Thu, Feb 6, 2020 at 4:31 PM Michael Paquier wrote: > > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > > About the implementation, how about defining a static

Re: Identifying user-created objects

2020-02-06 Thread Masahiko Sawada
On Thu, 6 Feb 2020 at 16:53, Amit Langote wrote: > > On Thu, Feb 6, 2020 at 4:31 PM Michael Paquier wrote: > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > About the implementation, how about defining a static inline function, > > > say is_user_object(), next to FirstNormal

Re: Identifying user-created objects

2020-02-06 Thread Michael Paquier
On Thu, Feb 06, 2020 at 04:52:48PM +0900, Amit Langote wrote: > On Thu, Feb 6, 2020 at 4:31 PM Michael Paquier wrote: >> FWIW, if we bother adding SQL functions for that, my first impression >> was to have three functions, each one of them returning: >> - FirstNormalObjectId >> - FirstGenbkiObject

Re: Identifying user-created objects

2020-02-05 Thread Julien Rouhaud
On Thu, Feb 6, 2020 at 8:53 AM Amit Langote wrote: > > On Thu, Feb 6, 2020 at 4:31 PM Michael Paquier wrote: > > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > > About the implementation, how about defining a static inline function, > > > say is_user_object(), next to FirstNorm

Re: Identifying user-created objects

2020-02-05 Thread Amit Langote
On Thu, Feb 6, 2020 at 4:31 PM Michael Paquier wrote: > On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > > About the implementation, how about defining a static inline function, > > say is_user_object(), next to FirstNormalObjectId's definition and > > make pg_is_user_object() call

Re: Identifying user-created objects

2020-02-05 Thread Michael Paquier
On Thu, Feb 06, 2020 at 04:25:47PM +0900, Amit Langote wrote: > About the implementation, how about defining a static inline function, > say is_user_object(), next to FirstNormalObjectId's definition and > make pg_is_user_object() call it? There are a few placed in the > backend code that perform

Re: Identifying user-created objects

2020-02-05 Thread Amit Langote
On Wed, Feb 5, 2020 at 8:27 PM Masahiko Sawada wrote: > User can create database objects such as functions into pg_catalog. > But if I'm not missing something, currently there is no > straightforward way to identify if the object is a user created object > or a system object which is created durin

Identifying user-created objects

2020-02-05 Thread Masahiko Sawada
Hi, User can create database objects such as functions into pg_catalog. But if I'm not missing something, currently there is no straightforward way to identify if the object is a user created object or a system object which is created during initdb. If we can do that user will be able to check if