!2615 support changing schema of foreign table(not mot)

Merge pull request !2615 from 吴岳川/master
This commit is contained in:
opengauss-bot
2022-12-14 06:50:47 +00:00
committed by Gitee
7 changed files with 49 additions and 5 deletions

View File

@ -249,11 +249,6 @@ void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt* stmt)
case OBJECT_MATVIEW:
case OBJECT_FOREIGN_TABLE:
case OBJECT_STREAM:
if (stmt->objectType == OBJECT_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Un-support feature"),
errdetail("target table is a foreign table")));
if (stmt->objectType == OBJECT_STREAM)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

View File

@ -18671,6 +18671,13 @@ void AlterTableNamespace(AlterObjectSchemaStmt* stmt)
return;
}
#ifdef ENABLE_MOT
if (IsMOTForeignTable(relid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Un-support feature"),
errdetail("target table is a mot table")));
}
#endif
TrForbidAccessRbObject(RelationRelationId, relid, stmt->relation->relname);
rel = relation_open(relid, NoLock);

View File

@ -0,0 +1,22 @@
CREATE SERVER alter_foreign_schema_test FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE file_f_table (id int) SERVER alter_foreign_schema_test OPTIONs (filename 'test');
select nspname from pg_class a left join pg_namespace b on b.oid = a.relnamespace where relname = 'file_f_table';
nspname
---------
public
(1 row)
create schema alter_foreign_schema_test_schema;
alter foreign table file_f_table set schema alter_foreign_schema_test_schema;
select nspname from pg_class a left join pg_namespace b on b.oid = a.relnamespace where relname = 'file_f_table';
nspname
----------------------------------
alter_foreign_schema_test_schema
(1 row)
select * from file_f_table;
ERROR: relation "file_f_table" does not exist on datanode1
LINE 1: select * from file_f_table;
^
select * from alter_foreign_schema_test_schema.file_f_table;
ERROR: could not open file "test" for reading: No such file or directory

View File

@ -446,6 +446,12 @@ SELECT * FROM bmsql_district ORDER BY d_id, d_w_id;
3 | 3 | 123.22 | .2234 | 100 | VVV | FFF | DDD | XXX | IL | 84965
(6 rows)
--unsupport feature
create schema alter_schema_mot_test;
alter foreign table bmsql_district set schema alter_schema_mot_test;
ERROR: Un-support feature
DETAIL: target table is a mot foreign table
drop schema alter_schema_mot_test;
--cleanup
DROP FOREIGN TABLE bmsql_warehouse;
DROP FOREIGN TABLE bmsql_district;

View File

@ -1039,3 +1039,4 @@ test: show_warnings
# partition expression key
test: partition_expr_key
test: alter_foreign_schema

View File

@ -0,0 +1,8 @@
CREATE SERVER alter_foreign_schema_test FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE file_f_table (id int) SERVER alter_foreign_schema_test OPTIONs (filename 'test');
select nspname from pg_class a left join pg_namespace b on b.oid = a.relnamespace where relname = 'file_f_table';
create schema alter_foreign_schema_test_schema;
alter foreign table file_f_table set schema alter_foreign_schema_test_schema;
select nspname from pg_class a left join pg_namespace b on b.oid = a.relnamespace where relname = 'file_f_table';
select * from file_f_table;
select * from alter_foreign_schema_test_schema.file_f_table;

View File

@ -143,6 +143,11 @@ DELETE FROM bmsql_district WHERE d_w_id=1;
SELECT * FROM bmsql_district ORDER BY d_id, d_w_id;
--unsupport feature
create schema alter_schema_mot_test;
alter foreign table bmsql_district set schema alter_schema_mot_test;
drop schema alter_schema_mot_test;
--cleanup
DROP FOREIGN TABLE bmsql_warehouse;
DROP FOREIGN TABLE bmsql_district;