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 1uvemo-00GsJQ-Af for pgsql-general@arkaria.postgresql.org; Mon, 08 Sep 2025 16:32:11 +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 1uvemm-00602j-Jo for pgsql-general@arkaria.postgresql.org; Mon, 08 Sep 2025 16:32:09 +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 1uvemm-00602a-96 for pgsql-general@lists.postgresql.org; Mon, 08 Sep 2025 16:32:08 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uveml-001BcF-0D for pgsql-general@lists.postgresql.org; Mon, 08 Sep 2025 16:32:07 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-55f753ec672so5246161e87.2 for ; Mon, 08 Sep 2025 09:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757349125; x=1757953925; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=sKtw7ib+h5vcFoysSexQggo/7YBgW7ZXqe3NmulpUi8=; b=NPoRot4kwiyb9h6QGWhWygBdW+vKvNM9OkAuCUXSxPwhoI0aXYMWR/QJbk8E0MhX/s 3jw8EtJ2hRadrJgYJewQ3IxErGcUB6H0JZw+6J3hXN1mTc32hUegrOOzH1jsoH2KxOlF dl+Y7NeIh4Dey5Ral3K10Myu+4lvPCye49nC26kpW5PzcXdqA8bFFoCkD1D/V84wqYrN eoepMJcqsekGq8Gu175kKaZdq+SvbKNX9zOqh5stuJKdevmZVdAFcoGEsXyuPuA3ZCFa vO8Rk6kopmKyqH8oT+sze8bVDuZebkeu8va21NDdT4bKeFrJo2bw5vnmuRgZUsNaUxmz dE2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757349125; x=1757953925; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sKtw7ib+h5vcFoysSexQggo/7YBgW7ZXqe3NmulpUi8=; b=kPnF5dO8/OpBPXiZPm/fDFpomH4+jFT1PnP1xCkSKysmAhrAyEpER+avzncWbSz4GX TorJOc24pRtofubdy7RrBaTw54WaHrCktwCCfhb415iTMGS5CXIiKngekHLUYerSHUCg ZA3paGKrsK8eH3jade3xaOkjZqJR6cNmWp1WAybuNkce8ar1yFIJbIrCatW3ii06NkRb drnYTJ/xMblu9QUN2B+fO082o0Y8Ex2ytulej//axHTEO4TbGa/BsAsHopKEuPsu+zlC 3rnXbLAOOsMttSyDd0WMrlzrzWo4wCJvp4Ux/gjQIJcqCuWjjMNlRPsnxZqsAmWQrvLH nD8w== X-Gm-Message-State: AOJu0YyrCgjDwbkPjYR5HJiePA56m+lhuWb0Bz52L3phVTMRI76APYvP LfPm8Sc/bKp0dkQ937gIlOhsHaZysW0VHbsNjWoe3bWq7GBZEhqXO7nWnqIKLuoYm9F1MoQxHDv sjFIFZvbwbKyIsjN3iZb9Mem17F9ZNeA= X-Gm-Gg: ASbGnctO2QpBCUeblcsp+lYO6ggSk/KdV8UhN01kXcVj8tVCT+kaWEBA1UZZwb/I1VY uMWpAhcXBHtXi47sZDEwBnk7H03CBYtGB8sx7fCM0CiFFqZ1xv3lHx1LC3Pu4lu2oNAKtIb7wT/ 9+3aiI2ayF+k3zgq31WJkDqjhcfac0AuFv4peLFFIQp7oN1hrVxyNRGfW2jud3Gt9OnUi6I6tQd B03r8jxwojT9dJFyIPSscQFza5rq9QfHnMC/+4+NBupFrVGXshrxhWP0MxHDPaW3cET8G08g4Ex ORERlg== X-Google-Smtp-Source: AGHT+IF5JD0mupqm7dxEk8tpoBhq8iHpkgVK7+amokYqKtuuTH1LcluwhXgVikYxTWza74jNYz6cc1lApaYZ36u6RPs= X-Received: by 2002:a05:6512:318e:b0:55f:6580:8160 with SMTP id 2adb3069b0e04-562618e1416mr2558842e87.42.1757349124934; Mon, 08 Sep 2025 09:32:04 -0700 (PDT) MIME-Version: 1.0 References: <1985501673.206991527.1757078030654.JavaMail.zimbra@meteo.fr> <890069544.207914575.1757324233380.JavaMail.zimbra@meteo.fr> In-Reply-To: <890069544.207914575.1757324233380.JavaMail.zimbra@meteo.fr> From: Merlin Moncure Date: Mon, 8 Sep 2025 10:31:52 -0600 X-Gm-Features: AS18NWAocBIDvMFSu6HW2vkYVo9el2iEADB1_FPNPyfnNQh9XwO3j9hxwsfN7O4 Message-ID: Subject: Re: PostgreSQL include directive in plpgsql language PL/pgSQL To: PALAYRET Jacques Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000569086063e4cba0f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000569086063e4cba0f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Sep 8, 2025 at 3:37=E2=80=AFAM PALAYRET Jacques wrote: > Hello, > Thanks for your response. > > # Currently, I have a function text and a function array with *the same > body* but a *distinct type return*. > -> Example with the array of text function : > SELECT public.calfxi3s_all_elements_text_array(12345678, '2025-01-01 > 00:00') ; > calfxi3s_all_elements_text_array > ------------------------------------------------------------------------- > {3.2,sonic,"Capteur Vent ultrasonique compact Brand xxx",2,-0.123,0.321} > That gives some parameters : the value of the wind strength (3.2), the > kind of sensor (sonic), the model (Capteur ...), the environmment (2), tw= o > coefficients (-0.123,0.321) > Right. I guess your issue might be in calfxi3s_all_elements_text_array(). Is there any specific reason why this must return an array vs a composite type? I guess the basic issue here is trying to abuse the array type when a composite type might have many advantages here. CREATE TYPE sensor_measurement_t AS ( wind_strength numeric, sensor text, model text, environment int, coefficient1 numeric, coefficient2 numeric ); CREATE FUNCTION calfxi3s_all_elements(...) RETURNS sensor_measurement_t AS .. SELECT * FROM calfxi3s_all_elements(...); SELECT model FROM calfxi3s_all_elements(...); melin --000000000000569086063e4cba0f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Sep 8, = 2025 at 3:37=E2=80=AFAM PALAYRET Jacques <jacques.palayret@meteo.fr> wrote:
Hello,
Thanks for your response.

