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 1nAea1-0003lE-Mo for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jan 2022 21:02:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAea0-0000Vq-K1 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Jan 2022 21:02:48 +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 1nAea0-0000Vc-B8 for pgsql-hackers@lists.postgresql.org; Thu, 20 Jan 2022 21:02:48 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAeZx-00036p-Si for pgsql-hackers@lists.postgresql.org; Thu, 20 Jan 2022 21:02:47 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0C39B5C00A1; Thu, 20 Jan 2022 16:02:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 20 Jan 2022 16:02:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Jm5btofQ6t2pyH+Tl/oqMvBDUFWBe4Amri/qM/ptr+I=; b=A4Gx39tU SLS4r+SfwHlCPcTtanF4KLiRmPBqoeNu4qL7GxsDi6x7rL7ejGuSs2pEbftQnbQW bo9fE/FoKPNZMFxfQvC+ptfb4nioYGqexTiIrYocY0Cybjt59kcmIHrdcwLt9Udu LIaTkr0X6FMfIfoWLlgPiWTYqk/95LmmwGU+0HPd/t7qtOzt5Fj2hPRKJjukGHka 72qdqKZDaFItI+w/iNfhalnFh+5S3Vy+XInUYEH2NNK1VOREITdKMDGzRwHfmzRg 2g0c1qxT6L5JRVfjXgcoDxq/U1fNRAWlYuw3oIEoqdff99xYlBry+n55CN0cm8Pv jbsRTBLcLTRLhQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekgddugedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeefudelkeetiefggeeltddvvddvtdeludfgfefhtdeiveet fedtueeuheduuedvleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmpd hpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Jan 2022 16:02:44 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 1EEA52A0780; Thu, 20 Jan 2022 18:02:43 -0300 (-03) Date: Thu, 20 Jan 2022 18:02:43 -0300 From: Alvaro Herrera To: Jaime Casanova Cc: Simon Riggs , Tomas Vondra , Zhihong Yu , Daniel Westermann , Amit Langote , Justin Pryzby , Pg Hackers , Pavan Deolasee Subject: Re: support for MERGE Message-ID: <202201202102.5ta7rb3vyvkh@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Jan-12, Jaime Casanova wrote: > I found two crashes, actually I found them on the original patch Álvaro > sent on november but just checked that those already exists. > > I configured with: > > CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" ./configure --prefix=/opt/var/pgdg/15/merge --enable-debug --enable-depend --enable-cassert --with-llvm --enable-tap-tests --with-pgport=54315 > > And tested on the regression database. > > Attached the SQL files for the crashes and its respective stacktraces. > FWIW, the second crash doesn't appear to be caused by the MERGE patch > but I cannot trigger it other way. Thanks for this! The problem in the first crash was that when partitioned tables are being used and the topmost one has a tuple descriptor different from the partitions, we were doing the projection to the partition's slot using the root's tupledesc and a targetlist written for the root. The reason this crashed in such ugly way is that in this case the parent has 3 columns (2 dropped) while the partitions only have one, so the projection was trying to write to an attribute that didn't exist. I fixed it by making all NOT MATCHED actions use the root table's descriptor and slot. This change fixes both your reported crashes. I didn't look closely to see if the second one is caused by exactly the same issue. -- Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/ Tom: There seems to be something broken here. Teodor: I'm in sackcloth and ashes... Fixed. http://archives.postgresql.org/message-id/482D1632.8010507@sigaev.ru