Skip to content

Commit

Permalink
Use %s instead of %I to allow schema-qualified table names
Browse files Browse the repository at this point in the history
  • Loading branch information
df7cb committed Apr 2, 2020
1 parent ff48388 commit af112f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contrib/bad_tuples.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ begin

for ctid in select t_ctid from heap_page_items(get_raw_page(relname::text, page)) loop
begin
execute format('SELECT length(t::text) FROM %I t WHERE ctid=%L', relname, ctid);
execute format('SELECT length(t::text) FROM %s t WHERE ctid=%L', relname, ctid);
exception -- bad tuple
when others then
bad_tuples.page := page;
Expand Down
2 changes: 1 addition & 1 deletion contrib/read_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ begin

for ctid in select t_ctid from heap_page_items(get_raw_page(relname::text, page)) loop
begin
execute format('SELECT * FROM %I WHERE ctid=%L', relname, ctid) into r;
execute format('SELECT * FROM %s WHERE ctid=%L', relname, ctid) into r;
if r is not null then
return next r;
end if;
Expand Down
6 changes: 3 additions & 3 deletions contrib/rescue_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ begin
savename := relname || '_rescue';
end if;
if rescue_table.create then
execute format('CREATE TABLE %I (LIKE %I)', savename, relname);
execute format('CREATE TABLE %s (LIKE %s)', savename, relname);
end if;

select pg_relation_size(relname) / current_setting('block_size')::int into pages;
Expand All @@ -30,7 +30,7 @@ begin

for ctid in select t_ctid from heap_page_items(get_raw_page(relname::text, page)) loop
begin
execute format('INSERT INTO %I SELECT * FROM %I WHERE ctid=%L', savename, relname, ctid);
execute format('INSERT INTO %s SELECT * FROM %s WHERE ctid=%L', savename, relname, ctid);
get diagnostics row_count = ROW_COUNT;
good_tuples := good_tuples + row_count;
exception -- bad tuple
Expand All @@ -52,7 +52,7 @@ begin

end loop;

error := format('rescue_table %I into %I: %s of %s pages are bad, %s bad tuples, %s tuples copied',
error := format('rescue_table %s into %s: %s of %s pages are bad, %s bad tuples, %s tuples copied',
relname, savename, bad_pages, pages, bad_tuples, good_tuples);
raise log '%', error;
return error;
Expand Down

0 comments on commit af112f0

Please sign in to comment.