Support procedures and ignore packages that look like schemas properly in PPAS

pull/3/head
Surinder Kumar 2016-04-16 10:01:28 +01:00 committed by Dave Page
parent 26aa5607ad
commit e7902d4b45
9 changed files with 46 additions and 17 deletions

View File

@ -227,6 +227,21 @@ def properties(gid, sid, did, node_id, node_type):
res_data.extend(res['rows'])
# Fetch procedures only if server type is ppas
if (len(server_prop) > 0 and
server_prop['server_type'] == 'ppas' and
ntype in ['schema', 'procedure']):
SQL = render_template("/".join(
[server_prop['template_path'], '/sql/function.sql']),
node_id=node_id, nspname=nspname, type='procedure')
status, res = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
res_data.extend(res['rows'])
# Fetch trigger functions
if ntype in ['schema', 'trigger_function']:
SQL = render_template("/".join(

View File

@ -41,8 +41,11 @@ define([
res.object_id = res.name_with_args;
// create name with args if its object is function
if(!_.isUndefined(res.object_type) && (res.object_type == 'Function' ||
res.object_type == 'Trigger Function'))
if(!_.isUndefined(res.object_type) &&
(res.object_type == 'Function' ||
res.object_type == 'Trigger Function' ||
res.object_type == 'Procedure'
))
res.name_with_args = res.name+'('+(typeof(res.proargs) != 'undefined' ? res.proargs : '')+')';
else
res.name_with_args = res.name;
@ -138,7 +141,7 @@ define([
// Define list of nodes on which grant wizard context menu option appears
var supported_nodes = [
'schema', 'coll-function', 'coll-sequence',
'coll-table', 'coll-view',
'coll-table', 'coll-view', 'coll-procedure',
'coll-materialized_view', 'database'
],
@ -508,6 +511,9 @@ define([
case 'Trigger Function':
object_type = 'function';
break;
case 'Procedure':
object_type = 'procedure';
break;
case 'Table':
object_type = 'table';
break;

View File

@ -26,5 +26,9 @@
"function": {
"type": "FUNCTION",
"acl": ["X"]
},
"procedure": {
"type": "PROCEDURE",
"acl": ["X"]
}
}

View File

@ -1,14 +1,14 @@
{# ===== Fetch list of Database object types(Functions) ====== #}
{% if type and node_id and nspname %}
{% set func_type = 'Trigger Function' if type == 'trigger_function' else 'Function' %}
{% set icon = 'icon-function' if type == 'function' else 'icon-trigger_function' %}
SELECT
pr.oid,
pg_get_function_identity_arguments(pr.oid) AS proargs,
{# pr.proname || '(' || pg_get_function_identity_arguments(pr.oid) || ')' AS name,#}
pr.proname AS name,
'{{ nspname }}' AS nspname,
'{{ func_type }}' AS object_type,
'{{ "icon-function" if type != "trigger_function" else "icon-trigger_function" }}' AS icon
'{{ nspname }}' AS nspname,
'{{ icon }}' AS icon
FROM
pg_proc pr
JOIN pg_type typ ON typ.oid=prorettype

View File

@ -2,9 +2,8 @@
{% import 'macros/functions/privilege.macros' as PRIVILEGE_FUNCTION %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{# ===== if object_type is Function then apply function marcros ===== #}
{% if (obj.object_type == 'Function' or obj.object_type == 'Trigger Function') %}
{{ PRIVILEGE_FUNCTION.SET(conn, 'FUNCTION', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname, obj.proargs)}}
{% if (obj.object_type == 'Function' or obj.object_type == 'Trigger Function' or obj.object_type == 'Procedure') %}{% set func_type = 'PROCEDURE' if obj.object_type == 'Procedure' else 'FUNCTION' if obj.object_type == 'Function' or obj.object_type == 'Trigger Function' -%}
{{ PRIVILEGE_FUNCTION.SET(conn, func_type, priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname, obj.proargs)}}
{% endif -%}
{% endfor -%}
{% endfor -%}

View File

@ -26,5 +26,9 @@
"function": {
"type": "FUNCTION",
"acl": ["X"]
},
"procedure": {
"type": "PROCEDURE",
"acl": ["X"]
}
}

View File

@ -1,14 +1,14 @@
{# ===== Fetch list of Database object types(Functions) ====== #}
{% if type and node_id and nspname %}
{% set func_type = 'Trigger Function' if type == 'trigger_function' else 'Function' %}
{% set func_type = 'Trigger Function' if type == 'trigger_function' else 'Procedure' if type == 'procedure' else 'Function' %}
{% set icon = 'icon-function' if type == 'function' else 'icon-procedure' if type == 'procedure' else 'icon-trigger_function' %}
SELECT
pr.oid,
pg_get_function_identity_arguments(pr.oid) AS proargs,
{# pr.proname || '(' || pg_get_function_identity_arguments(pr.oid) || ')' AS name,#}
pr.proname AS name,
'{{ nspname }}' AS nspname,
'{{ func_type }}' AS object_type,
'{{ "icon-function" if type != "trigger_function" else "icon-trigger_function" }}' AS icon
'{{ nspname }}' AS nspname,
'{{ icon }}' AS icon
FROM
pg_proc pr
JOIN pg_type typ ON typ.oid=prorettype
@ -18,6 +18,7 @@ LEFT OUTER JOIN pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_pr
WHERE
proisagg = FALSE AND pronamespace = {{ node_id }}::oid
AND typname {{ 'NOT' if type != 'trigger_function' else '' }} IN ('trigger', 'event_trigger')
AND pr.protype = {{ 0 if type != 'procedure' else 1 }}
ORDER BY
proname
{% endif %}

View File

@ -1,11 +1,12 @@
{# ===== Fetch list of all schemas ===== #}
{% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %}
{% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %}
SELECT
nsp.oid,
nsp.nspname as name
FROM
pg_namespace nsp
WHERE
nsp.nspparent = 0 AND
{% if nspid %}
nsp.oid={{nspid}}::int AND
{% else %}

View File

@ -2,9 +2,8 @@
{% import 'macros/functions/privilege.macros' as PRIVILEGE_FUNCTION %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{# ===== if object_type is Function then apply function marcros ===== #}
{% if (obj.object_type == 'Function' or obj.object_type == 'Trigger Function') %}
{{ PRIVILEGE_FUNCTION.SET(conn, 'FUNCTION', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname, obj.proargs)}}
{% if (obj.object_type == 'Function' or obj.object_type == 'Trigger Function' or obj.object_type == 'Procedure') %}{% set func_type = 'PROCEDURE' if obj.object_type == 'Procedure' else 'FUNCTION' if obj.object_type == 'Function' or obj.object_type == 'Trigger Function' -%}
{{ PRIVILEGE_FUNCTION.SET(conn, func_type, priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname, obj.proargs)}}
{% endif -%}
{% endfor -%}
{% endfor -%}