HAWQ-1103. Added test cases with string containing a quote.

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

Branch: refs/heads/HAWQ-1103
Commit: 2497b6f327944e1fbdc5434dddacab0fcacfa7f9
Parents: d9f77da
Author: Oleksandr Diachenko <odiache...@pivotal.io>
Authored: Fri Oct 14 11:45:02 2016 -0700
Committer: Oleksandr Diachenko <odiache...@pivotal.io>
Committed: Fri Oct 14 11:45:02 2016 -0700

----------------------------------------------------------------------
 src/backend/access/external/pxffilters.c           | 4 ++--
 src/backend/access/external/test/pxffilters_test.c | 7 +++++--
 src/include/access/pxffilters.h                    | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/backend/access/external/pxffilters.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxffilters.c 
b/src/backend/access/external/pxffilters.c
index ded9f9a..ef7b16f 100644
--- a/src/backend/access/external/pxffilters.c
+++ b/src/backend/access/external/pxffilters.c
@@ -372,14 +372,14 @@ pxf_serialize_filter_list(List *expressionItems)
                                                appendStringInfo(resbuf, 
"%c%d%c%d%c%d%c%s",
                                                                                
                 PXF_ATTR_CODE, l.attnum - 1, /* Java attrs are 0-based */
                                                                                
                 PXF_CONST_CODE, r.consttype,
-                                                                               
                 PXF_LENGTH_TO_READ, strlen(r.conststr->data),
+                                                                               
                 PXF_SIZE_BYTES, strlen(r.conststr->data),
                                                                                
                 PXF_CONST_DATA, (r.conststr)->data);
                                        }
                                        else if (pxfoperand_is_const(l) && 
pxfoperand_is_attr(r))
                                        {
                                                appendStringInfo(resbuf, 
"%c%d%c%d%c%s%c%d",
                                                                                
                 PXF_CONST_CODE, l.consttype,
-                                                                               
                 PXF_LENGTH_TO_READ, strlen(l.conststr->data),
+                                                                               
                 PXF_SIZE_BYTES, strlen(l.conststr->data),
                                                                                
                 PXF_CONST_DATA, (l.conststr)->data,
                                                                                
                 PXF_ATTR_CODE, r.attnum - 1); /* Java attrs are 0-based */
                                        }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/backend/access/external/test/pxffilters_test.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/test/pxffilters_test.c 
b/src/backend/access/external/test/pxffilters_test.c
index 6db7ae7..3679587 100644
--- a/src/backend/access/external/test/pxffilters_test.c
+++ b/src/backend/access/external/test/pxffilters_test.c
@@ -517,20 +517,23 @@ test__pxf_serialize_filter_list__manyFilters(void **state)
        ExpressionItem* expressionItem2 = build_expression_item(2, TEXTOID, 
"George Orwell", TEXTOID, TextEqualOperator);
        ExpressionItem* expressionItem3 = build_expression_item(3, TEXTOID, 
"Winston", TEXTOID, TextEqualOperator);
        ExpressionItem* expressionItem4 = build_expression_item(4, TEXTOID, 
"Eric-%", TEXTOID, 1209);
+       ExpressionItem* expressionItem5 = build_expression_item(5, TEXTOID, 
"\"Ugly\" string with quotes", TEXTOID, TextEqualOperator);
 
 
        expressionItems = lappend(expressionItems, expressionItem1);
        expressionItems = lappend(expressionItems, expressionItem2);
        expressionItems = lappend(expressionItems, expressionItem3);
        expressionItems = lappend(expressionItems, expressionItem4);
+       expressionItems = lappend(expressionItems, expressionItem5);
 
        result = pxf_serialize_filter_list(expressionItems);
-       assert_string_equal(result, "a0c25s4d1984o5a1c25s13dGeorge 
Orwello5a2c25s7dWinstono5a3c25s6dEric-%o7");
+       assert_string_equal(result, "a0c25s4d1984o5a1c25s13dGeorge 
Orwello5a2c25s7dWinstono5a3c25s6dEric-%o7a4c25s25d\"Ugly\" string with 
quoteso5");
        pfree(result);
 
+       int trivialExpressionItems = expressionItems->length;
        enrich_trivial_expression(expressionItems);
 
-       assert_int_equal(expressionItems->length, 7);
+       assert_int_equal(expressionItems->length, 2*trivialExpressionItems - 1);
 
        pxf_free_expression_items_list(expressionItems, true);
        expressionItems = NIL;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/include/access/pxffilters.h
----------------------------------------------------------------------
diff --git a/src/include/access/pxffilters.h b/src/include/access/pxffilters.h
index 5f5ae4e..00c77d3 100644
--- a/src/include/access/pxffilters.h
+++ b/src/include/access/pxffilters.h
@@ -55,7 +55,7 @@ typedef enum PxfOperatorCode
  */
 #define PXF_ATTR_CODE                          'a'
 #define PXF_CONST_CODE                         'c'
-#define PXF_LENGTH_TO_READ                     's'
+#define PXF_SIZE_BYTES                         's'
 #define PXF_CONST_DATA                         'd'
 #define PXF_OPERATOR_CODE                      'o'
 #define PXF_LOGICAL_OPERATOR_CODE      'l'

Reply via email to