mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Showing consitent reversed engineered SQL for the database node.
This commit is contained in:
parent
a6466c091c
commit
1cb2a054ff
@ -2,20 +2,20 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data %}
|
||||
{# To change owner #}
|
||||
{# Change the owner #}
|
||||
{% if data.datowner %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
|
||||
{% endif %}
|
||||
{# To change comments #}
|
||||
{# Change the comments/description #}
|
||||
{% if data.comments %}
|
||||
COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
{# To change conn limit #}
|
||||
{# Change the connection limit #}
|
||||
{% if data.datconnlimit %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
|
||||
{% endif %}
|
||||
{# To change Variables #}
|
||||
{# Change the variables/options #}
|
||||
{% if data.variables and data.variables|length > 0 %}
|
||||
{% set variables = data.variables %}
|
||||
{% if 'deleted' in variables and variables.deleted|length > 0 %}
|
||||
@ -47,7 +47,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change priviledges #}
|
||||
{# Change the priviledges/ACLs #}
|
||||
{% if data.datacl %}
|
||||
{% if 'deleted' in data.datacl %}
|
||||
{% for priv in data.datacl.deleted %}
|
||||
@ -67,7 +67,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges for the tables #}
|
||||
{% if data.deftblacl %}
|
||||
{% if 'deleted' in data.deftblacl %}
|
||||
{% for priv in data.deftblacl.deleted %}
|
||||
@ -86,7 +86,8 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges for the sequences #}
|
||||
{% if data.deftblacl %}
|
||||
{% if data.defseqacl %}
|
||||
{% if 'deleted' in data.defseqacl %}
|
||||
{% for priv in data.defseqacl.deleted %}
|
||||
@ -106,7 +107,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges for the functions #}
|
||||
{% if data.deffuncacl %}
|
||||
{% if 'deleted' in data.deffuncacl %}
|
||||
{% for priv in data.deffuncacl.deleted %}
|
||||
|
@ -3,20 +3,20 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data %}
|
||||
{# To change owner #}
|
||||
{# Change the owner #}
|
||||
{% if data.datowner %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
|
||||
{% endif %}
|
||||
{# TO change comments #}
|
||||
{# Change the comments/description #}
|
||||
{% if data.comments %}
|
||||
COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
{# TO change conn limit #}
|
||||
{# Change the connection limit #}
|
||||
{% if data.datconnlimit %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
|
||||
{% endif %}
|
||||
{# To change Security Label #}
|
||||
{# Change the security labels #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
@ -35,7 +35,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# To change Variables #}
|
||||
{# Change the variables/options #}
|
||||
{% if data.variables and data.variables|length > 0 %}
|
||||
{% set variables = data.variables %}
|
||||
{% if 'deleted' in variables and variables.deleted|length > 0 %}
|
||||
@ -67,7 +67,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change priviledges #}
|
||||
{# Change the priviledges/ACLs #}
|
||||
{% if data.datacl %}
|
||||
{% if 'deleted' in data.datacl %}
|
||||
{% for priv in data.datacl.deleted %}
|
||||
@ -87,7 +87,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges/ACLs for the tables #}
|
||||
{% if data.deftblacl %}
|
||||
{% if 'deleted' in data.deftblacl %}
|
||||
{% for priv in data.deftblacl.deleted %}
|
||||
@ -107,7 +107,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges/ACLs for the sequences #}
|
||||
{% if data.defseqacl %}
|
||||
{% if 'deleted' in data.defseqacl %}
|
||||
{% for priv in data.defseqacl.deleted %}
|
||||
@ -127,7 +127,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges/ACLs for the functions #}
|
||||
{% if data.deffuncacl %}
|
||||
{% if 'deleted' in data.deffuncacl %}
|
||||
{% for priv in data.deffuncacl.deleted %}
|
||||
@ -147,7 +147,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# To change default priviledges #}
|
||||
{# Change the default priviledges/ACLs for the types #}
|
||||
{% if data.deftypeacl %}
|
||||
{% if 'deleted' in data.deftypeacl %}
|
||||
{% for priv in data.deftypeacl.deleted %}
|
||||
|
@ -2,7 +2,8 @@
|
||||
-- Given SQL is workaround
|
||||
-- We need to implement a mechanism to check for valid supported server encoding
|
||||
#}
|
||||
SELECT * FROM
|
||||
SELECT *
|
||||
FROM
|
||||
(SELECT pg_encoding_to_char(s.i) AS encoding
|
||||
FROM (SELECT generate_series(0, 100, 1) as i) s) a
|
||||
WHERE encoding != '';
|
||||
|
@ -1,5 +1,7 @@
|
||||
SELECT rl.*, r.rolname AS user_name, db.datname as db_name
|
||||
FROM pg_db_role_setting AS rl
|
||||
SELECT
|
||||
rl.*, r.rolname AS user_name, db.datname as db_name
|
||||
FROM
|
||||
pg_db_role_setting AS rl
|
||||
LEFT JOIN pg_roles AS r ON rl.setrole = r.oid
|
||||
LEFT JOIN pg_database AS db ON rl.setdatabase = db.oid
|
||||
WHERE setdatabase = {{did}}
|
||||
WHERE setdatabase = {{did}};
|
||||
|
@ -12,13 +12,13 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
|
||||
{# To generate Security Label SQL using macro #}
|
||||
{# Generate the security labels #}
|
||||
{% if data.securities %}
|
||||
{% for r in data.securities %}
|
||||
{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.securitylabel) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# To generate Variable SQL using macro #}
|
||||
{# Generate the variable/options #}
|
||||
{% if data.variables %}
|
||||
{% for var in data.variables %}
|
||||
{% if var.value == True %}
|
||||
@ -30,6 +30,7 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# Generate the privileges/ACLs #}
|
||||
{% if data.datacl %}
|
||||
{% for priv in data.datacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
|
@ -1 +1,4 @@
|
||||
SELECT name, vartype, min_val, max_val, enumvals FROM pg_settings WHERE context in ('user', 'superuser')
|
||||
SELECT
|
||||
name, vartype, min_val, max_val, enumvals
|
||||
FROM pg_settings
|
||||
WHERE context in ('user', 'superuser');
|
||||
|
@ -3,20 +3,20 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data %}
|
||||
{# The SQL generated below will change owner #}
|
||||
{# Change the owner #}
|
||||
{% if data.datowner %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
|
||||
{% endif %}
|
||||
{# The SQL generated below will change comments #}
|
||||
{# Change the comments/description #}
|
||||
{% if data.comments %}
|
||||
COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
{# The SQL generated below will change conn limit #}
|
||||
{# Change the connection limit #}
|
||||
{% if data.datconnlimit %}
|
||||
ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
|
||||
{% endif %}
|
||||
{# The SQL generated below will change Security Label #}
|
||||
{# Change the security labels #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
@ -35,7 +35,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# The SQL generated below will change Variables #}
|
||||
{# Change the variables/options #}
|
||||
{% if data.variables and data.variables|length > 0 %}
|
||||
{% set variables = data.variables %}
|
||||
{% if 'deleted' in variables and variables.deleted|length > 0 %}
|
||||
@ -67,7 +67,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# The SQL generated below will change priviledges #}
|
||||
{# Change the priviledges/ACLs #}
|
||||
{% if data.datacl %}
|
||||
{% if 'deleted' in data.datacl %}
|
||||
{% for priv in data.datacl.deleted %}
|
||||
@ -87,6 +87,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# Change the default priviledges/ACLs for tables #}
|
||||
{% if data.deftblacl %}
|
||||
{% if 'deleted' in data.deftblacl %}
|
||||
{% for priv in data.deftblacl.deleted %}
|
||||
@ -106,6 +107,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# Change the default priviledges/ACLs for sequences #}
|
||||
{% if data.defseqacl %}
|
||||
{% if 'deleted' in data.defseqacl %}
|
||||
{% for priv in data.defseqacl.deleted %}
|
||||
@ -125,6 +127,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# Change the default priviledges/ACLs for functions #}
|
||||
{% if data.deffuncacl %}
|
||||
{% if 'deleted' in data.deffuncacl %}
|
||||
{% for priv in data.deffuncacl.deleted %}
|
||||
@ -144,6 +147,7 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# Change the default priviledges/ACLs for types #}
|
||||
{% if data.deftypeacl %}
|
||||
{% if 'deleted' in data.deftypeacl %}
|
||||
{% for priv in data.deftypeacl.deleted %}
|
||||
|
@ -2,7 +2,8 @@
|
||||
-- Given SQL is workaround
|
||||
-- We need to implement a mechanism to check for valid supported server encoding
|
||||
#}
|
||||
SELECT * FROM
|
||||
SELECT *
|
||||
FROM
|
||||
(SELECT pg_encoding_to_char(s.i) AS encoding
|
||||
FROM (SELECT generate_series(0, 100, 1) as i) s) a
|
||||
WHERE encoding != '';
|
||||
|
@ -1,4 +1,5 @@
|
||||
SELECT rl.*, r.rolname AS user_name, db.datname as db_name
|
||||
SELECT
|
||||
rl.*, r.rolname AS user_name, db.datname as db_name
|
||||
FROM pg_db_role_setting AS rl
|
||||
LEFT JOIN pg_roles AS r ON rl.setrole = r.oid
|
||||
LEFT JOIN pg_database AS db ON rl.setdatabase = db.oid
|
||||
|
@ -12,13 +12,13 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
|
||||
{# We will generate Security Label SQL's using macro #}
|
||||
{# Change the security labels #}
|
||||
{% if data.securities %}
|
||||
{% for r in data.securities %}
|
||||
{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.securitylabel) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# We will generate Variable SQL's using macro #}
|
||||
{# Variables/options #}
|
||||
{% if data.variables %}
|
||||
{% for var in data.variables %}
|
||||
{% if var.value == True %}
|
||||
@ -30,26 +30,33 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Privileges/ACLs #}
|
||||
{% if data.datacl %}
|
||||
{% for priv in data.datacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Default privileges/ACLs for tables #}
|
||||
{% if data.deftblacl %}
|
||||
{% for priv in data.deftblacl %}
|
||||
{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# Default privileges/ACLs for sequences #}
|
||||
{% if data.defseqacl %}
|
||||
{% for priv in data.defseqacl %}
|
||||
{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# Default privileges/ACLs for functions #}
|
||||
{% if data.deffuncacl %}
|
||||
{% for priv in data.deffuncacl %}
|
||||
{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# Default privileges/ACLs for types #}
|
||||
{% if data.deftypeacl %}
|
||||
{% for priv in data.deftypeacl %}
|
||||
{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
|
@ -1 +1,4 @@
|
||||
SELECT name, vartype, min_val, max_val, enumvals FROM pg_settings WHERE context in ('user', 'superuser')
|
||||
SELECT
|
||||
name, vartype, min_val, max_val, enumvals
|
||||
FROM pg_settings
|
||||
WHERE context in ('user', 'superuser');
|
||||
|
Loading…
Reference in New Issue
Block a user