Created
October 7, 2011 22:26
-
-
Save rhelmer/1271484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \set ON_ERROR_STOP 1 | |
| -- function | |
| CREATE OR REPLACE FUNCTION backfill_hangreport ( | |
| firstday date, | |
| lastday date default NULL ) | |
| RETURNS BOOLEAN | |
| LANGUAGE plpgsql | |
| AS $f$ | |
| DECLARE thisday DATE := firstday; | |
| BEGIN | |
| -- this producedure is meant to be called manually | |
| -- by administrators in order to backfill | |
| -- the hang/crash report | |
| -- set optional end date | |
| lastday := coalesce(lastday, current_date ); | |
| -- check parameters | |
| IF firstday > current_date OR lastday > current_date or firstday > lastday THEN | |
| RAISE EXCEPTION 'date parameter error: cannot backfill into the future'; | |
| END IF; | |
| -- loop through the days, backfilling one at a time | |
| WHILE thisday <= lastday LOOP | |
| RAISE INFO 'backfilling for %',thisday; | |
| PERFORM update_hang_report(thisday); | |
| thisday := thisday + 1; | |
| END LOOP; | |
| RETURN true; | |
| END; $f$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment