Обсуждение: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
I found that the OBJECT_ATTRIBUTE symbol is useless. I can just remove it and replace it with OBJECT_COLUMN, and everything continues to work; no test fails that I can find. I thought we had a prohibition against ALTER TABLE when used on composites, but it's not as severe as I thought. The following commands fail in master: ALTER TABLE comptype RENAME TO comptype2; -- HINT: Use ALTER TYPE ALTER TABLE comptype SET SCHEMA sch; -- HINT: Use ALTER TYPE However, the following command works in master: ALTER TABLE comptype RENAME COLUMN a TO b; and has the same effect as this: ALTER TYPE comptype RENAME ATTRIBUTE a TO b; The RENAME ATTTRIBUTE case in RenameStmt is the only thing currently using OBJECT_ATTRIBUTE; therefore, since in precisely that case we do not prohibit using ALTER TABLE, we can just remove OBJECT_ATTRIBUTE completely. That leads to the attached patch, which changes no test result at all. This symbol was added in commit e440e12c562432a2a695b8054964fb34e3bd823e Author: Peter Eisentraut <peter_e@gmx.net> Date: Sun Sep 26 14:41:03 2010 +0300 Add ALTER TYPE ... ADD/DROP/ALTER/RENAME ATTRIBUTE Like with tables, this also requires allowing the existence of composite types with zero attributes. reviewed by KaiGai Kohei Thoughts? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Вложения
Re: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
От
Kouhei Kaigai
Дата:
Please see check_object_ownership(). It checks relation's ownership if OBJECT_COLUMN, however, type's ownership is the correct check if OBJECT_ATTRIBUTE. -- NEC OSS Promotion Center / PG-Strom Project KaiGai Kohei <kaigai@ak.jp.nec.com> > -----Original Message----- > From: pgsql-hackers-owner@postgresql.org > [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Alvaro Herrera > Sent: Tuesday, February 24, 2015 4:02 AM > To: Pg Hackers; Peter Eisentraut > Subject: [HACKERS] OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE > for composites) > > I found that the OBJECT_ATTRIBUTE symbol is useless. I can just remove > it and replace it with OBJECT_COLUMN, and everything continues to work; > no test fails that I can find. > > I thought we had a prohibition against ALTER TABLE when used on > composites, but it's not as severe as I thought. The following commands > fail in master: > > ALTER TABLE comptype RENAME TO comptype2; -- HINT: Use ALTER TYPE > ALTER TABLE comptype SET SCHEMA sch; -- HINT: Use ALTER TYPE > > However, the following command works in master: > > ALTER TABLE comptype RENAME COLUMN a TO b; > and has the same effect as this: > ALTER TYPE comptype RENAME ATTRIBUTE a TO b; > > The RENAME ATTTRIBUTE case in RenameStmt is the only thing currently > using OBJECT_ATTRIBUTE; therefore, since in precisely that case we do > not prohibit using ALTER TABLE, we can just remove OBJECT_ATTRIBUTE > completely. That leads to the attached patch, which changes no test > result at all. > > This symbol was added in > > commit e440e12c562432a2a695b8054964fb34e3bd823e > Author: Peter Eisentraut <peter_e@gmx.net> > Date: Sun Sep 26 14:41:03 2010 +0300 > > Add ALTER TYPE ... ADD/DROP/ALTER/RENAME ATTRIBUTE > > Like with tables, this also requires allowing the existence of > composite types with zero attributes. > > reviewed by KaiGai Kohei > > Thoughts? > > -- > Álvaro Herrera http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
От
Alvaro Herrera
Дата:
Kouhei Kaigai wrote: > Please see check_object_ownership(). It checks relation's ownership > if OBJECT_COLUMN, however, type's ownership is the correct check if > OBJECT_ATTRIBUTE. Hmm. Is there any case where the two are different? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
От
Kouhei Kaigai
Дата:
> Kouhei Kaigai wrote: > > Please see check_object_ownership(). It checks relation's ownership > > if OBJECT_COLUMN, however, type's ownership is the correct check if > > OBJECT_ATTRIBUTE. > > Hmm. Is there any case where the two are different? > AlterObjectTypeCommandTag()? OBJECT_ATTRIBUTE makes "ALTER TYPE" tag, but "ALTER COLUMN" tag is made with OBJECT_COLUMN. Above two cases are all I could found. Thanks, -- NEC OSS Promotion Center / PG-Strom Project KaiGai Kohei <kaigai@ak.jp.nec.com>
Re: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
От
Peter Eisentraut
Дата:
On 2/23/15 2:01 PM, Alvaro Herrera wrote: > I found that the OBJECT_ATTRIBUTE symbol is useless. I can just remove > it and replace it with OBJECT_COLUMN, and everything continues to work; > no test fails that I can find. It appears that it would change the command tag from ALTER TYPE to ALTER TABLE.
Re: OBJECT_ATTRIBUTE is useless (or: ALTER TYPE vs ALTER TABLE for composites)
От
Alvaro Herrera
Дата:
Peter Eisentraut wrote: > On 2/23/15 2:01 PM, Alvaro Herrera wrote: > > I found that the OBJECT_ATTRIBUTE symbol is useless. I can just remove > > it and replace it with OBJECT_COLUMN, and everything continues to work; > > no test fails that I can find. > > It appears that it would change the command tag from ALTER TYPE to ALTER > TABLE. Ah, that it does. I guess I unconsciously believed that command tags would be part of regression tests expected output, but clearly they are not. I don't think this change is all that terrible, but I've seen past discussions about changing command type and they aren't pretty, so I will drop this. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services