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.96) (envelope-from ) id 1w9xMI-001vLU-2d for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 03:44:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9xMF-00E12a-2P for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 03:44:08 +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.96) (envelope-from ) id 1w9xME-00E12R-3D for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 03:44:07 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w9xMC-00000000xqw-3s7x for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 03:44:06 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 42E7414001F4; Mon, 6 Apr 2026 23:44:04 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-06.internal (MEProxy); Mon, 06 Apr 2026 23:44:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1775533444; x=1775619844; bh=hhy3GDsD7LdsT57J+7PX1Z2nUmnX/ZCuR4hZjPQmK5g=; b= YvC5Hle2nlqZgyCDJB7AF8bjlIPyuNLiiDy0FO/JpUQIkor5MkPMJAIC3osuWBgP gQGAxvX6EKXR6Ry+lEAsmMLKbz5T9JCAitvIeBaiddtUTDJaR6k9zF5WNQrcJWld 8npDwD2zfSTzk3mWXn+HOIB80bhxBMIVupKOj+vzWseZpi5xbhjSbVLLr+GCsJP1 N+mF11cag6EX7kyiVRctzJ3wmtK8IsslscNCZCDyeVvR11PJPgbJcWhBT0Rve4Ug SSBBQfInc7UKgBvj61z3wlcXrCvqATHhbxf0Xsjhz46BLx5BE8G5QaTZ3PQK+KD8 sjz2T2AOqXmvXng6ti834w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1775533444; x= 1775619844; bh=hhy3GDsD7LdsT57J+7PX1Z2nUmnX/ZCuR4hZjPQmK5g=; b=R IAPXM4VV/TB0IrSXjckKwHZpIjs+JczSSyru4m4RiWX0NTkVkFKi3N0AzNuDEB6F MRRSVyIGiFhR5qZDE+S1rr3dF1Z6PHiA2u9egHV6iq8G9lQeHoOVZDfln4lUTqNX dsjXJ5YuaU9UvphGFcOb0gUujSg6a0GnO0n8NzALFuZTd7VSW2CKRFdB9tuGd96F Jq0x4PlzGHt/gV07CMdkFHtPYUh6t0Dz8WRw59peN2cGULaFPkzbZnWjT6bpF7Df YAcBknqTQooi55tp2hvhD5zkRdGl6sHHKaLgvjsNtuqus7qQs2+Vpw6i/u9ppV/9 rHGqDZDpHxtm6ur9+MWjA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduleehlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvvefkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfguhhlvghr ucfvrghvvghirhgrfdcuoegvuhhlvghrsegvuhhlvghrthhordgtohhmqeenucggtffrrg htthgvrhhnpeefhefgjeehgeelleekgffhteehveehteelffefjefgvddvudeiveehheek jeevueenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgpdgvnhhtvghrphhrih hsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegvuhhlvghrsegvuhhlvghrthhordgtohhmpdhnsggprhgtphhtthhopeejpd hmohguvgepshhmthhpohhuthdprhgtphhtthhopegrnhgurhgvfiesughunhhslhgrnhgv rdhnvghtpdhrtghpthhtohepuggrvhhiugdrghdrjhhohhhnshhtohhnsehgmhgrihhlrd gtohhmpdhrtghpthhtohepjhgrphhinhhliheshhhothhmrghilhdrtghomhdprhgtphht thhopehpohhsthhgrhgvshesjhgvlhhtvghfrdhnlhdprhgtphhtthhopegrlhhvhhgvrh hrvgeskhhurhhilhgvmhhurdguvgdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhs sehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopeiishholhhtrd hprghrrhgrghhisehpvghrtghonhgrrdgtohhm X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id A582E182007A; Mon, 6 Apr 2026 23:44:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: AmclnrQ3QCH- Date: Tue, 07 Apr 2026 00:43:43 -0300 From: "Euler Taveira" To: "Jelte Fennema" Cc: "Andrew Dunstan" , "David G. Johnston" , japin , "Zsolt Parragi" , =?UTF-8?Q?=C3=81lvaro_Herrera?= , "PostgreSQL Hackers" Message-Id: <97c1633b-b534-4b7e-bd89-6a8fc7bbf4fc@app.fastmail.com> In-Reply-To: References: <202603201311.yhtqmvektawm@alvherre.pgsql> <8ec9b67d-939e-4b22-8d56-a5129f92d32d@app.fastmail.com> <555cdee4-c024-4872-9d96-82ef4216239c@dunslane.net> <34dc4d59-fec8-43c2-aa7b-38917b3ce0aa@dunslane.net> <6ecd7573-850d-424a-9794-3ee1f73851c0@app.fastmail.com> Subject: Re: pg_get__*_ddl consolidation Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 6, 2026, at 5:24 PM, Jelte Fennema-Nio wrote: > On Mon, 6 Apr 2026 at 19:10, Euler Taveira wrote: >> although we already use this style >> in some of the backend functions -- e.g. pg_logical_slot_*_changes()). > > Thanks for the additional context. I didn't know about > pg_logical_slot_*_changes using this style. I searched the docs > locally and cannot find any other functions that use this style. I > think what makes pg_logical_slot_*_changes special, is that it passes > these options to the plugin. The plugin can define any valid options, > and postgres core cannot know what they are. I think this approach > makes sense for those functions because of that, but the ddl functions > don't pass the options to a plugin, so that argument does not apply > here. > There are other functions. See pg_restore_extended_stats() [1] and related functions. If you are looking for flexibility, this key-value pair arguments is one of the ways to achieve it. >> I also consider your approach but decided not to use it. The argument against >> named arguments is that you cannot add new argument *without* a DEFAULT value; >> if you do, all existing functions will fail. > > I'm not sure what kind of change you're referring to here. I don't > understand how variadic options allow you to add a required argument > to an existing function without breaking existing callers. Could you > give a concrete example of a change that the VARIADIC allows, but the > named arguments don't? > Indeed. My sentence was confused. I want to say that the regular argument list is not as flexible as the VARIADIC argument. Once you have an argument with DEFAULT, you cannot have a next argument *without* DEFAULT. For VARIADIC arguments, this restriction does not exist; there is no need to change the function signature. The argument manipulation (default value, non null) happens inside the function. postgres=# create function foo(arg1 int default 0, arg2 int) returns int as $$ begin return arg1 + arg2; end; $$ language plpgsql; ERROR: input parameters after one with a default value must also have defaults LINE 1: create function foo(arg1 int default 0, arg2 int) returns in... It means these functions cannot add a new required argument (without DEFAULT). Unless you change the current order of the arguments and put arg2 argument before arg1. Doing that you could silently break existing function calls (if argument type is that same as the existing one). postgres=# create function foo(arg1 int default 0, arg2 int default 0) returns int as $$ begin return arg1 + arg2; end; $$ language plpgsql; CREATE FUNCTION postgres=# select foo(arg1 => 5, arg2 => 8); foo ----- 13 (1 row) postgres=# select foo(5, 8); foo ----- 13 (1 row) postgres=# -- include new argument postgres=# drop function foo(int, int); DROP FUNCTION postgres=# create function foo(arg3 int, arg1 int default 0, arg2 int default 0) returns int as $$ begin return (arg1 + arg2) * arg3; end; $$ language plpgsql; CREATE FUNCTION postgres=# select foo(5, 8); foo ----- 40 (1 row) Of course, if you are using named arguments an error is emitted. postgres=# select foo(arg1 => 5, arg2 => 8); ERROR: function foo(arg1 => integer, arg2 => integer) does not exist LINE 1: select foo(arg1 => 5, arg2 => 8); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. The VARIADIC argument forces you to always specify the argument name; that's a good thing. The regular argument list requires you to remember the order of the arguments (unless you are using named arguments). It is just a few arguments for the current functions but I predict that pg_get_table_dll may have a dozen of arguments. IMO the VARIADIC approach is superior when you want several options. The function call is smaller in comparison to your proposal. (Let's say you want to specify the last argument value. Inform all the other default arguments plus the argument you want to change. For VARIADIC, specify only the argument you want to change.) >> You also need to create another >> function with a different list of arguments to support a new option. > > I don't understand this either. We often add new optional arguments to > existing functions in a new major release. e.g. pg_start_backup got > the exclusive argument in PG9.6. Or do you mean something else here? I meant modifying the pg_proc.dat every time a new argument is added. [1] https://www.postgresql.org/docs/18/functions-admin.html#FUNCTIONS-ADMIN-STATSMOD -- Euler Taveira EDB https://www.enterprisedb.com/