hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nh...@apache.org
Subject incubator-hawq git commit: HAWQ-56. Add format option to external protocol struct, and disallow HEADER format option to be used in PXF tables
Date Mon, 23 Nov 2015 21:54:21 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 70543630a -> 2058ea5b4


HAWQ-56. Add format option to external protocol struct, and disallow HEADER format option
to be used in PXF tables


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/2058ea5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/2058ea5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/2058ea5b

Branch: refs/heads/master
Commit: 2058ea5b491c48293fef66a792ac408697a66a45
Parents: 7054363
Author: Noa Horn <nhorn@pivotal.io>
Authored: Mon Nov 23 13:47:49 2015 -0800
Committer: Noa Horn <nhorn@pivotal.io>
Committed: Mon Nov 23 13:47:49 2015 -0800

----------------------------------------------------------------------
 src/backend/commands/tablecmds.c        | 12 +++++++-----
 src/backend/utils/mdver/test/.gitignore |  1 +
 src/bin/gpfusion/pxf.c                  | 15 +++++++++++++++
 src/include/access/extprotocol.h        |  6 ++++++
 4 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2058ea5b/src/backend/commands/tablecmds.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index b47bdce..fe48e09 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -369,7 +369,7 @@ static void update_ri_trigger_args(Oid relid,
 					   const char *newname,
 					   bool fk_scan,
 					   bool update_relname);
-static Datum transformLocationUris(List *locs, bool isweb, bool iswritable);
+static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable);
 static Datum transformExecOnClause(List	*on_clause, int *preferred_segment_num);
 static char transformFormatType(char *formatname);
 static Datum transformFormatOpts(char formattype, List *formatOpts, int numcols, bool iswritable);
@@ -389,7 +389,7 @@ static RangeVar *make_temp_table_name(Relation rel, BackendId id);
 static bool prebuild_temp_table(Relation rel, RangeVar *tmpname, List *distro,
 								List *opts, List **hidden_types, bool isTmpTableAo);
 static void ATPartitionCheck(AlterTableType subtype, Relation rel, bool rejectroot, bool
recursing);
-static void InvokeProtocolValidation(Oid procOid, char *procName, bool iswritable, List *locs);
+static void InvokeProtocolValidation(Oid procOid, char *procName, bool iswritable, List *locs,
List* fmtopts);
 
 static char *alterTableCmdString(AlterTableType subtype);
 
@@ -948,6 +948,7 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt)
 
 			/* Parse and validate URI strings (LOCATION clause) */
 			locationUris = transformLocationUris(exttypeDesc->location_list,
+												 createExtStmt->formatOpts,
 												 isweb, iswritable);
 			
 			break;
@@ -17404,7 +17405,7 @@ AtEOSubXact_on_commit_actions(bool isCommit, SubTransactionId mySubid,
  * The result is a text array but we declare it as Datum to avoid
  * including array.h in analyze.h.
  */
-static Datum transformLocationUris(List *locs, bool isweb, bool iswritable)
+static Datum transformLocationUris(List *locs, List* fmtopts, bool isweb, bool iswritable)
 {
 	ListCell   *cell;
 	ArrayBuildState *astate;
@@ -17522,7 +17523,7 @@ static Datum transformLocationUris(List *locs, bool isweb, bool iswritable)
 				InvokeProtocolValidation(procOid, 
 										 uri->customprotocol, 
 										 iswritable, 
-										 locs);
+										 locs, fmtopts);
 		}
 		
 		if(first_uri)
@@ -18272,7 +18273,7 @@ char *alterTableCmdString(AlterTableType subtype)
 }
 
 static void 
