Skip to content

Commit f713452

Browse files
committed
Fix an issue on type casting of default string function/procedure arguments in debugger tool. #9036
1 parent 65860fc commit f713452

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,24 @@ SELECT
4949
pg_catalog.pg_get_function_identity_arguments(p.oid) AS signature,
5050

5151
{% if hasFeatureFunctionDefaults %}
52-
pg_catalog.pg_get_expr(p.proargdefaults, 'pg_catalog.pg_class'::regclass, false) AS proargdefaults,
52+
pg_catalog.array_to_string(
53+
ARRAY(
54+
SELECT
55+
-- Removing type cast, then removing surrounding single quotes if present
56+
CASE
57+
WHEN regexp_replace(val, E'::[a-zA-Z_]+$', '') ~ E'^''.*''$'
58+
THEN substring(regexp_replace(val, E'::[a-zA-Z_]+$', '') FROM E'^''(.*)''$')
59+
ELSE regexp_replace(val, E'::[a-zA-Z_]+$', '')
60+
END
61+
FROM unnest(
62+
regexp_split_to_array(
63+
pg_catalog.pg_get_expr(p.proargdefaults, 'pg_catalog.pg_class'::regclass, false),
64+
',\s*'
65+
)
66+
) AS val
67+
),
68+
','
69+
) AS proargdefaults,
5370
p.pronargdefaults
5471
{%else%}
5572
'' AS proargdefaults, 0 AS pronargdefaults

0 commit comments

Comments
 (0)