mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 07:16:52 -06:00
Fixed an issue in the debugger where function arguments of the character data type were being truncated. #8007
This commit is contained in:
parent
b649094d36
commit
7a7782a350
@ -1065,38 +1065,6 @@ def start_debugger_listener(trans_id):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if de_inst.function_data['arg_mode']:
|
||||
# In EDBAS 90, if an SPL-function has both an OUT-parameter
|
||||
# and a return value (which is not possible on PostgreSQL
|
||||
# otherwise), the return value is transformed into an extra
|
||||
# OUT-parameter named "_retval_"
|
||||
if de_inst.function_data['args_name']:
|
||||
arg_name = de_inst.function_data['args_name'].split(",")
|
||||
if '_retval_' in arg_name:
|
||||
arg_mode = de_inst.function_data['arg_mode'].split(",")
|
||||
arg_mode.pop()
|
||||
else:
|
||||
arg_mode = de_inst.function_data['arg_mode'].split(",")
|
||||
else:
|
||||
arg_mode = de_inst.function_data['arg_mode'].split(",")
|
||||
else:
|
||||
arg_mode = ['i'] * len(
|
||||
de_inst.function_data['args_type'].split(",")
|
||||
)
|
||||
|
||||
if de_inst.function_data['args_type']:
|
||||
if de_inst.function_data['args_name']:
|
||||
arg_name = de_inst.function_data['args_name'].split(",")
|
||||
if '_retval_' in arg_name:
|
||||
arg_type = de_inst.function_data[
|
||||
'args_type'].split(",")
|
||||
arg_type.pop()
|
||||
else:
|
||||
arg_type = de_inst.function_data[
|
||||
'args_type'].split(",")
|
||||
else:
|
||||
arg_type = de_inst.function_data['args_type'].split(",")
|
||||
|
||||
debugger_args_values = []
|
||||
if de_inst.function_data['args_value']:
|
||||
debugger_args_values = copy.deepcopy(
|
||||
@ -1107,29 +1075,16 @@ def start_debugger_listener(trans_id):
|
||||
val_list = arg['value'][1:-1].split(',')
|
||||
arg['value'] = get_debugger_arg_val(val_list)
|
||||
|
||||
# Below are two different template to execute and start executer
|
||||
if manager.server_type != 'pg' and manager.version < 90300:
|
||||
str_query = render_template(
|
||||
"/".join([DEBUGGER_SQL_PATH, 'execute_edbspl.sql']),
|
||||
func_name=func_name,
|
||||
is_func=de_inst.function_data['is_func'],
|
||||
lan_name=de_inst.function_data['language'],
|
||||
ret_type=de_inst.function_data['return_type'],
|
||||
data=debugger_args_values,
|
||||
arg_type=arg_type,
|
||||
args_mode=arg_mode,
|
||||
conn=conn
|
||||
)
|
||||
else:
|
||||
str_query = render_template(
|
||||
"/".join([DEBUGGER_SQL_PATH, 'execute_plpgsql.sql']),
|
||||
func_name=func_name,
|
||||
is_func=de_inst.function_data['is_func'],
|
||||
ret_type=de_inst.function_data['return_type'],
|
||||
data=debugger_args_values,
|
||||
is_ppas_database=de_inst.function_data['is_ppas_database'],
|
||||
conn=conn
|
||||
)
|
||||
# Template to execute and start executer
|
||||
str_query = render_template(
|
||||
"/".join([DEBUGGER_SQL_PATH, 'execute_plpgsql.sql']),
|
||||
func_name=func_name,
|
||||
is_func=de_inst.function_data['is_func'],
|
||||
ret_type=de_inst.function_data['return_type'],
|
||||
data=debugger_args_values,
|
||||
is_ppas_database=de_inst.function_data['is_ppas_database'],
|
||||
conn=conn
|
||||
)
|
||||
|
||||
status, result = execute_async_search_path(
|
||||
conn, str_query, de_inst.debugger_data['search_path'])
|
||||
@ -1150,34 +1105,16 @@ def start_debugger_listener(trans_id):
|
||||
# other information during debugging
|
||||
int_session_id = res['rows'][0]['pldbg_create_listener']
|
||||
|
||||
# In EnterpriseDB versions <= 9.1 the
|
||||
# pldbg_set_global_breakpoint function took five arguments,
|
||||
# the 2nd argument being the package's OID, if any. Starting
|
||||
# with 9.2, the package OID argument is gone, and the function
|
||||
# takes four arguments like the community version has always
|
||||
# done.
|
||||
if server_type == 'ppas' and ver <= 90100:
|
||||
sql = render_template(
|
||||
"/".join([template_path, 'add_breakpoint_edb.sql']),
|
||||
session_id=int_session_id,
|
||||
function_oid=de_inst.debugger_data['function_id']
|
||||
)
|
||||
sql = render_template(
|
||||
"/".join([template_path, 'add_breakpoint_pg.sql']),
|
||||
session_id=int_session_id,
|
||||
function_oid=de_inst.debugger_data['function_id']
|
||||
)
|
||||
|
||||
status, res = execute_dict_search_path(
|
||||
conn, sql, de_inst.debugger_data['search_path'])
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
else:
|
||||
sql = render_template(
|
||||
"/".join([template_path, 'add_breakpoint_pg.sql']),
|
||||
session_id=int_session_id,
|
||||
function_oid=de_inst.debugger_data['function_id']
|
||||
)
|
||||
|
||||
status, res = execute_dict_search_path(
|
||||
conn, sql, de_inst.debugger_data['search_path'])
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
status, res = execute_dict_search_path(
|
||||
conn, sql, de_inst.debugger_data['search_path'])
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
# wait for the target
|
||||
sql = render_template(
|
||||
|
@ -1,104 +0,0 @@
|
||||
{### 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 %}
|
||||
|
||||
{% 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' %}
|
||||
{### Handle Null parameters received from client ###}
|
||||
{% if data[input_value_index]['type'] == 'text' and data[input_value_index]['value'] != 'NULL' %}
|
||||
{% set tmp_val = data[input_value_index]['value']|qtLiteral(conn) %}
|
||||
{% set str_declare = str_declare ~ " := " ~ strParam ~ " " ~ tmp_val ~ "::" ~ data[input_value_index]['type'] %}
|
||||
{% else %}
|
||||
{% set str_declare = str_declare ~ " := " ~ strParam ~ " " ~ data[input_value_index]['value'] ~ "::" ~ data[input_value_index]['type'] %}
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
|
||||
{### Handle Null parameters received from client ###}
|
||||
{% if data[input_value_index]['type'] == 'text' and data[input_value_index]['value'] != 'NULL' %}
|
||||
{% set tmp_var = data[input_value_index]['value']|qtLiteral(conn) %}
|
||||
{% set str_statement = str_statement ~ tmp_var ~ "::" ~ data[input_value_index]['type'] %}
|
||||
{% else %}
|
||||
{% set str_statement = str_statement ~ data[input_value_index]['value'] ~ "::" ~ data[input_value_index]['type'] %}
|
||||
{% endif %}
|
||||
{% 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 %}
|
@ -11,9 +11,9 @@
|
||||
{% for dict_item in data %}
|
||||
{% if 'type' in dict_item and 'value' in dict_item %}
|
||||
{% if ('NULL:' not in dict_item['value']|string and dict_item['value'] != 'NULL' and '[]' not in dict_item['type']) %}
|
||||
{{ dict_item['value']|qtLiteral(conn) }}::{{ dict_item['type'] }}{% if not loop.last %}, {% endif %}
|
||||
{{ dict_item['value']|qtLiteral(conn) }}::{{ dict_item['type'] }}{% if dict_item['type'] == 'character' %}({{ dict_item['value']|length }}){% endif %}{% if not loop.last %}, {% endif %}
|
||||
{% elif dict_item['value'] == 'NULL' or 'NULL:' in dict_item['value'] %}
|
||||
{{ dict_item['value'] }}::{{ dict_item['type'] }}{% if not loop.last %}, {% endif %}
|
||||
{{ dict_item['value'] }}::{{ dict_item['type'] }}{% if dict_item['type'] == 'character' %}({{ dict_item['value']|length }}){% endif %}{% if not loop.last %}, {% endif %}
|
||||
{% else %}
|
||||
{% if '[]' in dict_item['type'] %}
|
||||
ARRAY[
|
||||
@ -22,9 +22,9 @@
|
||||
{{ dict_list['value']|qtLiteral(conn) }}{% if not loop.last %}, {% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
]::{{ dict_item['type'] }}
|
||||
]::{{ dict_item['type'] }}{% if dict_item['type'] == 'character' %}({{ dict_item['value']|length }}){% endif %}
|
||||
|
||||
{% else %} {{ dict_item['value'] }}::{{ dict_item['type'] }}
|
||||
{% else %} {{ dict_item['value'] }}::{{ dict_item['type'] }}{% if dict_item['type'] == 'character' %}({{ dict_item['value']|length }}){% endif %}
|
||||
{% endif %} {% if not loop.last %}, {% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -1,4 +0,0 @@
|
||||
{### 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 %}
|
@ -1,4 +0,0 @@
|
||||
{### 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 %}
|
Loading…
Reference in New Issue
Block a user