Background: I'm working on a side-effect-free branch of MonetDB. No in-place operations allowed. 

With bat.append() already changed this way, everything seemed to work so far, except TRACE. Even TRACE SELECT 1 would fail.

I looked at it and the reason is that SQLsetTrace assumed in-place appends, thus first adding new empty bats to resultset, then filling in those bats. Everywhere else this is not assumed. The return bat of append is always created and used, even if it is the same of the first operand. 

The diff in attachment makes it work for both branches and is in my opinion more correct and consistent with the rest of the code.

Best, 
Roberto