Primary fix is the search_path to ensure that the collection table is in the search path so that the copy into dav_binding (and possibly others) will work. I also suppressed the warning about plpgsql.