Fix bug in CREATE TABLE AS SELECT