Add support of DEPENDS/NO DEPENDS ON EXTENSION for PROCEDURE. #6391

pull/9308/head
Rohit Bhati 2025-10-31 18:17:04 +05:30 committed by GitHub
parent 48b4a8d448
commit 38ebb43bac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
76 changed files with 1732 additions and 59 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -36,6 +36,9 @@ Use the fields in the *Definition* tab to define the procedure:
* Use the drop-down listbox next to *Language* to select a language. The default
is *edbspl*.
* Use the drop-down listbox next to *Depends on extensions* to select the extension that this procedure
depends on (for example, edbspl). If set, dropping the extension will automatically drop the
procedure as well.
* Use the fields in the *Arguments* section to define an argument. Click *Add* to set
parameters and values for the argument:
* Use the drop-down listbox next to *Data type* to select a data type.

View File

@ -1171,7 +1171,10 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
old_data['proparallel'] = \
parallel_dict[old_data['proparallel']]
if self.node_type == 'function':
if self.node_type in ('function', 'procedure') and (
old_data.get('dependsonextensions') is None or
data.get('dependsonextensions') is None
):
old_data['dependsonextensions'] = \
old_data.get('dependsonextensions') or []
data['dependsonextensions'] = \

View File

@ -288,8 +288,7 @@ export default class FunctionSchema extends BaseUISchema {
placeholder: gettext('Select the Depends on extensions...'),
},
min_version: 130000,
mode: ['create', 'edit', 'properties'],
visible: obj.isVisible
mode: ['create', 'edit', 'properties']
},{
id: 'probin', label: gettext('Object file'), cell: 'string',
type: 'text', group: gettext('Definition'), deps: ['lanname'], visible:

View File

@ -92,6 +92,7 @@ define('pgadmin.node.procedure', [
);
},
getSchema: function(treeNodeInfo, itemNodeData) {
let nodeObj = pgBrowser.Nodes['extension'];
return new FunctionSchema(
(privileges)=>getNodePrivilegeRoleSchema(this, treeNodeInfo, itemNodeData, privileges),
()=>getNodeVariableSchema(this, treeNodeInfo, itemNodeData, false, false),
@ -101,6 +102,16 @@ define('pgadmin.node.procedure', [
cacheLevel: 'database'
}
),
extensionsList:()=>getNodeAjaxOptions('nodes', nodeObj, treeNodeInfo, itemNodeData, { cacheLevel: 'server'},
(data)=>{
let res = [];
if (data && _.isArray(data)) {
_.each(data, function(d) {
res.push({label: d.label, value: d.label, data: d});
});
}
return res;
}),
getTypes: ()=>getNodeAjaxOptions('get_types', this, treeNodeInfo, itemNodeData),
getLanguage: ()=>getNodeAjaxOptions('get_languages', this, treeNodeInfo, itemNodeData),
getSupportFunctions: ()=>getNodeAjaxOptions('get_support_functions', this, treeNodeInfo, itemNodeData, {

View File

@ -0,0 +1,66 @@
{% 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 OR REPLACE PROCEDURE {{func_def}}
{% else %}
CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}{% if data.arguments is defined %}
({% 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 %}
LANGUAGE {{ data.lanname|qtLiteral(conn) }}{% if data.prosecdef %}
SECURITY DEFINER {% 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(conn) }}{% endif %}{% endfor -%}
{% endif %}
AS {% if data.lanname == 'c' %}
{{ data.probin|qtLiteral(conn) }}, {{ data.prosrc_c|qtLiteral(conn) }}
{% else %}
$BODY${{ data.prosrc }}$BODY${% endif -%};
{% if data.funcowner %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{% if data.dependsonextensions %}
{% for ext in data.dependsonextensions %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endfor %}
{% endif %}
{% if data.acl and not is_sql %}
{% for p in data.acl %}
{{ PRIVILEGE.SET(conn, "PROCEDURE", 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, "PROCEDURE", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}}
{% endif %}
{% if data.description %}
COMMENT ON PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
IS {{ data.description|qtLiteral(conn) }};
{% endif -%}
{% if data.seclabels %}
{% for r in data.seclabels %}
{% if r.label and r.provider %}
{{ SECLABEL.SET(conn, 'PROCEDURE', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }}
{% endif %}
{% endfor %}
{% endif -%}
{% endif %}

View File

@ -0,0 +1,53 @@
SELECT
pr.oid, pr.xmin,
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
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_catalog.pg_get_function_result(pr.oid) AS prorettypename,
typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames,
pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals,
pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description,
(
SELECT array_agg(DISTINCT e.extname)
FROM pg_depend d
JOIN pg_extension e ON d.refobjid = e.oid
WHERE d.objid = pr.oid
) AS dependsonextensions,
(
WITH name_with_args_tab AS (SELECT pg_catalog.pg_get_function_identity_arguments(pr.oid) AS val)
SELECT CASE WHEN
val <> ''
THEN
pr.proname || '(' || val || ')'
ELSE
pr.proname::text
END
FROM name_with_args_tab
) AS name_with_args,
(SELECT
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=pr.oid) AS seclabels
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
LEFT OUTER JOIN
pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0)
WHERE
pr.prokind = 'p'
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

@ -0,0 +1,128 @@
{% import 'macros/functions/security.macros' as SECLABEL %}
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
{% set name = o_data.name %}
{% set exclude_quoting = ['search_path'] %}
{% if data.name %}
{% if data.name != o_data.name %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %}
RENAME TO {{ conn|qtIdent(data.name) }};
{% set name = data.name %}
{% endif %}
{% endif -%}
{% if data.change_func %}
CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, 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 %}
)
{% if 'lanname' in data %}
LANGUAGE {{ data.lanname|qtLiteral(conn) }} {% else %}
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
{% endif %}
{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %}SECURITY DEFINER{% endif %}
{% if data.merged_variables %}{% for v in data.merged_variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
{% endif %}
AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %}
{% if 'probin' in data %}{{ data.probin|qtLiteral(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% else %}
$BODY${{ o_data.prosrc }}$BODY${% endif -%};
{% endif -%}
{% if data.funcowner %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %}
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{# The SQL generated below will change priviledges #}
{% if data.acl %}
{% if 'deleted' in data.acl %}
{% for priv in data.acl.deleted %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'changed' in data.acl %}
{% for priv in data.acl.changed %}
{% if priv.grantee != priv.old_grantee %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% else %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% endif %}
{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant,
priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'added' in data.acl %}
{% for priv in data.acl.added %}
{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif %}
{% endif -%}
{% if data.change_func == False %}
{% if data.variables %}
{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %}
{{ VARIABLE.UNSET(conn, 'PROCEDURE', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }}
{% endif -%}
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
{{ VARIABLE.SET(conn, 'PROCEDURE', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }}
{% endif -%}
{% endif -%}
{% endif -%}
{% set seclabels = data.seclabels %}
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
{% for r in seclabels.deleted %}
{{ SECLABEL.UNSET(conn, 'PROCEDURE', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if data.description is defined and data.description != o_data.description%}
COMMENT ON PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
IS {{ data.description|qtLiteral(conn) }};
{% endif -%}
{% if data.pronamespace %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
{% endif -%}
{% set old_exts = (o_data.dependsonextensions or []) | list %}
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
{% if new_exts is not none and old_exts != new_exts %}
{% for ext in (old_exts + new_exts) | unique %}
{% if ext in new_exts and ext not in old_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% elif ext in old_exts and ext not in new_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

View File

@ -35,6 +35,14 @@ ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_arg
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{% if data.dependsonextensions %}
{% for ext in data.dependsonextensions %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endfor %}
{% endif %}
{% if data.acl and not is_sql %}
{% for p in data.acl %}

View File

@ -10,6 +10,12 @@ SELECT
pg_catalog.pg_get_function_sqlbody(pr.oid) AS prosrc_sql,
CASE WHEN pr.prosqlbody IS NOT NULL THEN true ELSE false END as is_pure_sql,
pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description,
(
SELECT array_agg(DISTINCT e.extname)
FROM pg_depend d
JOIN pg_extension e ON d.refobjid = e.oid
WHERE d.objid = pr.oid
) AS dependsonextensions,
(
WITH name_with_args_tab AS (SELECT pg_catalog.pg_get_function_identity_arguments(pr.oid) AS val)
SELECT CASE WHEN

View File

@ -111,4 +111,20 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
{% endif -%}
{% set old_exts = (o_data.dependsonextensions or []) | list %}
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
{% if new_exts is not none and old_exts != new_exts %}
{% for ext in (old_exts + new_exts) | unique %}
{% if ext in new_exts and ext not in old_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% elif ext in old_exts and ext not in new_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

View File

@ -0,0 +1,66 @@
{% 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 OR REPLACE PROCEDURE {{func_def}}
{% else %}
CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}{% if data.arguments is defined %}
({% 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 %}
LANGUAGE {{ data.lanname|qtLiteral(conn) }}{% if data.prosecdef %}
SECURITY DEFINER {% 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(conn) }}{% endif %}{% endfor -%}
{% endif %}
AS {% if data.lanname == 'c' %}
{{ data.probin|qtLiteral(conn) }}, {{ data.prosrc_c|qtLiteral(conn) }}
{% else %}
$BODY${{ data.prosrc }}$BODY${% endif -%};
{% if data.funcowner %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{% if data.dependsonextensions %}
{% for ext in data.dependsonextensions %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endfor %}
{% endif %}
{% if data.acl and not is_sql %}
{% for p in data.acl %}
{{ PRIVILEGE.SET(conn, "PROCEDURE", 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, "PROCEDURE", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}}
{% endif %}
{% if data.description %}
COMMENT ON PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
IS {{ data.description|qtLiteral(conn) }};
{% endif -%}
{% if data.seclabels %}
{% for r in data.seclabels %}
{% if r.label and r.provider %}
{{ SECLABEL.SET(conn, 'PROCEDURE', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }}
{% endif %}
{% endfor %}
{% endif -%}
{% endif %}

View File

@ -0,0 +1,53 @@
SELECT
pr.oid, pr.xmin,
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
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_catalog.pg_get_function_result(pr.oid) AS prorettypename,
typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames,
pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals,
pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description,
(
SELECT array_agg(DISTINCT e.extname)
FROM pg_depend d
JOIN pg_extension e ON d.refobjid = e.oid
WHERE d.objid = pr.oid
) AS dependsonextensions,
(
WITH name_with_args_tab AS (SELECT pg_catalog.pg_get_function_identity_arguments(pr.oid) AS val)
SELECT CASE WHEN
val <> ''
THEN
pr.proname || '(' || val || ')'
ELSE
pr.proname::text
END
FROM name_with_args_tab
) AS name_with_args,
(SELECT
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=pr.oid) AS seclabels
FROM
pg_catalog.pg_proc pr
JOIN
pg_catalog.pg_type typ ON typ.oid=prorettype
JOIN
pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace
JOIN
pg_catalog.pg_language lng ON lng.oid=prolang
LEFT OUTER JOIN
pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0)
WHERE
pr.prokind = 'p'
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

@ -0,0 +1,128 @@
{% import 'macros/functions/security.macros' as SECLABEL %}
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
{% set name = o_data.name %}
{% set exclude_quoting = ['search_path'] %}
{% if data.name %}
{% if data.name != o_data.name %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %}
RENAME TO {{ conn|qtIdent(data.name) }};
{% set name = data.name %}
{% endif %}
{% endif -%}
{% if data.change_func %}
CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, 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 %}
)
{% if 'lanname' in data %}
LANGUAGE {{ data.lanname|qtLiteral(conn) }} {% else %}
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
{% endif %}
{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %}SECURITY DEFINER{% endif %}
{% if data.merged_variables %}{% for v in data.merged_variables %}
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
{% endif %}
AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %}
{% if 'probin' in data %}{{ data.probin|qtLiteral(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% else %}
$BODY${{ o_data.prosrc }}$BODY${% endif -%};
{% endif -%}
{% if data.funcowner %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %}
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{# The SQL generated below will change priviledges #}
{% if data.acl %}
{% if 'deleted' in data.acl %}
{% for priv in data.acl.deleted %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'changed' in data.acl %}
{% for priv in data.acl.changed %}
{% if priv.grantee != priv.old_grantee %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% else %}
{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
{% endif %}
{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant,
priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'added' in data.acl %}
{% for priv in data.acl.added %}
{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif %}
{% endif -%}
{% if data.change_func == False %}
{% if data.variables %}
{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %}
{{ VARIABLE.UNSET(conn, 'PROCEDURE', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }}
{% endif -%}
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
{{ VARIABLE.SET(conn, 'PROCEDURE', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }}
{% endif -%}
{% endif -%}
{% endif -%}
{% set seclabels = data.seclabels %}
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
{% for r in seclabels.deleted %}
{{ SECLABEL.UNSET(conn, 'PROCEDURE', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
{% endfor %}
{% endif -%}
{% if data.description is defined and data.description != o_data.description%}
COMMENT ON PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
IS {{ data.description|qtLiteral(conn) }};
{% endif -%}
{% if data.pronamespace %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
{% endif -%}
{% set old_exts = (o_data.dependsonextensions or []) | list %}
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
{% if new_exts is not none and old_exts != new_exts %}
{% for ext in (old_exts + new_exts) | unique %}
{% if ext in new_exts and ext not in old_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% elif ext in old_exts and ext not in new_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

View File

@ -43,6 +43,14 @@ ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_arg
OWNER TO {{ conn|qtIdent(data.funcowner) }};
{% endif -%}
{% if data.dependsonextensions %}
{% for ext in data.dependsonextensions %}
ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endfor %}
{% endif %}
{% if data.acl and not is_sql %}
{% for p in data.acl %}

View File

@ -8,6 +8,12 @@ SELECT
typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames,
pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals,
pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description,
(
SELECT array_agg(DISTINCT e.extname)
FROM pg_depend d
JOIN pg_extension e ON d.refobjid = e.oid
WHERE d.objid = pr.oid
) AS dependsonextensions,
pg_catalog.pg_get_function_sqlbody(pr.oid) AS prosrc_sql,
CASE WHEN pr.prosqlbody IS NOT NULL THEN true ELSE false END as is_pure_sql,
(

View File

@ -121,4 +121,20 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
{% endif -%}
{% set old_exts = (o_data.dependsonextensions or []) | list %}
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
{% if new_exts is not none and old_exts != new_exts %}
{% for ext in (old_exts + new_exts) | unique %}
{% if ext in new_exts and ext not in old_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% elif ext in old_exts and ext not in new_exts %}
ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

View File

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

View File

@ -0,0 +1,23 @@
-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#()
-- DROP FUNCTION IF EXISTS 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;
REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC;

View File

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

View File

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

View File

@ -1,13 +1,3 @@
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC;

View File

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

View File

@ -0,0 +1,23 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO postgres;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM PUBLIC;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,10 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;

View File

@ -234,7 +234,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -5,6 +5,7 @@
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
@ -24,22 +25,27 @@
"proleakproof": false,
"probin": "$libdir/"
},
"expected_sql_file": "create_procedure.sql"
}, {
"expected_sql_file": "create_procedure.sql",
"expected_msql_file": "create_procedure.msql"
},
{
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_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",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"variables": {
"added": [{"name": "application_name", "value": "pgadmin"}]
@ -53,6 +59,7 @@
"name": "Alter procedure add privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"added": [
@ -80,13 +87,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_add_priv.sql",
"expected_msql_file": "alter_proc_add_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure delete privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"deleted": [
@ -103,13 +113,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_delete_priv.sql",
"expected_msql_file": "alter_proc_delete_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure change privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"changed": [

View File

@ -0,0 +1,2 @@
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
NO DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,18 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;

View File

@ -0,0 +1,16 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,21 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -9,7 +9,8 @@
"name": "postgres_fdw",
"version": "",
"relocatable": true
}
},
"store_object_id": true
},
{
"type": "create",
@ -76,6 +77,15 @@
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create function with all options.",
@ -310,7 +320,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -0,0 +1,224 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Extension",
"endpoint": "NODE-extension.obj",
"sql_endpoint": "NODE-extension.sql_id",
"data": {
"name": "postgres_fdw",
"version": "",
"relocatable": true
},
"store_object_id": true
},
{
"type": "create",
"name": "Create procedure with extensions.",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"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/",
"dependsonextensions": ["plpgsql", "postgres_fdw"]
},
"expected_sql_file": "create_procedure_on_depends.sql",
"expected_msql_file": "create_procedure_on_depends.msql"
},
{
"type": "alter",
"name": "Alter procedure with NO DEPENDS ON",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"dependsonextensions": ["plpgsql"]
},
"expected_sql_file": "alter_proc_no_depends.sql",
"expected_msql_file": "alter_proc_no_depends.msql"
},
{
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"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",
"expected_msql_file": "create_procedure.msql"
},
{
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_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",
"msql_endpoint": "NODE-procedure.msql_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": "alter",
"name": "Alter procedure add privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
},
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_add_priv.sql",
"expected_msql_file": "alter_proc_add_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure delete privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_delete_priv.sql",
"expected_msql_file": "alter_proc_delete_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure change privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"changed": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"old_grantee": "postgres",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_change_grantee_priv.sql",
"expected_msql_file": "alter_proc_change_grantee_priv.msql"
},
{
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
}
]
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,22 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO postgres;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM PUBLIC;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,2 @@
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
NO DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,17 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;

View File

@ -1,4 +1,4 @@
CREATE PROCEDURE public."Proc3_$%{}[]()&*^!@"'`\/#"()
CREATE PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
LANGUAGE 'sql'
SET application_name='demo'
@ -6,5 +6,8 @@ begin atomic
select 1;
end;
COMMENT ON PROCEDURE public."Proc3_$%{}[]()&*^!@"'`\/#"()
ALTER PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
OWNER TO postgres;
COMMENT ON PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
IS 'demo comments';

View File

@ -0,0 +1,9 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;

View File

@ -0,0 +1,15 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,20 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO postgres;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -9,7 +9,8 @@
"name": "postgres_fdw",
"version": "",
"relocatable": true
}
},
"store_object_id": true
},
{
"type": "create",
@ -76,6 +77,15 @@
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create function with all options.",
@ -310,7 +320,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -1,10 +1,80 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Extension",
"endpoint": "NODE-extension.obj",
"sql_endpoint": "NODE-extension.sql_id",
"data": {
"name": "postgres_fdw",
"version": "",
"relocatable": true
},
"store_object_id": true
},
{
"type": "create",
"name": "Create procedure with extensions.",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"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/",
"dependsonextensions": ["plpgsql", "postgres_fdw"]
},
"expected_sql_file": "create_procedure_on_depends.sql",
"expected_msql_file": "create_procedure_on_depends.msql"
},
{
"type": "alter",
"name": "Alter procedure with NO DEPENDS ON",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"dependsonextensions": ["plpgsql"]
},
"expected_sql_file": "alter_proc_no_depends.sql",
"expected_msql_file": "alter_proc_no_depends.msql"
},
{
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
@ -24,12 +94,14 @@
"proleakproof": false,
"probin": "$libdir/"
},
"expected_sql_file": "create_procedure.sql"
"expected_sql_file": "create_procedure.sql",
"expected_msql_file": "create_procedure.msql"
}, {
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"description": "some comment"
},
@ -40,6 +112,7 @@
"name": "Alter procedure param",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"variables": {
"added": [{"name": "application_name", "value": "pgadmin"}]
@ -53,6 +126,7 @@
"name": "Alter procedure add privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"added": [
@ -80,13 +154,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_add_priv.sql",
"expected_msql_file": "alter_proc_add_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure delete privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"deleted": [
@ -103,13 +180,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_delete_priv.sql",
"expected_msql_file": "alter_proc_delete_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure change privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"changed": [
@ -143,6 +223,7 @@
"name": "Create procedure (atomic)",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name":"Proc3_$%{}[]()&*^!@\"'`\\/#",
"funcowner":"postgres",

View File

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

View File

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

View File

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

View File

@ -0,0 +1,3 @@
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO enterprisedb;

View File

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

View File

@ -1,13 +1,3 @@
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC;

View File

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

View File

@ -0,0 +1,23 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO enterprisedb;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM PUBLIC;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,10 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;

View File

@ -246,7 +246,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -0,0 +1,2 @@
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
NO DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,18 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;

View File

@ -0,0 +1,16 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,21 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -9,7 +9,8 @@
"name": "postgres_fdw",
"version": "",
"relocatable": true
}
},
"store_object_id": true
},
{
"type": "create",
@ -76,6 +77,15 @@
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create function with all options.",
@ -202,7 +212,8 @@
]
}
},
"expected_sql_file": "alter_function_add_parameter.sql"
"expected_sql_file": "alter_function_add_parameter.sql",
"expected_msql_file": "alter_function_add_parameter.msql"
},
{
"type": "alter",
@ -322,7 +333,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -0,0 +1,155 @@
{
"scenarios": [
{
"type": "create",
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
"arguments": [{"argtype": "integer", "argmode": "IN", "argname": "i1", "argdefval": ""}],
"funcowner": "enterprisedb",
"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",
"expected_msql_file": "create_procedure.msql"
},
{
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_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",
"msql_endpoint": "NODE-procedure.msql_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": "alter",
"name": "Alter procedure add privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
},
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_add_priv.sql",
"expected_msql_file": "alter_proc_add_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure delete privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_delete_priv.sql",
"expected_msql_file": "alter_proc_delete_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure change privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"changed": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"old_grantee": "enterprisedb",
"privileges": [
{
"privilege": true,
"privilege_type": "X",
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_proc_change_grantee_priv.sql",
"expected_msql_file": "alter_proc_change_grantee_priv.msql"
},
{
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
}
]
}

View File

@ -0,0 +1,3 @@
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO enterprisedb;

View File

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

View File

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

View File

@ -0,0 +1,22 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
SET application_name='pgadmin'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO enterprisedb;
REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM PUBLIC;
COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
IS 'some comment';

View File

@ -0,0 +1,2 @@
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
NO DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,17 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;

View File

@ -1,4 +1,4 @@
CREATE PROCEDURE public."Proc3_$%{}[]()&*^!@"'`\/#"()
CREATE PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
LANGUAGE 'sql'
SET application_name='demo'
@ -6,5 +6,8 @@ begin atomic
select 1;
end;
COMMENT ON PROCEDURE public."Proc3_$%{}[]()&*^!@"'`\/#"()
ALTER PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
OWNER TO enterprisedb;
COMMENT ON PROCEDURE public."Proc3_$%{}[]()&*^!@""'`\/#"()
IS 'demo comments';

View File

@ -0,0 +1,9 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;

View File

@ -0,0 +1,15 @@
CREATE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -0,0 +1,20 @@
-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer)
-- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer);
CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(
IN i1 integer)
LANGUAGE 'plpgsql'
AS $BODY$
begin
select 1;
end;
$BODY$;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
OWNER TO enterprisedb;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION plpgsql;
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
DEPENDS ON EXTENSION postgres_fdw;

View File

@ -9,7 +9,8 @@
"name": "postgres_fdw",
"version": "",
"relocatable": true
}
},
"store_object_id": true
},
{
"type": "create",
@ -76,6 +77,15 @@
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create function with all options.",
@ -202,7 +212,8 @@
]
}
},
"expected_sql_file": "alter_function_add_parameter.sql"
"expected_sql_file": "alter_function_add_parameter.sql",
"expected_msql_file": "alter_function_add_parameter.msql"
},
{
"type": "alter",
@ -322,7 +333,9 @@
}
]
}
}
},
"expected_sql_file": "alter_func_remove_partial_pri.sql",
"expected_msql_file": "alter_func_remove_partial_pri.msql"
},
{
"type": "alter",

View File

@ -1,10 +1,80 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Extension",
"endpoint": "NODE-extension.obj",
"sql_endpoint": "NODE-extension.sql_id",
"data": {
"name": "postgres_fdw",
"version": "",
"relocatable": true
},
"store_object_id": true
},
{
"type": "create",
"name": "Create procedure with extensions.",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
"arguments": [{"argtype": "integer", "argmode": "IN", "argname": "i1", "argdefval": ""}],
"funcowner": "enterprisedb",
"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/",
"dependsonextensions": ["plpgsql", "postgres_fdw"]
},
"expected_sql_file": "create_procedure_on_depends.sql",
"expected_msql_file": "create_procedure_on_depends.msql"
},
{
"type": "alter",
"name": "Alter procedure with NO DEPENDS ON",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"dependsonextensions": ["plpgsql"]
},
"expected_sql_file": "alter_proc_no_depends.sql",
"expected_msql_file": "alter_proc_no_depends.msql"
},
{
"type": "delete",
"name": "Drop procedure",
"endpoint": "NODE-procedure.delete_id",
"data": {
}
},
{
"type": "delete",
"name": "Drop Extension",
"endpoint": "NODE-extension.delete",
"data": {
"ids": ["<postgres_fdw>"]
},
"preprocess_data": true
},
{
"type": "create",
"name": "Create procedure",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name": "Proc1_$%{}[]()&*^!@\"'`\\/#",
"acl": [],
@ -24,22 +94,27 @@
"proleakproof": false,
"probin": "$libdir/"
},
"expected_sql_file": "create_procedure.sql"
}, {
"expected_sql_file": "create_procedure.sql",
"expected_msql_file": "create_procedure.msql"
},
{
"type": "alter",
"name": "Alter procedure comment",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_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",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"variables": {
"added": [{"name": "application_name", "value": "pgadmin"}]
@ -53,6 +128,7 @@
"name": "Alter procedure add privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"added": [
@ -80,13 +156,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_add_priv.sql",
"expected_msql_file": "alter_proc_add_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure delete privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"deleted": [
@ -103,13 +182,16 @@
}
]
}
}
},
"expected_sql_file": "alter_proc_delete_priv.sql",
"expected_msql_file": "alter_proc_delete_priv.msql"
},
{
"type": "alter",
"name": "Alter procedure change privileges",
"endpoint": "NODE-procedure.obj_id",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql_id",
"data": {
"acl": {
"changed": [
@ -143,6 +225,7 @@
"name": "Create procedure (atomic)",
"endpoint": "NODE-procedure.obj",
"sql_endpoint": "NODE-procedure.sql_id",
"msql_endpoint": "NODE-procedure.msql",
"data": {
"name":"Proc3_$%{}[]()&*^!@\"'`\\/#",
"funcowner":"enterprisedb",

View File

@ -62,6 +62,7 @@ class ProcedureAddTestCase(BaseTestGenerator):
"prosrc": "BEGIN RAISE EXCEPTION 'command % is disabled',"
" tg_tag; END;",
"seclabels": [],
"dependsonextensions": ["plpgsql"],
"variables": [
{
"name": "enable_sort",

View File

@ -43,7 +43,8 @@ class ProcedurePutTestCase(BaseTestGenerator):
proc_id = proc_info[0]
data = {
"description": "This is procedure update comment",
"id": proc_id
"id": proc_id,
"dependsonextensions": ["plpgsql"]
}
put_response = self.tester.put(