Implement redo by PL/pgSQL

This commit is contained in:
wqy
2022-09-03 17:29:50 +08:00
parent 03a0d6cf64
commit 57728681b6
3 changed files with 25 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ begin
end;
$$ language plpgsql;
-- update_title()
-- set_title()
create function tj.set_title(new_title text) returns void as
$$
declare

View File

@@ -84,4 +84,26 @@ declare
begin
perform tj.execute_undo(true);
end;
$$ language plpgsql;
create function tj.redo() returns void as
$$
declare
curr_id int;
child_id int;
redo_sql text;
begin
select id into curr_id from tj.current_operation;
select redo_child into child_id from tj.operation where id = curr_id;
if child_id = null then
return;
end if;
select redo into redo_sql from tj.operation where id = child_id;
execute redo_sql;
update tj.current_operation set id = child_id where id = curr_id;
end;
$$ language plpgsql;

View File

@@ -1,3 +1,5 @@
drop function if exists tj.redo;
drop function if exists tj.discard_undo;
drop function if exists tj.undo;
drop function if exists tj.execute_undo;