');
+ vSplitter.bottom().addItem($stack);
+
+ var stackFrame = new wcTabFrame($stack, panel);
+ var stackTab = self.stackTab = stackFrame.addTab(
+ '{{ _('Stack pane') }}', -1, wcDocker.LAYOUT.SIMPLE
+ );
+ stackTab.addItem(
+ $('
'));
+
+ // By default, the splitter splits down the middle, we split the main panel by 80%.
+ vSplitter.pos(0.75);
+
+ // Now create a tab widget and put that into one of the sub splits.
+ var editor_pane = $('
');
+ var code_editor_area = $('
').append(editor_pane);
+ vSplitter.top().addItem(code_editor_area);
+
+ // To show the line-number and set breakpoint marker details by user.
+ var editor = self.editor = CodeMirror.fromTextArea(
+ code_editor_area.get(0), {
+ lineNumbers: true,
+ gutters: ["note-gutter", "CodeMirror-linenumbers", "breakpoints"],
+ mode: "text/x-sql",
+ readOnly: true
+ });
+ });
+
+ // On loading the docker, register the callbacks
+ var onLoad = function() {
+ self.docker.finishLoading(100);
+ self.docker.off(wcDocker.EVENT.LOADED);
+ // Register the callback when user set/clear the breakpoint on gutter area.
+ self.editor.on("gutterClick", self.onBreakPoint.bind(self), self);
+ };
+
+ self.docker.startLoading('{{ _('Loading...') }}');
+ self.docker.on(wcDocker.EVENT.LOADED, onLoad);
+
+ self.main_panel = self.docker.addPanel(
+ 'code', wcDocker.DOCK.TOP, null, {h: '100%', w: '100%'}
+ );
+
+ // Create the toolbar view for debugging the function
+ this.toolbarView = new DebuggerToolbarView();
+ },
+
+ // Register the panel with new debugger docker instance.
+ registerPanel: function(name, title, width, height, onInit) {
+ var self = this;
+
+ this.docker.registerPanelType(name, {
+ title: title,
+ isPrivate: true,
+ onCreate: function(panel) {
+ self.panels[name] = panel;
+ panel.initSize(width, height);
+ if (!title)
+ panel.title(false);
+ else
+ panel.title(title);
+ panel.closeable(false);
+ panel.layout().addItem(
+ $('
', {'class': 'pg-debugger-panel'})
+ );
+ if (onInit) {
+ onInit.apply(self, [panel]);
+ }
+ }
+ });
+ }
+ });
+
+ pgTools.DirectDebug = new DirectDebug();
+
+ return pgTools.DirectDebug;
+});
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/execute_edbspl.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/execute_edbspl.sql
new file mode 100755
index 0000000..04c0953
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/execute_edbspl.sql
@@ -0,0 +1,115 @@
+{### Create executer function for edb spl function debugging ###}
+{% set inside_loop = {'value': False} %}
+
+{% if lan_name == 'edbspl' %}
+{% set useAnonymousBlock = "true" %}
+{% if not is_func %}
+ {% set str_statement = "\tEXEC " ~ func_name %}
+{% elif ret_type == 'void' %}
+ {% set str_statement = "\tPERFORM " ~ func_name %}
+{% else %}
+ {% set resultVar = "v_retVal" %}
+ {% set str_statement = "\t" ~ resultVar ~ " := " ~ func_name %}
+ {% set str_declare = str_declare ~ "\t" ~ resultVar ~ " " ~ ret_type ~ ";\n" %}
+ {% set str_result = "\tDBMS_OUTPUT.PUT_LINE(E'\\n\\nResult:\\n--------\\n' || " ~ resultVar ~ "::text || E'\\n\\nNOTE: This is the result generated during the function execution by the debugger.\\n');\n" %}
+{% endif %}
+
+{% else %}
+{% if ret_type == 'record' %}
+ {% set str_statement = "\tSELECT " ~ func_name %}
+{% else %}
+ {% set str_statement = "\tSELECT * FROM " ~ func_name %}
+{% endif %}
+
+{% endif %}
+
+
+{% set firstProceesed = "false" %}
+{% set input_value_index = 0 %}
+
+{% if arg_type|length > 0 %}
+{% set str_statement = str_statement ~ "(" %}
+
+{% for arg_mode in args_mode %}
+.... ARG_MODE: .... {{ arg_mode }}... Index.... {{ loop.index }}....
+{% if useAnonymousBlock == "true" and (arg_mode == 'o' or arg_mode == 'b') %}
+{% set strParam = "p_param" ~ (loop.index - 1) %}
+{% set str_declare = str_declare ~ "\t" ~ strParam ~ " " ~ arg_type[loop.index - 1] %}
+{% if arg_mode == 'b' %}
+{### TODO: to check for Null parameters received from client ###}
+{% set str_declare = str_declare ~ " := " ~ strParam ~ " " ~ data[input_value_index]['value'] ~ "::" ~ data[input_value_index]['type'] %}
+{% set input_value_index = input_value_index + 1 %}
+{% endif %}
+{% set str_declare = str_declare ~ ";\n" %}
+
+{% if firstProceesed == "true" %}
+{% set str_statement = str_statement ~ ", " %}
+{% endif %}
+{% set firstProceesed = "true" %}
+{% set str_statement = str_statement ~ strParam %}
+
+
+
+
+
+{% elif arg_mode != 'o' %}
+{% if firstProceesed == "true" %}
+{% set str_statement = str_statement ~ ", " %}
+{% endif %}
+{% set firstProceesed = "true" %}
+
+{% if arg_mode == 'v' %}
+{% set str_statement = str_statement ~ "VARIADIC " %}
+{% endif %}
+
+{### TODO: to check for Null parameters received from client ###}
+
+{% set str_statement = str_statement ~ data[input_value_index]['value'] ~ "::" ~ data[input_value_index]['type'] %}
+{% set input_value_index = input_value_index + 1 %}
+
+
+{% endif %}
+
+{% if loop.last %}
+{% set str_statement = str_statement ~ ")" %}
+{% set strQuery = str_statement %}
+{% if useAnonymousBlock == "true" %}
+{% set strQuery = "DECLARE\n" ~ str_declare ~ "BEGIN\n" ~ str_statement ~ ";\n" ~ str_result ~ "END;" %}
+{% endif %}
+
+{{ strQuery }}
+{% if inside_loop.update({'value': True}) %} {% endif %}
+{% endif %}
+
+{% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
+{% elif not is_func and lan_name == 'edbspl' %}
+{% set strQuery = str_statement %}
+{% if useAnonymousBlock == "true" %}
+{% set strQuery = "DECLARE\n" ~ str_declare ~ "BEGIN\n" ~ str_statement ~ ";\n" ~ str_result ~ "END;" %}
+{% endif %}
+{% else %}
+{% set strQuery = str_statement ~ "()" %}
+{% if useAnonymousBlock == "true" %}
+{% set strQuery = "DECLARE\n" ~ str_declare ~ "BEGIN\n" ~ str_statement ~ ";\n" ~ str_result ~ "END;" %}
+{% endif %}
+{% endif %}
+
+
+
+
+{### Return final query formed with above condition ###}
+{% if not inside_loop.value %}
+{{ strQuery }}
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/execute_plpgsql.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/execute_plpgsql.sql
new file mode 100755
index 0000000..f4201c3
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/execute_plpgsql.sql
@@ -0,0 +1,20 @@
+{### Create executer function for plpgsql function debugging ###}
+{% if is_func == 'False' %}
+ EXEC {{ func_name }} (
+{% elif ret_type == 'record' %}
+ SELECT {{ func_name }} (
+{% else %}
+ SELECT * FROM {{ func_name }} (
+{% endif %}
+{% if data %}
+{% for dict_item in data %}
+{% if 'type' in dict_item and 'value' in dict_item %}
+{% if dict_item['type'] == 'text' %}
+{{ dict_item['value']|qtLiteral }}::{{ dict_item['type'] }}{% if not loop.last %}, {% endif %}
+{% else %}
+{% if '[]' in dict_item['type'] %} ARRAY{{ dict_item['value'] }}::{{ dict_item['type'] }} {% else %} {{ dict_item['value'] }}::{{ dict_item['type'] }} {% endif %} {% if not loop.last %}, {% endif %}
+{% endif %}
+{% endif %}
+{% endfor %}
+{% endif %}
+)
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql
new file mode 100755
index 0000000..30e47e5
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql
@@ -0,0 +1,66 @@
+{### To fetch debug function information ###}
+SELECT
+ p.proname AS name, p.prosrc, l.lanname, p.proretset, p.prorettype, y.typname AS rettype,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proallargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proallargtypes, 1)) AS s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proargtypes, 1)) AS s(i)), ',')
+ END AS proargtypenames,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proallargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proallargtypes, 1)) s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proargtypes, 1)) s(i)), ',')
+ END AS proargtypes,
+ pg_catalog.array_to_string(p.proargnames, ',') AS proargnames,
+ pg_catalog.array_to_string(proargmodes, ',') AS proargmodes,
+
+ {% if is_ppas_database %}
+ CASE WHEN n.nspparent <> 0 THEN n.oid ELSE 0 END AS pkg,
+ CASE WHEN n.nspparent <> 0 THEN n.nspname ELSE '' END AS pkgname,
+ CASE WHEN n.nspparent <> 0 THEN (SELECT oid FROM pg_proc WHERE pronamespace=n.oid AND proname='cons') ELSE 0 END AS pkgconsoid,
+ CASE WHEN n.nspparent <> 0 THEN g.oid ELSE n.oid END AS schema,
+ CASE WHEN n.nspparent <> 0 THEN g.nspname ELSE n.nspname END AS schemaname,
+ NOT (l.lanname = 'edbspl' AND protype = '1') AS isfunc,
+ {%else%}
+ 0 AS pkg,
+ '' AS pkgname,
+ 0 AS pkgconsoid,
+ n.oid AS schema,
+ n.nspname AS schemaname,
+ true AS isfunc,
+ {%endif%}
+ pg_catalog.pg_get_function_identity_arguments(p.oid) AS signature,
+
+ {% if hasFeatureFunctionDefaults %}
+ pg_catalog.pg_get_expr(p.proargdefaults, 'pg_catalog.pg_class'::regclass, false) AS proargdefaults,
+ p.pronargdefaults
+ {%else%}
+ '' AS proargdefaults, 0 AS pronargdefaults
+ {%endif%}
+ FROM
+ pg_catalog.pg_proc p
+ LEFT JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
+ LEFT JOIN pg_catalog.pg_language l ON p.prolang = l.oid
+ LEFT JOIN pg_catalog.pg_type y ON p.prorettype = y.oid
+
+ {% if is_ppas_database %}
+ LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
+ {% endif %}
+
+ {% if fid %}
+ WHERE p.oid = {{fid}}::int;
+ {% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/Backend_running.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/Backend_running.sql
new file mode 100755
index 0000000..c5770d0
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/Backend_running.sql
@@ -0,0 +1,4 @@
+{### Check backend target is running or not for debugging ###}
+{% if backend_pid %}
+ SELECT COUNT(*) FROM (SELECT pg_catalog.pg_stat_get_backend_idset() AS bid) AS s WHERE pg_catalog.pg_stat_get_backend_pid(s.bid) = {{ conn|qtIdent(backend_pid) }}::integer;
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/abort_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/abort_target.sql
new file mode 100755
index 0000000..8f89ae3
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/abort_target.sql
@@ -0,0 +1,4 @@
+{### Abort the target for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_abort_target({{session_id}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_edb.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_edb.sql
new file mode 100755
index 0000000..0129462
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_edb.sql
@@ -0,0 +1,4 @@
+{### Add EDB breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_global_breakpoint({{session_id}}::int, {{package_oid}}::int, {{function_oid}}::OID, -1, {{target_oid}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_pg.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_pg.sql
new file mode 100755
index 0000000..f83e1cf
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/add_breakpoint_pg.sql
@@ -0,0 +1,4 @@
+{### Add PG breakpoint for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_global_breakpoint({{session_id}}, {{function_oid}}, -1, NULL)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/attach_to_port.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/attach_to_port.sql
new file mode 100755
index 0000000..bb74477
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/attach_to_port.sql
@@ -0,0 +1,4 @@
+{### Attach the target to port for debugging ###}
+{% if port %}
+ SELECT * FROM pldbg_attach_to_port({{port}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/clear_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/clear_breakpoint.sql
new file mode 100755
index 0000000..eecc674
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/clear_breakpoint.sql
@@ -0,0 +1,4 @@
+{### Clear breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_drop_breakpoint({{session_id}}::int, {{poid}}::OID, {{foid}}::OID, {{line_number}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/continue.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/continue.sql
new file mode 100755
index 0000000..071c53e
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/continue.sql
@@ -0,0 +1,11 @@
+{### Continue for debugging ###}
+{% if session_id %}
+ SELECT
+ p.pkg AS pkg, p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber, pldbg_get_source({{session_id}}::INTEGER, p.pkg, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func AND s.pkg = p.pkg) AS args
+ FROM pldbg_continue({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/create_listener.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/create_listener.sql
new file mode 100755
index 0000000..1d47739
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/create_listener.sql
@@ -0,0 +1,2 @@
+{### Create listener for debugging ###}
+ SELECT * from pldbg_create_listener()
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_execute_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_execute_target.sql
new file mode 100755
index 0000000..5be078d
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_execute_target.sql
@@ -0,0 +1,4 @@
+{### Debug execute target for plpgsql function ###}
+{% if function_oid %}
+ SELECT plpgsql_oid_debug({{packge_oid}}::OID, {{function_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_init.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_init.sql
new file mode 100755
index 0000000..14ad3c5
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_plpgsql_init.sql
@@ -0,0 +1,4 @@
+{### Debug Initialization for plpgsql function ###}
+{% if packge_init_oid %}
+ SELECT plpgsql_oid_debug({{packge_oid}}::OID, {{packge_init_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_execute_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_execute_target.sql
new file mode 100755
index 0000000..84afb34
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_execute_target.sql
@@ -0,0 +1,4 @@
+{### Debug execute target for EDB spl function ###}
+{% if function_oid %}
+ SELECT edb_oid_debug({{packge_oid}}::OID, {{function_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_init.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_init.sql
new file mode 100755
index 0000000..aa5b324
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/debug_spl_init.sql
@@ -0,0 +1,4 @@
+{### Debug Initialization for EDB spl function ###}
+{% if packge_init_oid %}
+ SELECT edb_oid_debug({{packge_oid}}::OID, {{packge_init_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/deposit_value.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/deposit_value.sql
new file mode 100755
index 0000000..86e9f4a
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/deposit_value.sql
@@ -0,0 +1,4 @@
+{### Change the variable value and submit during debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_deposit_value({{session_id}}::int, {{var_name|qtLiteral}}, {{line_number}}, {{val|qtLiteral}})
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_breakpoints.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_breakpoints.sql
new file mode 100755
index 0000000..19da5db
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_breakpoints.sql
@@ -0,0 +1,4 @@
+{### Get the breakpoint information for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_get_breakpoints({{session_id}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_function_info.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_function_info.sql
new file mode 100755
index 0000000..7989da7
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_function_info.sql
@@ -0,0 +1,66 @@
+{### To fetch debug function information ###}
+SELECT
+ p.proname AS name, l.lanname, p.proretset, p.prorettype, y.typname AS rettype,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proallargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proallargtypes, 1)) AS s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proargtypes, 1)) AS s(i)), ',')
+ END AS proargtypenames,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proallargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proallargtypes, 1)) s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proargtypes, 1)) s(i)), ',')
+ END AS proargtypes,
+ pg_catalog.array_to_string(p.proargnames, ',') AS proargnames,
+ pg_catalog.array_to_string(proargmodes, ',') AS proargmodes,
+
+ {% if is_ppas_database %}
+ CASE WHEN n.nspparent <> 0 THEN n.oid ELSE 0 END AS pkg,
+ CASE WHEN n.nspparent <> 0 THEN n.nspname ELSE '' END AS pkgname,
+ CASE WHEN n.nspparent <> 0 THEN (SELECT oid FROM pg_proc WHERE pronamespace=n.oid AND proname='cons') ELSE 0 END AS pkgconsoid,
+ CASE WHEN n.nspparent <> 0 THEN g.oid ELSE n.oid END AS schema,
+ CASE WHEN n.nspparent <> 0 THEN g.nspname ELSE n.nspname END AS schemaname,
+ NOT (l.lanname = 'edbspl' AND protype = '1') AS isfunc,
+ {%else%}
+ 0 AS pkg,
+ '' AS pkgname,
+ 0 AS pkgconsoid,
+ n.oid AS schema,
+ n.nspname AS schemaname,
+ true AS isfunc,
+ {%endif%}
+ pg_catalog.pg_get_function_identity_arguments(p.oid) AS signature,
+
+ {% if hasFeatureFunctionDefaults %}
+ pg_catalog.pg_get_expr(p.proargdefaults, 'pg_catalog.pg_class'::regclass, false) AS proargdefaults,
+ p.pronargdefaults
+ {%else%}
+ '' AS proargdefaults, 0 AS pronargdefaults
+ {%endif%}
+ FROM
+ pg_catalog.pg_proc p
+ LEFT JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
+ LEFT JOIN pg_catalog.pg_language l ON p.prolang = l.oid
+ LEFT JOIN pg_catalog.pg_type y ON p.prorettype = y.oid
+
+ {% if is_ppas_database %}
+ LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
+ {% endif %}
+
+ {% if fid %}
+ WHERE p.oid = {{fid}}::int;
+ {% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_stack_info.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_stack_info.sql
new file mode 100755
index 0000000..05034c9
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_stack_info.sql
@@ -0,0 +1,4 @@
+{### Get the stack information for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_get_stack({{session_id}}::int) ORDER BY level
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_variables.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_variables.sql
new file mode 100755
index 0000000..47ebed5
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/get_variables.sql
@@ -0,0 +1,8 @@
+{### Get the variables information for debugging ###}
+{% if session_id %}
+ SELECT
+ name, varClass, value,
+ pg_catalog.format_type(dtype, NULL) as dtype, isconst
+ FROM pldbg_get_variables({{session_id}}::int)
+ ORDER BY varClass
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/select_frame.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/select_frame.sql
new file mode 100755
index 0000000..e31e634
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/select_frame.sql
@@ -0,0 +1,12 @@
+{### select the frame to debug the function ###}
+{% if session_id and frame_id %}
+ SELECT
+ p.pkg AS pkg, p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber,
+ CASE WHEN p.func <> 0 THEN pldbg_get_source({{session_id}}::INTEGER, p.func, p.pkg) ELSE '' END AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func AND s.pkg = p.pkg) AS args
+ FROM pldbg_select_frame({{session_id}}::INTEGER, {{frame_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/set_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/set_breakpoint.sql
new file mode 100755
index 0000000..61c8b13
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/set_breakpoint.sql
@@ -0,0 +1,4 @@
+{### Set the breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_breakpoint({{session_id}}::int ,{{poid}}::OID, {{foid}}::OID, {{line_number}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_into.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_into.sql
new file mode 100755
index 0000000..837287d
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_into.sql
@@ -0,0 +1,11 @@
+{### Step into function for debugging ###}
+{% if session_id %}
+ SELECT
+ p.pkg AS pkg, p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber, pldbg_get_source({{session_id}}::INTEGER, p.pkg, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func AND s.pkg = p.pkg) AS args
+ FROM pldbg_step_into({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_over.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_over.sql
new file mode 100755
index 0000000..a5ced66
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/step_over.sql
@@ -0,0 +1,11 @@
+{### Step over function for debugging ###}
+{% if session_id %}
+ SELECT
+ p.pkg AS pkg, p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber, pldbg_get_source({{session_id}}::INTEGER, p.pkg, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func AND s.pkg = p.pkg) AS args
+ FROM pldbg_step_over({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_breakpoint.sql
new file mode 100755
index 0000000..0271056
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_breakpoint.sql
@@ -0,0 +1,11 @@
+{### select the frame to debug the function ###}
+{% if session_id %}
+ SELECT
+ p.pkg AS pkg, p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber, pldbg_get_source({{session_id}}::INTEGER, p.pkg, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func AND s.pkg = p.pkg) AS args
+ FROM pldbg_wait_for_breakpoint({{session_id}}::INTEGER) p;
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_target.sql
new file mode 100755
index 0000000..c4f5634
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v1/wait_for_target.sql
@@ -0,0 +1,4 @@
+{### Wait for the target for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_wait_for_target({{session_id}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/Backend_running.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/Backend_running.sql
new file mode 100755
index 0000000..c5770d0
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/Backend_running.sql
@@ -0,0 +1,4 @@
+{### Check backend target is running or not for debugging ###}
+{% if backend_pid %}
+ SELECT COUNT(*) FROM (SELECT pg_catalog.pg_stat_get_backend_idset() AS bid) AS s WHERE pg_catalog.pg_stat_get_backend_pid(s.bid) = {{ conn|qtIdent(backend_pid) }}::integer;
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/abort_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/abort_target.sql
new file mode 100755
index 0000000..8f89ae3
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/abort_target.sql
@@ -0,0 +1,4 @@
+{### Abort the target for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_abort_target({{session_id}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_edb.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_edb.sql
new file mode 100755
index 0000000..0129462
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_edb.sql
@@ -0,0 +1,4 @@
+{### Add EDB breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_global_breakpoint({{session_id}}::int, {{package_oid}}::int, {{function_oid}}::OID, -1, {{target_oid}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_pg.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_pg.sql
new file mode 100755
index 0000000..f83e1cf
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/add_breakpoint_pg.sql
@@ -0,0 +1,4 @@
+{### Add PG breakpoint for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_global_breakpoint({{session_id}}, {{function_oid}}, -1, NULL)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/attach_to_port.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/attach_to_port.sql
new file mode 100755
index 0000000..bb74477
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/attach_to_port.sql
@@ -0,0 +1,4 @@
+{### Attach the target to port for debugging ###}
+{% if port %}
+ SELECT * FROM pldbg_attach_to_port({{port}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/clear_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/clear_breakpoint.sql
new file mode 100755
index 0000000..c3d83f8
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/clear_breakpoint.sql
@@ -0,0 +1,4 @@
+{### Clear breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_drop_breakpoint({{session_id}}::int, {{foid}}::OID, {{line_number}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/continue.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/continue.sql
new file mode 100755
index 0000000..85dcd27
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/continue.sql
@@ -0,0 +1,11 @@
+{### Continue for debugging ###}
+{% if session_id %}
+ SELECT
+ p.func, p.targetName, p.linenumber,
+ pldbg_get_source({{session_id}}::INTEGER, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func) AS args
+ FROM pldbg_continue({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/create_listener.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/create_listener.sql
new file mode 100755
index 0000000..1d47739
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/create_listener.sql
@@ -0,0 +1,2 @@
+{### Create listener for debugging ###}
+ SELECT * from pldbg_create_listener()
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_execute_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_execute_target.sql
new file mode 100755
index 0000000..9bdb8ef
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_execute_target.sql
@@ -0,0 +1,4 @@
+{### Debug execute target for plpgsql function ###}
+{% if function_oid %}
+ SELECT plpgsql_oid_debug({{function_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_init.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_init.sql
new file mode 100755
index 0000000..e56ad98
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_plpgsql_init.sql
@@ -0,0 +1,4 @@
+{### Debug Initialization for plpgsql function ###}
+{% if packge_init_oid %}
+ SELECT plpgsql_oid_debug({{packge_init_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_execute_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_execute_target.sql
new file mode 100755
index 0000000..7cb382f
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_execute_target.sql
@@ -0,0 +1,4 @@
+{### Debug execute target for EDB spl function ###}
+{% if function_oid %}
+ SELECT edb_oid_debug({{function_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_init.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_init.sql
new file mode 100755
index 0000000..d16b1b1
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/debug_spl_init.sql
@@ -0,0 +1,4 @@
+{### Debug Initialization for EDB spl function ###}
+{% if packge_init_oid %}
+ SELECT edb_oid_debug({{packge_init_oid}}::OID)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/deposit_value.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/deposit_value.sql
new file mode 100755
index 0000000..6ee3259
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/deposit_value.sql
@@ -0,0 +1,4 @@
+{### Change the variable value and submit during debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_deposit_value({{session_id}}::int, {{var_name|qtLiteral }}, {{line_number}}, {{val|qtLiteral}})
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_breakpoints.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_breakpoints.sql
new file mode 100755
index 0000000..19da5db
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_breakpoints.sql
@@ -0,0 +1,4 @@
+{### Get the breakpoint information for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_get_breakpoints({{session_id}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_function_info.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_function_info.sql
new file mode 100755
index 0000000..7989da7
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_function_info.sql
@@ -0,0 +1,66 @@
+{### To fetch debug function information ###}
+SELECT
+ p.proname AS name, l.lanname, p.proretset, p.prorettype, y.typname AS rettype,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proallargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proallargtypes, 1)) AS s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT
+ pg_catalog.format_type(p.proargtypes[s.i], NULL)
+ FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(
+ p.proargtypes, 1)) AS s(i)), ',')
+ END AS proargtypenames,
+ CASE WHEN proallargtypes IS NOT NULL THEN
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proallargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proallargtypes, 1)) s(i)), ',')
+ ELSE
+ pg_catalog.array_to_string(ARRAY(
+ SELECT proargtypes[s.i] FROM
+ pg_catalog.generate_series(0, pg_catalog.array_upper(proargtypes, 1)) s(i)), ',')
+ END AS proargtypes,
+ pg_catalog.array_to_string(p.proargnames, ',') AS proargnames,
+ pg_catalog.array_to_string(proargmodes, ',') AS proargmodes,
+
+ {% if is_ppas_database %}
+ CASE WHEN n.nspparent <> 0 THEN n.oid ELSE 0 END AS pkg,
+ CASE WHEN n.nspparent <> 0 THEN n.nspname ELSE '' END AS pkgname,
+ CASE WHEN n.nspparent <> 0 THEN (SELECT oid FROM pg_proc WHERE pronamespace=n.oid AND proname='cons') ELSE 0 END AS pkgconsoid,
+ CASE WHEN n.nspparent <> 0 THEN g.oid ELSE n.oid END AS schema,
+ CASE WHEN n.nspparent <> 0 THEN g.nspname ELSE n.nspname END AS schemaname,
+ NOT (l.lanname = 'edbspl' AND protype = '1') AS isfunc,
+ {%else%}
+ 0 AS pkg,
+ '' AS pkgname,
+ 0 AS pkgconsoid,
+ n.oid AS schema,
+ n.nspname AS schemaname,
+ true AS isfunc,
+ {%endif%}
+ pg_catalog.pg_get_function_identity_arguments(p.oid) AS signature,
+
+ {% if hasFeatureFunctionDefaults %}
+ pg_catalog.pg_get_expr(p.proargdefaults, 'pg_catalog.pg_class'::regclass, false) AS proargdefaults,
+ p.pronargdefaults
+ {%else%}
+ '' AS proargdefaults, 0 AS pronargdefaults
+ {%endif%}
+ FROM
+ pg_catalog.pg_proc p
+ LEFT JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
+ LEFT JOIN pg_catalog.pg_language l ON p.prolang = l.oid
+ LEFT JOIN pg_catalog.pg_type y ON p.prorettype = y.oid
+
+ {% if is_ppas_database %}
+ LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
+ {% endif %}
+
+ {% if fid %}
+ WHERE p.oid = {{fid}}::int;
+ {% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_stack_info.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_stack_info.sql
new file mode 100755
index 0000000..05034c9
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_stack_info.sql
@@ -0,0 +1,4 @@
+{### Get the stack information for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_get_stack({{session_id}}::int) ORDER BY level
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_variables.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_variables.sql
new file mode 100755
index 0000000..47ebed5
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/get_variables.sql
@@ -0,0 +1,8 @@
+{### Get the variables information for debugging ###}
+{% if session_id %}
+ SELECT
+ name, varClass, value,
+ pg_catalog.format_type(dtype, NULL) as dtype, isconst
+ FROM pldbg_get_variables({{session_id}}::int)
+ ORDER BY varClass
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/select_frame.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/select_frame.sql
new file mode 100755
index 0000000..4a18839
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/select_frame.sql
@@ -0,0 +1,11 @@
+{### select the frame to debug the function ###}
+{% if session_id %}
+ SELECT
+ p.func AS func, p.targetName AS targetName, p.linenumber AS linenumber,
+ CASE WHEN p.func <> 0 THEN pldbg_get_source({{session_id}}::INTEGER, p.func) ELSE '' END AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func) AS args
+ FROM pldbg_select_frame({{session_id}}::INTEGER, {{frame_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/set_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/set_breakpoint.sql
new file mode 100755
index 0000000..a56d6f6
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/set_breakpoint.sql
@@ -0,0 +1,4 @@
+{### Set the breakpoints for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_set_breakpoint({{session_id}}::int, {{foid}}::OID,{{line_number}}::int)
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_into.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_into.sql
new file mode 100755
index 0000000..cd05240
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_into.sql
@@ -0,0 +1,11 @@
+{### Step into function for debugging ###}
+{% if session_id %}
+ SELECT
+ p.func, p.targetName, p.linenumber,
+ pldbg_get_source({{session_id}}::INTEGER, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func) AS args
+ FROM pldbg_step_into({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_over.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_over.sql
new file mode 100755
index 0000000..ed3153d
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/step_over.sql
@@ -0,0 +1,11 @@
+{### Step over function for debugging ###}
+{% if session_id %}
+ SELECT
+ p.func, p.targetName, p.linenumber,
+ pldbg_get_source({{session_id}}::INTEGER, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func) AS args
+ FROM pldbg_step_over({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_breakpoint.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_breakpoint.sql
new file mode 100755
index 0000000..96efcb8
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_breakpoint.sql
@@ -0,0 +1,12 @@
+{### select the frame to debug the function ###}
+{% if session_id %}
+ SELECT
+ p.func AS func, p.targetName AS targetName,
+ p.linenumber AS linenumber,
+ pldbg_get_source({{session_id}}::INTEGER, p.func) AS src,
+ (SELECT
+ s.args
+ FROM pldbg_get_stack({{session_id}}::INTEGER) s
+ WHERE s.func = p.func) AS args
+ FROM pldbg_wait_for_breakpoint({{session_id}}::INTEGER) p
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_target.sql b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_target.sql
new file mode 100755
index 0000000..c4f5634
--- /dev/null
+++ b/web/pgadmin/tools/debugger/templates/debugger/sql/v2/wait_for_target.sql
@@ -0,0 +1,4 @@
+{### Wait for the target for debugging ###}
+{% if session_id %}
+ SELECT * FROM pldbg_wait_for_target({{session_id}}::int)
+{% endif %}
\ No newline at end of file