Fix oversight in the previous patch that made LIKE throw error for \ at the
authorTom Lane
Fri, 28 May 2010 18:18:19 +0000 (18:18 +0000)
committerTom Lane
Fri, 28 May 2010 18:18:19 +0000 (18:18 +0000)
end of the pattern: the code path that handles \ just after % should throw
error too.  As in the previous patch, not back-patching for fear of breaking
apps that worked before.

src/backend/utils/adt/like_match.c

index b67ba020cf33f392cdc0bb2df613683b3ecdacc7..be3b9515dfe11c13142200d2bc0a1deddf4d7f2b 100644 (file)
@@ -19,7 +19,7 @@
  * Copyright (c) 1996-2010, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.28 2010/05/28 17:35:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.29 2010/05/28 18:18:19 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -158,7 +158,9 @@ MatchText(char *t, int tlen, char *p, int plen)
            if (*p == '\\')
            {
                if (plen < 2)
-                   return LIKE_FALSE; /* XXX should throw error */
+                   ereport(ERROR,
+                           (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
+                            errmsg("LIKE pattern must not end with escape character")));
                firstpat = GETCHAR(p[1]);
            }
            else