Added RESQL/MSQL test cases for Functions. Fixes #5395

Initial patch sent by Nikhil Mohite.
This commit is contained in:
Akshay Joshi 2020-10-06 17:13:41 +05:30
parent 9466278be2
commit 6c4049f29a
188 changed files with 5504 additions and 94 deletions

View File

@ -17,6 +17,7 @@ Housekeeping
************
| `Issue #5330 <https://redmine.postgresql.org/issues/5330>`_ - Improve code coverage and API test cases for Functions.
| `Issue #5395 <https://redmine.postgresql.org/issues/5395>`_ - Added RESQL/MSQL test cases for Functions.
| `Issue #5497 <https://redmine.postgresql.org/issues/5497>`_ - Merged the latest code of 'pgcli' used for the autocomplete feature.
Bug fixes

View File

@ -1,69 +0,0 @@
{% import 'macros/functions/security.macros' as SECLABEL %}
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
{% import 'macros/functions/variable.macros' as VARIABLE %}
{% set is_columns = [] %}
{% set exclude_quoting = ['search_path'] %}
{% if data %}
{% if query_for == 'sql_panel' and func_def is defined %}
CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}}
{% else %}
CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %}
{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif -%}
)
{% endif %}
RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %}
LANGUAGE {{ data.lanname|qtLiteral }}
{% if data.procost %}
COST {{data.procost}}
{% endif %}
{% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %}
{% if data.proisstrict %}STRICT {% endif %}
{% if data.prosecdef %}SECURITY DEFINER {% endif %}
{% if data.proiswindow %}WINDOW {% endif %}
{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %}
{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.prorows and (data.prorows | int) > 0 %}
ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %}
{% endif %}
AS {% if data.lanname == 'c' %}
{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }}
{% else %}
$BODY${{ data.prosrc }}$BODY${% endif -%};
{% if data.funcowner %}
ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{% if data.acl %}
{% for p in data.acl %}
{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}}
{% endfor %}{% endif %}
{% if data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}}
{% endif %}
{% if data.description %}
COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
IS {{ data.description|qtLiteral }};
{% endif -%}
{% if data.seclabels %}
{% for r in data.seclabels %}
{% if r.label and r.provider %}
{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }}
{% endif %}
{% endfor %}
{% endif -%}
{% endif %}

View File

@ -18,7 +18,6 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
LANGUAGE {{ data.lanname|qtLiteral }}
{% if data.procost %}
COST {{data.procost}}
{% endif %}
{% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %}
@ -26,12 +25,16 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
{% if data.prosecdef %}SECURITY DEFINER {% endif %}
{% if data.proiswindow %}WINDOW {% endif %}
{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %}
{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.prorows and (data.prorows | int) > 0 %}
ROWS {{data.prorows}}{% endif %}
ROWS {{data.prorows}}
{% endif %}
{% if data.prosupportfunc %}
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% endif -%}{% if data.variables %}{% for v in data.variables %}
SUPPORT {{ data.prosupportfunc }}
{% endif -%}
{% if data.variables %}{% for v in data.variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %}
{% endif %}

View File

@ -18,7 +18,6 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
LANGUAGE {{ data.lanname|qtLiteral }}
{% if data.procost %}
COST {{data.procost}}
{% endif %}
{% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %}
@ -26,10 +25,12 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con
{% if data.prosecdef %}SECURITY DEFINER {% endif %}
{% if data.proiswindow %}WINDOW {% endif %}
{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %}
{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif -%}
{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.prorows and (data.prorows | int) > 0 %}
ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
ROWS {{data.prorows}}
{% endif %}
{% if data.variables %}{% for v in data.variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %}
{% endif %}

View File

@ -9,27 +9,32 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func
{% else %}
CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %}
{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %}
{% if not loop.last %},{% endif %}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif -%}
)
{% endif -%}
)
{% endif %}
RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %}
LANGUAGE {{ data.lanname|qtLiteral }}
{% if data.procost %}
COST {{data.procost}}
{% endif %}
{% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %}
{% if data.proisstrict %}STRICT {% endif %}
{% if data.prosecdef %}SECURITY DEFINER {% endif %}
{% if data.proiswindow %}WINDOW {% endif %}
{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %}
{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.procost %}
{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.prorows and (data.prorows | int) > 0 %}
COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %}
ROWS {{data.prorows}}
{% endif %}
{% if data.prosupportfunc %}
ROWS {{data.prorows}}{% endif %}
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% endif -%}{% if data.variables %}{% for v in data.variables %}
SUPPORT {{ data.prosupportfunc }}
{% endif -%}
{% if data.variables %}{% for v in data.variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %}
{% endif %}

