Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vH1er-00BMk5-Eq for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Nov 2025 15:12:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vH1ds-008hC5-6u for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Nov 2025 15:11:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vH1dr-008hBw-TT for pgsql-hackers@lists.postgresql.org; Thu, 06 Nov 2025 15:11:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vH1dk-005jqQ-2c for pgsql-hackers@lists.postgresql.org; Thu, 06 Nov 2025 15:11:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5A6FB3IV1032333; Thu, 6 Nov 2025 10:11:03 -0500 From: Tom Lane To: =?utf-8?Q?=C3=81lvaro?= Herrera cc: Mats Kindahl , David Rowley , pgsql-hackers@lists.postgresql.org Subject: Re: Use stack-allocated StringInfoData In-reply-to: <202511061027.6kun3grytx2d@alvherre.pgsql> References: <202511061027.6kun3grytx2d@alvherre.pgsql> Comments: In-reply-to =?utf-8?Q?=C3=81lvaro?= Herrera message dated "Thu, 06 Nov 2025 11:31:38 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1032331.1762441863.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 06 Nov 2025 10:11:03 -0500 Message-ID: <1032332.1762441863@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?utf-8?Q?=3DC3=3D81lvaro?=3D Herrera writes: > Yeah, I came across this a few weeks ago as well. I was thinking maybe > we can expand the ereport() macro instead of duplicating things. It > looks a bit ugly and I don't think we do it anywhere else ... I mean > something like > errstart(WARNING, NULL); > if (cond) > errmsg( ... ); > else > errmsg( ... ); > // and so on > errfinish(__FILE__, __LINE__, __func__); > Is this too ugly to live? (I swear I had this on a branch already, but > can't find it right this instant.) I really dislike exposing errstart/errfinish to calling code like that. I agree that check_publications_origin_tables is not pretty as-is, but it's better than breaking open the ereport abstraction. In the particular case at hand, it seems best to just write two separate ereport calls for the check_table_sync and not-check_table_sync cases, as David mentioned. Duplicating the errdetail_plural call is slightly annoying but it's net less code and less surprise than what's there now. In general, in most other places where we have conditional message text, it's done via ?: operators within the ereport macro, for example this decades-old bit in sysv_shmem.c: ereport(FATAL, (errmsg("could not create shared memory segment: %m"), errdetail("Failed system call was shmget(key=3D%lu, size=3D= %zu, 0%o).", (unsigned long) memKey, size, IPC_CREAT | IPC_EXCL | IPCProtection), (shmget_errno =3D=3D EINVAL) ? errhint("This error usually means that PostgreSQL's reque= st for a shared memory " "segment exceeded your kernel's SHMMAX parameter,= or possibly that " "it is less than " "your kernel's SHMMIN parameter.\n" "The PostgreSQL documentation contains more infor= mation about shared " "memory configuration.") : 0, (shmget_errno =3D=3D ENOMEM) ? errhint("This error usually means that PostgreSQL's reque= st for a shared " "memory segment exceeded your kernel's SHMALL par= ameter. You might need " "to reconfigure the kernel with larger SHMALL.\n" "The PostgreSQL documentation contains more infor= mation about shared " "memory configuration.") : 0, (shmget_errno =3D=3D ENOSPC) ? errhint("This error does *not* mean that you have run out= of disk space. " "It occurs either if all available shared memory = IDs have been taken, " "in which case you need to raise the SHMMNI param= eter in your kernel, " "or because the system's overall limit for shared= memory has been " "reached.\n" "The PostgreSQL documentation contains more infor= mation about shared " "memory configuration.") : 0)); We could do something similar here, but I'm not convinced it's better than just writing two ereport's. regards, tom lane