-- One relation, no join: the two target-list shapes of Kirill Reshke's review (BUG #19861). \pset format unaligned \pset tuples_only on \set QUIET on select version(); create table sje_target (id int primary key); create sequence sje_seq; insert into sje_target values (0); \echo == two identical volatile expressions, ORDER BY x select setval('sje_seq', 1, false) \g /dev/null select nextval('sje_seq') + a.id as x, nextval('sje_seq') + a.id as y from sje_target a order by x; select 'last_value', last_value from sje_seq; \echo == the same, no ORDER BY select setval('sje_seq', 1, false) \g /dev/null select nextval('sje_seq') + a.id as x, nextval('sje_seq') + a.id as y from sje_target a; select 'last_value', last_value from sje_seq; \echo == two identical set-returning expressions select setval('sje_seq', 1, false) \g /dev/null select generate_series(1, (nextval('sje_seq') + a.id)::int) + 0 as x, generate_series(1, (nextval('sje_seq') + a.id)::int) + 0 as y from sje_target a; select 'last_value', last_value from sje_seq;