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 1gr8Kx-000115-Ov for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Feb 2019 21:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gr8Kv-0007d3-J8 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Feb 2019 21:32:57 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gr8Kv-0007cq-83 for pgsql-hackers@lists.postgresql.org; Tue, 05 Feb 2019 21:32:57 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gr8Kr-0003c4-La for pgsql-hackers@postgresql.org; Tue, 05 Feb 2019 21:32:56 +0000 Received: by mail-wr1-x444.google.com with SMTP id z3so5357557wrv.3 for ; Tue, 05 Feb 2019 13:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=lO9Uc1jioLptCUxGnx0Swh+UOmYEyqHsD1dIyGjbglo=; b=Guu4/rjdV1y9ikgiewMh0hGM7Wn2VSbXcLkVJgL/WGOfrzDlmLlUe5pL313xY+gvJq EVxkamr0B28BostiwMtmKgwguOMiMakmy16mJHjavq3dfL4XH6fylXUz/KOT+pZbo1iF /hhfkwrJMblnfFuJEEfBiZYmFGLRa5g1D4ZtNXb2UWQjqiEMvr7t/lCJ+aTLQu8iY8Ro 2rVv3G3wD6oVXNDAox+FUyL4HqK9LOZKcdE6jAm5lGqCm0+pmjN1HXOWQeeSSfOdDFp4 nhHkNUjxljpxBJQw85FqCxFMtfMsd3FS/mG01c2wq5zYKR/i5dutn50HD3/Jf9jLUhVw 3pwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=lO9Uc1jioLptCUxGnx0Swh+UOmYEyqHsD1dIyGjbglo=; b=RUYI+R5Wc7UcQUyeo6Z+4EDllEttD7+TGBVCiX5PYOgi7G4fTPJXWNWtIqNZBLMKRc U8fne08ikWYoYthOYW1EouXnLx7o0KmuzTNthyribmff/KuuoM7EGBgDbVFf/9zjaMTd jppziD8DCw5DWaYV5GmRZjPOkbFG3pUv+ekZx+zhtIhkQFlpU+lsTpcia0HkvVzV1XwQ oc8jocgw9XJrVKMFwQnX4OHvTpjNU/M2k5NirXBy9ZJhxPUsvxX+HDhjX2DL9MIi6oSg 5/P6PwiG2zcJH7h0OAHjrejxj80wiobzO2+Q/BASXkUCVLzrW2chI9fqE0yOUuszQ6zj Nd5g== X-Gm-Message-State: AHQUAuYCT0ou4WjLwDuBVOroQmBoWFJOM1EolOj5c8SAkLf0wFDDw+eV T6TWNduYkYqc/Y2tnHzGv0aZ0h4Rw+UfBQ== X-Google-Smtp-Source: AHgI3IZQn4xH2yH+hcFW/LtHOllV7gpYlHOl62yDB5ebVJ2TEN3Ec5W/eCFVMGZGnOCIezmiqHWy/w== X-Received: by 2002:a5d:47d1:: with SMTP id l17mr5139955wrs.319.1549402372627; Tue, 05 Feb 2019 13:32:52 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([212.145.226.69]) by smtp.gmail.com with ESMTPSA id l12sm6340341wrt.87.2019.02.05.13.32.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 13:32:51 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id E510D12458E; Tue, 5 Feb 2019 18:28:29 -0300 (-03) Date: Tue, 5 Feb 2019 18:28:29 -0300 From: Alvaro Herrera To: Tom Lane Cc: Peter Geoghegan , PostgreSQL Hackers Subject: Re: Fixing findDependentObjects()'s dependency on scan order (regressions in DROP diagnostic messages) Message-ID: <20190205212829.GA20127@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <16136.1548790124@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jan-29, Tom Lane wrote: > The closest I could get to solving it along the original lines > went like this: > > * In addition, we support INTERNAL_AUTO dependencies, which alter the > * rules for this. If the target has both INTERNAL and INTERNAL_AUTO > * dependencies, then it can be dropped if any one of those objects is > * dropped, but not unless at least one of them is. In this situation we > * mustn't automatically transform a random deletion request into a > * parent-object deletion. Instead, we proceed with deletion if we are > * recursing from any owning object, and otherwise set the object aside to > * recheck at the end. If we don't later find a reason to delete one of > * the owning objects, we'll throw an error. > > I think that's ugly as sin: INTERNAL means something different if there's > another dependency beside it? I agree it's pretty weird :-( > A theoretically purer answer is to split INTERNAL_AUTO into two new > dependency types, one linking to the real "owning" object (the parent > index or trigger) and the other to the secondary owner (the partition > table), while leaving regular INTERNAL as it stands. I don't especially > want to go that way, though: it seems overcomplicated from the standpoint > of outside inspections of pg_depend, and it'd be very risky to back-patch > into v11. (For instance, if someone went backwards on their postmaster > minor release, the older v11 version would not know what to do with the > new dependency type.) I don't put a lot of value in the idea of people going back in minor releases, but I agree with the general principle of not making pg_depend any harder to inspect than it already is. Even so, I wouldn't dismiss a solution along these lines, if it was clean enough; we could provide better tools for pg_depend inspection (some sensible view, at least). It might make sense to implement this in master only, if it turns out to be better in some way. I'm not volunteering right now, but maybe in the future. > It strikes me however that we can stick with the existing catalog contents > by making this definition: of the INTERNAL_AUTO dependencies of a given > object, the "true owner" to be reported in errors is the dependency > that is of the same classId as that object. If this doesn't uniquely > identify one dependency, the report will mention a random one. This is > ugly as well, but it's certainly a lot more practical to cram into v11, > and it seems like it would cover the current and likely future use-cases > for partition-related objects. When and if we find a use-case for which > this doesn't work, we can think about extending the catalog representation > to identify a unique owner in a less ad-hoc way. This seems a great idea. Do you want me to implement it? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services