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 1hJ0Un-0004hD-A4 for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Apr 2019 18:50: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 1hJ0Ul-00029t-T9 for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Apr 2019 18:50: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 1hJ0Ul-00029m-Fk for pgsql-hackers@lists.postgresql.org; Tue, 23 Apr 2019 18:50:19 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJ0Uf-0005VM-Ok for pgsql-hackers@lists.postgresql.org; Tue, 23 Apr 2019 18:50:16 +0000 Received: by mail-qt1-x841.google.com with SMTP id c35so2615105qtk.3 for ; Tue, 23 Apr 2019 11:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=z2u40ejkNTNs6vhXWXgWRpLvzPoGnoDhS5Q2jcJktV4=; b=Dre4cSqVnKtUSLt4WO9j1vaQOoN4c1YnzLnfChwRhOdHGWfhpygOfKKoN67S97gd1O ehKIm0lwV24CV3vwcc3n+vpIv5qICuujWJaCkPW57w1Siuj4gX6O2pobGw0OWjlAjSA0 P7GkY82lUxmDsHwKRxgapp1laW+IwTni2ahuELKAn+gnpIuJYXeJ71yth2gJogpSVXRr 6rv46+oDKh3+HACO/RRnPHk+yGRThHEF5iUXuKL9xn6h0NeiIpSdSCZJHguOyG9CH0Zx Wc4xA+Kw8uP1YxxOAGpj7ICSr1dVYzzYs/o+gBHV+MfTzSdzUlUZoflRZD9INPhQjDnX 24cQ== 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:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=z2u40ejkNTNs6vhXWXgWRpLvzPoGnoDhS5Q2jcJktV4=; b=Pg/C8VLm+FXMveEgPPpD3iVQKLbmXGlkY3rfrtKTdTuytp3QWeEAwrwnt+hMXlhzaB WeEQx96nOxak/6a1cLvtNlnzNA9xOx05GVJbnINxmteWsyT5NnPMBAphZsRFTzFMmSMR HP18pM64tD3N2b3+RtbP235BEDF2lVxyMGjgGzE4HdDBCfi/6OUJiCVS6Rx/KkXyPa0t peGG+Hk/JECiCD7pykdzEzqmyGUH3GROLWfiTowPgRWJwmutCfspzLQALNJYvsp2yHs3 fpe4dS50soiraCsRcCEPJpUn+WO01v+hgY8hM+134aP0NSMm5JByjpzCgxJDJqEMgzP2 04ow== X-Gm-Message-State: APjAAAX3siSS5KN2/mIkQJQ0LtNILAfkFGrqa3wwEVdjZ9uAO04TE2IK 8v7doLZN1EfD/3Vfw5rwrR2DTnyxvmXERX6YFwlnioXwJ/MxjzThUpRZh+2B3nZ84YZnYYWzY/H 9puIRbOCXXhhakwi2OYLpZRspPXwMGd7WYdG+p9h0CwrdZxEEeZ4rszW19lJXDzQbyDGbY1z6fU 932JTL1QlruoJE7Q== X-Google-Smtp-Source: APXvYqz7HArbbTHZFfi6jjmkmPC2cTzHN681P1F7vsjDCxJxCDA4/NGn+kk/1Mca6f4JujxNmUmGvw== X-Received: by 2002:a0c:b0ef:: with SMTP id p44mr22052180qvc.127.1556045411257; Tue, 23 Apr 2019 11:50:11 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id 11sm10977239qtu.5.2019.04.23.11.50.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Apr 2019 11:50:10 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 61F72120446; Tue, 23 Apr 2019 14:50:07 -0400 (-04) Date: Tue, 23 Apr 2019 14:50:07 -0400 From: Alvaro Herrera To: Pg Hackers Subject: pg_dump partitions can lead to inconsistent state after restore Message-ID: <20190423185007.GA27954@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Per my comment at https://postgr.es/m/20190422225129.GA6126@alvherre.pgsql I think that pg_dump can possibly cause bogus partition definitions, when the users explicitly decide to join tables as partitions that have different column ordering than the parent table. Any COPY or INSERT command without an explicit column list that tries to put tuples in the table will fail after the restore. Tom Lane said: > I haven't looked at the partitioning code, but I am quite sure that that's > always happened for old-style inheritance children, and I imagine pg_dump > is just duplicating that old behavior. Actually, the new code is unrelated to the old one; for legacy inheritance, the children are always created exactly as they were created at definition time. If you use ALTER TABLE ... INHERITS (attach a table as a children after creation) then obviously the child table cannot be modified to match its new parent; and pg_dump reproduces the exact column ordering that the table originally had. If you use "CREATE TABLE ... INHERITS (parent)" then the child columns are reordered *at that point* (creation time); the dump will, again, reproduce the exact same definition. I think failing to reproduce the exact same definition is a pg_dump bug that should be fixed and backpatched to pg10. It's just sheer luck that nobody has complained of being bitten by it. -- Álvaro Herrera http://www.twitter.com/alvherre