提交 22ece6e5 编写于 作者: D Daniel Gustafsson

Issue a WARNING for external tables with too many URIs

External tables with protocols file or http which specify more URIs
than segments won't be allowed to query until the cluster has been
extended. Rather than silently allow creation, issue a warning and
hint to the user to assist troubleshooting. Writable tables error
out for the same problem but avoiding to change behavior this late
in the release cycle seems like a good idea.
上级 2a3df5d0
......@@ -369,6 +369,36 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt)
if (encoding < 0)
encoding = pg_get_client_encoding();
/*
* If the number of locations (file or http URIs) exceed the number of
* segments in the cluster, then all queries against the table will fail
* since locations must be mapped at most one per segment. Allow the
* creation since this is old pre-existing behavior but throw a WARNING
* that the user must expand the cluster in order to use it (or alter
* the table).
*/
if (exttypeDesc->exttabletype == EXTTBL_TYPE_LOCATION)
{
if (Gp_role == GP_ROLE_DISPATCH)
{
Value *loc = lfirst(list_head(exttypeDesc->location_list));
Uri *uri = ParseExternalTableUri(loc->val.str);
if (uri->protocol == URI_FILE || uri->protocol == URI_HTTP)
{
if (getgpsegmentCount() < list_length(exttypeDesc->location_list))
ereport(WARNING,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("number of locations (%) exceeds the number "
"of segments (%d)",
list_length(exttypeDesc->location_list),
getgpsegmentCount()),
errhint("The table cannot be queried until cluster "
"is expanded so that there are at least as "
"many segments as locations.")));
}
}
}
/*
* First, create the pg_class and other regular relation catalog entries.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册