Skip to content

Commit e2a277b

Browse files
committed
A few additional test cases for array functionality
1 parent e0dc7d0 commit e2a277b

File tree

2 files changed

+75
-2
lines changed

2 files changed

+75
-2
lines changed

src/test/regress/expected/arrays.out

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,14 @@ select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
725725
{1,5,3}
726726
(2 rows)
727727

728-
-- note: if above select doesn't produce the expected tuple order,
728+
select * from arr_tbl where f1 >= '{1,2,3}' and f1 < '{1,5,3}';
729+
f1
730+
----------
731+
{1,2,3}
732+
{1,2,10}
733+
(2 rows)
734+
735+
-- note: if above selects don't produce the expected tuple order,
729736
-- then you didn't get an indexscan plan, and something is busted.
730737
reset enable_seqscan;
731738
reset enable_bitmapscan;
@@ -858,6 +865,12 @@ select array[]::text[];
858865
{}
859866
(1 row)
860867

868+
select '[0:1]={1.1,2.2}'::float8[];
869+
float8
870+
-----------------
871+
[0:1]={1.1,2.2}
872+
(1 row)
873+
861874
-- all of the above should be accepted
862875
-- tests for array aggregates
863876
CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]);
@@ -1014,3 +1027,51 @@ ERROR: wrong number of array_subscripts
10141027
DETAIL: Low bound array has different size than dimensions array.
10151028
select array_fill(1, array[1,2,null]);
10161029
ERROR: dimension values cannot be null
1030+
select string_to_array('1|2|3', '|');
1031+
string_to_array
1032+
-----------------
1033+
{1,2,3}
1034+
(1 row)
1035+
1036+
select string_to_array('1|2|3|', '|');
1037+
string_to_array
1038+
-----------------
1039+
{1,2,3,""}
1040+
(1 row)
1041+
1042+
select string_to_array('1||2|3||', '||');
1043+
string_to_array
1044+
-----------------
1045+
{1,2|3,""}
1046+
(1 row)
1047+
1048+
select string_to_array('1|2|3', '');
1049+
string_to_array
1050+
-----------------
1051+
{1|2|3}
1052+
(1 row)
1053+
1054+
select string_to_array('', '|');
1055+
string_to_array
1056+
-----------------
1057+
1058+
(1 row)
1059+
1060+
select string_to_array('1|2|3', NULL);
1061+
string_to_array
1062+
-----------------
1063+
1064+
(1 row)
1065+
1066+
select string_to_array(NULL, '|');
1067+
string_to_array
1068+
-----------------
1069+
1070+
(1 row)
1071+
1072+
select array_to_string(string_to_array('1|2|3', '|'), '|');
1073+
array_to_string
1074+
-----------------
1075+
1|2|3
1076+
(1 row)
1077+

src/test/regress/sql/arrays.sql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ insert into arr_tbl values ('{1,2,10}');
257257
set enable_seqscan to off;
258258
set enable_bitmapscan to off;
259259
select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
260-
-- note: if above select doesn't produce the expected tuple order,
260+
select * from arr_tbl where f1 >= '{1,2,3}' and f1 < '{1,5,3}';
261+
-- note: if above selects don't produce the expected tuple order,
261262
-- then you didn't get an indexscan plan, and something is busted.
262263
reset enable_seqscan;
263264
reset enable_bitmapscan;
@@ -297,6 +298,7 @@ select '{
297298
@ 1 hour @ 42 minutes @ 20 seconds
298299
}'::interval[];
299300
select array[]::text[];
301+
select '[0:1]={1.1,2.2}'::float8[];
300302
-- all of the above should be accepted
301303

302304
-- tests for array aggregates
@@ -374,3 +376,13 @@ select array_fill(1, null, array[2,2]);
374376
select array_fill(1, array[2,2], null);
375377
select array_fill(1, array[3,3], array[1,1,1]);
376378
select array_fill(1, array[1,2,null]);
379+
380+
select string_to_array('1|2|3', '|');
381+
select string_to_array('1|2|3|', '|');
382+
select string_to_array('1||2|3||', '||');
383+
select string_to_array('1|2|3', '');
384+
select string_to_array('', '|');
385+
select string_to_array('1|2|3', NULL);
386+
select string_to_array(NULL, '|');
387+
388+
select array_to_string(string_to_array('1|2|3', '|'), '|');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy