On 3. sep. 2015, at 14:00, Sjon Hortensius <sjon@hortensius.net> wrote:
> I have worked around this by clustering the old table on the new id before=
SELECTing but this behavior doesn't seem to be documented, is this a bug?
Your nextval is run before the ordering. Otherwise, you wouldn't be able to o=
rder based on things computed in the select.=20
You can stack it though, such as:
INSERT INTO <...>
SELECT name, nextval(sequence), old_id FROM
( SELECT name, old_id FROM test ORDER BY old ASC ) as=20
x;
That way, you sort before pulling a new value with nextval, giving you the r=
esult you want. Did that make sense?
Or simply put; not a bug. :-)
Terje=