From fc1bdb57f8de402e5b602be7b860e5056fe5eab2 Mon Sep 17 00:00:00 2001 From: li-judong Date: Thu, 17 Nov 2022 19:09:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E6=A0=A1=E9=AA=8Cfo?= =?UTF-8?q?reign=20table=E7=9A=84=E8=87=AA=E5=A2=9E=E5=88=97=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84core=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/parser/parse_utilcmd.cpp | 6 ++++++ src/test/regress/expected/test_auto_increment.out | 8 ++++++++ src/test/regress/sql/test_auto_increment.sql | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index 78d9785db..ec2bb8243 100644 --- a/src/common/backend/parser/parse_utilcmd.cpp +++ b/src/common/backend/parser/parse_utilcmd.cpp @@ -1285,6 +1285,12 @@ static void transformColumnDefinition(CreateStmtContext* cxt, ColumnDef* column, /* transformConstraintAttrs took care of these */ break; case CONSTR_AUTO_INCREMENT: + if (IsA(cxt->node, CreateForeignTableStmt) || + (cxt->rel != NULL && (IS_FOREIGNTABLE(cxt->rel) || IS_STREAM_TABLE(cxt->rel)))) { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Un-support feature"), + errdetail("auto_increment column is not supported in foreign table"))); + } if (column->is_serial) { ereport(ERROR, (errcode(ERRCODE_OPERATE_NOT_SUPPORTED), errmsg("The datatype of column '%s' does not support auto_increment", column->colname))); diff --git a/src/test/regress/expected/test_auto_increment.out b/src/test/regress/expected/test_auto_increment.out index 41e4724aa..b8a9f8d23 100644 --- a/src/test/regress/expected/test_auto_increment.out +++ b/src/test/regress/expected/test_auto_increment.out @@ -96,6 +96,14 @@ DETAIL: Orientation type orc is not supported for auto_increment CREATE TABLE test_create_autoinc_err(id INTEGER auto_increment, name varchar(200),a int, primary key(id)) with (ORIENTATION=timeseries); ERROR: Un-supported feature DETAIL: Orientation type timeseries is not supported for auto_increment +CREATE FOREIGN TABLE t_table_0020 ( + col01 integer AUTO_INCREMENT NOT NULL, + col02 float, + col03 int, + PRIMARY KEY (col01,col02,col03) +) server gsmpp_server; +ERROR: Un-support feature +DETAIL: auto_increment column is not supported in foreign table --test different type with auto_increment start value CREATE TABLE test_create_autoinc(id bool auto_increment primary key, name varchar(200),a int) auto_increment=1; NOTICE: CREATE TABLE will create implicit sequence "test_create_autoinc_id_seq" for serial column "test_create_autoinc.id" diff --git a/src/test/regress/sql/test_auto_increment.sql b/src/test/regress/sql/test_auto_increment.sql index 211dfd0e1..599232565 100644 --- a/src/test/regress/sql/test_auto_increment.sql +++ b/src/test/regress/sql/test_auto_increment.sql @@ -38,7 +38,12 @@ CREATE TABLE test_create_autoinc_err(id int16 auto_increment, name varchar(200), CREATE TABLE test_create_autoinc_err(id INTEGER auto_increment, name varchar(200),a int, primary key(id)) with (ORIENTATION=column); CREATE TABLE test_create_autoinc_err(id INTEGER auto_increment, name varchar(200),a int, primary key(id)) with (ORIENTATION=orc); CREATE TABLE test_create_autoinc_err(id INTEGER auto_increment, name varchar(200),a int, primary key(id)) with (ORIENTATION=timeseries); - +CREATE FOREIGN TABLE t_table_0020 ( + col01 integer AUTO_INCREMENT NOT NULL, + col02 float, + col03 int, + PRIMARY KEY (col01,col02,col03) +) server gsmpp_server; --test different type with auto_increment start value CREATE TABLE test_create_autoinc(id bool auto_increment primary key, name varchar(200),a int) auto_increment=1; INSERT INTO test_create_autoinc VALUES(DEFAULT,'Gauss',0);