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 1gtmMK-0002yR-S5 for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2019 04:41:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtmMJ-0005Ls-E7 for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2019 04:41:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtmMH-0005Ll-Kg for pgsql-bugs@lists.postgresql.org; Wed, 13 Feb 2019 04:41:19 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtmME-0004ji-4P for pgsql-bugs@lists.postgresql.org; Wed, 13 Feb 2019 04:41:16 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D3C6C3311; Tue, 12 Feb 2019 23:41:11 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 12 Feb 2019 23:41:12 -0500 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=fm3; bh=mmQy8CGnHqpLSR8/OTtJVeEkIUb 3OmNJLzyQADP8wFM=; b=AsjWmi0awoI5cEiUJ9FEbaTiGk6YWnHlZ7NfJTUxkJ0 9hg26k71WtLoFM6cEe3O3QzyOyqsmp/Uhg9n4qwbuiS4l9CkRGNebCcUP24YEceS DkKt3kuOozOPbiUW+3+BZjO+kmG8jofiTS1UeFen8HqaoW0etEAGK0MM63f6BtUe ZLUXj0GAL1nP34v+LpivXvwggdNYUgGR8V5gx9I/0BBLmO3qJywHWpD3a7CzdDX3 geYjgZD7XTTAfwFe74p7J8+8ruPV1QoHkIZRbXJLCFwOnxa6TQChj3xruiNoc58Z K9IDW3AgOhdHZFM3f9eRIlxKxAxhbO1nkLfkqaEy6XA== 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=fm2; bh=mmQy8C GnHqpLSR8/OTtJVeEkIUb3OmNJLzyQADP8wFM=; b=w8JXWXjtIiEvaJgATzV0+A bzXJ3z7UHPBX/BFCeXleJYIwgX11TsIH5hUvdzK0EsOvYAGSEEW150EOAUPK+ee2 CBQlRwRX7Fd1wMx4ztetvhsBdb8wX0Q6GOkjHIhtD2kV32XijP2EcF6IEsAbx/RC 86tF438HlB26J7/T2jecEC6PUXV8D2+iJ7eqzLad6QyH/sne95aV720JQjoIsgvj ApGzgBK3wF03S+Ok0fUwfIN0f+hcxNdLSkcNoc1ziHZ9lHWrbTBCQBoh4zEyqfwj uj8sKEVuSdIl2xnDf5w3t2yqY+1i110iILc04e21mxpqJZMhogvE8LVszOfH1XKA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledruddtvddgjeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtd dmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgt hhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqne cukfhppeeiuddrvdduhedrudefjedrudeivdenucfrrghrrghmpehmrghilhhfrhhomhep mhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 202D610311; Tue, 12 Feb 2019 23:41:07 -0500 (EST) Date: Wed, 13 Feb 2019 13:41:05 +0900 From: Michael Paquier To: Tom Lane Cc: Peter Eisentraut , dnsl48@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15631: Generated as identity field in a temporary table with on commit drop corrupts system catalogs Message-ID: <20190213044104.GE5746@paquier.xyz> References: <15631-188663b383e1e697@postgresql.org> <24188.1549917188@sss.pgh.pa.us> <043b0c10-5a27-b9ff-7451-b8a2ca9327b1@2ndquadrant.com> <31358.1549981670@sss.pgh.pa.us> <20190213023817.GD5746@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ls2Gy6y7jbHLe9Od" Content-Disposition: inline In-Reply-To: <20190213023817.GD5746@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Ls2Gy6y7jbHLe9Od Content-Type: multipart/mixed; boundary="IU5/I01NYhRvwH70" Content-Disposition: inline --IU5/I01NYhRvwH70 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 13, 2019 at 11:38:17AM +0900, Michael Paquier wrote: > Agreed. I don't think that it is the correct logic to put an > after-the-fact CCI just before executing any drop or truncate actions. > It should happen after the creation of the new object so as it becomes > correctly visible within the transaction. The problem comes from process_owned_by() in sequence.c which has added in v10 some handling for internal dependencies in the case of an identity sequence, and the dependency link between the sequence and its relation is added there. Another thing I was wondering is if we should add the CCI directly to recordMultipleDependencies() for internal dependencies, still it seems to me that it would be an overkill as some dependency registrers may do the CCI by themselves after adding the pg_depend link and doing some other operations, so I discarded the idea. The patch attached solves the problem, for consistency I would suggest doing the CCI even for auto dependencies. -- Michael --IU5/I01NYhRvwH70 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="identity-depend-cci.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequenc= e.c index 574b46a281..0ddc87da99 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1729,6 +1729,12 @@ process_owned_by(Relation seqrel, List *owned_by, bo= ol for_identity) depobject.objectId =3D RelationGetRelid(seqrel); depobject.objectSubId =3D 0; recordDependencyOn(&depobject, &refobject, deptype); + + /* + * Make dependency visible, which matters for identity sequences + * created with an internal dependency to the object it refers to. + */ + CommandCounterIncrement(); } =20 /* Done, but hold lock until commit */ --IU5/I01NYhRvwH70-- --Ls2Gy6y7jbHLe9Od Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlxjn+AACgkQnvQgOdby QH33bw/+JU0X4jsj6wnGemtbH9cIR8Hfv1mCSlwfD1+PQ4xk/DwiC5easJdmt6Wq IaV8s64jMEg9r1EGvLkLQ03jcregJyw8l5iiYW+jUjhmUyljIKLaxnUYil0+2wSG CqFaIqqBgMrE6FisO+e6U7Al02tCSGUfzO+ed5rWQpUKPXvGDIC77Fv5vMBdupRZ cNPDncwSwHDVL6ducJAeaXxs6YiAZ/yPN7mG3eViu8q2aICcEMbLl+CJxU6LG/mN 6b9TfZGgfmxok5Y2dJdEV4X12Y8lKYV3MNV7XfTnZP8NVFPqPG6dLJjs+NYU73xN OcYCwThSaFWzUTvjBIwmcxmPj8I3j1ZxMc01Ui5eVLs0elHP/6pyM5sZyeGkl0I/ XH/bb4XEQ/0YZpWzyEk0OG1n04V5NVJi3hDO+GYe/+VE28syickuB9wPwxRRkwZB q3xZJLsJqlmERI5oFyGCDwlW8hD44d5gBxVLlFHXhLcFQV+Kjp9vy8ek4JUJx1nc 0KyH6gfnq1JVFy3TD5sBKR5TalRxeM2bx4ww93eU7ORYJ4fH7661U4IIj1h7UFRs 6Qy2ZZjrdoJGv4dQEUA2n2y+VNZcFX8+1FhqTf6sK5p0+4Myg6w66wrjqAt0Z8Wi gXJ9Cdy8KFlmkeVBJYTxlsw0Uhz5a1BNpL1u9GH2b029/YMpqM8= =sRbD -----END PGP SIGNATURE----- --Ls2Gy6y7jbHLe9Od--