Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Tom Lane
Alvaro Herrera writes: > I have to say that I'm baffled as to why has_database_privilege et al > were declared in builtins.h but pg_table_is_visible et al in dependency.c. builtins.h is probably the right place, on the whole ... I agree that consistency is somewhat lacking in this area.

Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Tom Lane
Alvaro Herrera writes: > I just noticed that this is leaking a bit of memory, because we call > getObjectDescription (which pallocs its result) and then > cstring_to_text which pallocs a copy. This is not a lot and it's not > going to live much anyway, is it worrying about? No. The extra string

Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Alvaro Herrera
Excerpts from Tom Lane's message of jue nov 18 14:49:21 -0300 2010: > Please do not do this: > > +/* this doesn't really need to appear in any header file */ > +Datumpg_describe_object(PG_FUNCTION_ARGS); > > Put the extern declaration in a header file, don't be cute. Oh, I forgot to comment

Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Alvaro Herrera
I just noticed that this is leaking a bit of memory, because we call getObjectDescription (which pallocs its result) and then cstring_to_text which pallocs a copy. This is not a lot and it's not going to live much anyway, is it worrying about? I reworked it like this: { char *descr

Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Tom Lane
Alvaro Herrera writes: > In the process of looking it over again, I noticed that in an > assert-enabled build, it's trivial to crash the server with this > function: just pass a nonzero subobjid with an object class that doesn't > take one. This could be fixed easily by turning the Asserts into >

Re: [HACKERS] describe objects, as in pg_depend

2010-11-18 Thread Alvaro Herrera
Thanks for the comments. Updated patch attached. In the process of looking it over again, I noticed that in an assert-enabled build, it's trivial to crash the server with this function: just pass a nonzero subobjid with an object class that doesn't take one. This could be fixed easily by turnin

Re: [HACKERS] describe objects, as in pg_depend

2010-11-17 Thread Tom Lane
Alvaro Herrera writes: > Excerpts from Tom Lane's message of mié nov 17 12:20:06 -0300 2010: >> What's the point of the InvalidOid check? > If the check is not there, the calling query will have to prevent the > function from being called on rows having OID=0 in pg_depend. (These > rows show up

Re: [HACKERS] describe objects, as in pg_depend

2010-11-17 Thread Alvaro Herrera
Excerpts from Tom Lane's message of mié nov 17 12:20:06 -0300 2010: > Alvaro Herrera writes: > > A customer of ours (Enova Financial) requested the ability to describe > > objects in pg_depend. The wiki contains a simplistic SQL snippet that > > does the task, but only for some of the object type

Re: [HACKERS] describe objects, as in pg_depend

2010-11-17 Thread Tom Lane
Alvaro Herrera writes: > A customer of ours (Enova Financial) requested the ability to describe > objects in pg_depend. The wiki contains a simplistic SQL snippet that > does the task, but only for some of the object types, and it's rather > ugly. It struck me that we could fulfill this very eas

[HACKERS] describe objects, as in pg_depend

2010-11-17 Thread Alvaro Herrera
Hi, A customer of ours (Enova Financial) requested the ability to describe objects in pg_depend. The wiki contains a simplistic SQL snippet that does the task, but only for some of the object types, and it's rather ugly. It struck me that we could fulfill this very easily by exposing the getObje