pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Add tests for bytea LIKE operator
Date: Thu, 11 Feb 2021 14:23:14 +0100
Message-ID: <4d13563a-2c8d-fd91-20d5-e71b7a4eaa87@enterprisedb.com> (raw)

A few more easy tests for things not covered 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)

See also 
<https://coverage.postgresql.org/src/backend/utils/adt/like.c.func-sort-c.html;.

Attachments:

0001-Add-tests-for-bytea-LIKE-operator.patch (text/plain, 3.3K) download From e6af4a7baa2703cc8239a3e9670d21ef36009e90 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter@eisentraut.org> Date: Thu, 11 Feb 2021 14:21:06 +0100 Subject: [PATCH] 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) --- src/test/regress/expected/strings.out | 48 +++++++++++++++++++++++++++ src/test/regress/sql/strings.sql | 12 +++++++ 2 files changed, 60 insertions(+) diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 7c91afa6e4..fb4573d85f 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -1035,6 +1035,30 @@ SELECT 'indio' NOT LIKE 'in_o' AS "true"; t (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 SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; true @@ -1158,6 +1182,18 @@ SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false"; f (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 SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; true @@ -1271,6 +1307,18 @@ SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; f (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 -- diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index ef4bfb008a..57a48c9d0b 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -300,6 +300,12 @@ SELECT 'indio' LIKE 'in_o' AS "false"; 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 SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; SELECT 'hawkeye' NOT LIKE 'h%' ESCAPE '#' AS "false"; @@ -333,6 +339,9 @@ SELECT 'i_dio' LIKE 'i$_d%o' ESCAPE '$' AS "true"; 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 SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; SELECT 'maca' NOT LIKE 'm%aca' ESCAPE '%' AS "false"; @@ -367,6 +376,9 @@ SELECT 'Hawkeye' ILIKE 'h%' AS "true"; 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 -- -- 2.30.0

Message-ID: <4d13563a-2c8d-fd91-20d5-e71b7a4eaa87@enterprisedb.com>
Permalink:  ../4d13563a-2c8d-fd91-20d5-e71b7a4eaa87@enterprisedb.com/
Also on:    postgresql.org/message-id/4d13563a-2c8d-fd91-20d5-e71b7a4eaa87@enterprisedb.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@enterprisedb.com
  Subject: Re: Add tests for bytea LIKE operator
  In-Reply-To: <4d13563a-2c8d-fd91-20d5-e71b7a4eaa87@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox