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 1kApt3-00086j-2d for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Aug 2020 07:30:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kApt2-0005N3-1v for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Aug 2020 07:30:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kApt1-0005Mu-S7 for pgsql-bugs@lists.postgresql.org; Wed, 26 Aug 2020 07:30:23 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kApt0-0005Uz-1S for pgsql-bugs@postgresql.org; Wed, 26 Aug 2020 07:30:23 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 485CE5C01AB; Wed, 26 Aug 2020 03:30:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 26 Aug 2020 03:30:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=F4uWExRydIhQVOM/XqLFLHZe5Eq NgKnLPrpn1QdGx48=; b=BMQwS5xxI8oTLrHV8NmkGUEldCrhQZPc/zkGL9aA/DS YFN9pb9yhLyOS/IzCngBSjOIUYSASYu/MNYu+Z3PZln5QGZApVQkRWyAl8MwV5A4 e1Ms8DkAPJowE7yP5jBz9GhVySyAYqwU3Uog6LJlMj63rMqRxsQYr37fSXUec7lM QVcAPmr1j7J+nDy14sZBzry+e/UVgX5s7Opi8vkDtIGQE60BKukkcmvcNXrRMk3X uKDUJ2WnD3uWrBHIn3pZDZIpFY/SxK3JRd06PS7sdRv0rKRKUc0rSAssf5UewOpv VrfyBvEJyf4iSJKQcfzy9+cDOm0x+jYOScBX8E6HnrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm3; bh=F4uWEx RydIhQVOM/XqLFLHZe5EqNgKnLPrpn1QdGx48=; b=TjRZiBl0rOxPaGMqKgZoFF tCvIPFy5EeVVUKzRB8NTHABELQFM+RsOQjSt9X6lfgoYaHE9Op0cM9nvdzsm9rLG vZ98F/g6x9baxyRXOZRI5tESvGUDDNMRQGlgs6mXBiRHst1Ka5xpeEKYW1svlp7b lWzEND1kFFfVXlY0ZmwjusA3JgtOCt8igxAfjFTsnlO00AZg53KsonxQW0Knld2e Ul0f+ZVx0oAxy0mfA2a9xz1GKEEtIxy5T/oa7ujfrmIMcNeVnxyw9SIkJH1afkGe Z9rMt8LqiNaXPUYMUdO6zu2weIUKklIulPy2xIxwCAoA4i5j8MfzvOM/I9NpjwOw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvuddguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveej heehieevueeigeelteegleejleeiueeiheegvefhnecukfhppeduuddurddutddvrdduke dtrddukeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 2A77B30600DC; Wed, 26 Aug 2020 03:30:07 -0400 (EDT) Date: Wed, 26 Aug 2020 16:30:01 +0900 From: Michael Paquier To: Bruce Momjian Cc: Tom Lane , Robins Tharakan , pgsql-bugs@postgresql.org Subject: Re: ALTER TABLE ALTER COLUMN SET TYPE crash Message-ID: <20200826073001.GH2017@paquier.xyz> References: <20200825060511.GF2017@paquier.xyz> <20200825155544.GG32540@momjian.us> <2745154.1598372060@sss.pgh.pa.us> <20200825173511.GA20679@momjian.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pMCBjikF2xGw87uL" Content-Disposition: inline In-Reply-To: <20200825173511.GA20679@momjian.us> X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --pMCBjikF2xGw87uL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 25, 2020 at 01:35:11PM -0400, Bruce Momjian wrote: > On Tue, Aug 25, 2020 at 12:14:20PM -0400, Tom Lane wrote: >> I think the nature of the problem (and Robins' other report too) is pretty >> clear. We have a SQL or plpgsql function that's trying to access a table >> that is inconsistent during an ALTER TABLE operation. The function would >> be locked out from seeing that transient state if it were in another >> session, thanks to normal locking rules; but the lock acquisition rules >> don't prevent same-session accesses. There are already some safeguards to prevent directly the use of aggregates in USING, and here we have a function that itself calls an aggregate on the table. >> ALTER TABLE and related utility commands contain guards against the >> reverse form of this problem: CheckTableNotInUse will bitch if there's >> some already-active outer query referencing the table. But we haven't >> thought about the possibility of one of these commands executing >> user-defined code midway through. Hmm. That's not an easy problem as this would need restrictions for high-level commands directly in the executor.. And it is not like you should restrict everything either. -- Michael --pMCBjikF2xGw87uL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl9GD3kACgkQnvQgOdby QH2LrRAAomeQDO3R6LMfA16WSqIBMxJYKzMkRTJohVb9i7Iv8ILNh1pRrU/Kq+oa C5D41Sl853RLC2UyzRzmY7genQQFgZTqXsUwMVCQoEmYp3mm3Uxx4wqimAJyKhJH 5xhpnsMmtnb+oL66Ltlz9dBjnyBWethH2/nJf3gdc3UMEnTmRKfvmzhJze3qKtVw ahs4ExFLFtp3gra4R5Q8/03h0sZVE196mSS1BzfQxDHvZUzVF5RtVURB/8wCa7Dz 5hmlGlh15D8FM+zxJQofe/q7vEY1TPa08c3hUtbl1RdGye3QWrqPrFFnxjxp0EK4 RH8f1HAxLdJq3OROfwAjB4hgCM+RIthFh7aGWwgejG/5HFZtxlMtbsjjyeGfGIkE Qi+2eFs11yOOvIplT9cmbjfx/g7jfSXQ2ti0OFx7yq6tJX0dQqmFfOHe0ahHkKny pSfq5ml7B8vrT27Y79cNeZna4XwwWQIpRRvehQ28GXDkxfpJt9RWWPak8avqOUgt 5AT7q46LbuWOCDAyfjuFd84ms4N+ahbCm+xxRQkb7OT3FF+dsq1e5VDB9eiI0BIo SZ181z4tblLnC4lVUGEPih+Vo8gxq9YnX9Of09iRWs6AI5nw0jf6o9EZ8W1BTZ7p Zm1cG/2OzdzvC4e40Jpqpep7JbdtDOpMTApOni+4vr3mUjq2WL4= =6J/3 -----END PGP SIGNATURE----- --pMCBjikF2xGw87uL--