Retrieving comment of rules and triggers

Started by Alex Magnumalmost 10 years ago6 messagesgeneral
Jump to latest
#1Alex Magnum
magnum11200@gmail.com

Hi, is there a way to retrieve the comment of rules and triggers. I worked
it out on functions, tables, views but am kind of stuck with rules and
triggers.

Any help is appreciated.
Thanks
Alex

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Alex Magnum (#1)
Re: Retrieving comment of rules and triggers

On Thu, Jun 9, 2016 at 4:45 PM, Alex Magnum <magnum11200@gmail.com> wrote:

Hi, is there a way to retrieve the comment of rules and triggers. I worked
it out on functions, tables, views but am kind of stuck with rules and
triggers.


https://www.postgresql.org/docs/devel/static/functions-info.html

​Table ​9-63. Comment Information Functions

obj_description(object_oid, catalog_name)

Catalog Names:

pg_trigger
pg_rules

The source catalog for the data is:

pg_description

I'm suspect of your existing solution given that this is supposed to be a
universal interface for comment data...

David J.

#3Melvin Davidson
melvin6925@gmail.com
In reply to: David G. Johnston (#2)
Re: Retrieving comment of rules and triggers

On Thu, Jun 9, 2016 at 5:01 PM, David G. Johnston <
david.g.johnston@gmail.com> wrote:

On Thu, Jun 9, 2016 at 4:45 PM, Alex Magnum <magnum11200@gmail.com> wrote:

Hi, is there a way to retrieve the comment of rules and triggers. I
worked it out on functions, tables, views but am kind of stuck with rules
and triggers.


https://www.postgresql.org/docs/devel/static/functions-info.html

​Table ​9-63. Comment Information Functions

obj_description(object_oid, catalog_name)

Catalog Names:

pg_trigger
pg_rules

The source catalog for the data is:

pg_description

I'm suspect of your existing solution given that this is supposed to be a
universal interface for comment data...

David J.

-- To get all rule comments
SELECT DISTINCT r.rulename,
c.description
FROM pg_rewrite r
JOIN pg_description c ON c.objoid = r.oid;

-- To get all trigger comments

SELECT DISTINCT t.tgname,
c.description
FROM pg_trigger t
JOIN pg_description c ON c.objoid = t.oid;

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Alex Magnum (#1)
Re: Retrieving comment of rules and triggers

On 06/09/2016 01:45 PM, Alex Magnum wrote:

Hi, is there a way to retrieve the comment of rules and triggers. I
worked it out on functions, tables, views but am kind of stuck with
rules and triggers.

Any help is appreciated.
Thanks
Alex

From psql:

\dd some_rule_name
\dd some_trigger_name

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Melvin Davidson
melvin6925@gmail.com
In reply to: Melvin Davidson (#3)
Re: Retrieving comment of rules and triggers

On Thu, Jun 9, 2016 at 5:03 PM, Melvin Davidson <melvin6925@gmail.com>
wrote:

On Thu, Jun 9, 2016 at 5:01 PM, David G. Johnston <
david.g.johnston@gmail.com> wrote:

On Thu, Jun 9, 2016 at 4:45 PM, Alex Magnum <magnum11200@gmail.com>
wrote:

Hi, is there a way to retrieve the comment of rules and triggers. I
worked it out on functions, tables, views but am kind of stuck with rules
and triggers.


https://www.postgresql.org/docs/devel/static/functions-info.html

​Table ​9-63. Comment Information Functions

obj_description(object_oid, catalog_name)

Catalog Names:

pg_trigger
pg_rules

The source catalog for the data is:

pg_description

I'm suspect of your existing solution given that this is supposed to be a
universal interface for comment data...

David J.

-- To get all rule comments
SELECT DISTINCT r.rulename,
c.description
FROM pg_rewrite r
JOIN pg_description c ON c.objoid = r.oid;

-- To get all trigger comments

SELECT DISTINCT t.tgname,
c.description
FROM pg_trigger t
JOIN pg_description c ON c.objoid = t.oid;

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

FYI, in the future, it is always best to give your version of PostgreSQL &
O/S, as the developers have a nasty habit of changing
pg_catalog tables/columns.

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

#6Michael Paquier
michael@paquier.xyz
In reply to: Melvin Davidson (#5)
Re: Retrieving comment of rules and triggers

On Fri, Jun 10, 2016 at 6:06 AM, Melvin Davidson <melvin6925@gmail.com> wrote:

as the developers have a nasty habit of changing pg_catalog
tables/columns.

... When necessary to improve the quality of the project and the user
experience.
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general