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 1hDxSg-00029l-6M for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 20:35:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDxSe-00077z-J3 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 20:35:16 +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 1hDxSe-0006pH-2A for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 20:35:16 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDxSZ-0005Ag-Cy for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 20:35:14 +0000 Received: by mail-qt1-x841.google.com with SMTP id h39so307297qte.2 for ; Tue, 09 Apr 2019 13:35:11 -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=wjgcV9HEv5vGYN1Yw2ulkDMtknHd6XZySmJWWZ0POdo=; b=NdazH7HTpebgWiCsqCcJRQDMGPpq991n74ZOLWiqm70uQJqxdn0bDaEGp5g4/l9/iT oE8qK8BNBcqLi1/kuQ6F8Sb6hzyY3uIfdMlVOCM/dC9mxUuZGeBCQzyqhKNpgAetcVm2 1qbMSdfHWneCFArq291G+e51uQt0jXAugUKVKQ/dGRN1ARUURdsbyQk5S9qKrjluNGnS GN3fHDz+pGGTHWMxWudK/M0An0QE4sqdcpc34XF7/3mEb81BVBhK4VNKby4gSMZC7xuY 8j+wuL+qU30rb51aTsefgQDwVdNh3sjvK1pkMvlkyjhcnFNEJj8/Op4M8/0twnlrc3xl GmRw== 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=wjgcV9HEv5vGYN1Yw2ulkDMtknHd6XZySmJWWZ0POdo=; b=g97ooZhp6n/XecOq2/C+yGdxXloO5hWxLeWvT4LUl3vslCa5joA8qSq1zXXOcO8oT7 KzbAA0VCJCtme0AHDcmTop9Q8QezDVsmZg4psrw5I+9FGHIqD5JM0zeoi0S1D2CBv3Ix JVo8kNVlpoacqNzdESJqwUgv8rHLmaioCcdQKEekB0/Rrf8jT29i71eIHXSI2Ny8oc/8 U5Z0orgVv3cb1LocTk89XUmImY3XFVxet5i8BVDo1G5OronB97YAGj5biaHd3s2BaBJX W6gC1Iq93DYuyW/+wra/LeJaYjeokKukX5jxHl3tmIhoPt8eoFK+A7vty/y8CWehDA5C PDag== X-Gm-Message-State: APjAAAUDL7lcSFRqHbGD7vFJM24o5zb/OxXBCfsXxNGB37+6A36PIG08 Szq6bICXNnvTtPYywxCOrqobzQ== X-Google-Smtp-Source: APXvYqzSu66X2LqJlYFDBBtP1sJyX1+fyNmqqznOlu82nTu4vOporuRL2MJAxmYKQMyBGF6fMC3PVg== X-Received: by 2002:a0c:87b3:: with SMTP id 48mr30895447qvj.199.1554842110433; Tue, 09 Apr 2019 13:35:10 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id u26sm21583685qtb.81.2019.04.09.13.35.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2019 13:35:09 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id DCA38121045; Tue, 9 Apr 2019 16:35:07 -0400 (-04) Date: Tue, 9 Apr 2019 16:35:07 -0400 From: Alvaro Herrera To: David Rowley Cc: Andres Freund , PostgreSQL Hackers Subject: Re: pg_dump is broken for partition tablespaces Message-ID: <20190409203507.GA25150@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-07, David Rowley wrote: > On Thu, 7 Mar 2019 at 11:37, Andres Freund wrote: > > > > On 2019-03-07 11:31:15 +1300, David Rowley wrote: > > > Do you think it's fine to reword the docs to make this point more > > > clear, or do you see this as a fundamental problem with the patch? > > > > Hm, both? I mean I wouldn't necessarily characterize it as "fundamental" > > problem, but ... > > Okay, so if I understand you correctly, you're complaining about the > fact that if the user does: > > CREATE TABLE p (a int) PARTITION BY LIST(a) TABLESPACE pg_default; > > that the user intended that all future partitions go to pg_default and > not whatever default_tablespace is set to at the time? > > If so, that seems like a genuine concern. So, you don't need a partition in order to see a problem here: pg_dump doesn't do the right thing for the partitioned table. It does this: SET default_tablespace = pg_default; CREATE TABLE public.p ( a integer ) PARTITION BY LIST (a); which naturally has a different effect on partitions. Now, I think the problem for partitions can be solved in a simple manner: we can have this code David quoted ignore the MyDatabaseTableSpace exception for partitioned rels: > /* > * Never allow a pg_class entry to explicitly specify the database's > * default tablespace in reltablespace; force it to zero instead. This > * ensures that if the database is cloned with a different default > * tablespace, the pg_class entry will still match where CREATE DATABASE > * will put the physically copied relation. > * > * Yes, this is a bit of a hack. > */ > if (reltablespace == MyDatabaseTableSpace) > reltablespace = InvalidOid; This gives the right effect AFAICS, namely to store the specified tablespace regardless of what it is; and there is no problem with the "physically copied relation" as the comment says, because there *isn't* a physical relation in the first place. However, in order to fix the pg_dump behavior for the partitioned rel, we would need to emit the tablespace differently, i.e. not use SET default_tablespace, but instead attach the tablespace clause to the CREATE TABLE line. I'll go have a look at what problems are there with doing that. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services