From 63c0780dba39e0d25fbd4c5e7a94e9c0e9236ace Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 28 May 2010 17:35:36 +0000 Subject: Rewrite LIKE's %-followed-by-_ optimization so it really works (this time for sure ;-)). It now also optimizes more cases, such as %_%_. Improve comments too. Per bug #5478. In passing, also rename the TCHAR macro to GETCHAR, because pgindent is messing with the formatting of the former (apparently it now thinks TCHAR is a typedef name). Back-patch to 8.3, where the bug was introduced. --- src/test/regress/expected/strings.out | 8 +++++++- src/test/regress/sql/strings.sql | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index ce37780a3ae..abde8e921bd 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -827,7 +827,7 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; (1 row) -- --- test %/_ combination cases, cf bug #4821 +-- test %/_ combination cases, cf bugs #4821 and #5478 -- SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; t | t | f @@ -853,6 +853,12 @@ SELECT 'foo' LIKE '%__' as t, 'foo' LIKE '%___' as t, 'foo' LIKE '%____' as f; t | t | f (1 row) +SELECT 'jack' LIKE '%____%' AS t; + t +--- + t +(1 row) + -- -- test implicit type conversion -- diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index 80344da57dc..0a51287fb75 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -253,7 +253,7 @@ SELECT 'Hawkeye' ILIKE 'h%' AS "true"; SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; -- --- test %/_ combination cases, cf bug #4821 +-- test %/_ combination cases, cf bugs #4821 and #5478 -- SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; @@ -262,6 +262,8 @@ SELECT 'foo' LIKE '%_' as t, 'f' LIKE '%_' as t, '' LIKE '%_' as f; SELECT 'foo' LIKE '__%' as t, 'foo' LIKE '___%' as t, 'foo' LIKE '____%' as f; SELECT 'foo' LIKE '%__' as t, 'foo' LIKE '%___' as t, 'foo' LIKE '%____' as f; +SELECT 'jack' LIKE '%____%' AS t; + -- -- test implicit type conversion -- cgit v1.2.3