Обсуждение: BUG #8176: problem with the "ALTER TYPE name RENAME TO new_name [ CASCADE | RESTRICT ]" syntax

Поиск
Список
Период
Сортировка

BUG #8176: problem with the "ALTER TYPE name RENAME TO new_name [ CASCADE | RESTRICT ]" syntax

От
maxim.boguk@gmail.com
Дата:
The following bug has been logged on the website:

Bug reference:      8176
Logged by:          Maksym Boguk
Email address:      maxim.boguk@gmail.com
PostgreSQL version: 9.2.4
Operating system:   Any
Description:        =


Hi,

It seems that documentation wrong or [ CASCADE | RESTRICT ] feature of ALTER
TYPE ... RENAME TO isn't implemented.

Test case:

create type test as (qqq integer);
CREATE TYPE

alter type test rename to test1 RESTRICT;
ERROR:  syntax error at or near "RESTRICT"
LINE 1: alter type test rename to test1 RESTRICT;
                                        ^

alter type test rename to test1 CASCADE;
ERROR:  syntax error at or near "CASCADE"
LINE 1: alter type test rename to test1 CASCADE;
                                        ^

However:
[local]:5432 postgres@postgres=3D# alter type test rename to test1;
ALTER TYPE
Maxim,

* maxim.boguk@gmail.com (maxim.boguk@gmail.com) wrote:
> It seems that documentation wrong or [ CASCADE | RESTRICT ] feature of ALTER
> TYPE ... RENAME TO isn't implemented.

Actually, I'm pretty sure it's implemented but the grammar for it was
broken during refactoring to have all the ALTER .. RENAME operations go
through the same code paths.

> Test case:

Thanks for this.  I'm working on fixing this and will also add
regression tests to, hopefully, avoid this getting broken in the future.

    Thanks again,

        Stephen
Stephen Frost <sfrost@snowman.net> writes:
> * maxim.boguk@gmail.com (maxim.boguk@gmail.com) wrote:
>> It seems that documentation wrong or [ CASCADE | RESTRICT ] feature of ALTER
>> TYPE ... RENAME TO isn't implemented.

> Actually, I'm pretty sure it's implemented but the grammar for it was
> broken during refactoring to have all the ALTER .. RENAME operations go
> through the same code paths.

Are we sure the documentation's not wrong?  A quick test says this
syntax isn't accepted in *any* existing release, and I can't say I
understand what it should do anyway.

            regards, tom lane
Maxim,

* Stephen Frost (sfrost@snowman.net) wrote:
> * maxim.boguk@gmail.com (maxim.boguk@gmail.com) wrote:
> > It seems that documentation wrong or [ CASCADE | RESTRICT ] feature of =
ALTER
> > TYPE ... RENAME TO isn't implemented.
>=20
> Actually, I'm pretty sure it's implemented but the grammar for it was
> broken during refactoring to have all the ALTER .. RENAME operations go
> through the same code paths.

Nope, I was wrong- this looks to be a documentation bug, actually.  The
documentation should be:

ALTER TYPE name RENAME ATTRIBUTE attribute_name TO new_attribute_name [ CAS=
CADE | RESTRICT ]
ALTER TYPE name RENAME TO new_name

Which makes more sense (to me at least) anyway.  Do you have a need for
this version:

ALTER TYPE name RENAME TO new_name [ CASCADE | RESTRICT ]

or were you just playing with things..?

    Thanks,

        Stephen
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Are we sure the documentation's not wrong?  A quick test says this
> syntax isn't accepted in *any* existing release, and I can't say I
> understand what it should do anyway.

Was just composing an email to that effect, actually.  I agree that it's
a documentation issue.  Of course, that makes it easier to fix. :)

    Thanks,

        Stephen
Maxim,

* maxim.boguk@gmail.com (maxim.boguk@gmail.com) wrote:
> It seems that documentation wrong or [ CASCADE | RESTRICT ] feature of ALTER
> TYPE ... RENAME TO isn't implemented.

I've updated the documentation to reflect that [ CASCADE | RESTRICT ] is
supported for ALTER TYPE .. RENAME ATTRIBUTE and that it isn't supported
for ALTER TYPE .. RENAME TO.  This update will be pushed out with the
next releases.

    Thanks!

        Stephen