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 1tVMBY-007ZRw-2u for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 02:52:44 +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 1tVMBW-00BXBl-AF for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 02:52:41 +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 1tVMBV-00BXBJ-PN for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 02:52:41 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tVMBS-000S82-0W for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 02:52:40 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21634338cfdso26579825ad.2 for ; Tue, 07 Jan 2025 18:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1736304756; x=1736909556; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=5kaaoPDSXmLPWBkNHpYZ7xsJgtvRvbbAE4mIGu7EJcA=; b=WlBhmsMpgfwLB0sdDmKWdHtJBYfEKwaCuGJet5O04qauyy31zEmbIi8vX6s3lRFYRL osaN1Lg91SYCUKR6Ix2q1ijzC+3VONStr7BQYs24nh+r4Wvz7Ytv2/GQ3ii239QdFbgj 9ZOGBgNaQuHBrmYACFXeLYcJ/OZiuUKCJLcks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736304756; x=1736909556; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5kaaoPDSXmLPWBkNHpYZ7xsJgtvRvbbAE4mIGu7EJcA=; b=ezuv9JwyYPIgRq8Uy4LpXQwxoyGLTDwaPyR5CbAY6Up4W0SbeJyFDg/XqUjZqfKo7y tgZccL9XQJHAm1pmFYHlPgtJ+4PIiK0QbRZwpbPe9SbtgpL9cz0Hs8irBZ/woq4vUD9l D0yF5N37cNuHPk6/B9ON94nGZXB86WcP5Cb5SWzIzX0K1eAG6iNnrum9lRsq0Gb5xm8A FIe+5HHlIewJC0mGt9nPqlZhWtwK/quFVrbNkmDBvBPX4pcYSpgoNwe/lNW6O72W+L+d fyoppA2HJWJktu7CIZRXZdURMJfikd0j4JAis5FrH6/EUGX9D8ZrGwj+6a+lPzcVZln0 sFEA== X-Forwarded-Encrypted: i=1; AJvYcCX4HnRwUbPkz8Dc6qeURzCvjTW7VybLI6VB01KWYx03lOJ359OT3i64bdReBPQyqpgJ+O6nNQ1c1qOFGX4j@lists.postgresql.org X-Gm-Message-State: AOJu0YwYfCsDYvKdZF/eD+p6Ul0C8jbtHG1eePbstEkljx1WsjGfAD/k 9pAshl/QM3kQtn+Qoc5hwZmeySQdh3CA72qiBoov2NwxR3NLhQrTcuftnpvcSw== X-Gm-Gg: ASbGnctqvHnPgs2v9Qv51+c+kxcjv19b4ez14/Qdi9KV12cTVGCxHI2L1IwDZUMpy/C CWvMpURmMuRkJSEqocoh8hQ+StD5phtAA4BUiWi/36druOgZn9URudD8uFcRHA2da3h5Gk+UdlT r8Lmr1/HUQzXZjbX5Kf1fuWT0/MSDZQC0PR3crk+RG2hJrSFdrro2za9lR+JOa0wZVuzW8aOk2z t3SZmJ3MqfjRw80G4lmPuP1ZfGpCmayDNNk+pcT7kMVERdGcpM= X-Google-Smtp-Source: AGHT+IE8H59VJbe6RtLzz3jdPjv5UI7eF3sFa4/uvc08j9tbJS1pAxkbaJEvApIhV1/+vfTw7O4SBg== X-Received: by 2002:a05:6a00:170a:b0:725:d64c:f113 with SMTP id d2e1a72fcca58-72d21f18064mr1595747b3a.3.1736304756234; Tue, 07 Jan 2025 18:52:36 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72b5bde56f8sm13913714b3a.162.2025.01.07.18.52.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jan 2025 18:52:35 -0800 (PST) Date: Tue, 7 Jan 2025 18:52:33 -0800 From: Noah Misch To: Michael Paquier Cc: Ronan Dunklau , Tom Lane , pgsql-hackers@lists.postgresql.org, Peter Eisentraut Subject: Re: Converting contrib SQL functions to new style Message-ID: <20250108025233.12.nmisch@google.com> References: <3395418.1618352794@sss.pgh.pa.us> <3133933.1730855116@sss.pgh.pa.us> <5829980.DvuYhMxLoT@aivenlaptop> <20250106190428.ec.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jan 08, 2025 at 11:32:00AM +0900, Michael Paquier wrote: > On Mon, Jan 06, 2025 at 11:04:28AM -0800, Noah Misch wrote: > > Per postgr.es/m/3489827.1618411777@sss.pgh.pa.us and > > postgr.es/m/1471865.1734212070@sss.pgh.pa.us one requirement for migrating to > > SQL-standard function bodies is removing these inexact-match function and > > operator calls. Here, one could either write pg_catalog.generate_series or > > make the argument types match exactly. > > Thanks for the report. > > Tom has used casts for xml2 in 667368fd26de, and also combined some > pg_catalog for schema qualifications in citext for example. In this > case forcing the data types seems more elegant to me. > --- a/contrib/pg_freespacemap/pg_freespacemap--1.2--1.3.sql > +++ b/contrib/pg_freespacemap/pg_freespacemap--1.2--1.3.sql > @@ -9,5 +9,5 @@ RETURNS SETOF RECORD > LANGUAGE SQL PARALLEL SAFE > BEGIN ATOMIC > SELECT blkno, pg_freespace($1, blkno) AS avail > - FROM generate_series(0, pg_relation_size($1) / current_setting('block_size')::bigint - 1) AS blkno; > + FROM generate_series(0::bigint, pg_relation_size($1) / current_setting('block_size'::text)::bigint - 1::bigint) AS blkno; > END; It's more optimal to write '0'::bigint. That generates a CONST node, whereas 0::bigint generates a FUNCEXPR calling the cast function. No other concerns.