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 1t0EJt-00A9Cl-4u for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Oct 2024 06:12:41 +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 1t0EJq-00ANct-Ux for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Oct 2024 06:12:39 +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 1t0EJq-00ANcl-Kk for pgsql-hackers@lists.postgresql.org; Mon, 14 Oct 2024 06:12:39 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0EJn-000xUv-5E for pgsql-hackers@lists.postgresql.org; Mon, 14 Oct 2024 06:12:38 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43111cff9d3so28850805e9.1 for ; Sun, 13 Oct 2024 23:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728886355; x=1729491155; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Bw9/nSpB3tz6QWpxTpXL+O7ZIGrmCtSGwIsSMGYGGmw=; b=Dq2vEM9LzIt/k93FjwrAjrBooeNyBIaxvQUHNTxcddmkczU+BhhPJqPBDGrk0w1kRq SHWhtQJjXbOSPBKc/vmzx0sbu3bn21EEXEeOifEvyXk12PtFEDOX4d3Do+x+QgPFubH3 HIiQZeU1Q9q91YMjgKR2NFxuvf9YC7BqLhRfk1MUh29ZeP+lMEaE50ChcXO8WeDsSSa4 eUXe+EURualEvd96nIcGsz1jkrBK0sPJaEWDERnmrtwiI1GOv8F79wfZsLLEz/nPoPbR x1CkCOmeKY+ZfopapJ5CALrxxf10ZLkYKiUd+33aABnoOwYt1fSUOjQyhLYLL08z4r3X wsbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728886355; x=1729491155; h=in-reply-to:content-transfer-encoding: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=Bw9/nSpB3tz6QWpxTpXL+O7ZIGrmCtSGwIsSMGYGGmw=; b=IWWDV0zgiXIydlPfigmJVqOltcNOiB2r269TTmkseMK+hhEOxN36qZsLYoIrZyaNet ynUxCDljnmGWgzSOD5FrQbCg+k3o+6Y1r+ACfhuiMeW/Oo44YZYXWB+wLPWulH52MxnN uWVpVBStoIfrK8iJ/D8qkMCz5WER0NGrynAICW4BzpcorNw6uEV2JRnB24YG6UXwoUyp Kc0Qr7/ubGnbzkTnV+knbZaCctItYy9Rj8Pj+Yh9TTJqT1ymKwJSMPWeoJ+QyMmqZbmZ P8OtENhmdBWu68rRHtLn1uBI15jqbF2V6x2B0bxOU+asR5lWZSTp719kOM4ZF9zIdKDi +T9Q== X-Gm-Message-State: AOJu0Ywb3xwkiQrL+3lxfAsV2IFuL13swdRzI8puMkjpDYPKqcFurc7k ezOQyt3SD3dgkpvVXrA2iy4r4CEs4Yq4x8uoZYtzvXAnidbZZoSSkOIiuA== X-Google-Smtp-Source: AGHT+IG6y8j7G55CBb688AaVLLntvQa11wwbLy5+YuUJYdLSTYjYdNQqbEAfQz52JJtJ0qcRg7yB3Q== X-Received: by 2002:a05:600c:1e88:b0:426:5e91:3920 with SMTP id 5b1f17b1804b1-4311df5875fmr86791145e9.29.1728886354683; Sun, 13 Oct 2024 23:12:34 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431182d790fsm110807945e9.6.2024.10.13.23.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 23:12:33 -0700 (PDT) Date: Mon, 14 Oct 2024 06:12:32 +0000 From: Bertrand Drouvot To: Masahiko Sawada Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Missing deconstruct_array_builtin usage Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Fkzmc81Qd8vWzf7G" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Fkzmc81Qd8vWzf7G Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, On Fri, Oct 11, 2024 at 05:43:04PM -0700, Masahiko Sawada wrote: > Hi, > > On Thu, Oct 10, 2024 at 10:37 PM Bertrand Drouvot > wrote: > > > > Hi hackers, > > > > While working on [1], I noticed that we missed using deconstruct_array_builtin() > > in 062a8444242. > > > > Indeed, d746021de1 added construct_array_builtin and deconstruct_array_builtin > > but , later on, 062a8444242 made use of deconstruct_array for TEXTOID. > > > > Please find attached a tiny patch to add the $SUBJECT. > > > > That does not fix any issues, it just removes this unnecessary hardcoded > > parameters related to TEXTOID passed to deconstruct_array. > > +1 for better consistency and simplicity. > > > > > A quick check: > > > > $ git grep construct_array | grep OID | grep -v builtin > p> src/backend/catalog/pg_publication.c: > deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT, > > src/backend/utils/fmgr/funcapi.c: * For the OID and char arrays, we don't need to use deconstruct_array() > > > > shows that this is the "only" miss since d746021de1, so I still don't think it > > has to be more "complicated" than it is currently (as already mentioned by Peter > > in [2]). > > It seems that src/backend/utils/adt/float.c file still has functions > that can use [de]construct_array_builtin(), for example > float8_combine(). I think it's an oversight of d746021de1. Thanks for looking at it. Good catch, please find attached v2 taking care of those. I looked at the remaining [de]construct_array() usages and that looks ok to me. Please note that v1 has been committed (099c572d33). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --Fkzmc81Qd8vWzf7G Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-construct_array_builtin-usage-for-FLOAT8OID.patch" From 7227bc20a7d3863200129c13750089f642032332 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Sun, 13 Oct 2024 16:14:01 +0000 Subject: [PATCH v2] construct_array_builtin usage for FLOAT8OID Commit d746021de1 introduced use of construct_array_builtin for built-in types instead of construct_array but forgot some replacements linked to FLOAT8OID. --- src/backend/utils/adt/arrayfuncs.c | 6 ++++++ src/backend/utils/adt/float.c | 20 +++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) 100.0% src/backend/utils/adt/ diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index e5c7e57a5d..1640d83885 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -3404,6 +3404,12 @@ construct_array_builtin(Datum *elems, int nelems, Oid elmtype) elmalign = TYPALIGN_INT; break; + case FLOAT8OID: + elmlen = sizeof(float8); + elmbyval = FLOAT8PASSBYVAL; + elmalign = TYPALIGN_DOUBLE; + break; + case INT2OID: elmlen = sizeof(int16); elmbyval = true; diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index f709c21e1f..6fa6ffb51f 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -2946,9 +2946,7 @@ float8_combine(PG_FUNCTION_ARGS) transdatums[1] = Float8GetDatumFast(Sx); transdatums[2] = Float8GetDatumFast(Sxx); - result = construct_array(transdatums, 3, - FLOAT8OID, - sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE); + result = construct_array_builtin(transdatums, 3, FLOAT8OID); PG_RETURN_ARRAYTYPE_P(result); } @@ -3029,9 +3027,7 @@ float8_accum(PG_FUNCTION_ARGS) transdatums[1] = Float8GetDatumFast(Sx); transdatums[2] = Float8GetDatumFast(Sxx); - result = construct_array(transdatums, 3, - FLOAT8OID, - sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE); + result = construct_array_builtin(transdatums, 3, FLOAT8OID); PG_RETURN_ARRAYTYPE_P(result); } @@ -3114,9 +3110,7 @@ float4_accum(PG_FUNCTION_ARGS) transdatums[1] = Float8GetDatumFast(Sx); transdatums[2] = Float8GetDatumFast(Sxx); - result = construct_array(transdatums, 3, - FLOAT8OID, - sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE); + result = construct_array_builtin(transdatums, 3, FLOAT8OID); PG_RETURN_ARRAYTYPE_P(result); } @@ -3359,9 +3353,7 @@ float8_regr_accum(PG_FUNCTION_ARGS) transdatums[4] = Float8GetDatumFast(Syy); transdatums[5] = Float8GetDatumFast(Sxy); - result = construct_array(transdatums, 6, - FLOAT8OID, - sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE); + result = construct_array_builtin(transdatums, 6, FLOAT8OID); PG_RETURN_ARRAYTYPE_P(result); } @@ -3500,9 +3492,7 @@ float8_regr_combine(PG_FUNCTION_ARGS) transdatums[4] = Float8GetDatumFast(Syy); transdatums[5] = Float8GetDatumFast(Sxy); - result = construct_array(transdatums, 6, - FLOAT8OID, - sizeof(float8), FLOAT8PASSBYVAL, TYPALIGN_DOUBLE); + result = construct_array_builtin(transdatums, 6, FLOAT8OID); PG_RETURN_ARRAYTYPE_P(result); } -- 2.34.1 --Fkzmc81Qd8vWzf7G--