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 1sJeKQ-0063MW-9C for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2024 19:17:14 +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 1sJeKM-001GpW-Oc for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2024 19:17:11 +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 1sJeKM-001GpL-CJ for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2024 19:17:11 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJeKL-002Kdo-2T for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2024 19:17:10 +0000 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3d215a594b9so3061216b6e.3 for ; Tue, 18 Jun 2024 12:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718738227; x=1719343027; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tAPJd3wbpDJJh/qC+bymAwvYY3ajorFEsFv1oS/E4Bo=; b=FwalKY6CC3r5yHq6qnsmsHh5n2ijqSfybS9ceTLd2KIFUd59MXfELNbqYti/b5CR2a qtMctOQxGfJeN9hSShqhnTcw9koD3RTs9WQ2n1zGbQIIY67dLQe9aoqpgQkNxihFMDZq zBD/hVrbXIf4iZvm7o3oJNEPfB9XzE6gt9OoViJIYIz1rfS+qJGvCU7hZPTPnJXpGCM6 ffiLNrxTvKWMlCEwJUyhJdVXTWZfFY/cTVU8sXorE8Rtvbvg9tzeSHkX+CZc4ZbnTEzQ s6BwIb7QEHc3Q0aoK2hShVPdCbO9xklhKPwlmHNAKdw0oNrEFw0s8XC4GMwOn6xs+Nm5 RSLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718738227; x=1719343027; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tAPJd3wbpDJJh/qC+bymAwvYY3ajorFEsFv1oS/E4Bo=; b=Ot3OmeQLHxbTFQyu0o7Axrz1LgX8q5GzS8tgM6txMFDL9EBcGmcnHLUULlE8Y05M1N LCZ3HzRCydDOYquuZUSu5U1/Kz+mxJuEgT8CCjUZvp50A/8Ag08BdXDLVmJzbryu1FPn xbHFslpJWOSkG9rIHH2DexcHAHbgLRxAiXTKBWFLIgGfcwPlApCc5NtvIA75d5RISAxV 841H7+HF9o6ZK2qd/aFmhAeMEhbOV73N1bA98T+Cm8vAzNIYfyj2+Ekt9rMI6YKSibsu zM7Ms1kRcADjMMW6cxUU/DUO6zJUyuoNfCYGkzo6v/HRsqAZOfocrovCm9fV+7MBydsX y5dg== X-Gm-Message-State: AOJu0Yw1Xe8VPNp634FM0aniM780Cg7V0RLwxFKg0Dx2YxI/2jV/4RVE Ke33Df+xmPNzcay4Vkcdv/SLNpNYfLuJeu6PBwXAn5vQYHjHdkMk2Fqm2tkufk+wnCHv9Y4aybP 812lUuc92VxcYig5tqJch8Omsrki88w== X-Google-Smtp-Source: AGHT+IG5GyMfttDJ1kOdM2/KkogT61N3hTiPBgYwOw7Ka03cYuN9YM/Y3v0VCk84II7Y+LoFhSMbxPJzV4DUU/4TTBU= X-Received: by 2002:a05:6808:1928:b0:3d2:1759:7db0 with SMTP id 5614622812f47-3d51ba1bbc4mr876019b6e.35.1718738226955; Tue, 18 Jun 2024 12:17:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:77c6:0:b0:530:392d:d678 with HTTP; Tue, 18 Jun 2024 12:17:06 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Tue, 18 Jun 2024 12:17:06 -0700 Message-ID: Subject: Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions To: Ron Johnson Cc: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000007acbb1061b2eed32" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007acbb1061b2eed32 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, June 18, 2024, Ron Johnson wrote: > On Tue, Jun 18, 2024 at 2:37=E2=80=AFPM David G. Johnston < > david.g.johnston@gmail.com> wrote: > >> On Tuesday, June 18, 2024, Ron Johnson wrote: >> >>> On Tue, Jun 18, 2024 at 1:57=E2=80=AFPM David G. Johnston < >>> david.g.johnston@gmail.com> wrote: >>> >>>> On Tuesday, June 18, 2024, Ron Johnson wrote= : >>>> >>>>> >>>>> But I stand by returning OUT params and records at the same time. >>>>> >>>> >>>> You mean you dislike adding the optional returns clause when output >>>> parameters exist? >>>> >>> >>> Correct. It breaks the distinction between function and procedure. >>> >> >> How so? >> >> The two distinctions are functions can produce sets while procedures get >> transaction control. >> >> They both can produce a single multi-column output record. The presence >> or absence of the optional return clause on a function definition doesn= =E2=80=99t >> change that fact. >> > > "A function returns a value*, but a procedure does not." > > *In the case of SQL, "value" might be a set. > > Notably it=E2=80=99s the use of output arguments in create function that vi= olate the consistency, but using them is the only way to define an adhoc multi-column result. I=E2=80=99ll accept the narrow definition of =E2=80=9Creturn value=E2=80=9D= being something that be incorporated into an expression. Procedures do not have that. Hence they don;y have a return clause. Since the output arguments for a function are return values specifying =E2=80=9Creturns record=E2=80=9D just makes is per= fectly clear what is happening and that it is different than a procedure with the same output arguments. David J. --0000000000007acbb1061b2eed32 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tuesday, June 18, 2024, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Tue, Jun 18, 2024 at 2:37=E2= =80=AFPM David G. Johnston <david.g.johnston@gmail.com> wrote:
On= Tuesday, June 18, 2024, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Tue, Jun 18, 2024 at 1:57=E2=80=AFPM David G. Johnston <david.g.johnston@gmai= l.com> wrote:
On Tuesday, June 18, 2024, Ron Johnson <= ;ronljohnsonjr= @gmail.com> wrote:

=
But I stand by returning OUT params and records at the same=C2=A0time.=

You mean you dislike add= ing the optional returns clause when output parameters exist?=C2=A0
<= /blockquote>

Correct.=C2=A0 It breaks the distinction be= tween function and procedure.

=
How so?

The two distinctions are functions ca= n produce sets while procedures get transaction control.

They both can produce a single multi-column output record.=C2=A0 The= presence or absence of the optional return clause on a function definition= doesn=E2=80=99t change that fact.

&q= uot;A function returns a value*, but a procedure does not."
<= div>
*In the case of SQL, "value" might be a set.


Notably it= =E2=80=99s the use of output arguments in create function that violate the = consistency, but using them is the only way to define an adhoc multi-column= result.

I=E2=80=99ll accept the narrow definition= of =E2=80=9Creturn value=E2=80=9D being something that be incorporated int= o an expression.=C2=A0 Procedures do not have that.=C2=A0 Hence they don;y = have a return clause.=C2=A0 Since the output arguments for a function are r= eturn values specifying =E2=80=9Creturns record=E2=80=9D just makes is perf= ectly clear what is happening and that it is different than a procedure wit= h the same output arguments.

David J.
--0000000000007acbb1061b2eed32--