-InvokeProtocolValidation(Oid procOid, char *procName, bool iswritable, List *locs)
+InvokeProtocolValidation(Oid procOid, char *procName, bool iswritable, List *locs, List*
fmtopts)
 {
 	
 	ExtProtocolValidatorData   *validator_data;
@@ -18285,6 +18286,7 @@ InvokeProtocolValidation(Oid procOid, char *procName, bool iswritable,
List *loc
 	
 	validator_data->type 		= T_ExtProtocolValidatorData;
 	validator_data->url_list 	= locs;
+	validator_data->format_opts = fmtopts;
 	validator_data->errmsg		= NULL;
 	validator_data->direction 	= (iswritable ? EXT_VALIDATE_WRITE :
 											    EXT_VALIDATE_READ);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2058ea5b/src/backend/utils/mdver/test/.gitignore
----------------------------------------------------------------------
diff --git a/src/backend/utils/mdver/test/.gitignore b/src/backend/utils/mdver/test/.gitignore
new file mode 100644
index 0000000..a8d6b6c
--- /dev/null
+++ b/src/backend/utils/mdver/test/.gitignore
@@ -0,0 +1 @@
+*.t

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2058ea5b/src/bin/gpfusion/pxf.c
----------------------------------------------------------------------
diff --git a/src/bin/gpfusion/pxf.c b/src/bin/gpfusion/pxf.c
index bd8448a..75c4ab9 100644
--- a/src/bin/gpfusion/pxf.c
+++ b/src/bin/gpfusion/pxf.c
@@ -73,5 +73,20 @@ pxfprotocol_validate_urls(PG_FUNCTION_ARGS)
 	/* if we're here - the URI is valid. Don't need it no more */
 	freeGPHDUri(uri);
 
+	/* HEADER option is not allowed */
+	List* format_opts = EXTPROTOCOL_VALIDATOR_GET_FMT_OPT_LIST(fcinfo);
+	ListCell   *format_option;
+	foreach(format_option, format_opts)
+	{
+		DefElem    *defel = (DefElem *) lfirst(format_option);
+		if (strcmp(defel->defname, "header") == 0)
+		{
+			ereport(ERROR,
+					(errcode(ERRCODE_PROTOCOL_VIOLATION),
+							errmsg("HEADER option is not allowed in a PXF external table")));
+
+		}
+	}
+
 	PG_RETURN_VOID();
 }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2058ea5b/src/include/access/extprotocol.h
----------------------------------------------------------------------
diff --git a/src/include/access/extprotocol.h b/src/include/access/extprotocol.h
index e370aea..9e35dae 100644
--- a/src/include/access/extprotocol.h
+++ b/src/include/access/extprotocol.h
@@ -68,6 +68,7 @@ typedef struct ExtProtocolValidatorData
 {
 	NodeTag				 type;            /* see T_ExtProtocolValidatorData */
 	List 		  		*url_list;
+	List 		  		*format_opts;
 	ValidatorDirection 	 direction;  /* validating read or write? */
 	char				*errmsg;		  /* the validation error upon return, if any */
 	
@@ -82,6 +83,11 @@ typedef ExtProtocolValidatorData *ExtProtocolValidator;
 #define EXTPROTOCOL_VALIDATOR_GET_NUM_URLS(fcinfo)	(list_length(((ExtProtocolValidatorData*)
fcinfo->context)->url_list))
 
 #define EXTPROTOCOL_VALIDATOR_GET_NTH_URL(fcinfo, n) (((Value *)(list_nth(EXTPROTOCOL_VALIDATOR_GET_URL_LIST(fcinfo),(n
- 1))))->val.str)
+
+#define EXTPROTOCOL_VALIDATOR_GET_FMT_OPT_LIST(fcinfo)  (((ExtProtocolValidatorData*) fcinfo->context)->format_opts)
+#define EXTPROTOCOL_VALIDATOR_GET_NUM_FMT_OPTS(fcinfo)  (list_length(((ExtProtocolValidatorData*)
fcinfo->context)->format_opts))
+#define EXTPROTOCOL_VALIDATOR_GET_NTH_FMT_OPT(fcinfo, n) (((Value *)(list_nth(EXTPROTOCOL_VALIDATOR_GET_FMT_OPT_LIST(fcinfo),(n
- 1))))->val.str)
+
 #define EXTPROTOCOL_VALIDATOR_GET_DIRECTION(fcinfo)	(((ExtProtocolValidatorData*) fcinfo->context)->direction)
 
 


Mime
View raw message