Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYcfM-0002eh-Jn for pgsql-general@arkaria.postgresql.org; Sun, 16 Dec 2018 20:05:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYcfL-0002KI-C9 for pgsql-general@arkaria.postgresql.org; Sun, 16 Dec 2018 20:05:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYcfJ-0002Ia-MN for pgsql-general@lists.postgresql.org; Sun, 16 Dec 2018 20:05:31 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYcfF-0007V6-3H for pgsql-general@lists.postgresql.org; Sun, 16 Dec 2018 20:05:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A087E20A0D; Sun, 16 Dec 2018 15:05:21 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 16 Dec 2018 15:05:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=+ gFjmbHbZt60T/oFa2tcdjRx8bTIjO/Vpsq16ymAdfY=; b=surEx4rT7bVKOS4yT Mh09WyDMhwEjbSJVC6tW5vELp4jfHO4YxPv5g+5aeei85k9ZVbZeodwDFLuETyNH hEeWC9mu+CHkD1GY+limqJKYJ+Tn2AWXO+gSBKpN6qkKEP5fT5GmXktD/WuwYHRn dB71zu8NqjW3fYWNm53MfJfI05gj8Qdor8eJRsil0uzys3JjNqlKTqnZroMwv2eV jxxRr2LswHaRIbxuDwdZtaOWKqB4FKZO0RYJmAvFVTGxv/VhSp4MMKELpvE+KK5f Af3hXIWysz7NXVp6UK+n7BwmApSH6HBzGf+HEXfZi9LMqBhH2rX0KTFkzd1tUkop p+zMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=+gFjmbHbZt60T/oFa2tcdjRx8bTIjO/Vpsq16ymAd fY=; b=MTgSiNYMmF5XQofQJABUWDglZpYSI2MrRqM/lazlcmQYI41qKoynQ3A4z tqlYLpb5+D/GHyTY+1hZkqnfZZx6lrfES3QOZVuX/kmgEocyXfcXaRmVUEmhMWFa FQg8tsVcASoTYTx1n4CzBgcI0VhTZy1J+JVsOakDuAucHgs/Mqc9TqzXUWWrzXcs oSYvXWmp+bCsjBukcmxfzAUEA7Tfqo+iLlPURL4mLFE+jmEsir1KVNVucswUCxDD TJdWHvnWukt9BwEFMUabWhXn7R3VqZBulCXv28nEx/HL+Lp74hShaA+ICQ/zoLhy wOJWpb25C1wilRZKROHBwnQcpyf0A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehledgudefgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepuffvfhfhkf fffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcu oegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinh epphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvdduvddrudefgedrfeenucfr rghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrh drtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id BE57B10084; Sun, 16 Dec 2018 15:05:20 -0500 (EST) Subject: Re: new stored procedure with OUT parameters To: Anton Shen <4175george@gmail.com>, Pavel Stehule Cc: pgsql-general References: From: Adrian Klaver Message-ID: Date: Sun, 16 Dec 2018 12:05:19 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/16/18 11:33 AM, Anton Shen wrote: > Thanks for the thoughts. The part I'm missing is that why procedures > with OUT param 'will not be called from SQL environments'? Pretty sure Pavel was referring to: https://www.postgresql.org/docs/11/xfunc-sql.html#XFUNC-OUTPUT-PARAMETERS "Notice that output parameters are not included in the calling argument list when invoking such a function from SQL. This is because PostgreSQL considers only the input parameters to define the function's calling signature. ..." From this commit: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=e4128ee767df3c8c715eb08f8977647ae49dfb59 "SQL procedures This adds a new object type "procedure" that is similar to a function but does not have a return type and is invoked by the new CALL statement instead of SELECT or similar. ... While this commit is mainly syntax sugar around existing functionality, future features will rely on having procedures as a separate object type." I read this to mean that since SQL functions don't have OUT in the signature at this time, SQL procedures do not either. > > Thanks, > Anton > > On Sat, Dec 15, 2018 at 10:03 AM Pavel Stehule > wrote: > > Hi > > út 11. 12. 2018 v 7:20 odesílatel Anton Shen <4175george@gmail.com > > napsal: > > Hi all, > > I was playing around with the stored procedure support in v11 > and found that pure OUT parameters are not supported. Is there > any reason we only support INOUT but not OUT parameters? > > > The procedure implementation in v11 is initial stage - only > functionality with some simple implementation or without design > issues was implemented. > > If I remember there was not clean what is correct and expected > behave of usage of OUT variable when it is called from SQL > environment, and when it is called from plpgsql. > > On Oracle - the OUT variables are part of procedure signature - you > can write procedures P1(OUT a int), P1(OUT a text). Currently we > have not a variables in SQL environment. So if Peter implemented OUT > variables now then > > a) only IN parameters will be part of signature - like functions - > but it is different than on Oracle, and we lost a possibility to use > interesting feature > b) the procedures with OUT variables will not be callable from SQL > environment - that be messy for users. > c) disallow it. > > I hope so PostgreSQL 12 will have schema variables, and then we can > implement OUT variables. Now, it is not possible (do it most > correct) due missing some other feature. INOUT parameters are good > enough, and we have opened door for future correct design. > > Regards > > Pavel > > > psql (11.0 (Homebrew petere/postgresql)) > dev=# CREATE PROCEDURE test_sp(a OUT int) LANGUAGE plpgsql AS $$ > dev$# BEGIN > dev$# a = 5; > dev$# END; $$; > ERROR:  procedures cannot have OUT arguments > HINT:  INOUT arguments are permitted. > > Thanks, > Anton > -- Adrian Klaver adrian.klaver@aklaver.com