1--
2-- num_nulls()
3--
4
5SELECT num_nonnulls(NULL);
6SELECT num_nonnulls('1');
7SELECT num_nonnulls(NULL::text);
8SELECT num_nonnulls(NULL::text, NULL::int);
9SELECT num_nonnulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL);
10SELECT num_nonnulls(VARIADIC '{1,2,NULL,3}'::int[]);
11SELECT num_nonnulls(VARIADIC '{"1","2","3","4"}'::text[]);
12SELECT num_nonnulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i));
13
14SELECT num_nulls(NULL);
15SELECT num_nulls('1');
16SELECT num_nulls(NULL::text);
17SELECT num_nulls(NULL::text, NULL::int);
18SELECT num_nulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL);
19SELECT num_nulls(VARIADIC '{1,2,NULL,3}'::int[]);
20SELECT num_nulls(VARIADIC '{"1","2","3","4"}'::text[]);
21SELECT num_nulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i));
22
23-- special cases
24SELECT num_nonnulls(VARIADIC NULL::text[]);
25SELECT num_nonnulls(VARIADIC '{}'::int[]);
26SELECT num_nulls(VARIADIC NULL::text[]);
27SELECT num_nulls(VARIADIC '{}'::int[]);
28
29-- should fail, one or more arguments is required
30SELECT num_nonnulls();
31SELECT num_nulls();
32
33--
34-- Test some built-in SRFs
35--
36-- The outputs of these are variable, so we can't just print their results
37-- directly, but we can at least verify that the code doesn't fail.
38--
39select setting as segsize
40from pg_settings where name = 'wal_segment_size'
41\gset
42
43select count(*) > 0 as ok from pg_ls_waldir();
44-- Test ProjectSet as well as FunctionScan
45select count(*) > 0 as ok from (select pg_ls_waldir()) ss;
46-- Test not-run-to-completion cases.
47select * from pg_ls_waldir() limit 0;
48select count(*) > 0 as ok from (select * from pg_ls_waldir() limit 1) ss;
49select (w).size = :segsize as ok
50from (select pg_ls_waldir() w) ss where length((w).name) = 24 limit 1;
51
52select * from (select pg_ls_dir('.') a) a where a = 'base' limit 1;
53
54select * from (select (pg_timezone_names()).name) ptn where name='UTC' limit 1;
55
56select count(*) > 0 from
57  (select pg_tablespace_databases(oid) as pts from pg_tablespace
58   where spcname = 'pg_default') pts
59  join pg_database db on pts.pts = db.oid;
60