Security Labels, Privileges and Variables macros for the functions modules.

Usage of the macros:

Security labels:

SECLABLE.SET(conn, 'FUNCTION', func_name, provider, security_label, func_schema, func_args)

SECLABLE.UNSET(conn, 'FUNCTION', func_name, provider, func_schema, func_args)

Privileges:

PRIVILEGE.SET(conn, 'FUNCTION', grantee, func_name, privileges_without_grant, privileges_with_grant, func_schema, func_args)

PRIVILEGE.UNSETALL(conn, 'FUNCTION', grantee, func_name, func_schema, func_args)

Variables:

VARIABLES.SET(conn, 'FUNCTION', func_name, options, func_schema, func_args)

VARIABLES.UNSET(conn, 'FUNCTION', func_name, options, func_schema, func_args)
This commit is contained in:
Khushboo Vashi 2016-03-03 14:08:28 +00:00 committed by Dave Page
parent 789ece89fb
commit 3ff06da772
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{##############################################}
{# Macros for Privileges (functions module) #}
{##############################################}
{% macro SET(conn, type, role, param, priv, with_grant, schema, func_args) -%}
{% if priv %}
GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ conn|qtIdent(role) }};
{% endif %}
{% if with_grant %}
GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSETALL(conn, type, role, param, schema, func_args) -%}
REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) FROM {{conn|qtIdent(role) }};
{%- endmacro %}

View File

@ -0,0 +1,9 @@
{#################################################}
{# Macros for Security Labels (functions module) #}
{#################################################}
{% macro SET(conn, type, name, provider, label, schema, func_args) -%}
SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }}({{func_args}}) IS {{ label|qtLiteral }};
{%- endmacro %}
{% macro UNSET(conn, type, name, provider, schema, func_args) -%}
SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }}({{func_args}}) IS NULL;
{%- endmacro %}

View File

@ -0,0 +1,13 @@
{################################################}
{# Macros for Variables (functions module) #}
{################################################}
{% macro SET(conn, object_type, object_name, options, schema, func_args) -%}
ALTER {{object_type}} {{ conn|qtIdent(schema, object_name) }}({{func_args}})
SET ({% for opt in options %}{% if loop.index != 1 %}
, {% endif %}{{ conn|qtIdent(opt.name) }}={{ opt.value|qtLiteral }}{% endfor %});
{%- endmacro %}
{% macro UNSET(conn, object_type, object_name, options, schema, func_args) -%}
ALTER {{object_type}} {{ conn|qtIdent(schema, object_name) }}({{func_args}})
RESET ({% for opt in options %}{% if loop.index != 1 %}
, {% endif %}{{ conn|qtIdent(opt.name) }}{% endfor %});
{%- endmacro %}