Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkuG2-0000LZ-SE for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Dec 2020 19:27:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkuG0-0006hy-Ma for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Dec 2020 19:27:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkuFz-0006hL-WD for pgsql-hackers@lists.postgresql.org; Thu, 03 Dec 2020 19:27:12 +0000 Received: from forward3-smtp.messagingengine.com ([66.111.4.237]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkuFs-0007VA-Mk for pgsql-hackers@postgresql.org; Thu, 03 Dec 2020 19:27:10 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailforward.nyi.internal (Postfix) with ESMTP id 964C51943A48; Thu, 3 Dec 2020 14:27:02 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 03 Dec 2020 14:27:02 -0500 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=sum3x2dADbBBA5eLqZl7FVzrSYGWN24roW6cyfC95 60=; b=a4QzIuM1QwNIEucpTwq/i9eKjfMUGCDXYyHQJZeslQvtbq6cetBJfKNjh VTG8+d3mlwJr8D7copEXRTVyYEtxVFCNhVscitCXFOqQM8p4Ca/nZc8N5f6YcKot n/ECMo5f9VuC9ySOemzmNH5TzFCKvOT/LbqYT8rK3ruDLYITLg4PUh6dRGdJwYgH tK4h0blOottsUxO233JFBwrqiqaEPFRv1k6QpouOyKAibFVJGqV/5npW6Dcnu8gQ 5/4yC/m0MhDKhTlGRXx5yZZk5iCAS3+BEwva7SNKBzWeEvlDxAG5W+XXRXt6US5Q UUQfBPb73a9fHVHI0Ueg7piyF+jmA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeiiedguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhfhokffffgggjggtgfesthejredttdefjeenucfhrhhomheprfgv thgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnh htvghrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepheehieejgfevhfdv heelkeeuvefhheehvdehtefghfetfeeggefgveejjeffgfdvnecukfhppeekjedrudejje drjedvrddugedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepphgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtg homh X-ME-Proxy: Received: from april.pezone.net (p57b1488e.dip0.t-ipconnect.de [87.177.72.142]) by mail.messagingengine.com (Postfix) with ESMTPA id A9544240059; Thu, 3 Dec 2020 14:27:00 -0500 (EST) Subject: Re: SELECT INTO deprecation To: Tom Lane References: <96dc0df3-e13a-a85d-d045-d6e2c85218da@enterprisedb.com> <20201202175836.GX16415@tamriel.snowman.net> <1672926.1606941346@sss.pgh.pa.us> <8e05fc79-abca-dd3f-4d48-8aaae9525a8f@enterprisedb.com> <1723856.1607009655@sss.pgh.pa.us> Cc: Michael Paquier , Stephen Frost , pgsql-hackers From: Peter Eisentraut Organization: EnterpriseDB Message-ID: Date: Thu, 3 Dec 2020 20:26:59 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1723856.1607009655@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-12-03 16:34, Tom Lane wrote: > As I recall, a whole lot of the pain we have with INTO has to do > with the semantics we've chosen for INTO in a set-operation nest. > We think you can write something like > > SELECT ... INTO foo FROM ... UNION SELECT ... FROM ... > > but we insist on the INTO being in the first component SELECT. > I'd like to know exactly how much of that messiness is shared > by SQL Server. On sqlfiddle.com, this works: select a into t3 from t1 union select a from t2; but this gets an error: select a from t1 union select a into t4 from t2; SELECT INTO must be the first query in a statement containing a UNION, INTERSECT or EXCEPT operator.