You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2016/02/10 00:10:49 UTC

phoenix git commit: PHOENIX-2602 Parser does not handle escaped LPAREN

Repository: phoenix
Updated Branches:
  refs/heads/master d5518f02d -> c485a40c7


PHOENIX-2602 Parser does not handle escaped LPAREN


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c485a40c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c485a40c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c485a40c

Branch: refs/heads/master
Commit: c485a40c766e34e3a5a443e60057cfaa1cb92869
Parents: d5518f0
Author: Thomas D'Silva <td...@salesforce.com>
Authored: Mon Feb 8 16:47:36 2016 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Tue Feb 9 15:08:37 2016 -0800

----------------------------------------------------------------------
 .../phoenix/end2end/LikeExpressionIT.java       | 20 ++++++++++++++++++++
 phoenix-core/src/main/antlr3/PhoenixSQL.g       |  6 +++---
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c485a40c/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java
index 1d93341..ecd1e8c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java
@@ -123,4 +123,24 @@ public class LikeExpressionIT extends BaseHBaseManagedTimeIT {
         
         conn.close();
     }
+    
+    @Test
+    public void testLikeWithEscapenLParen() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        String ddl = "CREATE TABLE t (k VARCHAR, v VARCHAR, CONSTRAINT pk PRIMARY KEY (k))";
+        conn.createStatement().execute(ddl);
+        conn.createStatement().execute("UPSERT INTO t VALUES('aa','bb')");
+        conn.createStatement().execute("UPSERT INTO t VALUES('a\\(d','xx')");
+        conn.createStatement().execute("UPSERT INTO t VALUES('dd',null)");
+        conn.commit();
+        
+        ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM t WHERE k not like '%\\(%'");
+        assertTrue(rs.next());
+        assertEquals("aa", rs.getString(1));
+        assertEquals("bb", rs.getString(2));
+        assertTrue(rs.next());
+        assertEquals("dd", rs.getString(1));
+        assertEquals(null, rs.getString(2));
+        assertFalse(rs.next());
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c485a40c/phoenix-core/src/main/antlr3/PhoenixSQL.g
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g b/phoenix-core/src/main/antlr3/PhoenixSQL.g
index 23f7e8f..0be5717 100644
--- a/phoenix-core/src/main/antlr3/PhoenixSQL.g
+++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g
@@ -1213,14 +1213,14 @@ DIGIT
 STRING_LITERAL
 @init{ StringBuilder sb = new StringBuilder(); }
     :   '\''
-    ( t=CHAR { sb.append(t.getText()); }
-    | t=CHAR_ESC { sb.append(getText()); }
+    ( t=CHAR_ESC { sb.append(getText()); }
+    | t=CHAR { sb.append(t.getText()); }
     )* '\'' { setText(sb.toString()); }
     ;
 
 fragment
 CHAR
-    :   ( ~('\'' | '\\') )+
+    :   ( ~('\'') )
     ;
 
 fragment