SET log_error_verbosity = verbose;
drop table if exists vc;
create table vc 
(
	a int, 
	ts varchar, 
	te varchar
);
insert into vc values 
(0, 'A', 'D'), 
(1, 'C', 'X');
select * from ( vc normalize vc r2 on true with (ts,te,ts,te)) c;
 a | ts | te 
---+----+----
 0 | A  | C
 0 | C  | D
 1 | C  | D
 1 | D  | X
(4 rows)

select * from ( vc align vc r2 on true with (ts,te,ts,te)) c;
 a | ts | te 
---+----+----
 0 | A  | D
 0 | C  | D
 1 | C  | D
 1 | C  | X
(4 rows)

delete from vc;
insert into vc values 
(0, 'ABC', 'BCD'), 
(0, 'xABC', 'xBCD'),
(0, 'BAA', 'BBB');
select * from ( vc normalize vc r2 on true with (ts,te,ts,te)) c;
 a |  ts  |  te  
---+------+------
 0 | ABC  | BAA
 0 | BAA  | BBB
 0 | BBB  | BCD
 0 | xABC | xBCD
 0 | BAA  | BBB
(5 rows)

select * from ( vc align vc r2 on true with (ts,te,ts,te)) c;
 a |  ts  |  te  
---+------+------
 0 | ABC  | BCD
 0 | BAA  | BBB
 0 | xABC | xBCD
 0 | BAA  | BBB
(4 rows)

drop table vc;
create table vc 
(
	a int, 
	ts varchar COLLATE "de_DE", 
	te varchar COLLATE "POSIX"
);
insert into vc values 
(0, 'A', 'D'), 
(1, 'C', 'X');
-- We change the collation of "te" to "de_DE"
with vc as (select a, ts collate "de_DE", te collate "de_DE" from vc) select * from ( vc normalize vc r2 on true with (ts,te,ts,te)) c;
 a | ts | te 
---+----+----
 0 | A  | C
 0 | C  | D
 1 | C  | D
 1 | D  | X
(4 rows)

-- THE FOLLOWING SYNTAX IS NOT SUPPORTED!
-- select * from ( vc collate "de_DE" align vc r2 collate "de_DE" on true with (ts,te,ts,te)) c;
-- Test passed!
