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 1rNG9M-00AUZh-PW for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jan 2024 17:44:30 +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 1rNG9L-00Ehcc-L5 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jan 2024 17:44:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNG9K-00Eha1-7f for pgsql-hackers@lists.postgresql.org; Tue, 09 Jan 2024 17:44:27 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNG9F-000gcq-Rg for pgsql-hackers@postgresql.org; Tue, 09 Jan 2024 17:44:25 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3630C320092C; Tue, 9 Jan 2024 12:44:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 09 Jan 2024 12:44:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; 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=fm1; t=1704822257; x=1704908657; bh=oPfcAL5VT3ZHRmnms8KyibqY6HneOV2Q8nJseoOB4WU=; b= DF+Jf7opK0XpU/mffgnhh2/U1D2bMw3VERruelMg9R/T4Qr2vawYniTA+Qs4c08i EKhh0ROo8va43U/ItfBzLJFwR1eppN0fqR9DDaseqPYGyzvhvTn9y7LWZGoGvtAG cKeDiopPtYxZHhKZOVJCiMW1u8xvL0PwikRCA6HwO5a0DIWMLrLzv9pox5d+dJz4 CUSH+X3gg5tf1PHgNwk5Vjp8Lyyz149VGWslTkGJ/KoQ3GBuO7F3VhIt3Q2gcvrZ UqfVKVEe745Vz4WT4OxgMpndsQ/+ElRYpF26oE4VuTOyVZynJJRMmw7gP0B37eXY 08WhHkxonUQkkvLpjbb50Q== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1704822257; x= 1704908657; bh=oPfcAL5VT3ZHRmnms8KyibqY6HneOV2Q8nJseoOB4WU=; b=Z QDbzt/1bWNecvcnAgt5O72SIxo+vUaKo/7Y70n5rUTtItk5dMQTB5nSAUU2YJvIu KX6qND4VO27GbAOqDpHIrP5mYHI0RNI2niSHl9E/omTCVAMFj7qaqaoWjFQpZgh2 +mYWf+Gx8XSGCEGjNyXW0b3sddnQEx1AxJ/+3bqQderqK/dyvOJN8+TO/jvtg8mq opZleQIoj3cV4EmM2pHviPhhfs5TSpkLR0M7CGGZZGagSv1jvI8RW2iV7mXgj8o1 UTMPldaoR2uEVCGSSHF1wHZ8mZ3QkX/dwy/CYKo8iTcM9EFGGpKPXGfYFBT+KHqk 6KlcMgvpgKR6sPJ7tWJSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehledguddtvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufhfffgjkfgfgggtgfesthekredttderjeenucfhrhhomhepffgr ghhfihhnnhcukfhlmhgrrhhiucforghnnhhsnohkvghruceoihhlmhgrrhhisehilhhmrg hrihdrohhrgheqnecuggftrfgrthhtvghrnhepfeehteetveeltdduueduffdvtdeuudej ueethefgleegtdeftdefleehkefgudfgnecuffhomhgrihhnpehpohhsthhgrhdrvghsne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgr rhhisehilhhmrghrihdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Jan 2024 12:44:16 -0500 (EST) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: Peter Eisentraut , Nathan Bossart , vignesh C , pgsql-hackers@postgresql.org Subject: Re: Adding a pg_get_owned_sequence function? References: <87jzwcsasv.fsf@wibble.ilmari.org> <4970adf1-cdb0-9ae5-d405-e9c3395d9931@eisentraut.org> <2797313.1694529622@sss.pgh.pa.us> <87v8cfo32v.fsf@wibble.ilmari.org> <20231024162929.GA871220@nathanxps13> <87a5pfn4o5.fsf@wibble.ilmari.org> <20240108210847.GA2796792@nathanxps13> <2196399.1704819786@sss.pgh.pa.us> Date: Tue, 09 Jan 2024 17:44:13 +0000 In-Reply-To: <2196399.1704819786@sss.pgh.pa.us> (Tom Lane's message of "Tue, 09 Jan 2024 12:03:06 -0500") Message-ID: <877ckimmfm.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > Peter Eisentraut writes: >> Would it work to change the signature of pg_get_serial_sequence to >> pg_get_serial_sequence(table anyelement, column text) -> anyelement >> and then check inside the function code whether text or regclass was passed? > > Probably not very well, because then we'd get no automatic coercion of > inputs that were not either type. > > Maybe it would work to have both > > pg_get_serial_sequence(table text, column text) -> text > pg_get_serial_sequence(table regclass, column text) -> regclass I think it would be more correct to use name for the column argument type, rather than text. > but I wonder if that would create any situations where the parser > couldn't choose between these candidates. According to my my earlier testing¹, the parser prefers the text version for unknown-type arguments, and further testing shows that that's also the case for other types with implicit casts to text such as varchar and name. The regclass version gets chosen for oid and (big)int, because of the implicit cast from (big)int to oid and oid to regclass. The only case I could foresee failing would be types that have implicit casts to both text and regtype. It turns out that varchar does have both, but the parser still picks the text version without copmlaint. Does it prefer the binary-coercible cast over the one that requires calling a conversion function? > regards, tom lane - ilmari [1]: https://postgr.es/m/87v8cfo32v.fsf@wibble.ilmari.org