Re: Pretty printed trigger in psql

Lists: pgsql-hackers
From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Pretty printed trigger in psql
Date: 2010-01-12 09:06:22
Message-ID: 20100112180622.C529.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Psql shows too many parentheses when it prints triggers with WHEN clause.

postgres=# \d t1
Table "public.t1"
Column | Type | Modifiers
--------+---------+-----------
c1 | integer |
Triggers:
mytrig AFTER UPDATE ON t1 FOR EACH ROW
WHEN ((old.c1 <> new.c1)) EXECUTE PROCEDURE myfunc()
^ ^

The attached patch eliminates unneeded parentheses by using
pg_get_triggerdef(pretty = true) in psql.

Triggers:
mytrig AFTER UPDATE ON t1 FOR EACH ROW
WHEN (old.c1 <> new.c1) EXECUTE PROCEDURE myfunc()

I think this change is harmless because we don't use
pg_get_triggerdef(pretty = true) in any programs, including pg_dump.

Is this change ok?

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center

Attachment Content-Type Size
pretty-printed-trigger_20100112.patch application/octet-stream 9.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-14 04:08:54
Message-ID: 14160.1263442134@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> The attached patch eliminates unneeded parentheses by using
> pg_get_triggerdef(pretty = true) in psql.

Is this patch reversed? It seems so but the listed file timestamps
don't match that idea ...

regards, tom lane


From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-14 05:30:33
Message-ID: 20100114143033.9A26.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> > The attached patch eliminates unneeded parentheses by using
> > pg_get_triggerdef(pretty = true) in psql.
>
> Is this patch reversed? It seems so but the listed file timestamps
> don't match that idea ...

Sorry, I cannot understand what you mean...

My English might be broken. May I explain what I did again?

1. psql has been used pg_get_triggerdef(oid).

2. I added pg_get_triggerdef(oid, pretty = false) at the last commit fest
for pg_dump to support dumping triggeres with WHEN cluase. In that time,
PRETTYFLAG_PAREN and PRETTYFLAG_INDENT are used when pretty = true.

3 psql still uses pg_get_triggerdef(oid [, pretty=false] ).
Also, pg_dump should use (pretty=false) for safer migration.
No programs use pg_get_triggerdef(pretty=true) is for now.

4. psql will be better to use pg_get_triggerdef(oid, true) to display
trigger definitions cleanly, but it also should print them in one line.
For the purpose, the patch changes two things:
- Modify psql to use pg_get_triggerdef(oid, true) when server version >= 8.5.
- Remove PRETTYFLAG_INDENT from pg_get_triggerdef(). It will partially
revert the changes in 2.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-14 05:52:10
Message-ID: 15854.1263448330@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Is this patch reversed? It seems so but the listed file timestamps
>> don't match that idea ...

> Sorry, I cannot understand what you mean...

The patch looks like it removes, rather than adds, your intended
changes.

regards, tom lane


From: "Brad T(dot) Sliger" <brad(at)sliger(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-18 19:29:48
Message-ID: 201001181129.49439.brad@sliger.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tuesday 12 January 2010 01:06:22 Takahiro Itagaki wrote:
> Psql shows too many parentheses when it prints triggers with WHEN clause.
>
> postgres=# \d t1
> Table "public.t1"
> Column | Type | Modifiers
> --------+---------+-----------
> c1 | integer |
> Triggers:
> mytrig AFTER UPDATE ON t1 FOR EACH ROW
> WHEN ((old.c1 <> new.c1)) EXECUTE PROCEDURE myfunc()
> ^ ^
>
> The attached patch eliminates unneeded parentheses by using
> pg_get_triggerdef(pretty = true) in psql.
>
> Triggers:
> mytrig AFTER UPDATE ON t1 FOR EACH ROW
> WHEN (old.c1 <> new.c1) EXECUTE PROCEDURE myfunc()
>
> <snip>

Greetings,

I tried to apply this patch to the latest version of PostgreSQL in git (bbfc96e). Some of the patch did not apply. Please
find attached the output from patch. The full path of the ruleutils.c.rej is src/backend/utils/adt/ruleutils.c.rej

Thanks,

--bts

Attachment Content-Type Size
patch.output text/plain 2.1 KB
ruleutils.c.rej text/x-diff 2.6 KB

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: "Brad T(dot) Sliger" <brad(at)sliger(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-19 00:40:07
Message-ID: 20100119094007.AB77.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


"Brad T. Sliger" <brad(at)sliger(dot)org> wrote:

> I tried to apply this patch to the latest version of PostgreSQL in git
> (bbfc96e). Some of the patch did not apply. Please find attached the
> output from patch. The full path of the ruleutils.c.rej is
> src/backend/utils/adt/ruleutils.c.rej

The attached patch is rebased to current CVS.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center

Attachment Content-Type Size
pretty-printed-trigger_20100119.patch application/octet-stream 9.4 KB

From: "Brad T(dot) Sliger" <brad(at)sliger(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Pretty printed trigger in psql
Date: 2010-01-19 05:41:47
Message-ID: 201001182141.48138.brad@sliger.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Monday 18 January 2010 16:40:07 Takahiro Itagaki wrote:
> "Brad T. Sliger" <brad(at)sliger(dot)org> wrote:
> > I tried to apply this patch to the latest version of PostgreSQL in git
> > (bbfc96e). Some of the patch did not apply. Please find attached the
> > output from patch. The full path of the ruleutils.c.rej is
> > src/backend/utils/adt/ruleutils.c.rej
>
> The attached patch is rebased to current CVS.

That patch applies, builds and installs. `gmake check` and `gmake distcheck` pass. The code style looks fine and the
patch doesn't seem to add additional lint.

The patch does remove extra ()'s from trigger descriptions with \d in psql.

As far as I can tell, everything looks reasonable.

> Regards,
> ---
> Takahiro Itagaki
> NTT Open Source Software Center

Thanks,

--bts