Improve error message on failing CDB_CartodbfyTable

This commit is contained in:
Sandro Santilli 2014-05-23 16:04:54 +02:00
parent fe008b952d
commit 102e8bd018

View File

@ -83,7 +83,8 @@ BEGIN
RAISE NOTICE 'Column cartodb_id already exists'; RAISE NOTICE 'Column cartodb_id already exists';
had_column := TRUE; had_column := TRUE;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (cartodb_id): % (%)',
reloid, SQLERRM, SQLSTATE;
END; END;
IF had_column THEN IF had_column THEN
@ -114,7 +115,8 @@ BEGIN
WHEN unique_violation OR not_null_violation THEN WHEN unique_violation OR not_null_violation THEN
RAISE NOTICE '%, renaming', SQLERRM; RAISE NOTICE '%, renaming', SQLERRM;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (cartodb_id): % (%)',
reloid, SQLERRM, SQLSTATE;
END; END;
END IF; -- } END IF; -- }
@ -133,7 +135,8 @@ BEGIN
i := i+1; i := i+1;
CONTINUE rename_column; CONTINUE rename_column;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (renaming cartodb_id): % (%)',
reloid, SQLERRM, SQLSTATE;
END; END;
EXIT rename_column; EXIT rename_column;
END LOOP; --} END LOOP; --}
@ -195,7 +198,8 @@ BEGIN
RAISE NOTICE 'Column % already exists', rec.cname; RAISE NOTICE 'Column % already exists', rec.cname;
had_column := TRUE; had_column := TRUE;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (%): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
IF had_column THEN IF had_column THEN
@ -218,7 +222,8 @@ BEGIN
WHEN cannot_coerce THEN -- failed cast WHEN cannot_coerce THEN -- failed cast
RAISE NOTICE '%, renaming', SQLERRM; RAISE NOTICE '%, renaming', SQLERRM;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (%): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
-- invalid column, need rename and re-create it -- invalid column, need rename and re-create it
@ -235,7 +240,8 @@ BEGIN
i := i+1; i := i+1;
CONTINUE rename_column; CONTINUE rename_column;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (renaming %): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
EXIT rename_column; EXIT rename_column;
END LOOP; --} END LOOP; --}
@ -264,7 +270,8 @@ BEGIN
exists_geom_cols := array_append(exists_geom_cols, true); exists_geom_cols := array_append(exists_geom_cols, true);
RAISE NOTICE 'Column % already exists', rec.cname; RAISE NOTICE 'Column % already exists', rec.cname;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (%): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
<< column_fixup >> << column_fixup >>
@ -316,7 +323,8 @@ BEGIN
EXECUTE sql; EXECUTE sql;
EXCEPTION EXCEPTION
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (% index): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
END IF; -- } END IF; -- }
@ -339,7 +347,8 @@ BEGIN
i := i+1; i := i+1;
CONTINUE rename_column; CONTINUE rename_column;
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Got % (%)', SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (rename %): % (%)',
reloid, rec.cname, SQLERRM, SQLSTATE;
END; END;
EXIT rename_column; EXIT rename_column;
END LOOP; --} END LOOP; --}