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 1hDzhd-0000z4-17 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 22:58:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDzha-0008R5-Q2 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 22:58:50 +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 1hDzha-0008Qy-Ho for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 22:58:50 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDzhX-0001Ko-Aj for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 22:58:50 +0000 Received: by mail-qt1-x842.google.com with SMTP id w5so647688qtb.11 for ; Tue, 09 Apr 2019 15:58:46 -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=PAXvl34W8k0n77py25B0yIF9IQu0+PzeGKNO0upsWbM=; b=Z51a2vrFHyujjQHkWJ/KmW7iCgegF1W2jm8E//jbAiAk2SGTRkVVEAR2QGFaz9YO0T 9RF0ZOayWZDjYISjlEErA3OWo3Wy9VuhbrePSrallvtvGnu7SWjonkDKarCTY2f1xW3/ ae7JtYIfqFdEieJ2Yr1jXRrQ5Bsuid2c9s8NqiBxhM4X2J6+qPpF7ORenAuVZ1WujRkZ R5QqTHygaBy8xxYPhqBy/S5zI6BeWM1ChtQZZwZf1LBP+xNsV61RjoazDV/Fxc4Adxmt 7p48P6n3Ycv+H8AmUVB1UcQko6D0narN++VQM17zs2O4cwcuqKMFosSMgShIKTAf1pNq mhvg== 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=PAXvl34W8k0n77py25B0yIF9IQu0+PzeGKNO0upsWbM=; b=FtPvdxkdVTmhuOMTOST8q0m4QUyJ031pOtZ01CS7XEbgLpipR98JzGUqMJ9CgOjVja i/A0FRpvmyBRqstk5kIOxr0cGyQyIDcAOci6XTsw+2jd9wlETLm2TgID6MHPuqNwK1kt omCWA6sBNeZKQGWFxqt9sy3guR+sc5GMSv5AKA7SCkgBrgWD2aaiub3qXS/iIC94hZNJ NcIhqN5DfZdS6B6OORQUN+c+IknHqu1UbNndHGVxyEFant0c8bbLJMQLpNJWJCl1HuGy y0L+7whHogxvArHRd1hEB76T/pu9QAJ3w+1lcCPsn3F6iTXKmmz9fmARB9Tqerd51xJw Mkvw== X-Gm-Message-State: APjAAAVfKfpS7d6JcxIMRd92PK3aK1zLXds0HL1NQPVhugt5NRPlYQVQ HByfaayPBpThl3GXJfGBeX9/kg== X-Google-Smtp-Source: APXvYqxlztVjuOScTwiAejcfALbPomN+GFRAMMX0KzcVxEO0/vfg2id+HTyOtA1W5AyjJFa3YjemFg== X-Received: by 2002:ac8:6659:: with SMTP id j25mr21706119qtp.120.1554850725502; Tue, 09 Apr 2019 15:58:45 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id u44sm16232803qte.40.2019.04.09.15.58.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2019 15:58:44 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id BB6FB1214F4; Tue, 9 Apr 2019 18:58:42 -0400 (-04) Date: Tue, 9 Apr 2019 18:58:42 -0400 From: Alvaro Herrera To: Andres Freund Cc: David Rowley , PostgreSQL Hackers Subject: Re: pg_dump is broken for partition tablespaces Message-ID: <20190409225842.GA14993@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190306223741.lolaaimhkkp4kict@alap3.anarazel.de> 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-06, Andres Freund wrote: > I don't think the argument that the user intended to explicitly set a > tablespace holds much water if it was just set via default_tablespace, > rather than an explicit TABLESPACE. I think iff you really want > something like this feature, you'd have to mark a partition's > reltablespace as 0 unless an *explicit* assignment of the tablespace > happened. In which case you also would need to explicitly emit a > TABLESPACE for the partitioned table in pg_dump, to restore that. Thinking more about this, I think you're wrong about the behavior under nonempty default_tablespace. Quoth the fine manual: default_tablespace: [...] This variable specifies the default tablespace in which to create objects (tables and indexes) when a CREATE command does not explicitly specify a tablespace. The value is either the name of a tablespace, or an empty string to specify using the default tablespace of the current database. [...] https://www.postgresql.org/docs/11/runtime-config-client.html#RUNTIME-CONFIG-CLIENT-STATEMENT What this says to me, if default_tablespace is set, and there is no TABLESPACE clause, we should regard the default_tablespace just as if it were an explicitly named tablespace. Note that the default setting of default_tablespace is empty, meaning that tables are created in the database tablespace. Emerging behavior: default_tablespace is set to A, then partitioned table T is created, then default_tablespace is changed to B. Any partitions of T created afterwards still appear in tablespace A. If you really intended for new partitions to be created in default_tablespace (following future changes to that option), then you should just leave default_tablespace as empty when creating T. There is one deficiency that needs to be solved in order for this to work fully: currently there is no way to reset "reltablespace" to 0. Does that make sense? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services