Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkdUK-0003h5-IS for pgsql-bugs@arkaria.postgresql.org; Wed, 14 May 2014 18:01:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WkdUK-000080-0g for pgsql-bugs@arkaria.postgresql.org; Wed, 14 May 2014 18:01:08 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkdS9-0008OX-Sr for pgsql-bugs@postgresql.org; Wed, 14 May 2014 17:58:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WkdS7-0004M9-Q9 for pgsql-bugs@postgresql.org; Wed, 14 May 2014 17:58:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s4EHwo8d001489; Wed, 14 May 2014 13:58:50 -0400 From: Tom Lane To: parthibanp2@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10316: Alter table rename fails if the "new name" starts with '_' In-reply-to: <20140514124119.11846.62730@wrigleys.postgresql.org> References: <20140514124119.11846.62730@wrigleys.postgresql.org> Comments: In-reply-to parthibanp2@gmail.com message dated "Wed, 14 May 2014 12:41:19 -0000" Date: Wed, 14 May 2014 13:58:50 -0400 Message-ID: <1488.1400090330@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org parthibanp2@gmail.com writes: > -- I have created one new table with name t1 > test=# \d > No relations found. > test=# create table t1 (name varchar(10)); > CREATE TABLE > -- After that i tried to rename 't1' table as '_t1', now the Postgres server > saying '_t1' is already exists. i'm sure there is no other table in the > database other than 't1'. > test=# alter table t1 rename to _t1; > ERROR: type "_t1" already exists Note it's saying *type* _t1 already exists. This is the internal name of the type t1[], that is, arrays of the rowtype of t1. In general, our convention for the internal name of an array type is to prepend a _ to the name of its element type. (There's some logic to choose a different name if this name is already taken, but that doesn't help you when it's the array type that got there first.) > -- Now i renaming table from 't1' to '__t1' and again i renaming from '__t1' > to '_t1' now its working. You could have renamed to anything else and then back to _t1; the trick is just that the table's rowtype and array type have to get renamed out of the way first. By and large, though, it's probably best to avoid using table names that begin with an underscore in PG, since you'll tend to hit this kind of conflict with rowtype names if you do that. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs