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 1sJc2P-005rsS-8d for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2024 16:50:29 +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 1sJc2M-00GNIV-UN for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2024 16:50:27 +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 1sJc2M-00GNHr-Jj for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2024 16:50:27 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJc2K-001wb5-Te for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2024 16:50:26 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a63359aaacaso896271766b.1 for ; Tue, 18 Jun 2024 09:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718729422; x=1719334222; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=oviMyDSuoxgsAIa0II6ed2dc+kKhVxieeBHCFDYwm5s=; b=ne6U3t3AAZjvGeSXuBk2tKDxUCC1boTUfj+CMtIu300uTkMmFTC/Co0mw6ltth+akv /C+oggxgTZcPHzxRHwo8j5z64gi4GzwnMRFU4quyaOpjkTQ6XZ8ZrvTU/RSSWrJ2T98L JERUu01X8eEdAqK1QMm+5b/RWw1iKYY+a1riznX9NVwA76TsQwHHuFPKjCwzf3R7Yebw fHtN0Ofpte88wmHuYHVD3ftEDdi3nxE3reyNacJY1JixORuN05A7uXO+lnIadTjivDjS pGcRODvXwgb9BHcp6RLJaHNvkZMuu53LdLQhTk8gG26MGVM+qJNQtfODZYRrVGfcQzgH G+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718729422; x=1719334222; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oviMyDSuoxgsAIa0II6ed2dc+kKhVxieeBHCFDYwm5s=; b=SSGpj9mVv57SD8wAIiYAZhx2r8Z5hoSvCYANAZAuB40QOAhr1MgNFi47b4PgUzHU/5 evME78Swp1wwxP0AqrLTRjG6NS9N3Gf1GeH3J6hu7dqTPJ2dnFvITD/xPGwpHrGYSMOu F/LCHKDHFhVJo58pO1XLrS/JmA7ixFTJAlGhl/551ehHOUCEw//BdvjUDvLC3ZqYktjU ln/lRbHlb/bd6VT0iJ6zPt5AzKbRlHgCxO1sJ5lWjI7GCb4t5B0UCUFZ9H2948s7IFCp ymd2PaNfpqDSLRNwusu2djB3JNc7slRrGFGPOvJnXq3xy4sLxyEx2D3/7V3wk7HH1+36 uGrw== X-Gm-Message-State: AOJu0YwLWJXeLHPTo4wvRLEW+O3L7x0khp8a4y+m569JoHe9l0GyQdrp r4+2fxqg1yTETVvTRy5INprTtfRZ9+Xo9TqqXwFCbzaz4Fywh3v0QJEZwijinpQomttzIP+u337 0m/mGslJ4g0TYDUcTwoAm0DKKPd5sOu/G/AY= X-Google-Smtp-Source: AGHT+IHa129acD6s9TRBdtF943/F05lPrMz6TurVAnUzfcQEAQ/iignyyozhxknFo2Sagt5l1KaRsktPxZlhL/2FGPg= X-Received: by 2002:a50:bb4e:0:b0:57a:2e8d:c308 with SMTP id 4fb4d7f45d1cf-57d07ec65camr25635a12.40.1718729422118; Tue, 18 Jun 2024 09:50:22 -0700 (PDT) MIME-Version: 1.0 From: Ayush Vatsa Date: Tue, 18 Jun 2024 22:20:10 +0530 Message-ID: Subject: Seeking Clarification on Function Definitions in PostgreSQL Extensions To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000aba97f061b2ce087" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000aba97f061b2ce087 Content-Type: text/plain; charset="UTF-8" Hi PostgreSQL community, Recently I am exploring extensions in postgres and got a little confused regarding the function definition present in SQL file. For example consider below three functions: CREATE FUNCTION fun1(integer) RETURNS TABLE( col1 integer, col2 text ) AS 'MODULE_PATHNAME', 'fun1' LANGUAGE C; CREATE FUNCTION fun2( IN input integer, OUT col1 integer, OUT col2 text ) RETURNS SETOF record AS 'MODULE_PATHNAME', 'fun2' LANGUAGE C; CREATE FUNCTION fun3( IN input integer, OUT col1 integer, OUT col2 text ) AS 'MODULE_PATHNAME', 'fun3' LANGUAGE C; 1/ I wanted to know what's the difference between the above three definitions. As per my understanding, "fun1" and "fun2" look the same, taking one integer and returning two columns with multiple rows. Whereas "fun3" is used when we are returning only one row, but my doubt for "fun3" is that, Can the above definition (used for fun1 and fun2) cover both single and multiple row scenarios. 2/ How does someone decide which type of definition is to be used? Regards Ayush Vatsa --000000000000aba97f061b2ce087 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi PostgreSQL community,
Recently I am exploring extens= ions in postgres and got a little confused regarding the function definitio= n=C2=A0present in SQL file. For example consider below three functions:
=
CREATE FUNCTION fun1(integer)
RETURNS TABLE(
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 col1 integer,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 col2 text
)AS 'MODULE_PATHNAME', 'fun1'
LANGUAGE C;

CREATE= FUNCTION fun2(
=C2=A0 =C2=A0 IN =C2=A0input integer,
=C2=A0 =C2=A0 O= UT col1 integer,
=C2=A0 =C2=A0 OUT col2 text
)
RETURNS SETOF recor= d
AS 'MODULE_PATHNAME', 'fun2'
LANGUAGE C;

CRE= ATE FUNCTION fun3(
=C2=A0 =C2=A0 IN =C2=A0input integer,
=C2=A0 =C2= =A0 OUT col1 integer,
=C2=A0 =C2=A0 OUT col2 text
)
AS 'MODULE= _PATHNAME', 'fun3'
LANGUAGE C;

1/ I wanted to know wh= at's the difference between the above three definitions.
As per my = understanding, "fun1" and "fun2" look the same, taking = one integer and returning two columns with multiple rows.
Whereas=C2=A0= "fun3" is used when we are returning only one row, but my doubt f= or "fun3" is that, Can the above definition=C2=A0(used for fun1 a= nd fun2) cover both single and multiple row scenarios.

2/ How does s= omeone decide which type of definition is to be used?

Regards
Ayu= sh Vatsa
--000000000000aba97f061b2ce087--