Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0sB8-0002YQ-SL for pgsql-sql@arkaria.postgresql.org; Fri, 05 Jun 2015 14:00:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z0sB8-0006IJ-7u for pgsql-sql@arkaria.postgresql.org; Fri, 05 Jun 2015 14:00:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z0sB3-0006AR-OO for pgsql-sql@postgresql.org; Fri, 05 Jun 2015 14:00:53 +0000 Received: from oldperseverance.encs.concordia.ca ([132.205.96.92]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z0sAv-00038X-TC for pgsql-sql@postgresql.org; Fri, 05 Jun 2015 14:00:52 +0000 Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by oldperseverance.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id t55E0ew6011603; Fri, 5 Jun 2015 10:00:40 -0400 Message-ID: <5571AB88.6050900@encs.concordia.ca> Date: Fri, 05 Jun 2015 10:00:40 -0400 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Igor Neyman , "David G. Johnston" CC: "pgsql-sql@postgresql.org" Subject: Re: remove tablespace for primary key (*not* by drop/recreate constraint) References: <55707FAA.8060204@encs.concordia.ca> <55709A8A.7010005@encs.concordia.ca> <5571A511.9020805@encs.concordia.ca> In-Reply-To: Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.58 on oldperseverance.encs.concordia.ca at 2015-06-05 10:00:40 EDT X-Pg-Spam-Score: -3.5 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org


 z1 (c1 text) with pk_z1 PRIMARY KEY (c1), tablespace "abc"
how to remove tablespace(set tablespace to empty for z1)?

ALTER INDEX ... SET TABLESPACE pg_default;

This is what I prefer to run. But it seems that schema owner does not have permission to run it.

"permission denied for tablespace pg_default"

Probably only postmaster can run it?

 

GRANT USAGE ON SCHEMA…  GRANT CREATE ON SCHEMA…

schema owner already have full control for the whole schema, this username can create/drop tables/indexs, even drop schema. I think the permission is related to the pg_default - the tablespace. For example, there are 3 tablespaces: pg_default, abc, test (is the one used by table z1)

. alter index pk_z1 set tablespace abc; (success)
. alter index pk_z1 set tablespace test (permission denied)
. alter index pk_z1 set tablespace pg_default (permission denied)