Fixed segfault if COPY statements are executed

Close ticket #219
Merge branch 'bug-219' into maint_2_5