| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Philip Alger <paalger0(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] Add pretty formatting to pg_get_triggerdef |
| Date: | 2025-11-05 09:28:37 |
| Message-ID: | 1E06BA13-EE4D-4E09-AFFB-2B8F1EBBCE77@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Nov 5, 2025, at 04:56, Philip Alger <paalger0(at)gmail(dot)com> wrote:
>
> Hi Chao,
>
> +/*
> + * pg_get_triggerdef_compact
> + * Returns trigger definition in a compact, single-line format without
> + * schema qualification designed for the psql \d command.
> + */
> +Datum
> +pg_get_triggerdef_compact(PG_FUNCTION_ARGS)
> +{
> + Oid trigid = PG_GETARG_OID(0);
> + char *res;
> +
> + res = pg_get_triggerdef_worker(trigid, PRETTYFLAG_SCHEMA);
> ```
>
> I think this is a mis-use of PRETTYFLAG_SCHEMA that is for printing schema-qualified names but omitting schema.
>
> Yes, this is to omit the schema because the functions is used to print out the triggers when using \d in psql, The current practice isn't to print out a schema for the table/view/etc.
>
I guess I didn’t express myself clearly. My comment was that, this function wants to omit schema, so PRETTYFLAG_SCHEMA should not be used here, because it is for adding schema.
>
>
> 3 Looks like you forgot to update pg_get_triggerdef(), when it calls pg_get_triggerdef_worker(tirgid, false), the second parameter “false” should be updated to an int flag.
>
> I fixed this to set to 0. However, false is defined as 0 in stdbool.h
> #define false 0
>
I know false is actually 0, but passing false to an int argument is misleading.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shveta malik | 2025-11-05 09:41:20 | Re: Logical Replication of sequences |
| Previous Message | Chao Li | 2025-11-05 09:21:35 | Re: Optimize LISTEN/NOTIFY |