Add tests for POSITION(bytea, bytea)
authorDavid Rowley <drowley@postgresql.org>
Mon, 24 Mar 2025 06:32:02 +0000 (19:32 +1300)
committerDavid Rowley <drowley@postgresql.org>
Mon, 24 Mar 2025 06:32:02 +0000 (19:32 +1300)
Previously there was no coverage for this function.

Author: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Rustam ALLAKOV <rustamallakov@gmail.com>
Discussion: https://postgr.es/m/CAJ7c6TMT6XCooMVKnCd_tR2oBdGcnjefSeCDCv8jzKy9VkWA5w@mail.gmail.com

src/test/regress/expected/strings.out
src/test/regress/sql/strings.sql

index fbe7d7be71f4d9c135c4139da9270ee990b0b482..dc485735aa45093ed8b3e658c42a68fc77d192c3 100644 (file)
@@ -1353,6 +1353,36 @@ SELECT POSITION('5' IN '1234567890') = '5' AS "5";
  t
 (1 row)
 
+SELECT POSITION('\x11'::bytea IN ''::bytea) = 0 AS "0";
+ 0 
+---
+ t
+(1 row)
+
+SELECT POSITION('\x33'::bytea IN '\x1122'::bytea) = 0 AS "0";
+ 0 
+---
+ t
+(1 row)
+
+SELECT POSITION(''::bytea IN '\x1122'::bytea) = 1 AS "1";
+ 1 
+---
+ t
+(1 row)
+
+SELECT POSITION('\x22'::bytea IN '\x1122'::bytea) = 2 AS "2";
+ 2 
+---
+ t
+(1 row)
+
+SELECT POSITION('\x5678'::bytea IN '\x1234567890'::bytea) = 3 AS "3";
+ 3 
+---
+ t
+(1 row)
+
 -- T312 character overlay function
 SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f";
  abc45f 
index ed054e6e99c750f4d198374ce475fb3e73085221..aeba798dac1fafaa96a6c362cce8c60c7a475dbc 100644 (file)
@@ -367,6 +367,12 @@ SELECT POSITION('4' IN '1234567890') = '4' AS "4";
 
 SELECT POSITION('5' IN '1234567890') = '5' AS "5";
 
+SELECT POSITION('\x11'::bytea IN ''::bytea) = 0 AS "0";
+SELECT POSITION('\x33'::bytea IN '\x1122'::bytea) = 0 AS "0";
+SELECT POSITION(''::bytea IN '\x1122'::bytea) = 1 AS "1";
+SELECT POSITION('\x22'::bytea IN '\x1122'::bytea) = 2 AS "2";
+SELECT POSITION('\x5678'::bytea IN '\x1234567890'::bytea) = 3 AS "3";
+
 -- T312 character overlay function
 SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f";