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 1sJySd-007eOZ-JX for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2024 16:47:03 +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 1sJySa-002XQf-TZ for pgsql-general@arkaria.postgresql.org; Wed, 19 Jun 2024 16:47:01 +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 1sJySa-002XQW-Hm for pgsql-general@lists.postgresql.org; Wed, 19 Jun 2024 16:47:01 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJySY-0026kk-Lt for pgsql-general@lists.postgresql.org; Wed, 19 Jun 2024 16:47:00 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-57d044aa5beso2203475a12.2 for ; Wed, 19 Jun 2024 09:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718815616; x=1719420416; 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=RhOliW+Ahqs7WWcxikmQLsnC6qYt9n5a4hU053nzQ3A=; b=lNt0pSDAgw/TNMvaZ5HqawAxEbNA4I/Ze48WZ7XrGGycx90Iz5tjBZLCM9YqR+iyUC vBbuhV4fFVv3g3W2+K0qKfNK2+VjIZHLGmyiOqHl3Z81UkWdqHR9vN8XzDQqBOdu1vp1 dtifbbe35rPAHjEwcz1yuhlu7IU072Yy0iofM0C4IuYcm3XPnAAKVSsalnFGKDKwwyNq b7khiAKbStdFQY9W9RnxnuK98mRHkvhgZsayOnDpSbuEUFwzBWpyipeMXQlI/SGA7QVF +0eyKPD78PRc7fBKRR8mtE79NxNy7zSuz3epq42yGXCooHctJODuNW899KbLwF+EPwli 5+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718815616; x=1719420416; 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=RhOliW+Ahqs7WWcxikmQLsnC6qYt9n5a4hU053nzQ3A=; b=mw+9/CMR0dDQUoPQ6g1VA6QB2XVp4ivtIeH1Nauvi935YXFS6bxcG9f2J7WczqwSPC tIGPLKDsS2Slnp/8piD3e4r6MszxK7p6qr5bTtU8SgTS2pWLocQKweTMqp/Jqf4QjJPB MxZ6RenPy8GCWf6UL+BrP/V1y7BDpujv0S52wrslkIF0jgmQ4RCYWEixjo7KNUzK9Prl jmbW09BPBbNO3PMP3aieud2eCwfCBgSkltDX9jKWgI11mo3h1s8f/3z5irh/nAznpHIX I518Rg/C4YSvD8RAQog6EIXC/UYqLfqrzX2gnuylItyr+7Hzwy3mhauk9hd8c8JUGBgV udJw== X-Gm-Message-State: AOJu0Ywfo4Kg94zjGJxkpVmY+HaKEu2E5U2vz8AjlKXx30W2dcACztYr 0LvU98KH4dVd2sRoa8uze0JrnHcFEtCGdBwZ7yxfbKEZH7LMSGBNoLLCih1s/XjLvKWcZfSUFRC 5nDtvgNVMN3VYThVTK3KC1DuPSsk= X-Google-Smtp-Source: AGHT+IEHkjZ4YtgttPw5Jiunkp0f3+Y/pNK0fNBgvR7+9upPSEetbdEwcT0YQrVEiO6mCI0YWazA9tAttA1yEbH16ak= X-Received: by 2002:a50:cdd5:0:b0:57c:6d89:eaf0 with SMTP id 4fb4d7f45d1cf-57d07e4232fmr1530393a12.14.1718815616201; Wed, 19 Jun 2024 09:46:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ayush Vatsa Date: Wed, 19 Jun 2024 22:16:44 +0530 Message-ID: Subject: Re: Seeking Clarification on Function Definitions in PostgreSQL Extensions To: "David G. Johnston" Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000003cfcaf061b40f2b7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003cfcaf061b40f2b7 Content-Type: text/plain; charset="UTF-8" Hi David, Thanks for clarification > I prefer TABLE. Using setof is more useful when the returned type is predefined But in the table also isn't the returned type predefined? Example: CREATE FUNCTION fun1(integer) RETURNS TABLE( col1 integer, col2 text ) AS 'MODULE_PATHNAME', 'fun1' LANGUAGE C; We know the returned type will have two columns with type - integer and text. Am I correct? > Or a true record where the caller has to specify the shape. Sorry but didn't get this shape part? Thanks Ayush Vatsa --0000000000003cfcaf061b40f2b7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi David,
Thanks for clarification
= >=C2=A0I prefer T= ABLE.=C2=A0 Using setof is more useful when the returned type=C2=A0is prede= fined
But in the table also isn't the returned type predefined? Exam= ple:
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'
L= ANGUAGE C;
We know the returned type will have two columns wi= th type -=C2=A0 integer and text. Am=C2=A0I correct?

>=C2=A0Or a tr= ue record where the caller has to specify the shape.
Sorry but didn'= t get this shape part?

Thanks
Ayush Vatsa
--0000000000003cfcaf061b40f2b7--