Index: src/test/org/h2/test/testSimple.in.txt
===================================================================
--- src/test/org/h2/test/testSimple.in.txt	(revision 1852)
+++ src/test/org/h2/test/testSimple.in.txt	Wed Dec 09 15:28:17 NZDT 2009
@@ -606,4 +606,21 @@
 insert into test1 values ('abcaaaa');
 delete from test1;
 drop table test1;
-@reconnect;
\ No newline at end of file
+@reconnect;
+
+
+create table regex(a varchar(10));
+insert into regex values('a\aaa');
+insert into regex values('\a%b');
+
+select a from regex where a like 'a\a%' escape '!';
+> a\aaa;
+
+select a from regex where a like 'a\aa%';
+> a\aaa;
+
+select a from regex where a like '\a\%b%';
+> \a%b;
+
+drop table regex;
+@reconnect;
Index: src/main/org/h2/expression/CompareLike.java
===================================================================
--- src/main/org/h2/expression/CompareLike.java	(revision 1754)
+++ src/main/org/h2/expression/CompareLike.java	Wed Dec 09 15:37:14 NZDT 2009
@@ -311,7 +311,15 @@
                 }
                 c = p.charAt(++i);
                 if (c != '_' && c != '%' && c != escape) {
-                    throw Message.getSQLException(ErrorCode.LIKE_ESCAPE_ERROR_1, StringUtils.addAsterisk(p, i));
+                    char[] extendedPattern = new char[pattern.length + 1];
+                    System.arraycopy(pattern, 0, extendedPattern, 0, pattern.length);
+                    pattern = extendedPattern;
+                    pattern[patternLength++] = escape;
+
+                    int[] extendedTypes = new int[types.length + 1];
+                    System.arraycopy(types, 0, extendedTypes, 0, types.length);
+                    types = extendedTypes;
+                    types[patternLength] = MATCH;
                 }
                 type = MATCH;
                 lastAny = false;
