Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1elT85-0002p5-Jf for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Feb 2018 05:27:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1elT83-0004x7-Ts for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Feb 2018 05:27:43 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1elT83-0004wx-7O for pgsql-bugs@lists.postgresql.org; Tue, 13 Feb 2018 05:27:43 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1elT7z-0003aJ-87 for pgsql-bugs@lists.postgresql.org; Tue, 13 Feb 2018 05:27:42 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 19E52109D; Tue, 13 Feb 2018 00:27:37 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Tue, 13 Feb 2018 00:27:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=R7j+CnzWhYYx9zBEBDsbGGwzorONZ YUrccLIMHJOBBM=; b=aTzbx9ixbwAeAtko7EaZoIHk5JD835VFtFiJ/jax2y0zw 41h8pKSVwtFQSPPmACwyjpzt/tntz1YdgDkNiuDIVHxasr99jbOWtBrL9lZBVpa2 l37BTkqS0PJ64fN3XUhQXzLDRa5tlm3jzXQKf6Pa+rryRHXMeBF2vuC+uh+wInqU JRFuNNUMrI3+6W9bVW+cV8QQ6737xkjK/yxWB9+UJHdMJz1AaoKjd92bJWEGbkJ/ hRoo1D1a3AfGJCtCtL6QaeIdiJ/f2L5CTqPx9W1XZgdZGEGH552at4lKhSBYfqVs e5BxATu+GtE5WJRFCipzHN4yomZNo5LD6ALA2UQ6Q== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id AF20E7E645; Tue, 13 Feb 2018 00:27:35 -0500 (EST) Date: Tue, 13 Feb 2018 14:27:32 +0900 From: Michael Paquier To: myon@debian.org, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15061: Cannot use TEMP TABLE ON COMMIT DROP in extension Message-ID: <20180213052732.GF2915@paquier.xyz> References: <151845695673.1447.1976587386911561582@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Z0mFw3+mXTC5ycVe" Content-Disposition: inline In-Reply-To: <151845695673.1447.1976587386911561582@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Z0mFw3+mXTC5ycVe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 12, 2018 at 05:35:56PM +0000, PG Bug reporting form wrote: > Seen on 10.2 and git HEAD. >=20 > Workarounds: > 1) Explicitly drop the table within the .control file > 2) Don't use ON COMMIT DROP (but that leaks the temp tables to the invoki= ng > session) Even dropping the dependency link between the temporary relation and its extension is tricky because the ON COMMIT DROP happens within a hook at transaction commit after create_extension and CurrentExtensionObject are reset. One dirty trick I can think of here is to directly delete the dependency within pg_depend, say in your extension script: create temp table aa (a int); delete from pg_depend where objid =3D 'aa'::regclass and refclassid =3D 'pg= _extension'::regclass; This makes sure the extension is able to drop the object correctly. Have you actually thought about using unlogged tables? Keeping around relation definitions is not a big deal usually for upgrade scenarios, and temporary tables generate WAL, so if you move your data with a two-step process you never want to generate the same WAL data twice, making the upgrade perform faster. -- Michael --Z0mFw3+mXTC5ycVe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlqCd0QACgkQnvQgOdby QH3ggA/9EtIIDf0qnZsGye/xPsGJmzlmTQTtUWuluNSO/e/U4AEVwRWx/8Q7LWHK ln7ax774eQyL75OB6MY2YQhhaLTGutcZMGi5ppoT9GIXpb5xrTW5UNuPVPhTnVNE mVkb4GJXTc2XuaSuhTM991T4DKSqxHbAt0kfnqFRsNDAfRGncoes84OjKhkKAc7w E/kZc3+dmUwaEQezblASaBiCe/fV+jZN0JZuUnPNTo52hD6BNxoTKLWzmCiwT6SL Er/yiwi+Lit45FPCxtt+p/4SmbAd9W/iTxixHNxUlkFhfkDdtzWTYDFYfvT1gOpv peUdAfX26cQQv2Ho1gb6Iwxba5IvYXs5Ql9bzoOUQSBiS4+kSPzNUleRc5OX3CaI kOkR0PUyWztK01ZXs+9MTqUbxUDr2SO3KXb4SRwh5psNDshi/vgKcBdKxnZ5iYNk PxKKtQ3ymExS8NXSEy+38gUVCscy1bmn2CcWUTrW3vJzhIYCZbvu0rWXDsgipZlu gsv6J4mH8Le90jw0KKkhNgDVbeY7W906ZZwID63DXyF4/mECtIA2QPzeIn+2Pq4X xUt2rxraG75ma4wNdHSzi5jEh0QJVdVCtdOKjrXlErvnsxzJ8+v8MfpQwjzeQuTQ NbXPwnbLomwdVtCUhA7vsie20EIbaRmzzpV0yJZEmI31YvYn7MM= =fMqo -----END PGP SIGNATURE----- --Z0mFw3+mXTC5ycVe--