Church of Scotland upholds gay minister's appointment