Created
December 10, 2020 15:18
-
-
Save onderkalaci/1982a35da55c27b907308b453f9d9a17 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
| create or replace procedure top_function() | |
| language plpgsql | |
| as | |
| $$ | |
| begin | |
| RAISE NOTICE 'Top function is called'; | |
| call second_function(); | |
| EXCEPTION | |
| when others then | |
| RAISE NOTICE 'Top function exception handling'; | |
| PERFORM * FROM users_table; | |
| --call second_function(); | |
| end; $$; | |
| create or replace procedure second_function() | |
| language plpgsql | |
| as | |
| $$ | |
| declare | |
| n integer:= 1000; | |
| counter integer := 0 ; | |
| begin | |
| RAISE NOTICE 'Second function is called'; | |
| insert into users_table (user_id) SELECT i from generate_series(0,100)i; | |
| loop | |
| exit when counter = n ; | |
| counter := counter + 1 ; | |
| PERFORM user_id/0 FROM users_table as foo_second; | |
| RAISE NOTICE 'Second function loop % finished', counter; | |
| end loop; | |
| EXCEPTION | |
| when others then | |
| RAISE NOTICE 'Second function exception handling'; | |
| call third_function(); | |
| end; $$; | |
| create or replace procedure third_function() | |
| language plpgsql | |
| as | |
| $$ | |
| begin | |
| PERFORM count(*) FROM users_table as foo_third; | |
| TRUNCATE users_table; | |
| end; $$; | |
| SELECT citus.mitmproxy('conn.allow()'); | |
| SELECT citus.mitmproxy('conn.onQuery(query="^TRUNCATE").reset()'); | |
| BEGIN; | |
| SAVEPOINT s1; | |
| call top_function(); | |
| ROLLBACK TO SAVEPOINT s1; | |
| SELECT citus.mitmproxy('conn.allow()'); | |
| call top_function(); | |
| ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment