Skip to content

Commit 35a92b7

Browse files
committed
Add tests for POSITION(bytea, bytea)
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
1 parent 2a0cd38 commit 35a92b7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/test/regress/expected/strings.out

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,36 @@ SELECT POSITION('5' IN '1234567890') = '5' AS "5";
13531353
t
13541354
(1 row)
13551355

1356+
SELECT POSITION('\x11'::bytea IN ''::bytea) = 0 AS "0";
1357+
0
1358+
---
1359+
t
1360+
(1 row)
1361+
1362+
SELECT POSITION('\x33'::bytea IN '\x1122'::bytea) = 0 AS "0";
1363+
0
1364+
---
1365+
t
1366+
(1 row)
1367+
1368+
SELECT POSITION(''::bytea IN '\x1122'::bytea) = 1 AS "1";
1369+
1
1370+
---
1371+
t
1372+
(1 row)
1373+
1374+
SELECT POSITION('\x22'::bytea IN '\x1122'::bytea) = 2 AS "2";
1375+
2
1376+
---
1377+
t
1378+
(1 row)
1379+
1380+
SELECT POSITION('\x5678'::bytea IN '\x1234567890'::bytea) = 3 AS "3";
1381+
3
1382+
---
1383+
t
1384+
(1 row)
1385+
13561386
-- T312 character overlay function
13571387
SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f";
13581388
abc45f

src/test/regress/sql/strings.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ SELECT POSITION('4' IN '1234567890') = '4' AS "4";
367367

368368
SELECT POSITION('5' IN '1234567890') = '5' AS "5";
369369

370+
SELECT POSITION('\x11'::bytea IN ''::bytea) = 0 AS "0";
371+
SELECT POSITION('\x33'::bytea IN '\x1122'::bytea) = 0 AS "0";
372+
SELECT POSITION(''::bytea IN '\x1122'::bytea) = 1 AS "1";
373+
SELECT POSITION('\x22'::bytea IN '\x1122'::bytea) = 2 AS "2";
374+
SELECT POSITION('\x5678'::bytea IN '\x1234567890'::bytea) = 3 AS "3";
375+
370376
-- T312 character overlay function
371377
SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f";
372378

0 commit comments

Comments
 (0)