Fixing a destructor bug

Some query nodes copy schemas from its children and some just refer to
them. When the destructor executes, those shallow copies will be deleted
twice. This leads to very hard-to-find bugs, where the first queries can
execute nicely but subsequent ones failed.