View File

@ -9,25 +9,28 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func
{% else %}
CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %}
{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %}
{% if not loop.last %},{% endif %}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif -%}
)
{% endif -%}
)
{% endif %}
RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %}
LANGUAGE {{ data.lanname|qtLiteral }}
{% if data.procost %}
COST {{data.procost}}
{% endif %}
{% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %}
{% if data.proisstrict %}STRICT {% endif %}
{% if data.prosecdef %}SECURITY DEFINER {% endif %}
{% if data.proiswindow %}WINDOW {% endif %}
{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %}
{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.procost %}
{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %}
{% if data.prorows and (data.prorows | int) > 0 %}
COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %}
ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %}
ROWS {{data.prorows}}
{% endif %}
{% if data.variables %}{% for v in data.variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %}
{% endif %}

View File

@ -0,0 +1,35 @@
SELECT
pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c,
pr.pronamespace, pr.prolang, pr.procost, pr.prorows,
pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel,
pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl,
pr.proname, pr.proname AS name, pg_get_function_result(pr.oid) AS prorettypename,
typns.nspname AS typnsp, lanname, proargnames, oidvectortypes(proargtypes) AS proargtypenames,
pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals,
pr.pronargdefaults, proconfig, pg_get_userbyid(proowner) AS funcowner, description,
(SELECT
array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
WHERE
sl1.objoid=pr.oid) AS seclabels
FROM
pg_proc pr
JOIN
pg_type typ ON typ.oid=prorettype
JOIN
pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_language lng ON lng.oid=prolang
LEFT OUTER JOIN
pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0)
WHERE
proisagg = FALSE
AND typname NOT IN ('trigger', 'event_trigger')
{% if fnid %}
AND pr.oid = {{fnid}}::oid
{% else %}
AND pronamespace = {{scid}}::oid
{% endif %}
ORDER BY
proname;

View File

@ -32,4 +32,5 @@ FROM
) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;
GROUP BY g.rolname, gt.rolname
ORDER BY grantee

View File

@ -0,0 +1 @@
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;

View File

@ -0,0 +1,24 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC;

View File

@ -0,0 +1,13 @@
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
VOLATILE
PARALLEL UNSAFE
COST 100
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,3 @@
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RESET application_name;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RENAME TO "Function3_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1')
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,260 @@
{
"scenarios": [
{
"type": "create",
"name": "Create function with all options.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function1_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proretset": false,
"proisstrict": true,
"prosecdef": true,
"proiswindow": true,
"proparallel": "u",
"procost": "100",
"prorows": "0",
"proleakproof": true,
"arguments": [
{
"argtype": "character varying",
"argmode": "IN",
"argname": "param",
"argdefval": "'1'"
}
],
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function.sql",
"expected_msql_file": "create_function.msql"
},
{
"type": "alter",
"name": "Alter function comment",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"description": "Some comment"
},
"expected_sql_file": "alter_function_comment.sql",
"expected_msql_file": "alter_function_comment.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for alter.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proparallel": "u",
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function rename.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name":"Function3_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_function_rename.sql",
"expected_msql_file": "alter_function_rename.msql"
},
{
"type": "alter",
"name": "Alter function code and add parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"prosrc": "begin\nselect '2';\nend\n",
"variables": {
"added": [
{
"name": "application_name",
"value": "appname"
}
]
}
},
"expected_sql_file": "alter_function_add_parameter.sql",
"expected_msql_file": "alter_function_add_parameter.msql"
},
{
"type": "alter",
"name": "Alter function delete parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"variables": {
"deleted": [
{
"name": "application_name",
"value": true
}
]
}
},
"expected_sql_file": "alter_function_delete_parameter.sql",
"expected_msql_file": "alter_function_delete_parameter.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for acl.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proparallel": "u",
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"added": [
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_add_acl.sql",
"expected_msql_file": "alter_function_add_acl.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
},
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_delete_acl.sql",
"expected_msql_file": "alter_function_delete_acl.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1 @@
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;

View File

@ -0,0 +1,24 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC;

View File

@ -0,0 +1,14 @@
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
VOLATILE
PARALLEL UNSAFE
COST 100
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,3 @@
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RESET application_name;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RENAME TO "Function3_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,15 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,2 @@
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,16 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,2 @@
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
SET application_name=pgadmin;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
STABLE LEAKPROOF STRICT SECURITY DEFINER
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname'
SET search_path=public, pg_temp
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,23 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname2'
SET search_path=public, pg_catalog
SET array_nulls='true'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,26 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS SETOF event_trigger
LANGUAGE 'plpgsql'
COST 1234
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
ROWS 4321
SET application_name='appname'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION;
REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1')
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,17 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,27 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS SETOF trigger
LANGUAGE 'plpgsql'
COST 1234
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
ROWS 4321
SET application_name='appname'
SET search_path=public, pg_temp
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION;
REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,12 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;

