Commit eb42110d authored by Peter Eisentraut's avatar Peter Eisentraut

Add tests for bytea LIKE operator

Add test coverage for the following operations, which were previously
not tested at all:

bytea LIKE bytea (bytealike)
bytea NOT LIKE bytea (byteanlike)
ESCAPE clause for the above (like_escape_bytea)

also

name NOT ILIKE text (nameicnlike)

Discussion: https://www.postgresql.org/message-id/flat/4d13563a-2c8d-fd91-20d5-e71b7a4eaa87%40enterprisedb.com
parent f5465fad
...@@ -1035,6 +1035,30 @@ SELECT 'indio' NOT LIKE 'in_o' AS "true"; ...@@ -1035,6 +1035,30 @@ SELECT 'indio' NOT LIKE 'in_o' AS "true";
t t
(1 row) (1 row)
SELECT 'abc'::name LIKE '_b_' AS "true";
true
------
t
(1 row)
SELECT 'abc'::name NOT LIKE '_b_' AS "false";
false
-------
f
(1 row)
SELECT 'abc'::bytea LIKE '_b_'::bytea AS "true";
true
------
t
(1 row)
SELECT 'abc'::bytea NOT LIKE '_b_'::bytea AS "false";
false
-------
f
(1 row)
-- unused escape character -- unused escape character
SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true";
true true
...@@ -1158,6 +1182,18 @@ SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false"; ...@@ -1158,6 +1182,18 @@ SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false";
f f
(1 row) (1 row)
SELECT 'a_c'::bytea LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "true";
true
------
t
(1 row)
SELECT 'a_c'::bytea NOT LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "false";
false
-------
f
(1 row)
-- escape character same as pattern character -- escape character same as pattern character
SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true";
true true
...@@ -1271,6 +1307,18 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; ...@@ -1271,6 +1307,18 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false";
f f
(1 row) (1 row)
SELECT 'ABC'::name ILIKE '_b_' AS "true";
true
------
t
(1 row)
SELECT 'ABC'::name NOT ILIKE '_b_' AS "false";
false
-------
f
(1 row)
-- --
-- test %/_ combination cases, cf bugs #4821 and #5478 -- test %/_ combination cases, cf bugs #4821 and #5478
-- --
......
...@@ -300,6 +300,12 @@ SELECT 'indio' NOT LIKE 'in__o' AS "false"; ...@@ -300,6 +300,12 @@ SELECT 'indio' NOT LIKE 'in__o' AS "false";
SELECT 'indio' LIKE 'in_o' AS "false"; SELECT 'indio' LIKE 'in_o' AS "false";
SELECT 'indio' NOT LIKE 'in_o' AS "true"; SELECT 'indio' NOT LIKE 'in_o' AS "true";
SELECT 'abc'::name LIKE '_b_' AS "true";
SELECT 'abc'::name NOT LIKE '_b_' AS "false";
SELECT 'abc'::bytea LIKE '_b_'::bytea AS "true";
SELECT 'abc'::bytea NOT LIKE '_b_'::bytea AS "false";
-- unused escape character -- unused escape character
SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true";
SELECT 'hawkeye' NOT LIKE 'h%' ESCAPE '#' AS "false"; SELECT 'hawkeye' NOT LIKE 'h%' ESCAPE '#' AS "false";
...@@ -333,6 +339,9 @@ SELECT 'i_dio' NOT LIKE 'i$_nd_o' ESCAPE '$' AS "true"; ...@@ -333,6 +339,9 @@ SELECT 'i_dio' NOT LIKE 'i$_nd_o' ESCAPE '$' AS "true";
SELECT 'i_dio' LIKE 'i$_d%o' ESCAPE '$' AS "true"; SELECT 'i_dio' LIKE 'i$_d%o' ESCAPE '$' AS "true";
SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false"; SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false";
SELECT 'a_c'::bytea LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "true";
SELECT 'a_c'::bytea NOT LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "false";
-- escape character same as pattern character -- escape character same as pattern character
SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true";
SELECT 'maca' NOT LIKE 'm%aca' ESCAPE '%' AS "false"; SELECT 'maca' NOT LIKE 'm%aca' ESCAPE '%' AS "false";
...@@ -367,6 +376,9 @@ SELECT 'hawkeye' NOT ILIKE 'H%Eye' AS "false"; ...@@ -367,6 +376,9 @@ SELECT 'hawkeye' NOT ILIKE 'H%Eye' AS "false";
SELECT 'Hawkeye' ILIKE 'h%' AS "true"; SELECT 'Hawkeye' ILIKE 'h%' AS "true";
SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false";
SELECT 'ABC'::name ILIKE '_b_' AS "true";
SELECT 'ABC'::name NOT ILIKE '_b_' AS "false";
-- --
-- test %/_ combination cases, cf bugs #4821 and #5478 -- test %/_ combination cases, cf bugs #4821 and #5478
-- --
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment