提交 aac5391a 编写于 作者: H Heikki Linnakangas

Remove restriction that you cannot use ALTER TABLE on external tables.

In PostgreSQL, ALTER TABLE is allowed where ALTER FOREIGN TABLE is. Allow
external tables the same leniency.
上级 6a96f34f
......@@ -3507,35 +3507,6 @@ ATVerifyObject(AlterTableStmt *stmt, Relation rel)
if(stmt->relkind == OBJECT_INDEX)
return;
/*
* Verify the object specified against relstorage in the catalog.
* Enforce correct syntax usage.
*/
if (RelationIsExternal(rel) && stmt->relkind != OBJECT_EXTTABLE)
{
/*
* special case: in order to support 3.3 dumps with ALTER TABLE OWNER of
* external tables, we will allow using ALTER TABLE (without EXTERNAL)
* temporarily, and use a deprecation warning. This should be removed
* in future releases.
*/
if(stmt->relkind == OBJECT_TABLE)
{
if (Gp_role == GP_ROLE_DISPATCH) /* why are WARNINGs emitted from all segments? */
ereport(WARNING,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an external table. ALTER TABLE for external tables is deprecated.", RelationGetRelationName(rel)),
errhint("Use ALTER EXTERNAL TABLE instead")));
}
else
{
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an external table", RelationGetRelationName(rel)),
errhint("Use ALTER EXTERNAL TABLE instead")));
}
}
/*
* Check the ALTER command type is supported for this object
*/
......
......@@ -168,7 +168,7 @@ format 'text' (delimiter '|');
create external table ext (a int, x text)
location ('file://@hostname@@abs_srcdir@/data/no/such/place/badt1.tbl' )
format 'text';
alter table ext drop column a; -- should pass with warning
alter table ext drop column a; -- should pass
alter external table ext add column a int; -- pass
alter external table ext drop column a; -- pass
alter external table ext add column extnewcol int not null; -- should fail (constraints not allowed)
......
......@@ -215,9 +215,7 @@ ERROR: protocol "bad_protocol" does not exist
create external table ext (a int, x text)
location ('file://@hostname@@abs_srcdir@/data/no/such/place/badt1.tbl' )
format 'text';
alter table ext drop column a; -- should pass with warning
WARNING: "ext" is an external table. ALTER TABLE for external tables is deprecated.
HINT: Use ALTER EXTERNAL TABLE instead
alter table ext drop column a; -- should pass
alter external table ext add column a int; -- pass
alter external table ext drop column a; -- pass
alter external table ext add column extnewcol int not null; -- should fail (constraints not allowed)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册