phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject phoenix git commit: PHOENIX-2602 Parser does not handle escaped LPAREN
Date Tue, 09 Feb 2016 23:11:10 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 dbde8c387 -> e31ede5cd


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/e31ede5c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e31ede5c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e31ede5c

Branch: refs/heads/4.x-HBase-1.0
Commit: e31ede5cdce4ae5e23be30d749f7c3feaacde3bc
Parents: dbde8c3
Author: Thomas D'Silva <tdsilva@salesforce.com>
Authored: Mon Feb 8 16:47:36 2016 -0800
Committer: Thomas D'Silva <tdsilva@salesforce.com>
Committed: Tue Feb 9 15:08:29 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/e31ede5c/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/e31ede5c/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


Mime
View raw message