Hello,
On 20/11/25 07:55, Man Zeng wrote:
> Quick correction with an apology: I accidentally created a new thread
(https://www.postgresql.org/message-id/tencent_64301BB7627E58CD256CE15F%40qq.com)and submitted the patch there—my
apologiesfor the mix-up! Let’s just continue the discussion here as planned.
On 20/11/25 09:47, Chao Li wrote:
> 1. The error message "cache lookup failed for type 0” looks not good. At lease saying something like “domain ‘int’
doesnot exist”.
>
> 2. I created a domain “int” in “public”, as you see, “public” is in the search_path, but SELECT
pg_get_domain_ddl('int’);failed.
Thank you both Man Zeng and Chao Li for checking this. Changes added in v5.
I don't think there is a way to make the path issue work, so we just
give more info
to the caller. We exit with error when a built-in name is used and we
throw also a
hint saying that schema-qualified domain name should be used to be sure
it's not
conflicting with a built in name.
On 20/11/25 10:44, Neil Chen wrote:
> Hi Florin,
>
> +pg_get_domain_ddl_ext(PG_FUNCTION_ARGS)
> +{
> + Oid domain_oid = PG_GETARG_OID(0);
> + bool pretty = PG_GETARG_BOOL(1);
> + char *res;
> + int prettyFlags;
> +
> + prettyFlags = pretty ? GET_PRETTY_FLAGS(pretty) : 0;
>
>
> Seems like we should directly use GET_PRETTY_FLAGS here, as it already
> checks the value of "pretty". For a "display-oriented" result, using
> PRETTYFLAG_INDENT looks more appropriate.
Well, actually no,
GET_PRETTY_FLAGS(false) returns PRETTYFLAG_INDENT
But we actually want 0 when pretty is false (no indentation, just spaces)
> + appendStringInfo(buf, "CREATE DOMAIN %s AS %s",
> + generate_qualified_type_name(typForm->oid),
> + generate_qualified_type_name(typForm->typbasetype));
>
>
> It might be good to first call get_typtype to check if it is
> TYPTYPE_DOMAIN.
I added this in `pg_get_domain_ddl_worker`, as we need to make this
check ASAP.
Cheers,
Florin Irion
Tim Waizenegger
EDB (EnterpriseDB)