View File

@ -0,0 +1,260 @@
{
"scenarios": [
{
"type": "create",
"name": "Create function with all options.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function1_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proretset": false,
"proisstrict": true,
"prosecdef": true,
"proiswindow": true,
"proparallel": "u",
"procost": "100",
"prorows": "0",
"proleakproof": true,
"arguments": [
{
"argtype": "character varying",
"argmode": "IN",
"argname": "param",
"argdefval": "'1'"
}
],
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function.sql",
"expected_msql_file": "create_function.msql"
},
{
"type": "alter",
"name": "Alter function comment",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"description": "Some comment"
},
"expected_sql_file": "alter_function_comment.sql",
"expected_msql_file": "alter_function_comment.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for alter.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proparallel": "u",
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function rename.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name":"Function3_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_function_rename.sql",
"expected_msql_file": "alter_function_rename.msql"
},
{
"type": "alter",
"name": "Alter function code and add parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"prosrc": "begin\nselect '2';\nend\n",
"variables": {
"added": [
{
"name": "application_name",
"value": "appname"
}
]
}
},
"expected_sql_file": "alter_function_add_parameter.sql",
"expected_msql_file": "alter_function_add_parameter.msql"
},
{
"type": "alter",
"name": "Alter function delete parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"variables": {
"deleted": [
{
"name": "application_name",
"value": true
}
]
}
},
"expected_sql_file": "alter_function_delete_parameter.sql",
"expected_msql_file": "alter_function_delete_parameter.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for acl.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proparallel": "u",
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"added": [
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_add_acl.sql",
"expected_msql_file": "alter_function_add_acl.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
},
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_delete_acl.sql",
"expected_msql_file": "alter_function_delete_acl.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1,58 @@
{
"scenarios": [
{
"type": "create",
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
"arguments": [{"argtype": "integer", "argmode": "IN", "argname": "i1", "argdefval": ""}],
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"pronamespace": 2200,
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [],
"schema": "public",
"provolatile": null,
"proisstrict": false,
"proparallel": null,
"procost": null,
"proleakproof": false,
"probin": "$libdir/"
},
"expected_sql_file": "create_procedure.sql"
}, {
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"data": {
"description": "some comment"
},
"expected_sql_file": "alter_proc_comment.sql",
"expected_msql_file": "alter_proc_comment_msql.sql"
}, {
"type": "alter",
"name": "Alter procedure param",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"data": {
"variables": {
"added": [{"name": "application_name", "value": "pgadmin"}]
}
},
"expected_sql_file": "alter_proc_param.sql",
"expected_msql_file": "alter_proc_param_msql.sql"
}, {
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1,191 @@
{
"scenarios": [
{
"type": "create",
"name": "Create trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
"args": [],
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"pronamespace": 2200,
"prorettypename": "trigger",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [],
"schema": "public"
},
"expected_sql_file": "create_plain_trigger.sql"
}, {
"type": "alter",
"name": "Alter trigger function comment",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"description": "some comment"
},
"expected_sql_file": "alter_ptrig_comment.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 1 - Strict, Leakproof, Security of definer, Volatility",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"proisstrict": true,
"proleakproof": true,
"prosecdef": true,
"provolatile": "s"
},
"expected_sql_file": "alter_ptrig_set_1.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 2 - Cost, Volatility, Add Param",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"procost": "123",
"provolatile": "i",
"variables": {
"added": [{
"name": "application_name",
"value": "appname"
},{
"name": "search_path",
"value": "public, pg_temp"
}]
}
},
"expected_sql_file": "alter_ptrig_set_2.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 3 - Add Param, Change Param",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"variables": {
"added": [{
"name": "application_name",
"value": "appname2"
}],
"changed": [{
"name": "array_nulls",
"value": true
},{
"name": "search_path",
"value": "public, pg_catalog"
}]
}
},
"expected_sql_file": "alter_ptrig_set_3.sql"
}, {
"type": "delete",
"name": "Drop trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}, {
"type": "create",
"name": "Create full fledged trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": true
}
]
}],
"args": [],
"description": "some comment",
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"procost": "1234",
"proisstrict": true,
"proiswindow": true,
"proleakproof": true,
"pronamespace": 2200,
"proretset": true,
"prorettypename": "trigger",
"prorows": "4321",
"prosecdef": true,
"provolatile": "s",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [{
"name": "application_name",
"value": "appname"
},{
"name": "search_path",
"value": "public, pg_temp"
}],
"schema": "public"
},
"expected_sql_file": "create_plain_trigger_full.sql"
}, {
"type": "delete",
"name": "Drop full fledged trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}, {
"type": "create",
"name": "Create full fledged event trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": true
}
]
}],
"args": [],
"description": "some comment",
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"procost": "1234",
"proisstrict": true,
"proiswindow": true,
"proleakproof": true,
"pronamespace": 2200,
"proretset": true,
"prorettypename": "event_trigger",
"prorows": "4321",
"prosecdef": true,
"provolatile": "s",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [{
"name": "application_name",
"value": "appname"
}],
"schema": "public"
},
"expected_sql_file": "create_event_trigger_full.sql"
}, {
"type": "delete",
"name": "Drop full fledged event trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1 @@
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;

View File

@ -0,0 +1,26 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;

View File

@ -0,0 +1,12 @@
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
VOLATILE WINDOW
COST 100
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,3 @@
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RESET application_name;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RENAME TO "Function3_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
STABLE LEAKPROOF STRICT SECURITY DEFINER
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname'
SET search_path=public, pg_temp
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,23 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname2'
SET search_path=public, pg_catalog
SET array_nulls='true'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,26 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS SETOF event_trigger
LANGUAGE 'plpgsql'
COST 1234
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
ROWS 4321
SET application_name='appname'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION;
REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1')
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE WINDOW
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,17 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,27 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS SETOF trigger
LANGUAGE 'plpgsql'
COST 1234
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
ROWS 4321
SET application_name='appname'
SET search_path=public, pg_temp
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION;
REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,259 @@
{
"scenarios": [
{
"type": "create",
"name": "Create function with all options.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function1_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proretset": false,
"proisstrict": true,
"prosecdef": true,
"proiswindow": true,
"procost": "100",
"prorows": "0",
"proleakproof": true,
"arguments": [
{
"argtype": "character varying",
"argmode": "IN",
"argname": "param",
"argdefval": "'1'"
}
],
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function.sql",
"expected_msql_file": "create_function.msql"
},
{
"type": "alter",
"name": "Alter function comment",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"description": "Some comment"
},
"expected_sql_file": "alter_function_comment.sql",
"expected_msql_file": "alter_function_comment.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for alter.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proiswindow": true,
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function rename.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name":"Function3_$%{}[]()&*^!@\"'`\\/#"
},
"expected_sql_file": "alter_function_rename.sql",
"expected_msql_file": "alter_function_rename.msql"
},
{
"type": "alter",
"name": "Alter function code and add parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"prosrc": "begin\nselect '2';\nend\n",
"variables": {
"added": [
{
"name": "application_name",
"value": "appname"
}
]
}
},
"expected_sql_file": "alter_function_add_parameter.sql",
"expected_msql_file": "alter_function_add_parameter.msql"
},
{
"type": "alter",
"name": "Alter function delete parameters.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"variables": {
"deleted": [
{
"name": "application_name",
"value": true
}
]
}
},
"expected_sql_file": "alter_function_delete_parameter.sql",
"expected_msql_file": "alter_function_delete_parameter.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
},
{
"type": "create",
"name": "Create function for acl.",
"endpoint": "NODE-function.obj",
"msql_endpoint": "NODE-function.msql",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"name": "Function2_$%{}[]()&*^!@\"'`\\/#",
"funcowner": "postgres",
"pronamespace": 2200,
"prorettypename": "character varying",
"lanname": "plpgsql",
"provolatile": "v",
"proiswindow": true,
"arguments": [],
"procost": "100",
"prosrc": "begin\nselect '1';\nend",
"probin": "$libdir/",
"options": [],
"variables": [
{
"name": "enable_sort",
"value": true
}
],
"seclabels": [],
"acl": [],
"schema": "public"
},
"expected_sql_file": "create_function_for_alter.sql",
"expected_msql_file": "create_function_for_alter.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"added": [
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_add_acl.sql",
"expected_msql_file": "alter_function_add_acl.msql"
},
{
"type": "alter",
"name": "Alter function add acl.",
"endpoint": "NODE-function.obj_id",
"msql_endpoint": "NODE-function.msql_id",
"sql_endpoint": "NODE-function.sql_id",
"data": {
"acl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
},
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_function_delete_acl.sql",
"expected_msql_file": "alter_function_delete_acl.msql"
},
{
"type": "delete",
"name": "Drop function",
"endpoint": "NODE-function.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1,191 @@
{
"scenarios": [
{
"type": "create",
"name": "Create trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
"args": [],
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"pronamespace": 2200,
"prorettypename": "trigger",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [],
"schema": "public"
},
"expected_sql_file": "create_plain_trigger.sql"
}, {
"type": "alter",
"name": "Alter trigger function comment",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"description": "some comment"
},
"expected_sql_file": "alter_ptrig_comment.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 1 - Strict, Leakproof, Security of definer, Volatility",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"proisstrict": true,
"proleakproof": true,
"prosecdef": true,
"provolatile": "s"
},
"expected_sql_file": "alter_ptrig_set_1.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 2 - Cost, Volatility, Add Param",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"procost": "123",
"provolatile": "i",
"variables": {
"added": [{
"name": "application_name",
"value": "appname"
},{
"name": "search_path",
"value": "public, pg_temp"
}]
}
},
"expected_sql_file": "alter_ptrig_set_2.sql"
}, {
"type": "alter",
"name": "Alter trigger function Set 3 - Add Param, Change Param",
"endpoint": "NODE-trigger_function.obj_id",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"variables": {
"added": [{
"name": "application_name",
"value": "appname2"
}],
"changed": [{
"name": "array_nulls",
"value": true
},{
"name": "search_path",
"value": "public, pg_catalog"
}]
}
},
"expected_sql_file": "alter_ptrig_set_3.sql"
}, {
"type": "delete",
"name": "Drop trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}, {
"type": "create",
"name": "Create full fledged trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": true
}
]
}],
"args": [],
"description": "some comment",
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"procost": "1234",
"proisstrict": true,
"proiswindow": true,
"proleakproof": true,
"pronamespace": 2200,
"proretset": true,
"prorettypename": "trigger",
"prorows": "4321",
"prosecdef": true,
"provolatile": "s",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [{
"name": "application_name",
"value": "appname"
},{
"name": "search_path",
"value": "public, pg_temp"
}],
"schema": "public"
},
"expected_sql_file": "create_plain_trigger_full.sql"
}, {
"type": "delete",
"name": "Drop full fledged trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}, {
"type": "create",
"name": "Create full fledged event trigger function",
"endpoint": "NODE-trigger_function.obj",
"sql_endpoint": "NODE-trigger_function.sql_id",
"data": {
"name": "Trig1_$%{}[]()&*^!@\"'`\\/#",
"acl": [{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": true
}
]
}],
"args": [],
"description": "some comment",
"funcowner": "postgres",
"lanname": "plpgsql",
"options": [],
"procost": "1234",
"proisstrict": true,
"proiswindow": true,
"proleakproof": true,
"pronamespace": 2200,
"proretset": true,
"prorettypename": "event_trigger",
"prorows": "4321",
"prosecdef": true,
"provolatile": "s",
"prosrc": "begin\nselect 1;\nend;",
"seclabels": [],
"variables": [{
"name": "application_name",
"value": "appname"
}],
"schema": "public"
},
"expected_sql_file": "create_event_trigger_full.sql"
}, {
"type": "delete",
"name": "Drop full fledged event trigger function",
"endpoint": "NODE-trigger_function.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1 @@
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;

View File

@ -0,0 +1,24 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres;
GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC;

View File

@ -0,0 +1,13 @@
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RETURNS character varying
LANGUAGE 'plpgsql'
VOLATILE
PARALLEL UNSAFE
COST 100
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET application_name='appname'
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;
COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
IS 'Some comment';

View File

@ -0,0 +1,3 @@
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
RESET application_name;

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '2';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,2 @@
ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"()
RENAME TO "Function3_$%{}[]()&*^!@""'`\/#";

View File

@ -0,0 +1,19 @@
-- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"();
CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"(
)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
STABLE LEAKPROOF STRICT SECURITY DEFINER
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,22 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname'
SET search_path=public, pg_temp
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,23 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 123
IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER
SET application_name='appname2'
SET search_path=public, pg_catalog
SET array_nulls='true'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,26 @@
-- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"();
CREATE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
RETURNS SETOF event_trigger
LANGUAGE 'plpgsql'
COST 1234
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW
ROWS 4321
SET application_name='appname'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION;
REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;
COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"()
IS 'some comment';

View File

@ -0,0 +1,14 @@
CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1')
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort=true
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

View File

@ -0,0 +1,20 @@
-- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying)
-- DROP FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying);
CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(
param character varying DEFAULT '1'::character varying)
RETURNS character varying
LANGUAGE 'plpgsql'
COST 100
VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW PARALLEL UNSAFE
SET enable_sort='true'
AS $BODY$
begin
select '1';
end
$BODY$;
ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying)
OWNER TO postgres;

Some files were not shown because too many files have changed in this diff Show More