提交 fcf82234 编写于 作者: A Adam Lee 提交者: GitHub

Restrict 'ON MASTER' feature to custom protocols only

ON MASTER feature is not fully supported by built-in protocols other
than s3 yet, disable it with those protocols for now.
上级 c17a9e8c
......@@ -1195,6 +1195,7 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
int total_primaries = 0;
int i;
Oid fmtErrTblOid = InvalidOid;
char *on_clause = NULL;
/* various processing flags */
bool using_execute = false; /* true if EXECUTE is used */
......@@ -1291,6 +1292,14 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
uri = ParseExternalTableUri(first_uri_str);
}
/* get the ON clause information, and restrict 'ON MASTER' to custom
* protocols only */
on_clause = (char *) strVal(lfirst(list_head(rel->execlocationlist)));
if ((strcmp(on_clause, "MASTER_ONLY") == 0)
&& using_location && (uri->protocol != URI_CUSTOM)) {
ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("\'ON MASTER\' is not supported by this protocol yet.")));
}
/*
* Now we do the actual assignment of work to the segment databases (where
......@@ -1434,14 +1443,11 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
}
/* (2) */
else if(using_location && (uri->protocol == URI_GPFDIST ||
uri->protocol == URI_GPFDISTS ||
else if (using_location && (uri->protocol == URI_GPFDIST ||
uri->protocol == URI_GPFDISTS ||
uri->protocol == URI_CUSTOM))
{
char *on_clause = NULL;
on_clause = (char *) strVal(lfirst(list_head(rel->execlocationlist)));
if (strcmp(on_clause, "MASTER_ONLY") == 0 && uri->protocol == URI_CUSTOM){
if ((strcmp(on_clause, "MASTER_ONLY") == 0) && (uri->protocol == URI_CUSTOM)) {
const char *uri_str = (char *) strVal(lfirst(list_head(rel->urilocationlist)));
segdb_file_map[0] = pstrdup(uri_str);
ismasteronly = true;
......@@ -1621,7 +1627,6 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
" when trying to assign segments for gpfdist(s)")));
}
}
}
}
/* (3) */
......@@ -1630,7 +1635,6 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
const char *command = rel->execcommand;
const char *prefix = "execute:";
char *prefixed_command = NULL;
char *on_clause = NULL;
bool match_found = false;
/* build the command string for the executor - 'execute:command' */
......@@ -1643,9 +1647,6 @@ create_externalscan_plan(PlannerInfo *root, Path *best_path,
pfree(buf);
buf = NULL;
/* get the ON clause (execute location) information */
on_clause = (char *) strVal(lfirst(list_head(rel->execlocationlist)));
/*
* Now we handle each one of the ON locations separately:
*
......
......@@ -1336,7 +1336,7 @@ DROP EXTERNAL TABLE IF EXISTS exttab_with_on_master;
CREATE EXTERNAL TABLE exttab_with_on_master( i int, j text )
LOCATION ('file://@hostname@@abs_srcdir@/data/exttab_few_errors.data') ON MASTER FORMAT 'TEXT' (DELIMITER '|');
\d exttab_with_on_master
SELECT * FROM exttab_with_on_master;
DROP EXTERNAL TABLE IF EXISTS exttab_with_on_master;
......
......@@ -2721,20 +2721,8 @@ NOTICE: table "exttab_with_on_master" does not exist, skipping
-- Create external table with on clause
CREATE EXTERNAL TABLE exttab_with_on_master( i int, j text )
LOCATION ('file://@hostname@@abs_srcdir@/data/exttab_few_errors.data') ON MASTER FORMAT 'TEXT' (DELIMITER '|');
\d exttab_with_on_master
External table "public.exttab_with_on_master"
Column | Type | Modifiers
--------+---------+-----------
i | integer |
j | text |
Type: readable
Encoding: UTF8
Format type: text
Format options: delimiter '|' null '\N' escape '\'
External options: {}
External location: file://@hostname@@abs_srcdir@/data/exttab_few_errors.data
Execute on: master segment
SELECT * FROM exttab_with_on_master;
ERROR: 'ON MASTER' is not supported by this protocol yet.
DROP EXTERNAL TABLE IF EXISTS exttab_with_on_master;
-- start_ignore
DROP EXTERNAL TABLE IF EXISTS exttab_with_option_empty;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册