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 1sEm6s-003Y6D-Ls for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2024 08:35:08 +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 1sEm6s-006kY4-ME for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2024 08:35:06 +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 1sEm6s-006kXv-9m for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2024 08:35:06 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sEm6q-0005gu-J2 for pgsql-general@postgresql.org; Wed, 05 Jun 2024 08:35:05 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2e724bc466fso76130541fa.3 for ; Wed, 05 Jun 2024 01:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717576503; x=1718181303; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=XL6Gd1NFKlpLbvbFRYlrN2c9wNn3/gOEegSEfwT0Mkk=; b=J1ExYIPXgeqY+m2YjnbB1blJwq6cZYI6NMwLfbM0OKJWAJrRkthkcQgeTfRa9eTfvG fIeIoDyWx1tODw+Q+QPB6pxy5Y3jaUjxVWGbFF6ZSYglAf9pEU1tKvr+jRyJM3FH0+pY +wGl5uZXsFcZBTQ88zZJ8iAHiJpQsnKpwFkPo/Tx+hHcWUg4E/VNDN6SufMlsokduTgQ Vs1bKp5DS7aAyrZ7UrDlG2KCTQrzGEJaugNeKj8Nl5ZrcjPfUKxUVwoD30uQ/ot8lF6v z/fbIDSonx4xEDVd/wbiJ4iA2i+2sLuUQ4zp/jYt6w4u3KqxoXCBTZXglvhwZ8RHm3e+ 1HIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717576503; x=1718181303; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=XL6Gd1NFKlpLbvbFRYlrN2c9wNn3/gOEegSEfwT0Mkk=; b=o+s7Nka+pKHktA2uPfUHcoFUSXDk4fJdai+HsnQRoa9S8lhL1m6ys1SMJvhEc3H70O QaV9yNJVj9zTEnWsCPIfoJbiYiThAuAmhjdjlmNsGfozghnVS95aKafkGgLYo4c64dMP kGk+sEuDDo2aL70i3NxeWWguT4A+0kLUIFiDbcZnGy8AXY1fyjKvjCcNZQNVScE6hnQ+ +Pol9tsZPzcqiP/9VpFRJCwP9xyhvD/gpUqhg2wxnedLm8UzjjU4TTFpisfWGMw6OIW7 KQiMajaM7GkBa1UELcv9ejNj7Ryb4NEagJ3DMuLxknMBsK6TguRR8FYQojByqxZgsJnj 3omg== X-Gm-Message-State: AOJu0YxCWEZlTDfa/EGOHn8QU4BCcDGri15kLztBc70QbPloiUHq/2bQ do0npXjHBHwtjxnisty9LCQ5Jv8y/WTGfMb51+aVwqJNgCOiYiEv2vK7HNc8Hh2E6anunNo6nsH IkgelQGjl1IE6UG7RWTSw+9YQpCQHPBs4 X-Google-Smtp-Source: AGHT+IHdVnzNUaCQHzhhkZrKJm5HLQlx3+lgG9hUROHX1kRQDXJtQ0y21WjqSP8zlPj3Gzkxh9089zFpHpGfB5ClHLc= X-Received: by 2002:a05:651c:551:b0:2ea:89f6:258f with SMTP id 38308e7fff4ca-2eac77a26a9mr14044381fa.0.1717576503237; Wed, 05 Jun 2024 01:35:03 -0700 (PDT) MIME-Version: 1.0 From: Durumdara Date: Wed, 5 Jun 2024 10:34:54 +0200 Message-ID: Subject: Variant (Untyped) parameter for function/procedure To: Postgres General Content-Type: multipart/alternative; boundary="00000000000059a676061a2071ef" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000059a676061a2071ef Content-Type: text/plain; charset="UTF-8" Dear Members! As I experienced, the functions/procedures extremely depend on parameters (very typed). So if I have to restructure the input parameters, I can't modify the function, because I have to recreate the dependents too. For example: I have a type. If I pass this type to a function, I can't change the structure of the type without dropping and recreating the function. create type blahtype as (a int, b bool); create function blahcheck (input blahtype) ... If I have many dependent functions this causes that I have to drop (recreate) everything - just for an extra parameter. And sometimes this extra parameter doesn't change 10 functions, only one. But I have to recreate them all (without changing the body). Is there any way to use a Variant parameter? Like this: create procedure test(IN Input Record, OUT Output Record) ... Time = Input.Time::timestamp; ... Output = SomeHowMakeItTyped; Output.Result = 1; ... Caller: ... for r_in as select id, name from blah into ... test(r_in, r_out); if r_out.result <> 0 then ... Or: create procedure test(IN Inputs Records, OUT Output Record) ... for Input in Inputs: Time = Input.Time::timestamp; ... Output.Result = 1; ... Or is it impossible, because of the PGSQL's philosophy (very typed)? If it is not possible then I have one way I think. It is a JSON data type for inputs and outputs. Is that right? Thanks for your any help, info! Best regards dd --00000000000059a676061a2071ef Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Members!

As I experienced, the fun= ctions/procedures extremely depend on parameters (very typed).
So= if I have to restructure the input parameters, I can't modify the func= tion, because I have to recreate the dependents too.
For=C2=A0exa= mple:
I have a type. If I pass this type to a function, I can'= ;t change the structure of the type without dropping and recreating the fun= ction.

create type blahtype as (a in= t, b bool);
create function blahcheck (input blahtype) ...

If I have many dependent functions this cau= ses that=C2=A0I have to drop (recreate) everything - just for an extra para= meter. And sometimes this extra parameter doesn't change 10 functions, = only one. But I have to recreate=C2=A0them all (without changing the body).=

Is there any way to use a Variant parameter?
= Like this:
create procedure test(IN Input Record, O= UT Output Record)=C2=A0
...
=C2=A0 =C2=A0 Time =3D Input.Time::tim= estamp;
...
=C2=A0 =C2=A0 Output =3D SomeHowMakeItTyped;<= /div>
=C2=A0 =C2=A0 Output.Result =3D 1;
...
=
Caller:
...
for r_in as select=C2=A0 id, name from blah into
...
= =C2=A0 =C2=A0 =C2=A0test(r_in, r_out);
=C2=A0 =C2=A0 =C2=A0if r_out.result <> 0 then ...
<= /blockquote>
Or:
create procedure = test(IN Inputs Records, OUT Output Record)=C2=A0
...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for Input i= n Inputs:
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 Time =3D Input.Time::timestamp;
...
=C2=A0 =C2=A0 Output.Result = =3D 1;
...

=

O= r is it impossible, because of the PGSQL's=C2=A0philosophy (very typed)= ?

If it is not possible then I have one way I thin= k.=C2=A0
It is a JSON=C2=A0data type for inputs and outputs.

Is that right?

Thanks for you= r any help, info!

Best regards
dd
<= div>




--00000000000059a676061a2071ef--