= # Currently, I have a function text and a function array with the s= ame body but a distinct type return.
-> Exa= mple with the array of text function :
SELECT public.calfxi3s_all_elemen= ts_text_array(12345678, '2025-01-01 00:00') ;
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 calfxi3s_all_elements_text_array
-----------------= --------------------------------------------------------
=C2=A0{3.2,soni= c,"Capteur Vent ultrasonique compact Brand xxx",2,-0.123,0.321}That gives some parameters : the value of the wind strength (3.2), the ki= nd of sensor (sonic), the model (Capteur ...), the environmment (2), two co= efficients (-0.123,0.321)

Right.=C2=A0 I guess your issue might be in=C2=A0calfxi3s_all_elemen= ts_text_array().

Is there any specific reason why = this must return an array vs a composite type?=C2=A0 I guess the basic issu= e here is trying to abuse the array type when a composite type might have m= any advantages here.

CREATE TYPE sensor_measuremen= t_t AS
(
=C2=A0 wind_strength numeric,
=C2=A0= sensor text,
=C2=A0 model text,
=C2=A0 environment int= ,
=C2=A0 coefficient1 numeric,
=C2=A0 coefficient2 nume= ric
);

CREATE FUNCTION calfxi3s_all_elem= ents(...) RETURNS sensor_measurement_t=C2=A0 AS ..


SELECT * FROM calfxi3s_all_elements(...);
SELECT = model FROM calfxi3s_all_elements(...);

melin
=
=C2=A0
--000000000000569086063e4cba0f--