Skip to content

Commit

Permalink
contrib: Raise error if pageinspect is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
df7cb committed May 28, 2020
1 parent 7eb75ac commit fb3a90b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contrib/bad_tuples.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ begin
end loop;

exception -- bad page
when undefined_function then
raise exception undefined_function
using message = SQLERRM,
hint = 'Use CREATE EXTENSION pageinspect; to create it';
when others then
bad_tuples.page := page;
bad_tuples.sqlstate := sqlstate;
Expand Down
4 changes: 4 additions & 0 deletions contrib/read_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ begin
end loop;

exception -- bad page
when undefined_function then
raise exception undefined_function
using message = SQLERRM,
hint = 'Use CREATE EXTENSION pageinspect; to create it';
when others then
get stacked diagnostics sql_state := RETURNED_SQLSTATE;
get stacked diagnostics error := MESSAGE_TEXT;
Expand Down
6 changes: 5 additions & 1 deletion contrib/rescue_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ begin
end loop;

exception -- bad page
when undefined_function then
raise exception undefined_function
using message = SQLERRM,
hint = 'Use CREATE EXTENSION pageinspect; to create it';
when others then
get stacked diagnostics sql_state := RETURNED_SQLSTATE;
get stacked diagnostics error := MESSAGE_TEXT;
Expand All @@ -62,5 +66,5 @@ begin
end;
$$ language plpgsql;

comment on function rescue_table(regclass, name, boolean) is
comment on function rescue_table(regclass, name, boolean, int, int) is
'copy all good tuples from a table to another one';

0 comments on commit fb3a90b

Please sign in to comment.