Re: [PATCH] polish the error message of creating proc

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Junwang Zhao <zhjwpku(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] polish the error message of creating proc
Date: 2022-09-21 12:17:30
Message-ID: 20220921121730.dghlqkzee74diu67@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Sep 21, 2022 at 07:45:01PM +0800, Junwang Zhao wrote:
> when a error occurs when creating proc, it should point out the
> specific proc kind instead of just printing "function".

You should have kept the original thread in copy (1), or at least mention it.

> diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
> index a9fe45e347..58af4b48ce 100644
> --- a/src/backend/catalog/pg_proc.c
> +++ b/src/backend/catalog/pg_proc.c
> @@ -373,7 +373,11 @@ ProcedureCreate(const char *procedureName,
> if (!replace)
> ereport(ERROR,
> (errcode(ERRCODE_DUPLICATE_FUNCTION),
> - errmsg("function \"%s\"
> already exists with same argument types",
> + errmsg("%s \"%s\" already
> exists with same argument types",
> +
> (oldproc->prokind == PROKIND_AGGREGATE ? "aggregate function" :
> +
> oldproc->prokind == PROKIND_PROCEDURE ? "procedure" :
> +
> oldproc->prokind == PROKIND_WINDOW ? "window function" :
> + "function"),
> procedureName)));
> if (!pg_proc_ownercheck(oldproc->oid, proowner))
> aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,

You can't put part of the message in parameter, as the resulting string isn't
translatable. You should either use "routine" as a generic term or provide 3
different full messages.

[1] https://www.postgresql.org/message-id/29ea5666.6ce8.1835f4b4992.Coremail.qtds_126@126.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2022-09-21 12:21:58 Re: Support pg_attribute_aligned and noreturn in MSVC
Previous Message Damir Belyalov 2022-09-21 12:11:46 Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features)