Remove the SQL files for the unsupported versions of the database server. Fixes #7462
Fixed API test cases for Postgres 14.4. Fixes #7527pull/90/head
parent
d1c94ac73d
commit
8c24d28740
|
@ -15,6 +15,7 @@ Housekeeping
|
|||
************
|
||||
|
||||
| `Issue #7344 <https://redmine.postgresql.org/issues/7344>`_ - Port Role Reassign dialog to React.
|
||||
| `Issue #7462 <https://redmine.postgresql.org/issues/7462>`_ - Remove the SQL files for the unsupported versions of the database server.
|
||||
| `Issue #7567 <https://redmine.postgresql.org/issues/7567>`_ - Port About dialog to React.
|
||||
| `Issue #7590 <https://redmine.postgresql.org/issues/7590>`_ - Port change ownership dialog to React.
|
||||
| `Issue #7595 <https://redmine.postgresql.org/issues/7595>`_ - Update the container base image to Alpine 3.16 (with Python 3.10.5).
|
||||
|
@ -23,5 +24,6 @@ Bug fixes
|
|||
*********
|
||||
|
||||
| `Issue #7497 <https://redmine.postgresql.org/issues/7497>`_ - Fixed an issue with the error message being displayed at the right place for Azure deployments.
|
||||
| `Issue #7527 <https://redmine.postgresql.org/issues/7527>`_ - Fixed API test cases for Postgres 14.4.
|
||||
| `Issue #7563 <https://redmine.postgresql.org/issues/7563>`_ - Fixed an issue where autocomplete is not working after clearing the query editor.
|
||||
| `Issue #7573 <https://redmine.postgresql.org/issues/7573>`_ - Ensure that autocomplete does not appear when navigating code using arrow keys.
|
||||
|
|
|
@ -194,7 +194,8 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||
PG_DEFAULT_DRIVER
|
||||
).connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
self.template_path = 'event_triggers/sql/9.3_plus'
|
||||
self.template_path = 'event_triggers/sql/#{0}#'.format(
|
||||
self.manager.version)
|
||||
|
||||
self.datistemplate = False
|
||||
if (
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: sslinfo
|
||||
|
||||
-- DROP EXTENSION sslinfo;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS sslinfo
|
||||
SCHEMA public
|
||||
VERSION "1.0";
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: citext
|
||||
|
||||
-- DROP EXTENSION citext;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS citext
|
||||
SCHEMA public
|
||||
VERSION "1.1";
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: sslinfo
|
||||
|
||||
-- DROP EXTENSION sslinfo;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS sslinfo
|
||||
SCHEMA test_extension_schema
|
||||
VERSION "1.0";
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: citext
|
||||
|
||||
-- DROP EXTENSION citext;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS citext
|
||||
SCHEMA public
|
||||
VERSION "1.0";
|
|
@ -1,2 +0,0 @@
|
|||
ALTER EXTENSION citext
|
||||
UPDATE TO "1.1";
|
|
@ -1,3 +0,0 @@
|
|||
CREATE EXTENSION sslinfo
|
||||
SCHEMA test_extension_schema
|
||||
VERSION "1.0";
|
|
@ -1,2 +0,0 @@
|
|||
CREATE EXTENSION citext
|
||||
VERSION "1.0";
|
|
@ -1,73 +0,0 @@
|
|||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Extension with all options",
|
||||
"endpoint": "NODE-extension.obj",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql",
|
||||
"data": {
|
||||
"name": "sslinfo",
|
||||
"schema": "test_extension_schema",
|
||||
"version": "1.0"
|
||||
},
|
||||
"expected_sql_file": "create_extension_with_all_options.sql",
|
||||
"expected_msql_file": "msql_create_extension_with_all_options.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Extension schema",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql_id",
|
||||
"data": {
|
||||
"schema": "public"
|
||||
},
|
||||
"expected_sql_file": "alter_extension_schema.sql",
|
||||
"expected_msql_file": "msql_alter_extension_schema.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Extension with all options",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"data": {},
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Extension with default schema",
|
||||
"endpoint": "NODE-extension.obj",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql",
|
||||
"data": {
|
||||
"name": "citext",
|
||||
"version": "1.0"
|
||||
},
|
||||
"expected_sql_file": "create_extension_with_default_schema.sql",
|
||||
"expected_msql_file": "msql_create_extension_with_default_schema.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Extension version",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql_id",
|
||||
"data": {
|
||||
"version": "1.1"
|
||||
},
|
||||
"expected_sql_file": "alter_extension_version.sql",
|
||||
"expected_msql_file": "msql_alter_extension_version.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.1';"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Extension default schema",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"data": {},
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.1';"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: sslinfo
|
||||
|
||||
-- DROP EXTENSION sslinfo;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS sslinfo
|
||||
SCHEMA public
|
||||
VERSION "1.0";
|
|
@ -1,7 +0,0 @@
|
|||
-- Extension: sslinfo
|
||||
|
||||
-- DROP EXTENSION sslinfo;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS sslinfo
|
||||
SCHEMA test_extension_schema
|
||||
VERSION "1.0";
|
|
@ -1,2 +0,0 @@
|
|||
ALTER EXTENSION sslinfo
|
||||
SET SCHEMA public;
|
|
@ -1,3 +0,0 @@
|
|||
CREATE EXTENSION sslinfo
|
||||
SCHEMA test_extension_schema
|
||||
VERSION "1.0";
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Extension with all options",
|
||||
"endpoint": "NODE-extension.obj",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql",
|
||||
"data": {
|
||||
"name": "sslinfo",
|
||||
"schema": "test_extension_schema",
|
||||
"version": "1.0"
|
||||
},
|
||||
"expected_sql_file": "create_extension_with_all_options.sql",
|
||||
"expected_msql_file": "msql_create_extension_with_all_options.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Extension schema",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"sql_endpoint": "NODE-extension.sql_id",
|
||||
"msql_endpoint": "NODE-extension.msql_id",
|
||||
"data": {
|
||||
"schema": "public"
|
||||
},
|
||||
"expected_sql_file": "alter_extension_schema.sql",
|
||||
"expected_msql_file": "msql_alter_extension_schema.sql",
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Extension with all options",
|
||||
"endpoint": "NODE-extension.obj_id",
|
||||
"data": {},
|
||||
"precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
ALTER EXTENSION sslinfo
|
||||
SET SCHEMA public;
|
|
@ -1,22 +0,0 @@
|
|||
SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
|
||||
FROM
|
||||
(SELECT
|
||||
d.grantee, d.grantor, d.is_grantable,
|
||||
CASE d.privilege_type
|
||||
WHEN 'USAGE' THEN 'U'
|
||||
ELSE 'UNKNOWN'
|
||||
END AS privilege_type
|
||||
FROM
|
||||
(SELECT srvacl FROM pg_catalog.pg_foreign_server fsrv
|
||||
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
|
||||
fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass)
|
||||
{% if fsid %}
|
||||
WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID
|
||||
{% endif %}
|
||||
) acl,
|
||||
pg_catalog.aclexplode(srvacl) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
ORDER BY grantee
|
|
@ -1,33 +0,0 @@
|
|||
{# ============= Create foreign server ============= #}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% if data.name %}
|
||||
CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %}
|
||||
|
||||
TYPE {{ data.fsrvtype|qtLiteral }}{% endif %}{% if data.fsrvversion %}
|
||||
|
||||
VERSION {{ data.fsrvversion|qtLiteral }}{%-endif %}{% if fdwdata %}
|
||||
|
||||
FOREIGN DATA WRAPPER {{ conn|qtIdent(fdwdata.name) }}{% endif %}{% if data.fsrvoptions %}
|
||||
|
||||
{% if is_valid_options %}
|
||||
OPTIONS ({% for variable in data.fsrvoptions %}{% if loop.index != 1 %}, {% endif %}
|
||||
{{ conn|qtIdent(variable.fsrvoption) }} {{ variable.fsrvvalue|qtLiteral }}{% endfor %}){% endif %}{% endif %};
|
||||
|
||||
{# ============= Set the owner for foreign server ============= #}
|
||||
{% if data.fsrvowner %}
|
||||
ALTER SERVER {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.fsrvowner) }};
|
||||
{% endif %}
|
||||
{# ============= Set the comment for foreign server ============= #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON SERVER {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Set the ACL for foreign server ============= #}
|
||||
{% if data.fsrvacl %}
|
||||
{% for priv in data.fsrvacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN SERVER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -1,30 +0,0 @@
|
|||
{# ============= Give all the properties of foreign server ============= #}
|
||||
{% if fdwid %}
|
||||
SELECT fdw.oid as fdwoid, fdwname as name
|
||||
FROM pg_catalog.pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
WHERE fdw.oid={{fdwid}}::oid
|
||||
{% else %}
|
||||
SELECT srv.oid, srvname as name, srvfdw as fdwid, srvtype as fsrvtype, srvversion as fsrvversion,
|
||||
fdw.fdwname as fdwname, description, srvoptions AS fsrvoptions,
|
||||
pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl
|
||||
FROM pg_catalog.pg_foreign_server srv
|
||||
LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
|
||||
{% if data and fdwdata %}
|
||||
WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.name|qtLiteral }}::text
|
||||
{% elif fdwdata %}
|
||||
WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text
|
||||
{% endif %}
|
||||
{% if fid %}
|
||||
WHERE srvfdw={{fid}}::oid
|
||||
{% endif %}
|
||||
{% if fsid %}
|
||||
WHERE srv.oid={{fsid}}::oid
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = srv.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY srvname;
|
||||
{% endif %}
|
|
@ -11,17 +11,12 @@ FROM
|
|||
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
|
||||
fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass)
|
||||
{% if fsid %}
|
||||
WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID
|
||||
WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID
|
||||
{% endif %}
|
||||
) acl,
|
||||
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
|
||||
(d).privilege_type AS privilege_type
|
||||
FROM (SELECT pg_catalog.aclexplode(srvacl) as d FROM pg_catalog.pg_foreign_server fsrv1
|
||||
{% if fsid %}
|
||||
WHERE fsrv1.oid = {{ fsid|qtLiteral }}::OID ) a
|
||||
{% endif %}
|
||||
pg_catalog.aclexplode(srvacl) d
|
||||
) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
ORDER BY grantee
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{# ============= Create foreign server ============= #}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% if data.name %}
|
||||
CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %}
|
||||
|
||||
TYPE {{ data.fsrvtype|qtLiteral }}{% endif %}{% if data.fsrvversion %}
|
||||
|
@ -15,7 +15,6 @@ CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %}
|
|||
|
||||
{# ============= Set the owner for foreign server ============= #}
|
||||
{% if data.fsrvowner %}
|
||||
|
||||
ALTER SERVER {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.fsrvowner) }};
|
||||
{% endif %}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{# ============= Give all the properties of foreign server ============= #}
|
||||
{% if fdwid %}
|
||||
SELECT fdw.oid as fdwoid,
|
||||
fdwname as name
|
||||
SELECT fdw.oid as fdwoid, fdwname as name
|
||||
FROM pg_catalog.pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
WHERE fdw.oid={{fdwid}}::oid
|
||||
{% else %}
|
||||
SELECT srv.oid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description,
|
||||
srvoptions AS fsrvoptions,
|
||||
SELECT srv.oid, srvname as name, srvfdw as fdwid, srvtype as fsrvtype, srvversion as fsrvversion,
|
||||
fdw.fdwname as fdwname, description, srvoptions AS fsrvoptions,
|
||||
pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl
|
||||
FROM pg_catalog.pg_foreign_server srv
|
||||
LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
|
||||
|
@ -23,5 +22,9 @@ WHERE srvfdw={{fid}}::oid
|
|||
{% if fsid %}
|
||||
WHERE srv.oid={{fsid}}::oid
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = srv.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY srvname;
|
||||
{% endif %}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
|
||||
FROM
|
||||
(SELECT
|
||||
d.grantee, d.grantor, d.is_grantable,
|
||||
CASE d.privilege_type
|
||||
WHEN 'USAGE' THEN 'U'
|
||||
ELSE 'UNKNOWN'
|
||||
END AS privilege_type
|
||||
FROM
|
||||
(SELECT fdwacl FROM pg_catalog.pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
|
||||
fdw.oid=descr.objoid AND descr.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
{% if fid %}
|
||||
WHERE fdw.oid = {{ fid|qtLiteral }}::OID
|
||||
{% endif %}
|
||||
) acl,
|
||||
pg_catalog.aclexplode(fdwacl) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
ORDER BY grantee
|
|
@ -1,31 +0,0 @@
|
|||
{# ============= Create foreign data wrapper ============= #}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% if data.name %}
|
||||
CREATE FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}{% if data.fdwvalue %}
|
||||
|
||||
VALIDATOR {{ data.fdwvalue }}{%endif%}{% if data.fdwhan %}
|
||||
|
||||
HANDLER {{ data.fdwhan }}{% endif %}{% if data.fdwoptions %}
|
||||
|
||||
{% if is_valid_options %}
|
||||
OPTIONS ({% for variable in data.fdwoptions %}{% if loop.index != 1 %}, {% endif %}
|
||||
{{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %}){% endif %}{% endif %};
|
||||
|
||||
{# ============= Set the owner for foreign data wrapper ============= #}
|
||||
{% if data.fdwowner %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.fdwowner) }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Comment on of foreign data wrapper object ============= #}
|
||||
{% if data.description %}
|
||||
COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Create ACL for foreign data wrapper ============= #}
|
||||
{% if data.fdwacl %}
|
||||
{% for priv in data.fdwacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -1,30 +0,0 @@
|
|||
{# ============= Get all the properties of foreign data wrapper ============= #}
|
||||
SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description,
|
||||
fdwoptions AS fdwoptions, pg_catalog.pg_get_userbyid(fdwowner) as fdwowner, pg_catalog.array_to_string(fdwacl::text[], ', ') as acl,
|
||||
CASE
|
||||
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
|
||||
WHEN vp.proname IS NULL THEN NULL
|
||||
ELSE pg_catalog.quote_ident(vp_nsp.nspname)||'.'||pg_catalog.quote_ident(vp.proname)
|
||||
END fdwvalue,
|
||||
CASE
|
||||
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
|
||||
WHEN vh.proname IS NULL THEN NULL
|
||||
ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname)
|
||||
END fdwhan
|
||||
FROM pg_catalog.pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
{% if fid %}
|
||||
WHERE fdw.oid={{fid}}::oid
|
||||
{% endif %}
|
||||
{% if fname %}
|
||||
WHERE fdw.fdwname={{ fname|qtLiteral }}::text
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = fdw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY fdwname
|
|
@ -1,86 +0,0 @@
|
|||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{# ============= Update foreign data wrapper name ============= #}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Update foreign data wrapper owner ============= #}
|
||||
{% if data.fdwowner and data.fdwowner != o_data.fdwowner %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.fdwowner) }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Update foreign data wrapper validator ============= #}
|
||||
{% if data.fdwvalue and data.fdwvalue != o_data.fdwvalue %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
VALIDATOR {{ data.fdwvalue }};
|
||||
|
||||
{% endif %}
|
||||
{% if (data.fdwvalue == '' or data.fdwvalue == None) and data.fdwvalue != o_data.fdwvalue %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
NO VALIDATOR;
|
||||
|
||||
{% endif %}
|
||||
{# ============= Update foreign data wrapper handler ============= #}
|
||||
{% if data.fdwhan and data.fdwhan != o_data.fdwhan %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
HANDLER {{ data.fdwhan }};
|
||||
|
||||
{% endif %}
|
||||
{% if (data.fdwhan == '' or data.fdwhan == None) and data.fdwhan != o_data.fdwhan %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
NO HANDLER;
|
||||
|
||||
{% endif %}
|
||||
{# ============= Update foreign data wrapper comments ============= #}
|
||||
{% if data.description is defined and data.description != o_data.description %}
|
||||
COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ============= Update foreign data wrapper options and values ============= #}
|
||||
{% if data.fdwoptions and data.fdwoptions.deleted and data.fdwoptions.deleted|length > 0 %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
OPTIONS ({% for variable in data.fdwoptions.deleted %}{% if loop.index != 1 %}, {% endif %}
|
||||
DROP {{ conn|qtIdent(variable.fdwoption) }}{% endfor %}
|
||||
);
|
||||
|
||||
{% endif %}
|
||||
{% if data.fdwoptions and data.fdwoptions.added %}
|
||||
{% if is_valid_added_options %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
OPTIONS ({% for variable in data.fdwoptions.added %}{% if loop.index != 1 %}, {% endif %}
|
||||
ADD {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %}
|
||||
);
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if data.fdwoptions and data.fdwoptions.changed %}
|
||||
{% if is_valid_changed_options %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
OPTIONS ({% for variable in data.fdwoptions.changed %}{% if loop.index != 1 %}, {% endif %}
|
||||
SET {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %}
|
||||
);
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# Change the privileges #}
|
||||
{% if data.fdwacl %}
|
||||
{% if 'deleted' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.deleted %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.changed %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.added %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -14,14 +14,8 @@ FROM
|
|||
WHERE fdw.oid = {{ fid|qtLiteral }}::OID
|
||||
{% endif %}
|
||||
) acl,
|
||||
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
|
||||
(d).privilege_type AS privilege_type
|
||||
FROM (SELECT pg_catalog.aclexplode(fdwacl) as d FROM pg_catalog.pg_foreign_data_wrapper fdw1
|
||||
{% if fid %}
|
||||
WHERE fdw1.oid = {{ fid|qtLiteral }}::OID ) a
|
||||
{% endif %}
|
||||
) d
|
||||
) d
|
||||
pg_catalog.aclexplode(fdwacl) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
|
|
|
@ -26,7 +26,6 @@ COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
|||
{# ============= Create ACL for foreign data wrapper ============= #}
|
||||
{% if data.fdwacl %}
|
||||
{% for priv in data.fdwacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -12,15 +12,19 @@ SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description,
|
|||
ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname)
|
||||
END fdwhan
|
||||
FROM pg_catalog.pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
{% if fid %}
|
||||
WHERE fdw.oid={{fid}}::oid
|
||||
{% endif %}
|
||||
{% if fname %}
|
||||
WHERE fdw.fdwname={{ fname|qtLiteral }}::text
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = fdw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY fdwname
|
||||
|
|
|
@ -70,12 +70,13 @@ SET {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% e
|
|||
{% if data.fdwacl %}
|
||||
{% if 'deleted' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.deleted %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}{% endfor %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.changed %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in data.fdwacl %}
|
||||
{% for priv in data.fdwacl.added %}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor,
|
||||
pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
|
||||
FROM
|
||||
(SELECT
|
||||
d.grantee, d.grantor, d.is_grantable,
|
||||
CASE d.privilege_type
|
||||
WHEN 'USAGE' THEN 'U'
|
||||
ELSE 'UNKNOWN'
|
||||
END AS privilege_type
|
||||
FROM
|
||||
(SELECT lanacl FROM pg_catalog.pg_language lan
|
||||
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
|
||||
WHERE lan.oid = {{ lid|qtLiteral }}::OID
|
||||
) acl,
|
||||
pg_catalog.aclexplode(lanacl) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
GROUP BY g.rolname, gt.rolname
|
||||
ORDER BY grantee
|
|
@ -1,42 +0,0 @@
|
|||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
-- Language: {{data.name}}
|
||||
|
||||
-- DROP LANGUAGE IF EXISTS {{ conn|qtIdent(data.name) }}
|
||||
|
||||
{# ============= CREATE LANGUAGE Query ============= #}
|
||||
CREATE{% if add_replace_clause %} OR REPLACE{% endif %}{% if data.trusted %} TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
{% if data.lanproc %}
|
||||
HANDLER {{ conn|qtIdent(data.lanproc) }}
|
||||
{% endif %}
|
||||
{% if data.laninl %}
|
||||
INLINE {{ conn|qtIdent(data.laninl) }}
|
||||
{% endif %}
|
||||
{% if data.lanval %}
|
||||
VALIDATOR {{ conn|qtIdent(data.lanval) }}{% endif %};
|
||||
{# ============= ALTER LANGUAGE Query ============= #}
|
||||
{% if data.lanowner %}
|
||||
|
||||
ALTER LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.lanowner) }};
|
||||
{% endif %}
|
||||
{# ============= Comment on LANGUAGE Query ============= #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.lanacl and data.lanacl|length > 0 %}
|
||||
|
||||
{% for priv in data.lanacl %}
|
||||
{{ PRIVILEGE.APPLY(conn, 'LANGUAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -12,11 +12,7 @@ FROM
|
|||
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
|
||||
WHERE lan.oid = {{ lid|qtLiteral }}::OID
|
||||
) acl,
|
||||
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
|
||||
(d).privilege_type AS privilege_type
|
||||
FROM (SELECT pg_catalog.aclexplode(lanacl) as d FROM pg_catalog.pg_language lan1
|
||||
WHERE lan1.oid = {{ lid|qtLiteral }}::OID ) a
|
||||
) d
|
||||
pg_catalog.aclexplode(lanacl) d
|
||||
) d
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
|
||||
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{% if data %}
|
||||
CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }}
|
||||
{# if user has provided lc_collate & lc_type #}
|
||||
{% if data.lc_collate and data.lc_type %}
|
||||
(LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }});
|
||||
{% endif %}
|
||||
{# if user has provided locale only #}
|
||||
{% if data.locale %}
|
||||
(LOCALE = {{ data.locale|qtLiteral }});
|
||||
{% endif %}
|
||||
{# if user has choosed to copy from existing collation #}
|
||||
{% if data.copy_collation %}
|
||||
FROM {{ data.copy_collation }};
|
||||
{% endif %}
|
||||
{% if data.owner %}
|
||||
|
||||
ALTER COLLATION {{ conn|qtIdent(data.schema, data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.owner) }};
|
||||
{% endif %}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON COLLATION {{ conn|qtIdent(data.schema, data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -1,10 +1,5 @@
|
|||
{% if data %}
|
||||
{% if not data.lc_collate and not data.lc_type and not data.locale and not data.copy_collation %}
|
||||
CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }}
|
||||
FROM pg_catalog."default";
|
||||
{% else %}
|
||||
CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }}
|
||||
{% endif %}
|
||||
{# if user has provided lc_collate & lc_type #}
|
||||
{% if data.lc_collate and data.lc_type %}
|
||||
(LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }});
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
SELECT
|
||||
typcategory
|
||||
FROM
|
||||
pg_catalog.pg_type
|
||||
WHERE typname = {{datatype}};
|
|
@ -1,41 +0,0 @@
|
|||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname and data.collname != "pg_catalog.\"default\"" %}
|
||||
|
||||
COLLATE {{ data.collname }}{% endif %}{% if data.typdefault %}
|
||||
|
||||
DEFAULT {{ data.typdefault }}{% endif %}{% if data.typnotnull %}
|
||||
|
||||
NOT NULL{% endif %};
|
||||
|
||||
{% if data.owner %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %}
|
||||
|
||||
{% if data.constraints %}
|
||||
{% for c in data.constraints %}{% if c.conname and c.consrc %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% endif -%};
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
IS '{{ c.description }}';
|
||||
{% endif %}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
{% if data.description %}
|
||||
COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
IS '{{ data.description }}';{% endif -%}
|
||||
|
||||
{% if data.seclabels %}
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
{% endif -%}
|
|
@ -1,10 +0,0 @@
|
|||
SELECT --nspname, collname,
|
||||
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
|
||||
pg_catalog.concat(nspname, '."', collname,'"')
|
||||
ELSE '' END AS copy_collation
|
||||
FROM
|
||||
pg_catalog.pg_collation c, pg_catalog.pg_namespace n
|
||||
WHERE
|
||||
c.collnamespace=n.oid
|
||||
ORDER BY
|
||||
nspname, collname;
|
|
@ -1,15 +0,0 @@
|
|||
SELECT
|
||||
'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description,
|
||||
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated
|
||||
FROM
|
||||
pg_catalog.pg_constraint c
|
||||
JOIN
|
||||
pg_catalog.pg_type t ON t.oid=contypid
|
||||
JOIN
|
||||
pg_catalog.pg_namespace nl ON nl.oid=typnamespace
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
|
||||
WHERE
|
||||
contype = 'c' AND contypid = {{doid}}::oid
|
||||
ORDER BY
|
||||
conname;
|
|
@ -1,21 +0,0 @@
|
|||
SELECT
|
||||
d.oid, d.typname as name, pg_catalog.pg_get_userbyid(d.typowner) as owner,
|
||||
bn.nspname as basensp
|
||||
FROM
|
||||
pg_catalog.pg_type d
|
||||
JOIN
|
||||
pg_catalog.pg_type b ON b.oid = d.typbasetype
|
||||
JOIN
|
||||
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
|
||||
{% if scid is defined %}
|
||||
WHERE
|
||||
d.typnamespace = {{scid}}::oid
|
||||
{% elif doid %}
|
||||
WHERE d.oid = {{doid}}::oid
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = d.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
d.typname;
|
|
@ -1,34 +0,0 @@
|
|||
SELECT
|
||||
d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, pg_catalog.pg_get_userbyid(d.typowner) as owner,
|
||||
c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype,
|
||||
CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN
|
||||
pg_catalog.concat(cn.nspname, '."', c.collname,'"')
|
||||
ELSE '' END AS collname,
|
||||
d.typtypmod, d.typnotnull, d.typdefault, d.typndims, d.typdelim, bn.nspname as basensp,
|
||||
description, (SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup,
|
||||
(SELECT COUNT(1) FROM pg_catalog.pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup,
|
||||
(SELECT
|
||||
pg_catalog.array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_catalog.pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=d.oid) AS seclabels
|
||||
FROM
|
||||
pg_catalog.pg_type d
|
||||
JOIN
|
||||
pg_catalog.pg_type b ON b.oid = d.typbasetype
|
||||
JOIN
|
||||
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass)
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_collation c ON d.typcollation=c.oid
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid
|
||||
WHERE
|
||||
d.typnamespace = {{scid}}::oid
|
||||
{% if doid %}
|
||||
AND d.oid={{doid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
d.typname;
|
|
@ -1,100 +0,0 @@
|
|||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
{% set name = data.name %}
|
||||
{% endif %}
|
||||
{% endif -%}
|
||||
{% if data.typnotnull and not o_data.typnotnull %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
SET NOT NULL;
|
||||
{% elif 'typnotnull' in data and not data.typnotnull and o_data.typnotnull%}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP NOT NULL;
|
||||
{% endif -%}{% if data.typdefault %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
SET DEFAULT {{ data.typdefault }};
|
||||
{% elif (data.typdefault == '' or data.typdefault == None) and data.typdefault != o_data.typdefault %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP DEFAULT;
|
||||
{% endif -%}{% if data.owner %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.owner) }};
|
||||
{% endif -%}{% if data.constraints %}
|
||||
{% for c in data.constraints.deleted %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }};
|
||||
{% endfor -%}
|
||||
{% if data.is_schema_diff is defined and data.is_schema_diff %}
|
||||
{% for c in data.constraints.changed %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP CONSTRAINT {{ conn|qtIdent(c.conname) }};
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};
|
||||
|
||||
{% if c.description is defined and c.description != '' %}
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
IS {{ c.description|qtLiteral }};{% endif %}
|
||||
{% endfor -%}
|
||||
{% else %}
|
||||
{% for c in data.constraints.changed %}
|
||||
{% if c.conname and c.conname !=o_data['constraints'][c.conoid]['conname'] %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
RENAME CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }} TO {{ conn|qtIdent(c.conname) }};
|
||||
{% endif %}
|
||||
{% if c.convalidated and not o_data['constraints'][c.conoid]['convalidated'] %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }};
|
||||
{% endif %}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% for c in data.constraints.added %}
|
||||
{% if c.conname and c.consrc %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};{% endif -%}
|
||||
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
IS '{{ c.description }}';
|
||||
{% endif %}
|
||||
{% endfor -%}{% endif -%}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if data.description is defined and data.description != o_data.description %}
|
||||
|
||||
COMMENT ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
{% endif -%}{% if data.basensp %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
SET SCHEMA {{ conn|qtIdent(data.basensp) }};{% endif -%}
|
||||
{% endif -%}
|
|
@ -1,24 +1,35 @@
|
|||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname %}
|
||||
AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname and data.collname != "pg_catalog.\"default\"" %}
|
||||
|
||||
COLLATE {{ data.collname }}{% endif %}{% if data.typdefault %}
|
||||
|
||||
DEFAULT {{ data.typdefault }}{% endif %}{% if data.typnotnull %}
|
||||
|
||||
NOT NULL{% endif %}{% if data.constraints %}{% for c in data.constraints %}{% if c.conname and c.consrc %}
|
||||
|
||||
CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% endif -%}
|
||||
{% endfor -%}
|
||||
{% endif -%};
|
||||
NOT NULL{% endif %};
|
||||
|
||||
{% if data.owner %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %}{% if data.description %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %}
|
||||
|
||||
{% if data.constraints %}
|
||||
{% for c in data.constraints %}{% if c.conname and c.consrc %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% endif -%};
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
IS '{{ c.description }}';
|
||||
{% endif %}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
{% if data.description %}
|
||||
COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
IS '{{ data.description }}';{% endif -%}{% if data.seclabels %}
|
||||
IS '{{ data.description }}';{% endif -%}
|
||||
|
||||
{% if data.seclabels %}
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SELECT --nspname, collname,
|
||||
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
|
||||
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
|
||||
pg_catalog.concat(nspname, '."', collname,'"')
|
||||
ELSE '' END AS copy_collation
|
||||
FROM
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SELECT
|
||||
'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description,
|
||||
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as cons
|
||||
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated
|
||||
FROM
|
||||
pg_catalog.pg_constraint c
|
||||
JOIN
|
||||
|
@ -10,6 +10,6 @@ JOIN
|
|||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
|
||||
WHERE
|
||||
contype = 'c'
|
||||
AND contypid = {{doid}}::oid
|
||||
ORDER BY conname;
|
||||
contype = 'c' AND contypid = {{doid}}::oid
|
||||
ORDER BY
|
||||
conname;
|
||||
|
|
|
@ -7,11 +7,15 @@ JOIN
|
|||
pg_catalog.pg_type b ON b.oid = d.typbasetype
|
||||
JOIN
|
||||
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
|
||||
{% if scid %}
|
||||
{% if scid is defined %}
|
||||
WHERE
|
||||
d.typnamespace = {{scid}}::oid
|
||||
{% elif doid %}
|
||||
WHERE d.oid = {{doid}}::oid
|
||||
{% endif %}
|
||||
{% if schema_diff %}
|
||||
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = d.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
d.typname;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
SELECT
|
||||
d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype,
|
||||
pg_catalog.pg_get_userbyid(d.typowner) as owner,
|
||||
d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, pg_catalog.pg_get_userbyid(d.typowner) as owner,
|
||||
c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype,
|
||||
CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN
|
||||
pg_catalog.concat(cn.nspname, '."', c.collname,'"')
|
||||
|
@ -28,8 +27,8 @@ LEFT OUTER JOIN
|
|||
pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid
|
||||
WHERE
|
||||
d.typnamespace = {{scid}}::oid
|
||||
{% if doid %}
|
||||
AND d.oid={{doid}}::oid
|
||||
{% endif %}
|
||||
{% if doid %}
|
||||
AND d.oid={{doid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
d.typname;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% set name = o_data.name %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER TYPE {{ conn|qtIdent(o_data.basensp, o_data.name) }}
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
{% set name = data.name %}
|
||||
{% endif %}
|
||||
|
@ -20,7 +20,7 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
|||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
SET DEFAULT {{ data.typdefault }};
|
||||
{% elif data.typdefault == '' and o_data.typdefault %}
|
||||
{% elif (data.typdefault == '' or data.typdefault == None) and data.typdefault != o_data.typdefault %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP DEFAULT;
|
||||
|
@ -32,32 +32,63 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
|||
{% for c in data.constraints.deleted %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP CONSTRAINT {{ conn|qtIdent(c.conname) }};
|
||||
DROP CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }};
|
||||
{% endfor -%}
|
||||
{% if data.is_schema_diff is defined and data.is_schema_diff %}
|
||||
{% for c in data.constraints.changed %}
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
DROP CONSTRAINT {{ conn|qtIdent(c.conname) }};
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};
|
||||
|
||||
{% if c.description is defined and c.description != '' %}
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
IS {{ c.description|qtLiteral }};{% endif %}
|
||||
{% endfor -%}
|
||||
{% else %}
|
||||
{% for c in data.constraints.changed %}
|
||||
{% if c.conname and c.conname !=o_data['constraints'][c.conoid]['conname'] %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
RENAME CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }} TO {{ conn|qtIdent(c.conname) }};
|
||||
{% endif %}
|
||||
{% if c.convalidated and not o_data['constraints'][c.conoid]['convalidated'] %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }};
|
||||
{% endif %}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% for c in data.constraints.added %}
|
||||
{% if c.conname and c.consrc %}
|
||||
|
||||
ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }} );{% endif -%}
|
||||
ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};{% endif -%}
|
||||
|
||||
{% if c.description %}
|
||||
|
||||
COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
IS '{{ c.description }}';
|
||||
{% endif %}
|
||||
{% endfor -%}{% endif -%}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if data.description is defined and data.description != o_data.description %}
|
||||
|
||||
COMMENT ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}(
|
||||
{% if data.columns %}
|
||||
{% for c in data.columns %}
|
||||
{{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %}
|
||||
{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %}
|
||||
{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
|
||||
{% endfor %}{% endif %}{% if c.attnotnull %}
|
||||
NOT NULL{% else %} NULL{% endif %}{% if c.typdefault is defined and c.typdefault is not none %}
|
||||
DEFAULT {{c.typdefault}}{% endif %}{% if c.collname %}
|
||||
COLLATE {{c.collname}}{% endif %}
|
||||
{% if not loop.last %},
|
||||
{% endif %}{% endfor -%}{% endif %}
|
||||
|
||||
)
|
||||
SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %}
|
||||
|
||||
{% for o in data.ftoptions %}
|
||||
{% if o.option is defined and o.value is defined %}
|
||||
{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
|
||||
{% endfor %}{% endif %};
|
||||
{% if data.owner %}
|
||||
|
||||
ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.owner) }};
|
||||
{% endif -%}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
IS '{{ data.description }}';
|
||||
{% endif -%}
|
||||
{% if data.acl %}
|
||||
|
||||
{% for priv in data.acl %}
|
||||
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.basensp) }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{% if data.seclabels %}
|
||||
|
||||
{% for r in data.seclabels %}{% if r.label and r.provider %}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -1,17 +0,0 @@
|
|||
{% if scid and foid %}
|
||||
SELECT
|
||||
c.relname AS name, nspname as basensp
|
||||
FROM
|
||||
pg_catalog.pg_class c
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
|
||||
WHERE
|
||||
c.relnamespace = {{scid}}::oid
|
||||
AND
|
||||
c.oid = {{foid}}::oid;
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if name %}
|
||||
DROP FOREIGN TABLE IF EXISTS {{ conn|qtIdent(basensp, name) }}{% if cascade%} CASCADE{% endif %};
|
||||
{% endif %}
|
|
@ -1,9 +0,0 @@
|
|||
SELECT --nspname, collname,
|
||||
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
|
||||
pg_catalog.concat(nspname, '."', collname,'"')
|
||||
ELSE '' END AS copy_collation
|
||||
FROM
|
||||
pg_catalog.pg_collation c, pg_catalog.pg_namespace n
|
||||
WHERE
|
||||
c.collnamespace=n.oid
|
||||
ORDER BY nspname, collname;
|
|
@ -1,25 +0,0 @@
|
|||
SELECT
|
||||
attname, attndims, atttypmod, attoptions, attfdwoptions, pg_catalog.format_type(t.oid,NULL) AS datatype,
|
||||
attnotnull, attstattarget, attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype,
|
||||
CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN
|
||||
pg_catalog.concat(cn.nspname, '."', cl.collname,'"') ELSE '' END AS collname,
|
||||
(SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup,
|
||||
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault
|
||||
FROM
|
||||
pg_catalog.pg_attribute att
|
||||
JOIN
|
||||
pg_catalog.pg_type t ON t.oid=atttypid
|
||||
JOIN
|
||||
pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_type b ON t.typelem=b.oid
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_collation cl ON att.attcollation=cl.oid
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid
|
||||
WHERE
|
||||
att.attrelid={{foid}}::oid
|
||||
AND attnum>0
|
||||
ORDER by attnum;
|
|
@ -1,7 +0,0 @@
|
|||
SELECT
|
||||
conname, contype, consrc, conislocal
|
||||
FROM
|
||||
pg_catalog.pg_constraint
|
||||
WHERE
|
||||
conrelid={{foid}}::oid
|
||||
ORDER by conname;
|
|
@ -1,6 +0,0 @@
|
|||
SELECT
|
||||
srvname
|
||||
FROM
|
||||
pg_catalog.pg_foreign_server
|
||||
ORDER BY
|
||||
srvname;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue