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 1h6DcP-0003iv-93 for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Mar 2019 12:13: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 1h6DcN-0008IY-RX for pgsql-hackers@arkaria.postgresql.org; Tue, 19 Mar 2019 12:13:19 +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 1h6DcN-0008Hp-KN for pgsql-hackers@lists.postgresql.org; Tue, 19 Mar 2019 12:13:19 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6DcL-0007WG-GK for pgsql-hackers@postgresql.org; Tue, 19 Mar 2019 12:13:18 +0000 Received: by mail-qt1-x844.google.com with SMTP id s1so21730696qte.5 for ; Tue, 19 Mar 2019 05:13:16 -0700 (PDT) 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=x4BGkqbCvyQyd3WdkZGrx8s25j4spEVRonn6CIFgTuY=; b=RRZAQFnTFyo2wSsm+9GsGzNPDn7QoH9xVutzslNY4dwEG3CGiSa4jGWKvV3iKfQbOk vOH7Xxq1oucXEKPqqyaKQ4oQxvvIUkuxzmShPJXQAgPl/oW4g7m/Tt+brrJWG1Cu9dPZ jPBulnxSl015J1DbARPoFHdgQGfUCRXKM1IJIUdTJLBOyFDo+CbZyCtZFMGJavZQsNIQ 9yCNqob0DQbshzlMYmo1peZdqAerHc96C2SKqGenX4hCYNiTFP2V+82IxW9WmtZ4CdNd NIoY0WEkloz51M4thqOY4iKN98Alsy3vB1Y2TBtXVslLMX5zXZyv6b+8N4iPhh/CeWYJ IXtQ== 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=x4BGkqbCvyQyd3WdkZGrx8s25j4spEVRonn6CIFgTuY=; b=D+tmGuvkWng4cON2Q4vdmKQn+6MGSHpPVk/zuHxToJii2TB/tAsjnkAA194XC2KmZ1 TTWJtGftPl01ad1JvMP5qLyIB0uLOGFTUorHKWMmaiFnWm6u+Aby8F8b+m+4/DgBP0Kk 0RMSznlyw7/S9emPwf2W17NgOIsbxQKNe0oVlXhKT9LKvWYsfkpH6zn7az0GLLHagozL qlQrewBB1P4HafhGLx48KbGotWeC1SxhPI72UxWOS2IuPeMLR83a2xWUK2pDOtzEFDG/ zdyBf651xZQ86nk+mt68CHNVCwNTe0fIcEg3On1TFNk2u2/iSll6xdlE6BtJ1Anb3HLM AyjQ== X-Gm-Message-State: APjAAAW5i369tjnQG0dWvRTriuqUsP0It80LYHRb5SaBllpRVMdRU08i xG6fygp1sJYtghhrkGu8YUW6BNklCd/hKg== X-Google-Smtp-Source: APXvYqx5DzHY3xqB/Kf8qkSlDf+PDGpevltaNHx5Fh8fsiZZMl1k790FDEUvWIjrSNNWAzsSdzyBmA== X-Received: by 2002:aed:3c09:: with SMTP id t9mr1630040qte.353.1552997595709; Tue, 19 Mar 2019 05:13:15 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id r58sm8518175qtr.24.2019.03.19.05.13.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 05:13:15 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 1EA17121C2E; Tue, 19 Mar 2019 09:13:11 -0300 (-03) Date: Tue, 19 Mar 2019 09:13:11 -0300 From: Alvaro Herrera To: Amit Langote Cc: Amit Langote , Pg Hackers Subject: Re: partitioned tables referenced by FKs Message-ID: <20190319121311.GA11582@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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-Mar-19, Amit Langote wrote: > On Tue, Mar 19, 2019 at 8:49 PM Alvaro Herrera wrote: > > On 2019-Mar-19, Amit Langote wrote: > > > > > Will it suffice or be OK if we skipped invoking the pre-drop callback for > > > objects that are being "indirectly" dropped? I came up with the attached > > > patch to resolve this problem, if that idea has any merit. We also get > > > slightly better error message as seen the expected/foreign_key.out changes. > > > > I don't think this works ... consider putting some partition in a > > different schema and then doing DROP SCHEMA CASCADE. > > Ah, I did test DROP SCHEMA CASCADE, but only tested putting the top > table into the schema, not a partition. :-( I think this is fixable by using a two-step strategy where we first compile a list of constraints being dropped, and in the second step we know to ignore those when checking partitions that are being dropped. Now, maybe the order of objects visited guarantees that the constraint is seen (by drop) before each corresponding partition, and in that case we don't need two steps, just one. I'll have a look at that. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services