Postgresql / split one record on two rows depending of two fields Depending of this users table structure : 

CREATE TABLE users
AS
  SELECT id,name,email1,email2
  FROM ( VALUES 
    ( 1, 'John', 'john@doe.com', 'foo@bar.com' ),
    ( 2, 'Baz' , 'baz@bar.com' , null )
  ) AS t(id,name,email1,email2);


Is it possible to have this output with one query ?

John | john@doe.com
John | foo@bar.com
Baz  | baz@bar.com
SELECT name, email FROM users
UNION
SELECT name, email2 FROM users;


email and email2 have to be of the same type