create cached table tarray (id int primary key, description varchar(20) array);
insert into tarray values 1, array['light', 'red', 'hot']
insert into tarray values 2, array['dark', 'grey', 'cold']
select * from tarray
select t1.description || t2.description from tarray t1 join tarray t2 on t1.id = t2.id + 1
select t1.description || t2.description[2] from tarray t1 join tarray t2 on t1.id = t2.id + 1
select (t1.description || t2.description)[2] from tarray t1 join tarray t2 on t1.id = t2.id + 1
select max(t1.description[1]) from tarray t1
select max(t1.description[1]) || min(t1.description[1]) from tarray t1
select cardinality(t1.description || t2.description) from tarray t1 join tarray t2 on t1.id = t2.id + 1
update tarray t1 set t1.description[2] = 'cool' where id = 2
select trim_array(t1.description, 1) from tarray t1
select trim_array(t1.description, 1)[1] from tarray t1
select trim_array(t1.description, 1)[1] from tarray t1

select * from tarray t1 where t1.id = 2 and t1.description[2] = 'cold'

CREATE TABLE iarray (i BIGINT PRIMARY KEY, ar INTEGER ARRAY);

INSERT INTO iarray VALUES (1, array [11, null, 13]);
INSERT INTO iarray VALUES (2, null);
INSERT INTO iarray VALUES (3, array [21, 22]);

/*c3*/SELECT * FROM iarray;

/*c1*/SELECT count(*) FROM iarray WHERE i = 1 AND ar[3] = 13;

-- using customer and invoice tables defined in TestSelf.txt
select firstname, lastname, a.c from customer, unnest(array[(select sum(total) from invoice where addressid = customer.id)]) a (c)
alter table customer add column arr varchar(40) array
update customer set arr = array[firstname, lastname, street, city]
SELECT id, w, y FROM customer, unnest (arr) with ordinality j(w,y)

--
select * from customer, lateral(select sum(invoice.total) from invoice where invoice.addressid = customer.id)
explain plan for select * from customer where firstname in(unnest(?))
