| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com> |
| Cc: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Subject: | Re: Fix variadic argument types for pg_get_xxx_ddl() functions |
| Date: | 2026-06-23 09:29:04 |
| Message-ID: | 331BD983-FB9D-413B-8F01-3651CFDEACD6@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 23, 2026, at 16:34, Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com> wrote:
>
> Hi Chao,
>
> Patch looks good to me. I have added the following test cases in my local version in "src/test/modules/test_misc/t/012_ddlutils.pl". If possible add those and resend the patch
>
> +# Options passed via VARIADIC ARRAY
> +$result = $node->safe_psql('postgres',
> + q{SELECT * FROM pg_get_role_ddl('regress_role_ddl_test2',
> + VARIADIC ARRAY['pretty', 'false'])});
> +unlike($result, qr/\n\s+SUPERUSER/,
> + 'role VARIADIC ARRAY pretty=false suppresses indentation');
> +like($result, qr/SUPERUSER/, 'role VARIADIC ARRAY pretty=false still emits attributes');
>
>
> +# Options passed via VARIADIC ARRAY
> +$result = ddl_filter(
> + $node->safe_psql(
> + 'postgres',
> + q{SELECT pg_get_database_ddl
> + FROM pg_get_database_ddl('regression_ddlutils_test',
> + VARIADIC ARRAY['pretty', 'false'])}));
> +unlike($result, qr/\n\s+WITH TEMPLATE/,
> + 'database VARIADIC ARRAY pretty=false suppresses indentation');
> +like(
> + $result,
> + qr/CREATE DATABASE regression_ddlutils_test/,
> + 'database VARIADIC ARRAY still emits CREATE');
>
>
> +# Options passed via VARIADIC ARRAY (name variant)
> +$result = $node->safe_psql(
> + 'postgres',
> + q{SELECT * FROM pg_get_tablespace_ddl('regress_allopt_tblsp',
> + VARIADIC ARRAY['pretty', 'false'])});
> +unlike($result, qr/\n\s+OWNER/,
> + 'tablespace VARIADIC ARRAY pretty=false suppresses indentation (name)');
> +like(
> + $result,
> + qr/OWNER regress_role_ddl_test1/,
> + 'tablespace VARIADIC ARRAY still emits OWNER (name)');
> +
> +# Options passed via VARIADIC ARRAY (oid variant)
> +$result = $node->safe_psql(
> + 'postgres', q{
> + SELECT * FROM pg_get_tablespace_ddl(
> + (SELECT oid FROM pg_tablespace
> + WHERE spcname = 'regress_allopt_tblsp'),
> + VARIADIC ARRAY['pretty', 'false'])});
> +unlike($result, qr/\n\s+OWNER/,
> + 'tablespace VARIADIC ARRAY pretty=false suppresses indentation (oid)');
> +like(
> + $result,
> + qr/CREATE TABLESPACE regress_allopt_tblsp/,
> + 'tablespace VARIADIC ARRAY still emits CREATE (oid)');
> +
>
Hi Akshay,
I actually considered adding VARIADIC ARRAY test cases when I worked on the patch, but I intentionally avoided them because I found that similar variadic functions, such as json_extract_path and jsonb_extract_path, don’t have such tests either. Also, the sanity check is now able to detect this problem.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shlok Kyal | 2026-06-23 09:33:20 | Re: Support EXCEPT for ALL SEQUENCES publications |
| Previous Message | Akshay Joshi | 2026-06-23 09:22:37 | Re: [PATCH] Add pg_get_table_ddl() to reconstruct CREATE TABLE statements |