diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/arrays.out | 101 | ||||
| -rw-r--r-- | src/test/regress/expected/domain.out | 2 | ||||
| -rw-r--r-- | src/test/regress/sql/arrays.sql | 20 |
3 files changed, 116 insertions, 7 deletions
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out index dcc9e9c1ab..da218f0047 100644 --- a/src/test/regress/expected/arrays.out +++ b/src/test/regress/expected/arrays.out @@ -63,9 +63,9 @@ SELECT a[1:3], FROM arrtest; a | b | c | d ------------+-----------------+-----------+--------------- - {1,2,3} | {{{0,0},{1,2}}} | | - {11,12,23} | | {foobar} | {{elt1,elt2}} - | | {foo,bar} | + {1,2,3} | {{{0,0},{1,2}}} | {} | {} + {11,12,23} | {} | {foobar} | {{elt1,elt2}} + {} | {} | {foo,bar} | {} (3 rows) SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c @@ -111,9 +111,36 @@ SELECT a[1:3], FROM arrtest; a | b | c | d ------------+-----------------------+-------------------+---------- - {16,25,3} | {{{113,142},{1,147}}} | | - | | {foo,new_word} | - {16,25,23} | | {foobar,new_word} | {{elt2}} + {16,25,3} | {{{113,142},{1,147}}} | {} | {} + {} | {} | {foo,new_word} | {} + {16,25,23} | {} | {foobar,new_word} | {{elt2}} +(3 rows) + +INSERT INTO arrtest(a) VALUES('{1,null,3}'); +SELECT a FROM arrtest; + a +--------------- + {16,25,3,4,5} + {} + {16,25,23} + {1,NULL,3} +(4 rows) + +UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL; +SELECT a FROM arrtest WHERE a[2] IS NULL; + a +----------------- + [4:4]={NULL} + {1,NULL,3,NULL} +(2 rows) + +DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL; +SELECT a,b,c FROM arrtest; + a | b | c +---------------+-----------------------+------------------- + {16,25,3,4,5} | {{{113,142},{1,147}}} | {} + {16,25,23} | {{3,4},{4,5}} | {foobar,new_word} + [4:4]={NULL} | {3,4} | {foo,new_word} (3 rows) -- @@ -176,6 +203,19 @@ SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY"; {1.15,1.15,1.18,1.21,1.24,1.26,1.26,1.3,1.32} (1 row) +-- with nulls +SELECT '{1,null,3}'::int[]; + int4 +------------ + {1,NULL,3} +(1 row) + +SELECT ARRAY[1,NULL,3]; + array +------------ + {1,NULL,3} +(1 row) + -- functions SELECT array_append(array[42], 6) AS "{42,6}"; {42,6} @@ -355,6 +395,55 @@ select 33 * any ('{1,2,3}'); ERROR: op ANY/ALL (array) requires operator to yield boolean select 33 * any (44); ERROR: op ANY/ALL (array) requires array on right side +-- nulls +select 33 = any (null::int[]); + ?column? +---------- + +(1 row) + +select null::int = any ('{1,2,3}'); + ?column? +---------- + +(1 row) + +select 33 = any ('{1,null,3}'); + ?column? +---------- + +(1 row) + +select 33 = any ('{1,null,33}'); + ?column? +---------- + t +(1 row) + +select 33 = all (null::int[]); + ?column? +---------- + +(1 row) + +select null::int = all ('{1,2,3}'); + ?column? +---------- + +(1 row) + +select 33 = all ('{1,null,3}'); + ?column? +---------- + f +(1 row) + +select 33 = all ('{33,null,33}'); + ?column? +---------- + +(1 row) + -- test indexes on arrays create temp table arr_tbl (f1 int[] unique); NOTICE: CREATE TABLE / UNIQUE will create implicit index "arr_tbl_f1_key" for table "arr_tbl" diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out index d2766ee2a4..5309234ce2 100644 --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@ -91,7 +91,7 @@ select testint4arr[1], testtextarr[2:2] from domarrtest; testint4arr | testtextarr -------------+------------- 2 | {{c,d}} - | + | {} 2 | {{c,d}} 2 | {{c}} | {{d,e,f}} diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index bc4d1345fb..d0574beda0 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -83,6 +83,13 @@ SELECT a[1:3], d[1:1][2:2] FROM arrtest; +INSERT INTO arrtest(a) VALUES('{1,null,3}'); +SELECT a FROM arrtest; +UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL; +SELECT a FROM arrtest WHERE a[2] IS NULL; +DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL; +SELECT a,b,c FROM arrtest; + -- -- array expressions and operators -- @@ -128,6 +135,10 @@ SELECT ARRAY[[[[[['hello'],['world']]]]]]; SELECT ARRAY[ARRAY['hello'],ARRAY['world']]; SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY"; +-- with nulls +SELECT '{1,null,3}'::int[]; +SELECT ARRAY[1,NULL,3]; + -- functions SELECT array_append(array[42], 6) AS "{42,6}"; SELECT array_prepend(6, array[42]) AS "{6,42}"; @@ -168,6 +179,15 @@ select 33.4 > all (array[1,2,3]); -- errors select 33 * any ('{1,2,3}'); select 33 * any (44); +-- nulls +select 33 = any (null::int[]); +select null::int = any ('{1,2,3}'); +select 33 = any ('{1,null,3}'); +select 33 = any ('{1,null,33}'); +select 33 = all (null::int[]); +select null::int = all ('{1,2,3}'); +select 33 = all ('{1,null,3}'); +select 33 = all ('{33,null,33}'); -- test indexes on arrays create temp table arr_tbl (f1 int[] unique); |
