Обсуждение: Observed an issue in CREATE TABLE syntax

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

Observed an issue in CREATE TABLE syntax

От
Rajeev rastogi
Дата:

I observed an issue that even if invalid syntax is provided for CREATE TABLE, table is getting created successfully.

               

                Below table creation succeed even though same constraint name is given multiple times.

                None of the below constraints has any meaning of giving multiple times.

 

                postgres=# create table new (id int NULL NULL);

CREATE TABLE

 

postgres=# create table new1(id serial NOT NULL NOT NULL);

CREATE TABLE

 

postgres=# create table new2 (id int unique unique);

CREATE TABLE  

 

Should we not throw error for above syntaxes?

 

Please find the attached patch with the fix.

 

Thanks and Regards,

Kumar Rajeev Rastogi

 

Вложения

Re: Observed an issue in CREATE TABLE syntax

От
Tom Lane
Дата:
Rajeev rastogi <rajeev.rastogi@huawei.com> writes:
> Should we not throw error for above syntaxes?

No.  There's nothing wrong with those statements, and complaining about
them will accomplish nothing except to break applications that used to
work.  Admittedly, code that generates such declarations would be a bit
sloppy, but people won't thank us for breaking it.
        regards, tom lane