From febbb15390426a44537820e3291dc7836041feb0 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Tue, 20 Sep 2022 17:12:50 +0800 Subject: [PATCH] option should not be null when modifying column --- src/common/backend/parser/gram.y | 4 ++-- src/test/regress/expected/b_comments.out | 15 +++++++++++++-- src/test/regress/sql/b_comments.sql | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index e2fde0431..35eabe2bf 100644 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -3424,7 +3424,7 @@ modify_column_cmd: $$ = (Node *)n; } /* modify column comments start */ - | COLUMN ColId opt_column_options + | COLUMN ColId column_options { AlterTableCmd *n = makeNode(AlterTableCmd); ColumnDef *def = makeNode(ColumnDef); @@ -3436,7 +3436,7 @@ modify_column_cmd: $$ = (Node *)n; } ; - | ColId opt_column_options + | ColId column_options { AlterTableCmd *n = makeNode(AlterTableCmd); ColumnDef *def = makeNode(ColumnDef); diff --git a/src/test/regress/expected/b_comments.out b/src/test/regress/expected/b_comments.out index 858ab6cc3..b71a9b5e5 100644 --- a/src/test/regress/expected/b_comments.out +++ b/src/test/regress/expected/b_comments.out @@ -55,6 +55,16 @@ create database b_comments dbcompatibility 'B'; \c b_comments create schema b_comments; set search_path to 'b_comments'; +/* unsupported */ +create table test_unsupported(id int); +alter table test_unsupported modify column id; +ERROR: syntax error at or near ";" +LINE 1: alter table test_unsupported modify column id; + ^ +alter table test_unsupported modify id; +ERROR: syntax error at or near ";" +LINE 1: alter table test_unsupported modify id; + ^ /* sanity check */ create table test_row(a int not null comment 'test_row.a', b int not null comment 'test_row.b') comment 'test_row'; create index on test_row(a,b) comment 'test_row_index'; @@ -236,8 +246,9 @@ where pc.relname = 'uq_0034'; (1 row) drop schema b_comments cascade; -NOTICE: drop cascades to 15 other objects -DETAIL: drop cascades to table test_row +NOTICE: drop cascades to 16 other objects +DETAIL: drop cascades to table test_unsupported +drop cascades to table test_row drop cascades to table test_column drop cascades to table test drop cascades to table partition_test diff --git a/src/test/regress/sql/b_comments.sql b/src/test/regress/sql/b_comments.sql index 28f6c047e..5ee25efc9 100644 --- a/src/test/regress/sql/b_comments.sql +++ b/src/test/regress/sql/b_comments.sql @@ -38,6 +38,11 @@ create database b_comments dbcompatibility 'B'; \c b_comments create schema b_comments; set search_path to 'b_comments'; +/* unsupported */ +create table test_unsupported(id int); +alter table test_unsupported modify column id; +alter table test_unsupported modify id; + /* sanity check */ create table test_row(a int not null comment 'test_row.a', b int not null comment 'test_row.b') comment 'test_row'; create index on test_row(a,b) comment 'test_row_index';