Move the setting of cursor->query up to cursor creation.