diff --git a/contrib/gms_debug/expected/gms_debugger_client1.out b/contrib/gms_debug/expected/gms_debugger_client1.out index b02d884ff661983ac9563b56118537a5f83c9a10..61e9c5473002b54c1ebf0d0ebe158de46af8df65 100644 --- a/contrib/gms_debug/expected/gms_debugger_client1.out +++ b/contrib/gms_debug/expected/gms_debugger_client1.out @@ -31,6 +31,7 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test1; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) returns void as $$ declare @@ -50,7 +51,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -64,7 +65,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -78,7 +79,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -101,7 +102,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-0', 1); attach_session ---------------- @@ -266,4 +267,8 @@ CONTEXT: referenced column: gms_continue (1 row) select gms_debug.detach_session(); -connection to server was lost + detach_session +---------------- + +(1 row) + diff --git a/contrib/gms_debug/expected/gms_debugger_client2.out b/contrib/gms_debug/expected/gms_debugger_client2.out index 8455178587d5b0bca11165c88c25651155a00e7e..2843e9afc725a118281795c16f72cbd01e38b082 100644 --- a/contrib/gms_debug/expected/gms_debugger_client2.out +++ b/contrib/gms_debug/expected/gms_debugger_client2.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test2; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -51,7 +52,21 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; +CREATE or REPLACE FUNCTION gms_step() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-1'); attach_session ---------------- @@ -136,6 +151,22 @@ CONTEXT: referenced column: gms_continue (1 row) +select gms_continue(); +NOTICE: breakpoint= -1 +CONTEXT: referenced column: gms_continue +NOTICE: stackdepth= 0 +CONTEXT: referenced column: gms_continue +NOTICE: line= 0 +CONTEXT: referenced column: gms_continue +NOTICE: reason= 0 +CONTEXT: referenced column: gms_continue +NOTICE: ret= 0 +CONTEXT: referenced column: gms_continue + gms_continue +-------------- + +(1 row) + select gms_debug.detach_session(); detach_session ---------------- diff --git a/contrib/gms_debug/expected/gms_debugger_client3.out b/contrib/gms_debug/expected/gms_debugger_client3.out index 58f388db4ea4f16bea1756c37677ce22f56ea327..c43ef8c1acc8ac48edf922a244c54ed13ddefcfc 100644 --- a/contrib/gms_debug/expected/gms_debugger_client3.out +++ b/contrib/gms_debug/expected/gms_debugger_client3.out @@ -31,13 +31,28 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test3; +set behavior_compat_options='proc_outparam_override'; +CREATE or REPLACE FUNCTION gms_continue() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +60,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-2'); attach_session ---------------- @@ -136,6 +151,22 @@ CONTEXT: referenced column: gms_next (1 row) +select gms_continue(); +NOTICE: breakpoint= -1 +CONTEXT: referenced column: gms_continue +NOTICE: stackdepth= 0 +CONTEXT: referenced column: gms_continue +NOTICE: line= 14 +CONTEXT: referenced column: gms_continue +NOTICE: reason= 0 +CONTEXT: referenced column: gms_continue +NOTICE: ret= 0 +CONTEXT: referenced column: gms_continue + gms_continue +-------------- + +(1 row) + select gms_debug.detach_session(); detach_session ---------------- diff --git a/contrib/gms_debug/expected/gms_debugger_client4.out b/contrib/gms_debug/expected/gms_debugger_client4.out index 0024bb853460ece5650153935eb5b860a813c7a8..c7e6cfe58fba875ef8773b76e5e198745211f97d 100644 --- a/contrib/gms_debug/expected/gms_debugger_client4.out +++ b/contrib/gms_debug/expected/gms_debugger_client4.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test4; -CREATE or REPLACE FUNCTION gms_step() +set behavior_compat_options='proc_outparam_override'; +CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +46,27 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_next() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-3'); attach_session ---------------- diff --git a/contrib/gms_debug/expected/gms_debugger_client5.out b/contrib/gms_debug/expected/gms_debugger_client5.out index 6a030edd3fa84b2325fd2f9dc0c1f05c6584d3e7..15d2f5dbb50afc2267d0b1b5002d3666b4ff52ec 100644 --- a/contrib/gms_debug/expected/gms_debugger_client5.out +++ b/contrib/gms_debug/expected/gms_debugger_client5.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test5; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +46,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_step() +CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -59,13 +60,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_next() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -79,7 +80,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -88,7 +89,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-4'); attach_session ---------------- @@ -197,4 +198,8 @@ CONTEXT: referenced column: gms_finish (1 row) select gms_debug.detach_session(); -connection to server was lost + detach_session +---------------- + +(1 row) + diff --git a/contrib/gms_debug/expected/gms_debugger_client6.out b/contrib/gms_debug/expected/gms_debugger_client6.out index f58a3ac9c47733ac542aea59187dd7f641638880..0133050820a476c753710ca23a5f8ad170cfbe3f 100644 --- a/contrib/gms_debug/expected/gms_debugger_client6.out +++ b/contrib/gms_debug/expected/gms_debugger_client6.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test6; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -64,7 +65,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -73,7 +74,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-5'); attach_session ---------------- diff --git a/contrib/gms_debug/expected/gms_debugger_server1.out b/contrib/gms_debug/expected/gms_debugger_server1.out index 5e9758952454d7382188e388f27f027630080d7f..f37430ab5a4032c45332c15c117e5a4e4be22134 100644 --- a/contrib/gms_debug/expected/gms_debugger_server1.out +++ b/contrib/gms_debug/expected/gms_debugger_server1.out @@ -132,8 +132,12 @@ select * from gms_debug.attach_session('datanode1-0'); ERROR: target session should be init first. -- turn off without turn on select * from gms_debug.debug_off(); -ERROR: target session should be init first -select * from gms_debug.initialize(); + debug_off +----------- + +(1 row) + +select * from gms_debug.initialize('datanode1-0'); initialize ------------- datanode1-0 @@ -169,6 +173,12 @@ INFO: cnt is 3 1 | Happy Children's Day! | Tue Jun 01 00:00:00 2021 (6 rows) +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test1 cascade; NOTICE: drop cascades to 8 other objects DETAIL: drop cascades to table test diff --git a/contrib/gms_debug/expected/gms_debugger_server2.out b/contrib/gms_debug/expected/gms_debugger_server2.out index e3106e5bba794a283ace6839520d9744104954e8..16aa23cf3293f3b9818e3646c28bf830523f10bc 100644 --- a/contrib/gms_debug/expected/gms_debugger_server2.out +++ b/contrib/gms_debug/expected/gms_debugger_server2.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test2 cascade; NOTICE: schema "gms_debugger_test2" does not exist, skipping create schema gms_debugger_test2; @@ -15,10 +16,10 @@ begin end; / -- start debug -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-1'); initialize ------------- - datanode1-0 + datanode1-1 (1 row) select pg_sleep(1); @@ -36,11 +37,21 @@ select * from test_debug2(); -- start debug - 2nd run - to be aborted select * from test_debug2(); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug2() line 2 at SQL statement + test_debug2 +------------- + +(1 row) + +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test2 cascade; -NOTICE: drop cascades to 4 other objects +NOTICE: drop cascades to 5 other objects DETAIL: drop cascades to table tb1 drop cascades to function test_debug2() drop cascades to function gms_continue() drop cascades to function gms_next() +drop cascades to function gms_step() diff --git a/contrib/gms_debug/expected/gms_debugger_server3.out b/contrib/gms_debug/expected/gms_debugger_server3.out index 245965bf22bfe15015d742866856f3c346e27c19..b683f59b51ae548ac229d7a2a2f6270d61aaae2f 100644 --- a/contrib/gms_debug/expected/gms_debugger_server3.out +++ b/contrib/gms_debug/expected/gms_debugger_server3.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test3 cascade; NOTICE: schema "gms_debugger_test3" does not exist, skipping create schema gms_debugger_test3; @@ -23,10 +24,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-2'); initialize ------------- - datanode1-0 + datanode1-2 (1 row) select pg_sleep(1); @@ -44,10 +45,20 @@ select * from test_debug3(1); -- start debug - 2nd run - to be aborted select * from test_debug3(1); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug3(integer) line 13 at assignment + test_debug3 +------------- + 101 +(1 row) + +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test3 cascade; -NOTICE: drop cascades to 3 other objects +NOTICE: drop cascades to 4 other objects DETAIL: drop cascades to function test_debug3(integer) -drop cascades to function gms_next() drop cascades to function gms_continue() +drop cascades to function gms_next() +drop cascades to function gms_step() diff --git a/contrib/gms_debug/expected/gms_debugger_server4.out b/contrib/gms_debug/expected/gms_debugger_server4.out index 16213e6d24901100a5a004676308a7b29e3619b6..cca885612a61efcf44228be7f6cc0b6ea4dcf122 100644 --- a/contrib/gms_debug/expected/gms_debugger_server4.out +++ b/contrib/gms_debug/expected/gms_debugger_server4.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test4 cascade; NOTICE: schema "gms_debugger_test4" does not exist, skipping create schema gms_debugger_test4; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-3'); initialize ------------- - datanode1-0 + datanode1-3 (1 row) select pg_sleep(1); @@ -102,13 +103,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement (1 row) -- test with client error in exception -select * from test_debug4(1); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug4(integer) line 14 at assignment +-- select * from test_debug4(1); +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test4 cascade; -NOTICE: drop cascades to 5 other objects +NOTICE: drop cascades to 6 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) +drop cascades to function gms_continue() drop cascades to function test_debug4(integer) +drop cascades to function gms_next() drop cascades to function gms_step() -drop cascades to function gms_continue() diff --git a/contrib/gms_debug/expected/gms_debugger_server5.out b/contrib/gms_debug/expected/gms_debugger_server5.out index c3518210daa4a2a83c8bd3e48e52a02e5b9fdd0d..f5b6a3f5f1d6b22f929374d402777e2b0a616068 100644 --- a/contrib/gms_debug/expected/gms_debugger_server5.out +++ b/contrib/gms_debug/expected/gms_debugger_server5.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test5 cascade; NOTICE: schema "gms_debugger_test5" does not exist, skipping create schema gms_debugger_test5; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-4'); initialize ------------- - datanode1-0 + datanode1-4 (1 row) select pg_sleep(1); @@ -111,12 +112,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement 101 (1 row) +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test5 cascade; NOTICE: drop cascades to 7 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) -drop cascades to function test_debug4(integer) drop cascades to function gms_continue() -drop cascades to function gms_step() +drop cascades to function test_debug4(integer) drop cascades to function gms_next() +drop cascades to function gms_step() drop cascades to function gms_finish() diff --git a/contrib/gms_debug/expected/gms_debugger_server6.out b/contrib/gms_debug/expected/gms_debugger_server6.out index 1a78fa213dd2994606b106cefab4335a894ddac2..6c36b96df98443571b0366b5fd76b57b35242aba 100644 --- a/contrib/gms_debug/expected/gms_debugger_server6.out +++ b/contrib/gms_debug/expected/gms_debugger_server6.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test6 cascade; NOTICE: schema "gms_debugger_test6" does not exist, skipping create schema gms_debugger_test6; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-5'); initialize ------------- - datanode1-0 + datanode1-5 (1 row) select pg_sleep(1); @@ -102,13 +103,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement (1 row) -- test with client error in exception -select * from test_debug4(1); -ERROR: Debug Comm 0 has been released or not turned on yet. +-- select * from test_debug4(1); +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test6 cascade; NOTICE: drop cascades to 6 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) -drop cascades to function test_debug4(integer) drop cascades to function gms_continue() +drop cascades to function test_debug4(integer) drop cascades to function gms_breakpoint(text,integer) drop cascades to function gms_finish() diff --git a/contrib/gms_debug/gms_debug--1.0.sql b/contrib/gms_debug/gms_debug--1.0.sql index b7a50dff8c52c8da9fe49d34e0c06939faf88674..597922c54f27b75cd7b5afc554aea3594e14e777 100644 --- a/contrib/gms_debug/gms_debug--1.0.sql +++ b/contrib/gms_debug/gms_debug--1.0.sql @@ -273,30 +273,6 @@ return 8; END; $$ language plpgsql IMMUTABLE; -CREATE FUNCTION gms_debug.break_return() RETURNS int AS $$ -BEGIN -return 16; -END; -$$ language plpgsql IMMUTABLE; - -CREATE FUNCTION gms_debug.break_exception() RETURNS int AS $$ -BEGIN -return 32; -END; -$$ language plpgsql IMMUTABLE; - -CREATE FUNCTION gms_debug.break_handler() RETURNS int AS $$ -BEGIN -return 64; -END; -$$ language plpgsql IMMUTABLE; - -CREATE FUNCTION gms_debug.abort_execution() RETURNS int AS $$ -BEGIN -return 128; -END; -$$ language plpgsql IMMUTABLE; - CREATE FUNCTION gms_debug.reason_none() RETURNS int AS $$ BEGIN return 0; diff --git a/contrib/gms_debug/gms_debug.cpp b/contrib/gms_debug/gms_debug.cpp index d8353e958b945ffd79ab26e219ea8d52012779c4..dd7e030e64fab67cb111dcfe0a56f1f3df20686e 100644 --- a/contrib/gms_debug/gms_debug.cpp +++ b/contrib/gms_debug/gms_debug.cpp @@ -82,7 +82,7 @@ static bool GMSInterfaceCheck(const char* funcname, bool needAttach) #endif if (!superuser() && !is_member_of_role(GetUserId(), DEFAULT_ROLE_PLDEBUGGER)) { ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("must be system admin to execute", funcname)))); + (errmsg("must be system admin to execute %s", funcname)))); return false; } if (u_sess->plsql_cxt.debug_client != NULL && needAttach){ @@ -100,7 +100,7 @@ static bool GMSInterfaceCheck(const char* funcname, bool needAttach) debuglock.unLock(); ereport(ERROR, (errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED), - errmsg("must attach a execute func before execute", funcname), + errmsg("must attach a execute func before execute %s", funcname), errhint("attach a execute func and retry"))); return false; } @@ -119,10 +119,8 @@ static bool GMSInterfaceCheck(const char* funcname, bool needAttach) Datum gms_debug_initialize(PG_FUNCTION_ARGS) { StringInfoData buf; - bool found = false; // TupleDesc tupdesc; int commIdx = -1; - const int DEBUG_TURN_ON_ATTR_NUM = 1; GMSInterfaceCheck("gms_debug.initialize", false); if (unlikely(u_sess->plsql_cxt.debug_proc_htbl == NULL)) { init_pldebug_htcl(); @@ -133,24 +131,25 @@ Datum gms_debug_initialize(PG_FUNCTION_ARGS) char *debug_session_id = text_to_cstring(PG_GETARG_VARCHAR_PP(0)); char *psave = NULL; char *nodename = strtok_r(debug_session_id, "-", &psave); + if (nodename == NULL) { + ereport(ERROR, (errmsg("invalid debug_session_id %s", debug_session_id))); + } char *fir = AssignStr(psave, false); char *new_fir = TrimStr(fir); if (new_fir == NULL) { - ereport(ERROR, ( (errmsg("invalid debug_session_id %s", debug_session_id)))); + ereport(ERROR, (errmsg("invalid debug_session_id %s", debug_session_id))); } commIdx = pg_strtoint32(new_fir); if (commIdx < 0 || commIdx >= PG_MAX_DEBUG_CONN) { - ereport(ERROR, ( (errmsg("invalid debug_session_id %s", debug_session_id)))); + ereport(ERROR, (errmsg("invalid debug_session_id %s", debug_session_id))); } if (!AcquireDebugCommIdx(commIdx)) { - ereport(ERROR, - ( errmsg("debug_session_id %s has already been used", debug_session_id))); + ereport(ERROR, (errmsg("debug_session_id %s has already been used", debug_session_id))); } } else { commIdx = GetValidDebugCommIdx(); if (commIdx == -1) { - ereport(ERROR, ( - (errmsg("max debug function is %d, turn_on function is out of range", PG_MAX_DEBUG_CONN)))); + ereport(ERROR, (errmsg("max debug function is %d, turn_on function is out of range", PG_MAX_DEBUG_CONN))); } } @@ -170,7 +169,6 @@ Datum gms_debug_attach_session(PG_FUNCTION_ARGS) { GMSInterfaceCheck("gms_debug.attach_session", false); char *debug_session_id = text_to_cstring(PG_GETARG_VARCHAR_PP(0)); - int32 diagnostics = PG_GETARG_INT32(1); char *psave = NULL; int commidx = -1; char *nodename = strtok_r(debug_session_id, "-", &psave); @@ -207,10 +205,6 @@ Datum gms_debug_set_breakpoint(PG_FUNCTION_ARGS) const int DEBUG_BREAK_TUPLE_ATTR_NUM = 2; Oid funcOid = PG_GETARG_OID(0); int32 lineno = PG_GETARG_INT32(1); - int32 fuzzy = PG_GETARG_INT32(2); - int32 iterations = PG_GETARG_INT32(3); - int headerlines = 0; - uint32 nLine = 0; CodeLine *lines = NULL; CodeLine cl; cl.code = NULL; @@ -259,7 +253,7 @@ Datum gms_debug_set_breakpoint(PG_FUNCTION_ARGS) } else { ereport(WARNING, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("pl debugger only support function with language plpgsql"), - errdetail("the given function is %lu", funcOid), + errdetail("the given function is %u", funcOid), errcause("pl debugger do not support the given function"), erraction("use pl debugger with only plpgsql function"))); values[0] = Int32GetDatum(ERROR_BAD_HANDLE); @@ -412,7 +406,6 @@ static Datum build_runtime_info(DebugClientInfo *client, int err_code) * (a mask of the events that are of interest) to Probe in the target process. * It tells Probe to continue execution of the target process, * and it waits until the target process runs to completion or signals an event. - * If info_requested is not NULL, then calls GET_RUNTIME_INFO. */ Datum gms_debug_continue(PG_FUNCTION_ARGS) { @@ -440,10 +433,9 @@ Datum gms_debug_continue(PG_FUNCTION_ARGS) return build_runtime_info(client,err_code); } int32 breakflags = PG_GETARG_INT32(0); - int32 info_requested = PG_GETARG_INT32(1); char action; std::bitset<DEBUG_ACTION_ATTR_NUM> breakflags_bitset(breakflags); - for (int i = 0; i < breakflags_bitset.size(); ++i) { + for (std::size_t i = 0; i < breakflags_bitset.size(); ++i) { if (breakflags_bitset.test(i)) { action = actions[i]; } @@ -455,8 +447,6 @@ Datum gms_debug_continue(PG_FUNCTION_ARGS) /*** * This function returns information about the current program. - * It is only needed if the info_requested parameter to SYNCHRONIZE - * or CONTINUE was set to 0. */ Datum gms_debug_get_runtime_info(PG_FUNCTION_ARGS) { @@ -475,7 +465,6 @@ Datum gms_debug_get_runtime_info(PG_FUNCTION_ARGS) err_code = ERROR_FUNC_NOT_ATTACHED; return build_runtime_info(client, err_code); } - int32 info_requested = PG_GETARG_INT32(0); debug_client_send_msg(client, GMS_DEBUG_RUNTIMEINFO_HEADER, NULL, 0); debug_client_rec_msg(client); return build_runtime_info(client, err_code); @@ -493,6 +482,21 @@ Datum gms_debug_off(PG_FUNCTION_ARGS) SetDebugCommGmsUsed(u_sess->plsql_cxt.gms_debug_idx, false); u_sess->plsql_cxt.gms_debug_idx = -1; + if ((u_sess->plsql_cxt.debug_proc_htbl == NULL)) { + PG_RETURN_VOID(); + } + + PlDebugEntry* elem = NULL; + HASH_SEQ_STATUS hash_seq; + hash_seq_init(&hash_seq, u_sess->plsql_cxt.debug_proc_htbl); + + /* Fetch all debugger entry info from the hash table */ + while ((elem = (PlDebugEntry*)hash_seq_search(&hash_seq)) != NULL) { + if (elem->func && elem->func->debug) { + clean_up_debug_server(elem->func->debug, true, false); + } + } + PG_RETURN_VOID(); } @@ -505,15 +509,6 @@ Datum gms_debug_off(PG_FUNCTION_ARGS) */ Datum gms_debug_detach_session(PG_FUNCTION_ARGS) { - DebugClientInfo *client = u_sess->plsql_cxt.debug_client; - if(client == nullptr) { - ereport(ERROR, - (errcode(ERRCODE_TARGET_SERVER_NOT_ATTACHED), - errmsg("error happened in debug session, please reattach target session and try"))); - } - GMSInterfaceCheck("gms_debug.detach_session",true); - debug_client_send_msg(client, DEBUG_ABORT_HEADER, NULL, 0); - debug_client_rec_msg(client); clean_up_debug_client(); PG_RETURN_VOID(); } diff --git a/contrib/gms_debug/sql/gms_debugger_client1.sql b/contrib/gms_debug/sql/gms_debugger_client1.sql index 9e872bb7e6efe37933320b6915cce937001c1127..07dfcb226ee2ee9c3cf7759b59a8b721b02162f3 100644 --- a/contrib/gms_debug/sql/gms_debugger_client1.sql +++ b/contrib/gms_debug/sql/gms_debugger_client1.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test1; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) returns void as $$ @@ -55,7 +56,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -70,7 +71,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -85,7 +86,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -111,7 +112,7 @@ end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-0', 1); select pg_sleep(3); diff --git a/contrib/gms_debug/sql/gms_debugger_client2.sql b/contrib/gms_debug/sql/gms_debugger_client2.sql index 20ca1912f4d7e1552f49761860046c79bda2d7e2..2efd2051238164f9ada34f27c84f8a79afc16221 100644 --- a/contrib/gms_debug/sql/gms_debugger_client2.sql +++ b/contrib/gms_debug/sql/gms_debugger_client2.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test2; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +42,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -56,7 +57,22 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; + +CREATE or REPLACE FUNCTION gms_step() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +83,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-1'); select pg_sleep(3); @@ -79,4 +95,6 @@ select gms_next(); select gms_continue(); +select gms_continue(); + select gms_debug.detach_session(); diff --git a/contrib/gms_debug/sql/gms_debugger_client3.sql b/contrib/gms_debug/sql/gms_debugger_client3.sql index 9f067ba961c8843dad1285ba1bd858cca88ff86a..02f3d21fbc1f400553cefc6ae0124fd18d621d74 100644 --- a/contrib/gms_debug/sql/gms_debugger_client3.sql +++ b/contrib/gms_debug/sql/gms_debugger_client3.sql @@ -34,6 +34,22 @@ BEGIN END $$; set search_path = gms_debugger_test3; +set behavior_compat_options='proc_outparam_override'; + +CREATE or REPLACE FUNCTION gms_continue() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; CREATE or REPLACE FUNCTION gms_next() returns void as $$ @@ -41,7 +57,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +66,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +83,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-2'); select pg_sleep(3); @@ -79,4 +95,6 @@ select gms_continue(); select gms_next(); +select gms_continue(); + select gms_debug.detach_session(); diff --git a/contrib/gms_debug/sql/gms_debugger_client4.sql b/contrib/gms_debug/sql/gms_debugger_client4.sql index fdbd708293423e119693ef4c389389010e86c445..c7eea0c714b186362b82dcc0ef8757c37695c0ab 100644 --- a/contrib/gms_debug/sql/gms_debugger_client4.sql +++ b/contrib/gms_debug/sql/gms_debugger_client4.sql @@ -34,14 +34,16 @@ BEGIN END $$; set search_path = gms_debugger_test4; +set behavior_compat_options='proc_outparam_override'; -CREATE or REPLACE FUNCTION gms_step() + +CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +52,28 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_next() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; + +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +84,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-3'); select pg_sleep(3); diff --git a/contrib/gms_debug/sql/gms_debugger_client5.sql b/contrib/gms_debug/sql/gms_debugger_client5.sql index c3b848c5b3a114a8b5368a8807a987a37c790adb..ee7ebfc8b67b46a95a35c5beb3f5a7372dbf9a8d 100644 --- a/contrib/gms_debug/sql/gms_debugger_client5.sql +++ b/contrib/gms_debug/sql/gms_debugger_client5.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test5; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +42,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +51,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_step() +CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -65,13 +66,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_next() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -86,7 +87,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -97,7 +98,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-4'); select pg_sleep(3); diff --git a/contrib/gms_debug/sql/gms_debugger_client6.sql b/contrib/gms_debug/sql/gms_debugger_client6.sql index c5fd2985b958854c8456ea5813336cbbff672b64..13730de1bb69b62b7fefd7de64731bd107aa34f7 100644 --- a/contrib/gms_debug/sql/gms_debugger_client6.sql +++ b/contrib/gms_debug/sql/gms_debugger_client6.sql @@ -34,6 +34,8 @@ BEGIN END $$; set search_path = gms_debugger_test6; +set behavior_compat_options='proc_outparam_override'; + CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +43,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -70,7 +72,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -79,9 +81,8 @@ begin end; $$ LANGUAGE plpgsql; - -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-5'); select pg_sleep(3); diff --git a/contrib/gms_debug/sql/gms_debugger_client7.sql b/contrib/gms_debug/sql/gms_debugger_client7.sql deleted file mode 100644 index c073663ca9e47a6838dc66ce5cd119c0289273ac..0000000000000000000000000000000000000000 --- a/contrib/gms_debug/sql/gms_debugger_client7.sql +++ /dev/null @@ -1,103 +0,0 @@ --- wait for server establishment - -CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension() -RETURNS BOOLEAN AS $$ -DECLARE - extension_exists BOOLEAN; -BEGIN - -- 初始化变量 - extension_exists := FALSE; - - -- 循环查询扩展是否存在 - WHILE NOT extension_exists LOOP - -- 查询扩展是否存在 - PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug'; - IF FOUND THEN - -- 如果扩展存在,则退出循环 - extension_exists := TRUE; - ELSE - -- 如果扩展不存在,则等待一段时间再重试 - PERFORM pg_sleep(1); -- 等待1秒 - END IF; - END LOOP; - - -- 返回扩展存在的标志 - RETURN extension_exists; -END; -$$ LANGUAGE plpgsql; - -DO $$ -BEGIN - IF wait_for_gms_debug_extension() THEN - -- 扩展存在,执行下一步操作 - END IF; -END $$; - -set search_path = gms_debugger_test7; - -CREATE or REPLACE FUNCTION gms_step() -returns void as $$ -declare - run_info gms_debug.runtime_info; - ret binary_integer; -begin - ret := gms_debug.continue(run_info, 4, 2); - RAISE NOTICE 'breakpoint= %', run_info.breakpoint; - RAISE NOTICE 'stackdepth= %', run_info.stackdepth; - RAISE NOTICE 'line= %', run_info.line#; - RAISE NOTICE 'reason= %', run_info.reason; - RAISE NOTICE 'ret= %',ret; -end; -$$ LANGUAGE plpgsql; - -CREATE or REPLACE FUNCTION gms_continue() -returns void as $$ -declare - run_info gms_debug.runtime_info; - ret binary_integer; -begin - ret := gms_debug.continue(run_info, 0, 2); - RAISE NOTICE 'breakpoint= %', run_info.breakpoint; - RAISE NOTICE 'stackdepth= %', run_info.stackdepth; - RAISE NOTICE 'line= %', run_info.line#; - RAISE NOTICE 'reason= %', run_info.reason; - RAISE NOTICE 'ret= %',ret; -end; -$$ LANGUAGE plpgsql; - -CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) -returns void as $$ -declare - pro_info gms_debug.program_info; - bkline binary_integer; - ret binary_integer; -begin - pro_info.name := funcname; - ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1); - RAISE NOTICE 'ret= %', ret; - RAISE NOTICE 'ret= %', bkline; -end; -$$ LANGUAGE plpgsql; - --- attach debug server -select * from gms_debug.attach_session('datanode1-0'); - -select pg_sleep(3); - -select gms_breakpoint('test_debug_recursive', 5); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_continue(); - -select gms_continue(); - -select gms_debug.detach_session(); diff --git a/contrib/gms_debug/sql/gms_debugger_server1.sql b/contrib/gms_debug/sql/gms_debugger_server1.sql index 8a47326ee0788be651aeff16dda3f7224ff6dc2a..e9ebebb34b3d3d4bd737720c1cd98694bab84678 100644 --- a/contrib/gms_debug/sql/gms_debugger_server1.sql +++ b/contrib/gms_debug/sql/gms_debugger_server1.sql @@ -80,7 +80,7 @@ select * from gms_debug.attach_session('datanode1-0'); -- turn off without turn on select * from gms_debug.debug_off(); -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-0'); select pg_sleep(1); diff --git a/contrib/gms_debug/sql/gms_debugger_server2.sql b/contrib/gms_debug/sql/gms_debugger_server2.sql index 559a9cf5735d81f700df2dfd4385c4f9bc8a945f..2da9b0c3bd132801c0a8d24459a0a67b43a8b087 100644 --- a/contrib/gms_debug/sql/gms_debugger_server2.sql +++ b/contrib/gms_debug/sql/gms_debugger_server2.sql @@ -17,7 +17,7 @@ end; -- start debug -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-1'); select pg_sleep(1); diff --git a/contrib/gms_debug/sql/gms_debugger_server3.sql b/contrib/gms_debug/sql/gms_debugger_server3.sql index 830599f5a09b5708ee5698cbeef1d856faa485a8..dd495943f91c6ffc05ff837f3a725bd249c0da4a 100644 --- a/contrib/gms_debug/sql/gms_debugger_server3.sql +++ b/contrib/gms_debug/sql/gms_debugger_server3.sql @@ -24,7 +24,7 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-2'); select pg_sleep(1); diff --git a/contrib/gms_debug/sql/gms_debugger_server4.sql b/contrib/gms_debug/sql/gms_debugger_server4.sql index 607e20d769492f9143b84c77a09508f03cb84966..5ea8fc748a4187194ad593ca0cb42f05c0e6ac6f 100644 --- a/contrib/gms_debug/sql/gms_debugger_server4.sql +++ b/contrib/gms_debug/sql/gms_debugger_server4.sql @@ -83,14 +83,14 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-3'); select pg_sleep(1); select * from test_debug4(1); -- test with client error in exception -select * from test_debug4(1); +-- select * from test_debug4(1); select * from gms_debug.debug_off(); diff --git a/contrib/gms_debug/sql/gms_debugger_server5.sql b/contrib/gms_debug/sql/gms_debugger_server5.sql index 1a4ac60b9169c8f5d5bd6c4291d48654fa457cdf..4134e5070366a09e692c553906f1552f1fb357f4 100644 --- a/contrib/gms_debug/sql/gms_debugger_server5.sql +++ b/contrib/gms_debug/sql/gms_debugger_server5.sql @@ -83,7 +83,7 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-4'); select pg_sleep(1); diff --git a/contrib/gms_debug/sql/gms_debugger_server6.sql b/contrib/gms_debug/sql/gms_debugger_server6.sql index d1ba000296d93e1af7eda73b074dd4cd3514d6ed..bf8108fa1bc7899ff49e1cf587cb099d09f6503d 100644 --- a/contrib/gms_debug/sql/gms_debugger_server6.sql +++ b/contrib/gms_debug/sql/gms_debugger_server6.sql @@ -83,14 +83,14 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-5'); select pg_sleep(1); select * from test_debug4(1); -- test with client error in exception -select * from test_debug4(1); +-- select * from test_debug4(1); select * from gms_debug.debug_off(); diff --git a/contrib/gms_debug/sql/gms_debugger_server7.sql b/contrib/gms_debug/sql/gms_debugger_server7.sql deleted file mode 100644 index 3d1625c6a03cad195a7a5b16567c19020dc44118..0000000000000000000000000000000000000000 --- a/contrib/gms_debug/sql/gms_debugger_server7.sql +++ /dev/null @@ -1,29 +0,0 @@ --- setups -create extension if not exists gms_debug; -drop schema if exists gms_debugger_test7 cascade; -create schema gms_debugger_test7; -set search_path = gms_debugger_test7; - -create or replace function test_debug_recursive (ct int, pr int) -returns table (counter int, product int) -language plpgsql -as $$ -begin - return query select ct, pr; - if ct < 5 then - return query select * from test_debug_recursive(ct+ 1, pr * (ct+ 1)); - end if; -end $$; - -select * from gms_debug.initialize(); - -select pg_sleep(1); - -select * from test_debug_recursive (1, 1); - --- test with client error in exception -select * from test_debug_recursive (1, 1); - -select * from gms_debug.debug_off(); - -drop schema gms_debugger_test7 cascade; diff --git a/src/common/pl/plpgsql/src/pl_debugger.cpp b/src/common/pl/plpgsql/src/pl_debugger.cpp index d209f3f1d4324d709df3874fe68b5203119dcb80..4acee54f11a29726e353bdc21236270a51751ecb 100644 --- a/src/common/pl/plpgsql/src/pl_debugger.cpp +++ b/src/common/pl/plpgsql/src/pl_debugger.cpp @@ -1540,9 +1540,12 @@ void add_gms_debug_func(Oid funcOid, int commIdx) void ReleaseDebugCommIdx(int idx) { - if (idx < 0 || idx >= PG_MAX_DEBUG_CONN) + if (idx < 0 || idx >= PG_MAX_DEBUG_CONN) { return; - Assert(g_instance.pldebug_cxt.debug_comm[idx].Used()); + } + if (!g_instance.pldebug_cxt.debug_comm[idx].Used()) { + return; + } PlDebuggerComm* comm = &g_instance.pldebug_cxt.debug_comm[idx]; AutoMutexLock debuglock(&comm->mutex); debuglock.lock(); diff --git a/src/test/regress/expected/gms_debugger_client1.out b/src/test/regress/expected/gms_debugger_client1.out index b02d884ff661983ac9563b56118537a5f83c9a10..61e9c5473002b54c1ebf0d0ebe158de46af8df65 100644 --- a/src/test/regress/expected/gms_debugger_client1.out +++ b/src/test/regress/expected/gms_debugger_client1.out @@ -31,6 +31,7 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test1; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) returns void as $$ declare @@ -50,7 +51,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -64,7 +65,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -78,7 +79,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -101,7 +102,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-0', 1); attach_session ---------------- @@ -266,4 +267,8 @@ CONTEXT: referenced column: gms_continue (1 row) select gms_debug.detach_session(); -connection to server was lost + detach_session +---------------- + +(1 row) + diff --git a/src/test/regress/expected/gms_debugger_client2.out b/src/test/regress/expected/gms_debugger_client2.out index 8455178587d5b0bca11165c88c25651155a00e7e..2843e9afc725a118281795c16f72cbd01e38b082 100644 --- a/src/test/regress/expected/gms_debugger_client2.out +++ b/src/test/regress/expected/gms_debugger_client2.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test2; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -51,7 +52,21 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; +CREATE or REPLACE FUNCTION gms_step() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-1'); attach_session ---------------- @@ -136,6 +151,22 @@ CONTEXT: referenced column: gms_continue (1 row) +select gms_continue(); +NOTICE: breakpoint= -1 +CONTEXT: referenced column: gms_continue +NOTICE: stackdepth= 0 +CONTEXT: referenced column: gms_continue +NOTICE: line= 0 +CONTEXT: referenced column: gms_continue +NOTICE: reason= 0 +CONTEXT: referenced column: gms_continue +NOTICE: ret= 0 +CONTEXT: referenced column: gms_continue + gms_continue +-------------- + +(1 row) + select gms_debug.detach_session(); detach_session ---------------- diff --git a/src/test/regress/expected/gms_debugger_client3.out b/src/test/regress/expected/gms_debugger_client3.out index 58f388db4ea4f16bea1756c37677ce22f56ea327..c43ef8c1acc8ac48edf922a244c54ed13ddefcfc 100644 --- a/src/test/regress/expected/gms_debugger_client3.out +++ b/src/test/regress/expected/gms_debugger_client3.out @@ -31,13 +31,28 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test3; +set behavior_compat_options='proc_outparam_override'; +CREATE or REPLACE FUNCTION gms_continue() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +60,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-2'); attach_session ---------------- @@ -136,6 +151,22 @@ CONTEXT: referenced column: gms_next (1 row) +select gms_continue(); +NOTICE: breakpoint= -1 +CONTEXT: referenced column: gms_continue +NOTICE: stackdepth= 0 +CONTEXT: referenced column: gms_continue +NOTICE: line= 14 +CONTEXT: referenced column: gms_continue +NOTICE: reason= 0 +CONTEXT: referenced column: gms_continue +NOTICE: ret= 0 +CONTEXT: referenced column: gms_continue + gms_continue +-------------- + +(1 row) + select gms_debug.detach_session(); detach_session ---------------- diff --git a/src/test/regress/expected/gms_debugger_client4.out b/src/test/regress/expected/gms_debugger_client4.out index 0024bb853460ece5650153935eb5b860a813c7a8..c7e6cfe58fba875ef8773b76e5e198745211f97d 100644 --- a/src/test/regress/expected/gms_debugger_client4.out +++ b/src/test/regress/expected/gms_debugger_client4.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test4; -CREATE or REPLACE FUNCTION gms_step() +set behavior_compat_options='proc_outparam_override'; +CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +46,27 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_next() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -60,7 +75,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-3'); attach_session ---------------- diff --git a/src/test/regress/expected/gms_debugger_client5.out b/src/test/regress/expected/gms_debugger_client5.out index 6a030edd3fa84b2325fd2f9dc0c1f05c6584d3e7..15d2f5dbb50afc2267d0b1b5002d3666b4ff52ec 100644 --- a/src/test/regress/expected/gms_debugger_client5.out +++ b/src/test/regress/expected/gms_debugger_client5.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test5; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -45,13 +46,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_step() +CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -59,13 +60,13 @@ begin RAISE NOTICE 'ret= %',ret; end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_next() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -79,7 +80,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -88,7 +89,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-4'); attach_session ---------------- @@ -197,4 +198,8 @@ CONTEXT: referenced column: gms_finish (1 row) select gms_debug.detach_session(); -connection to server was lost + detach_session +---------------- + +(1 row) + diff --git a/src/test/regress/expected/gms_debugger_client6.out b/src/test/regress/expected/gms_debugger_client6.out index f58a3ac9c47733ac542aea59187dd7f641638880..0133050820a476c753710ca23a5f8ad170cfbe3f 100644 --- a/src/test/regress/expected/gms_debugger_client6.out +++ b/src/test/regress/expected/gms_debugger_client6.out @@ -31,13 +31,14 @@ BEGIN END IF; END $$; set search_path = gms_debugger_test6; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -64,7 +65,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -73,7 +74,7 @@ begin end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-5'); attach_session ---------------- diff --git a/src/test/regress/expected/gms_debugger_server1.out b/src/test/regress/expected/gms_debugger_server1.out index 5e9758952454d7382188e388f27f027630080d7f..f37430ab5a4032c45332c15c117e5a4e4be22134 100644 --- a/src/test/regress/expected/gms_debugger_server1.out +++ b/src/test/regress/expected/gms_debugger_server1.out @@ -132,8 +132,12 @@ select * from gms_debug.attach_session('datanode1-0'); ERROR: target session should be init first. -- turn off without turn on select * from gms_debug.debug_off(); -ERROR: target session should be init first -select * from gms_debug.initialize(); + debug_off +----------- + +(1 row) + +select * from gms_debug.initialize('datanode1-0'); initialize ------------- datanode1-0 @@ -169,6 +173,12 @@ INFO: cnt is 3 1 | Happy Children's Day! | Tue Jun 01 00:00:00 2021 (6 rows) +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test1 cascade; NOTICE: drop cascades to 8 other objects DETAIL: drop cascades to table test diff --git a/src/test/regress/expected/gms_debugger_server2.out b/src/test/regress/expected/gms_debugger_server2.out index e3106e5bba794a283ace6839520d9744104954e8..16aa23cf3293f3b9818e3646c28bf830523f10bc 100644 --- a/src/test/regress/expected/gms_debugger_server2.out +++ b/src/test/regress/expected/gms_debugger_server2.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test2 cascade; NOTICE: schema "gms_debugger_test2" does not exist, skipping create schema gms_debugger_test2; @@ -15,10 +16,10 @@ begin end; / -- start debug -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-1'); initialize ------------- - datanode1-0 + datanode1-1 (1 row) select pg_sleep(1); @@ -36,11 +37,21 @@ select * from test_debug2(); -- start debug - 2nd run - to be aborted select * from test_debug2(); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug2() line 2 at SQL statement + test_debug2 +------------- + +(1 row) + +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test2 cascade; -NOTICE: drop cascades to 4 other objects +NOTICE: drop cascades to 5 other objects DETAIL: drop cascades to table tb1 drop cascades to function test_debug2() drop cascades to function gms_continue() drop cascades to function gms_next() +drop cascades to function gms_step() diff --git a/src/test/regress/expected/gms_debugger_server3.out b/src/test/regress/expected/gms_debugger_server3.out index 245965bf22bfe15015d742866856f3c346e27c19..b683f59b51ae548ac229d7a2a2f6270d61aaae2f 100644 --- a/src/test/regress/expected/gms_debugger_server3.out +++ b/src/test/regress/expected/gms_debugger_server3.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test3 cascade; NOTICE: schema "gms_debugger_test3" does not exist, skipping create schema gms_debugger_test3; @@ -23,10 +24,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-2'); initialize ------------- - datanode1-0 + datanode1-2 (1 row) select pg_sleep(1); @@ -44,10 +45,20 @@ select * from test_debug3(1); -- start debug - 2nd run - to be aborted select * from test_debug3(1); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug3(integer) line 13 at assignment + test_debug3 +------------- + 101 +(1 row) + +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test3 cascade; -NOTICE: drop cascades to 3 other objects +NOTICE: drop cascades to 4 other objects DETAIL: drop cascades to function test_debug3(integer) -drop cascades to function gms_next() drop cascades to function gms_continue() +drop cascades to function gms_next() +drop cascades to function gms_step() diff --git a/src/test/regress/expected/gms_debugger_server4.out b/src/test/regress/expected/gms_debugger_server4.out index 16213e6d24901100a5a004676308a7b29e3619b6..cca885612a61efcf44228be7f6cc0b6ea4dcf122 100644 --- a/src/test/regress/expected/gms_debugger_server4.out +++ b/src/test/regress/expected/gms_debugger_server4.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test4 cascade; NOTICE: schema "gms_debugger_test4" does not exist, skipping create schema gms_debugger_test4; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-3'); initialize ------------- - datanode1-0 + datanode1-3 (1 row) select pg_sleep(1); @@ -102,13 +103,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement (1 row) -- test with client error in exception -select * from test_debug4(1); -ERROR: receive abort message -CONTEXT: PL/pgSQL function test_debug4(integer) line 14 at assignment +-- select * from test_debug4(1); +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test4 cascade; -NOTICE: drop cascades to 5 other objects +NOTICE: drop cascades to 6 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) +drop cascades to function gms_continue() drop cascades to function test_debug4(integer) +drop cascades to function gms_next() drop cascades to function gms_step() -drop cascades to function gms_continue() diff --git a/src/test/regress/expected/gms_debugger_server5.out b/src/test/regress/expected/gms_debugger_server5.out index c3518210daa4a2a83c8bd3e48e52a02e5b9fdd0d..f5b6a3f5f1d6b22f929374d402777e2b0a616068 100644 --- a/src/test/regress/expected/gms_debugger_server5.out +++ b/src/test/regress/expected/gms_debugger_server5.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test5 cascade; NOTICE: schema "gms_debugger_test5" does not exist, skipping create schema gms_debugger_test5; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-4'); initialize ------------- - datanode1-0 + datanode1-4 (1 row) select pg_sleep(1); @@ -111,12 +112,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement 101 (1 row) +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test5 cascade; NOTICE: drop cascades to 7 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) -drop cascades to function test_debug4(integer) drop cascades to function gms_continue() -drop cascades to function gms_step() +drop cascades to function test_debug4(integer) drop cascades to function gms_next() +drop cascades to function gms_step() drop cascades to function gms_finish() diff --git a/src/test/regress/expected/gms_debugger_server6.out b/src/test/regress/expected/gms_debugger_server6.out index 1a78fa213dd2994606b106cefab4335a894ddac2..6c36b96df98443571b0366b5fd76b57b35242aba 100644 --- a/src/test/regress/expected/gms_debugger_server6.out +++ b/src/test/regress/expected/gms_debugger_server6.out @@ -1,5 +1,6 @@ -- setups create extension if not exists gms_debug; +NOTICE: extension "gms_debug" already exists in schema "public", skipping drop schema if exists gms_debugger_test6 cascade; NOTICE: schema "gms_debugger_test6" does not exist, skipping create schema gms_debugger_test6; @@ -80,10 +81,10 @@ BEGIN return b; END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-5'); initialize ------------- - datanode1-0 + datanode1-5 (1 row) select pg_sleep(1); @@ -102,13 +103,18 @@ PL/pgSQL function test_debug4(integer) line 7 at SQL statement (1 row) -- test with client error in exception -select * from test_debug4(1); -ERROR: Debug Comm 0 has been released or not turned on yet. +-- select * from test_debug4(1); +select * from gms_debug.debug_off(); + debug_off +----------- + +(1 row) + drop schema gms_debugger_test6 cascade; NOTICE: drop cascades to 6 other objects DETAIL: drop cascades to table test drop cascades to function test_debug(integer) -drop cascades to function test_debug4(integer) drop cascades to function gms_continue() +drop cascades to function test_debug4(integer) drop cascades to function gms_breakpoint(text,integer) drop cascades to function gms_finish() diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 02d900b673aaffd6165daf04a6bbb40347e92729..0701e2f01cef495e2b87ff835e33745944b8535a 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -85,6 +85,7 @@ test: plpgsql_sql_with_proc_keyword test: plsql_show_all_error b_pg_plsql_show_all_error test: pldeveloper_gs_source test: index_advisor +#test: pl_debugger_server pl_debugger_client #test: gms_debugger_server1 gms_debugger_client1 test: update_for_wait_s1 update_for_wait_s2 test: plan_hint plan_hint_set plan_hint_no_expand plan_hint_iud null_test_opt deserialize_func diff --git a/src/test/regress/sql/gms_debugger_client1.sql b/src/test/regress/sql/gms_debugger_client1.sql index 9e872bb7e6efe37933320b6915cce937001c1127..07dfcb226ee2ee9c3cf7759b59a8b721b02162f3 100644 --- a/src/test/regress/sql/gms_debugger_client1.sql +++ b/src/test/regress/sql/gms_debugger_client1.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test1; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) returns void as $$ @@ -55,7 +56,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -70,7 +71,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -85,7 +86,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -111,7 +112,7 @@ end; $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-0', 1); select pg_sleep(3); diff --git a/src/test/regress/sql/gms_debugger_client2.sql b/src/test/regress/sql/gms_debugger_client2.sql index 20ca1912f4d7e1552f49761860046c79bda2d7e2..2efd2051238164f9ada34f27c84f8a79afc16221 100644 --- a/src/test/regress/sql/gms_debugger_client2.sql +++ b/src/test/regress/sql/gms_debugger_client2.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test2; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +42,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -56,7 +57,22 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; + +CREATE or REPLACE FUNCTION gms_step() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +83,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-1'); select pg_sleep(3); @@ -79,4 +95,6 @@ select gms_next(); select gms_continue(); +select gms_continue(); + select gms_debug.detach_session(); diff --git a/src/test/regress/sql/gms_debugger_client3.sql b/src/test/regress/sql/gms_debugger_client3.sql index 9f067ba961c8843dad1285ba1bd858cca88ff86a..02f3d21fbc1f400553cefc6ae0124fd18d621d74 100644 --- a/src/test/regress/sql/gms_debugger_client3.sql +++ b/src/test/regress/sql/gms_debugger_client3.sql @@ -34,6 +34,22 @@ BEGIN END $$; set search_path = gms_debugger_test3; +set behavior_compat_options='proc_outparam_override'; + +CREATE or REPLACE FUNCTION gms_continue() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; CREATE or REPLACE FUNCTION gms_next() returns void as $$ @@ -41,7 +57,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +66,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +83,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-2'); select pg_sleep(3); @@ -79,4 +95,6 @@ select gms_continue(); select gms_next(); +select gms_continue(); + select gms_debug.detach_session(); diff --git a/src/test/regress/sql/gms_debugger_client4.sql b/src/test/regress/sql/gms_debugger_client4.sql index fdbd708293423e119693ef4c389389010e86c445..c7eea0c714b186362b82dcc0ef8757c37695c0ab 100644 --- a/src/test/regress/sql/gms_debugger_client4.sql +++ b/src/test/regress/sql/gms_debugger_client4.sql @@ -34,14 +34,16 @@ BEGIN END $$; set search_path = gms_debugger_test4; +set behavior_compat_options='proc_outparam_override'; -CREATE or REPLACE FUNCTION gms_step() + +CREATE or REPLACE FUNCTION gms_continue() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +52,28 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_continue() +CREATE or REPLACE FUNCTION gms_next() +returns void as $$ +declare + run_info gms_debug.runtime_info; + ret binary_integer; +begin + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); + RAISE NOTICE 'breakpoint= %', run_info.breakpoint; + RAISE NOTICE 'stackdepth= %', run_info.stackdepth; + RAISE NOTICE 'line= %', run_info.line#; + RAISE NOTICE 'reason= %', run_info.reason; + RAISE NOTICE 'ret= %',ret; +end; +$$ LANGUAGE plpgsql; + +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -67,7 +84,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-3'); select pg_sleep(3); diff --git a/src/test/regress/sql/gms_debugger_client5.sql b/src/test/regress/sql/gms_debugger_client5.sql index c3b848c5b3a114a8b5368a8807a987a37c790adb..ee7ebfc8b67b46a95a35c5beb3f5a7372dbf9a8d 100644 --- a/src/test/regress/sql/gms_debugger_client5.sql +++ b/src/test/regress/sql/gms_debugger_client5.sql @@ -34,6 +34,7 @@ BEGIN END $$; set search_path = gms_debugger_test5; +set behavior_compat_options='proc_outparam_override'; CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +42,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -50,13 +51,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_step() +CREATE or REPLACE FUNCTION gms_next() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 4, 2); + ret := gms_debug.continue(run_info, gms_debug.break_next_line, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -65,13 +66,13 @@ begin end; $$ LANGUAGE plpgsql; -CREATE or REPLACE FUNCTION gms_next() +CREATE or REPLACE FUNCTION gms_step() returns void as $$ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 2, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_call, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -86,7 +87,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -97,7 +98,7 @@ $$ LANGUAGE plpgsql; -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-4'); select pg_sleep(3); diff --git a/src/test/regress/sql/gms_debugger_client6.sql b/src/test/regress/sql/gms_debugger_client6.sql index c5fd2985b958854c8456ea5813336cbbff672b64..13730de1bb69b62b7fefd7de64731bd107aa34f7 100644 --- a/src/test/regress/sql/gms_debugger_client6.sql +++ b/src/test/regress/sql/gms_debugger_client6.sql @@ -34,6 +34,8 @@ BEGIN END $$; set search_path = gms_debugger_test6; +set behavior_compat_options='proc_outparam_override'; + CREATE or REPLACE FUNCTION gms_continue() returns void as $$ @@ -41,7 +43,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 0, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -70,7 +72,7 @@ declare run_info gms_debug.runtime_info; ret binary_integer; begin - ret := gms_debug.continue(run_info, 8, 2); + ret := gms_debug.continue(run_info, gms_debug.break_any_return, 2); RAISE NOTICE 'breakpoint= %', run_info.breakpoint; RAISE NOTICE 'stackdepth= %', run_info.stackdepth; RAISE NOTICE 'line= %', run_info.line#; @@ -79,9 +81,8 @@ begin end; $$ LANGUAGE plpgsql; - -- attach debug server -select * from gms_debug.attach_session('datanode1-0'); +select * from gms_debug.attach_session('datanode1-5'); select pg_sleep(3); diff --git a/src/test/regress/sql/gms_debugger_client7.sql b/src/test/regress/sql/gms_debugger_client7.sql deleted file mode 100644 index c073663ca9e47a6838dc66ce5cd119c0289273ac..0000000000000000000000000000000000000000 --- a/src/test/regress/sql/gms_debugger_client7.sql +++ /dev/null @@ -1,103 +0,0 @@ --- wait for server establishment - -CREATE OR REPLACE FUNCTION wait_for_gms_debug_extension() -RETURNS BOOLEAN AS $$ -DECLARE - extension_exists BOOLEAN; -BEGIN - -- 初始化变量 - extension_exists := FALSE; - - -- 循环查询扩展是否存在 - WHILE NOT extension_exists LOOP - -- 查询扩展是否存在 - PERFORM 1 FROM pg_extension WHERE extname = 'gms_debug'; - IF FOUND THEN - -- 如果扩展存在,则退出循环 - extension_exists := TRUE; - ELSE - -- 如果扩展不存在,则等待一段时间再重试 - PERFORM pg_sleep(1); -- 等待1秒 - END IF; - END LOOP; - - -- 返回扩展存在的标志 - RETURN extension_exists; -END; -$$ LANGUAGE plpgsql; - -DO $$ -BEGIN - IF wait_for_gms_debug_extension() THEN - -- 扩展存在,执行下一步操作 - END IF; -END $$; - -set search_path = gms_debugger_test7; - -CREATE or REPLACE FUNCTION gms_step() -returns void as $$ -declare - run_info gms_debug.runtime_info; - ret binary_integer; -begin - ret := gms_debug.continue(run_info, 4, 2); - RAISE NOTICE 'breakpoint= %', run_info.breakpoint; - RAISE NOTICE 'stackdepth= %', run_info.stackdepth; - RAISE NOTICE 'line= %', run_info.line#; - RAISE NOTICE 'reason= %', run_info.reason; - RAISE NOTICE 'ret= %',ret; -end; -$$ LANGUAGE plpgsql; - -CREATE or REPLACE FUNCTION gms_continue() -returns void as $$ -declare - run_info gms_debug.runtime_info; - ret binary_integer; -begin - ret := gms_debug.continue(run_info, 0, 2); - RAISE NOTICE 'breakpoint= %', run_info.breakpoint; - RAISE NOTICE 'stackdepth= %', run_info.stackdepth; - RAISE NOTICE 'line= %', run_info.line#; - RAISE NOTICE 'reason= %', run_info.reason; - RAISE NOTICE 'ret= %',ret; -end; -$$ LANGUAGE plpgsql; - -CREATE or REPLACE FUNCTION gms_breakpoint(funcname text, lineno int) -returns void as $$ -declare - pro_info gms_debug.program_info; - bkline binary_integer; - ret binary_integer; -begin - pro_info.name := funcname; - ret := gms_debug.set_breakpoint(pro_info, lineno, bkline,1,1); - RAISE NOTICE 'ret= %', ret; - RAISE NOTICE 'ret= %', bkline; -end; -$$ LANGUAGE plpgsql; - --- attach debug server -select * from gms_debug.attach_session('datanode1-0'); - -select pg_sleep(3); - -select gms_breakpoint('test_debug_recursive', 5); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_step(); - -select gms_continue(); - -select gms_continue(); - -select gms_debug.detach_session(); diff --git a/src/test/regress/sql/gms_debugger_server1.sql b/src/test/regress/sql/gms_debugger_server1.sql index 8a47326ee0788be651aeff16dda3f7224ff6dc2a..e9ebebb34b3d3d4bd737720c1cd98694bab84678 100644 --- a/src/test/regress/sql/gms_debugger_server1.sql +++ b/src/test/regress/sql/gms_debugger_server1.sql @@ -80,7 +80,7 @@ select * from gms_debug.attach_session('datanode1-0'); -- turn off without turn on select * from gms_debug.debug_off(); -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-0'); select pg_sleep(1); diff --git a/src/test/regress/sql/gms_debugger_server2.sql b/src/test/regress/sql/gms_debugger_server2.sql index 559a9cf5735d81f700df2dfd4385c4f9bc8a945f..2da9b0c3bd132801c0a8d24459a0a67b43a8b087 100644 --- a/src/test/regress/sql/gms_debugger_server2.sql +++ b/src/test/regress/sql/gms_debugger_server2.sql @@ -17,7 +17,7 @@ end; -- start debug -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-1'); select pg_sleep(1); diff --git a/src/test/regress/sql/gms_debugger_server3.sql b/src/test/regress/sql/gms_debugger_server3.sql index 830599f5a09b5708ee5698cbeef1d856faa485a8..dd495943f91c6ffc05ff837f3a725bd249c0da4a 100644 --- a/src/test/regress/sql/gms_debugger_server3.sql +++ b/src/test/regress/sql/gms_debugger_server3.sql @@ -24,7 +24,7 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-2'); select pg_sleep(1); diff --git a/src/test/regress/sql/gms_debugger_server4.sql b/src/test/regress/sql/gms_debugger_server4.sql index 607e20d769492f9143b84c77a09508f03cb84966..5ea8fc748a4187194ad593ca0cb42f05c0e6ac6f 100644 --- a/src/test/regress/sql/gms_debugger_server4.sql +++ b/src/test/regress/sql/gms_debugger_server4.sql @@ -83,14 +83,14 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-3'); select pg_sleep(1); select * from test_debug4(1); -- test with client error in exception -select * from test_debug4(1); +-- select * from test_debug4(1); select * from gms_debug.debug_off(); diff --git a/src/test/regress/sql/gms_debugger_server5.sql b/src/test/regress/sql/gms_debugger_server5.sql index 1a4ac60b9169c8f5d5bd6c4291d48654fa457cdf..4134e5070366a09e692c553906f1552f1fb357f4 100644 --- a/src/test/regress/sql/gms_debugger_server5.sql +++ b/src/test/regress/sql/gms_debugger_server5.sql @@ -83,7 +83,7 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-4'); select pg_sleep(1); diff --git a/src/test/regress/sql/gms_debugger_server6.sql b/src/test/regress/sql/gms_debugger_server6.sql index d1ba000296d93e1af7eda73b074dd4cd3514d6ed..bf8108fa1bc7899ff49e1cf587cb099d09f6503d 100644 --- a/src/test/regress/sql/gms_debugger_server6.sql +++ b/src/test/regress/sql/gms_debugger_server6.sql @@ -83,14 +83,14 @@ BEGIN END; / -select * from gms_debug.initialize(); +select * from gms_debug.initialize('datanode1-5'); select pg_sleep(1); select * from test_debug4(1); -- test with client error in exception -select * from test_debug4(1); +-- select * from test_debug4(1); select * from gms_debug.debug_off(); diff --git a/src/test/regress/sql/gms_debugger_server7.sql b/src/test/regress/sql/gms_debugger_server7.sql deleted file mode 100644 index 3d1625c6a03cad195a7a5b16567c19020dc44118..0000000000000000000000000000000000000000 --- a/src/test/regress/sql/gms_debugger_server7.sql +++ /dev/null @@ -1,29 +0,0 @@ --- setups -create extension if not exists gms_debug; -drop schema if exists gms_debugger_test7 cascade; -create schema gms_debugger_test7; -set search_path = gms_debugger_test7; - -create or replace function test_debug_recursive (ct int, pr int) -returns table (counter int, product int) -language plpgsql -as $$ -begin - return query select ct, pr; - if ct < 5 then - return query select * from test_debug_recursive(ct+ 1, pr * (ct+ 1)); - end if; -end $$; - -select * from gms_debug.initialize(); - -select pg_sleep(1); - -select * from test_debug_recursive (1, 1); - --- test with client error in exception -select * from test_debug_recursive (1, 1); - -select * from gms_debug.debug_off(); - -drop schema gms_debugger_test7 cascade;