Add support of DEPENDS/NO DEPENDS ON EXTENSION for PROCEDURE. #6391
							parent
							
								
									8d55e9a445
								
							
						
					
					
						commit
						657460a197
					
				
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 67 KiB  | 
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1171,11 +1171,9 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
 | 
			
		|||
            old_data['proparallel'] = \
 | 
			
		||||
                parallel_dict[old_data['proparallel']]
 | 
			
		||||
 | 
			
		||||
        if self.node_type == 'function':
 | 
			
		||||
            old_data['dependsonextensions'] = \
 | 
			
		||||
                old_data.get('dependsonextensions') or []
 | 
			
		||||
            data['dependsonextensions'] = \
 | 
			
		||||
                data.get('dependsonextensions') or []
 | 
			
		||||
        if self.node_type == 'function' and self.node_type == 'procedure' and \
 | 
			
		||||
                old_data['dependsonextensions'] is None:
 | 
			
		||||
            old_data['dependsonextensions'] = []
 | 
			
		||||
 | 
			
		||||
        # If any of the below argument is changed,
 | 
			
		||||
        # then CREATE OR REPLACE SQL statement should be called
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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, {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
    (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
 | 
			
		||||
    NO DEPENDS ON EXTENSION postgres_fdw;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,213 @@
 | 
			
		|||
{
 | 
			
		||||
  "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",
 | 
			
		||||
      "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": "alter",
 | 
			
		||||
      "name": "Alter procedure add privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_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
 | 
			
		||||
                }
 | 
			
		||||
              ]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "alter",
 | 
			
		||||
      "name": "Alter procedure delete privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_id",
 | 
			
		||||
      "data": {
 | 
			
		||||
        "acl": {
 | 
			
		||||
          "deleted": [
 | 
			
		||||
            {
 | 
			
		||||
              "grantee": "PUBLIC",
 | 
			
		||||
              "grantor": "postgres",
 | 
			
		||||
              "privileges": [
 | 
			
		||||
                {
 | 
			
		||||
                  "privilege": true,
 | 
			
		||||
                  "privilege_type": "X",
 | 
			
		||||
                  "with_grant": false
 | 
			
		||||
                }
 | 
			
		||||
              ]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "alter",
 | 
			
		||||
      "name": "Alter procedure change privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_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": {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
 | 
			
		||||
    NO DEPENDS ON EXTENSION postgres_fdw;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,74 @@
 | 
			
		|||
{
 | 
			
		||||
  "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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
 | 
			
		||||
    NO DEPENDS ON EXTENSION postgres_fdw;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,210 @@
 | 
			
		|||
{
 | 
			
		||||
  "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",
 | 
			
		||||
      "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"
 | 
			
		||||
    }, {
 | 
			
		||||
      "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": "alter",
 | 
			
		||||
      "name": "Alter procedure add privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_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
 | 
			
		||||
                }
 | 
			
		||||
              ]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "alter",
 | 
			
		||||
      "name": "Alter procedure delete privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_id",
 | 
			
		||||
      "data": {
 | 
			
		||||
        "acl": {
 | 
			
		||||
          "deleted": [
 | 
			
		||||
            {
 | 
			
		||||
              "grantee": "PUBLIC",
 | 
			
		||||
              "grantor": "enterprisedb",
 | 
			
		||||
              "privileges": [
 | 
			
		||||
                {
 | 
			
		||||
                  "privilege": true,
 | 
			
		||||
                  "privilege_type": "X",
 | 
			
		||||
                  "with_grant": false
 | 
			
		||||
                }
 | 
			
		||||
              ]
 | 
			
		||||
            }
 | 
			
		||||
          ]
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "type": "alter",
 | 
			
		||||
      "name": "Alter procedure change privileges",
 | 
			
		||||
      "endpoint": "NODE-procedure.obj_id",
 | 
			
		||||
      "sql_endpoint": "NODE-procedure.sql_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": {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer)
 | 
			
		||||
    NO DEPENDS ON EXTENSION postgres_fdw;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,74 @@
 | 
			
		|||
{
 | 
			
		||||
  "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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,6 +62,7 @@ class ProcedureAddTestCase(BaseTestGenerator):
 | 
			
		|||
            "prosrc": "BEGIN RAISE EXCEPTION 'command % is disabled',"
 | 
			
		||||
                      " tg_tag; END;",
 | 
			
		||||
            "seclabels": [],
 | 
			
		||||
            "dependsonextensions": ["plpgsql"],
 | 
			
		||||
            "variables": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "enable_sort",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue