Added Strategy, Locale Provider, ICU Locale, ICU Rules, and OID options while creating a database. #6383

This commit is contained in:
Akshay Joshi 2023-09-04 16:03:06 +05:30 committed by GitHub
parent 39a14920e3
commit c0b868b53b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 2351 additions and 26 deletions

View File

@ -19,6 +19,9 @@ Use the fields in the *General* tab to identify the database:
* Use the *Database* field to add a descriptive name for the database. The name
will be displayed in the *pgAdmin* tree control.
* Use the *OID* field to specify the object identifier to be used for the new
database. Users can specify the value greater than 16383. This option is available
from v15 and above.
* Select the owner of the database from the drop-down listbox in the *Owner*
field.
* Store notes about the database in the *Comment* field.
@ -38,11 +41,22 @@ Use the *Definition* tab to set properties for the database:
* Select a tablespace from the drop-down listbox in the *Tablespace* field. The
selected tablespace will be the default tablespace used to contain database
objects.
* Select the strategy from the drop-down listbox in the *Strategy* field while
creating a new database. This option is available from v15 and above.
* Select the locale provider from the drop-down listbox in the *Locale Provider*
field to set the default collation for this database. Possible values are: icu, libc.
This option is available from v15 and above.
* Select the collation order from the drop-down listbox in the *Collation* field.
* Select the character classification from the drop-down listbox in the
*Character Type* field. This affects the categorization of characters, e.g.
lower, upper and digit. The default, or a blank field, uses the character
classification of the template database.
* Select the icu locale from the drop-down listbox in the *ICU Locale* to
specifies the ICU locale ID if the ICU locale provider is used.
This option is available from v15 and above.
* Specify the icu rules in the *ICU Rules* field as additional collation
rules to customize the behavior of the default collation of this database.
This option is available from v16 and above.
* Specify a connection limit in the *Connection Limit* field to configure the
maximum number of connection requests. The default value (*-1*) allows
unlimited connections to the database.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -21,10 +21,12 @@ New features
************
| `Issue #4805 <https://github.com/pgadmin-org/pgadmin4/issues/4805>`_ - Added all the new options of the 'WITH' clause in the subscription dialog.
| `Issue #6383 <https://github.com/pgadmin-org/pgadmin4/issues/6383>`_ - Added Strategy, Locale Provider, ICU Locale, ICU Rules, and OID options while creating a database.
Housekeeping
************
| `Issue #2411 <https://github.com/pgadmin-org/pgadmin4/issues/2411>`_ - Added the 'data type' column in the properties tab of the Columns collection node.
Bug fixes
*********

View File

@ -193,6 +193,10 @@ class DatabaseView(PGChildNodeView):
{'get': 'get_ctypes'},
{'get': 'get_ctypes'}
],
'get_icu_locale': [
{'get': 'get_icu_locale'},
{'get': 'get_icu_locale'}
],
'vopts': [
{}, {'get': 'variable_options'}
],
@ -634,7 +638,7 @@ class DatabaseView(PGChildNodeView):
"""
This function to return list of available collation/character types
"""
res = [{'label': '', 'value': ''}]
res = []
default_list = ['C', 'POSIX']
for val in default_list:
res.append(
@ -656,6 +660,28 @@ class DatabaseView(PGChildNodeView):
status=200
)
@check_precondition(action="get_icu_locale")
def get_icu_locale(self, gid, sid, did=None):
"""
This function is used to get the list of icu locale
"""
res = []
SQL = render_template(
"/".join([self.template_path, 'get_icu_locale.sql'])
)
status, rset = self.conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=rset)
for row in rset['rows']:
res.append(
{'label': row['colliculocale'], 'value': row['colliculocale']})
return make_json_response(
data=res,
status=200
)
@check_precondition(action="create")
def create(self, gid, sid):
"""Create the database."""
@ -1230,6 +1256,12 @@ class DatabaseView(PGChildNodeView):
did=did, conn=conn, last_system_oid=0,
show_system_objects=False,
)
# try to connect the db if not connected
# don't delete the below code as it is needed for Database RESQL tests.
if not conn.connected():
conn.connect()
status, res = conn.execute_dict(SQL)
if not status:

View File

@ -332,6 +332,10 @@ define('pgadmin.node.database', [
cacheLevel: 'server',
});
let icu_locale = ()=>getNodeAjaxOptions('get_icu_locale', this, treeNodeInfo, itemNodeData, {
cacheLevel: 'server',
});
return new DatabaseSchema(
()=>getNodeVariableSchema(this, treeNodeInfo, itemNodeData, false, true),
(privileges)=>getNodePrivilegeRoleSchema(this, treeNodeInfo, itemNodeData, privileges),
@ -360,6 +364,7 @@ define('pgadmin.node.database', [
}),
datcollate: c_types,
datctype: c_types,
daticulocale: icu_locale,
},
{
datowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,

View File

@ -61,6 +61,7 @@ export default class DatabaseSchema extends BaseUISchema {
char_type: undefined,
datconnlimit: -1,
datallowconn: undefined,
datlocaleprovider: 'libc',
variables: [],
privileges: [],
securities: [],
@ -82,6 +83,7 @@ export default class DatabaseSchema extends BaseUISchema {
spcname: [],
datcollate: [],
datctype: [],
daticulocale: [],
...fieldOptions,
};
}
@ -100,6 +102,9 @@ export default class DatabaseSchema extends BaseUISchema {
id: 'did', label: gettext('OID'), cell: 'text', mode: ['properties'],
editable: false, type: 'text',
},{
id: 'datoid', label: gettext('OID'), mode: ['create'], type: 'int',
min: 16384, min_version: 150000
}, {
id: 'datowner', label: gettext('Owner'),
editable: false, type: 'select', options: this.fieldOptions.role,
controlProps: { allowClear: false }, isCollectionProperty: true,
@ -125,17 +130,90 @@ export default class DatabaseSchema extends BaseUISchema {
editable: false, type: 'select', group: gettext('Definition'),
options: this.fieldOptions.spcname,
controlProps: { allowClear: false },
},{
id: 'datstrategy', label: gettext('Strategy'),
editable: false, type: 'select', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
mode: ['create'],
options: [{
label: gettext('WAL Log'),
value: 'wal_log',
}, {
label: gettext('File Copy'),
value: 'file_copy',
}],
min_version: 150000
}, {
id: 'datlocaleprovider', label: gettext('Locale Provider'),
editable: false, type: 'select', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
controlProps: { allowClear: false },
options: [{
label: gettext('icu'),
value: 'icu',
}, {
label: gettext('libc'),
value: 'libc',
}],
min_version: 150000
},{
id: 'datcollate', label: gettext('Collation'),
editable: false, type: 'select', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
options: this.fieldOptions.datcollate,
deps: ['datlocaleprovider'],
depChange: (state)=>{
if (state.datlocaleprovider !== 'libc')
return { datcollate: '' };
},
disabled: function(state) {
return state.datlocaleprovider !== 'libc';
},
},{
id: 'datctype', label: gettext('Character type'),
editable: false, type: 'select', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
options: this.fieldOptions.datctype,
deps: ['datlocaleprovider'],
depChange: (state)=>{
if (state.datlocaleprovider !== 'libc')
return { datctype: '' };
},
disabled: function(state) {
return state.datlocaleprovider !== 'libc';
},
},{
id: 'daticulocale', label: gettext('ICU Locale'),
editable: false, type: 'select', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
options: this.fieldOptions.daticulocale,
deps: ['datlocaleprovider'],
depChange: (state)=>{
if (state.datlocaleprovider !== 'icu')
return { daticulocale: '' };
},
disabled: function(state) {
return state.datlocaleprovider !== 'icu';
},
min_version: 150000
}, {
id: 'datcollversion', label: gettext('Collation Version'),
editable: false, type: 'text', group: gettext('Definition'),
mode: ['properties'], min_version: 150000
}, {
id: 'daticurules', label: gettext('ICU Rules'),
editable: false, type: 'text', group: gettext('Definition'),
readonly: function(state) {return !obj.isNew(state); },
deps: ['datlocaleprovider'],
depChange: (state)=>{
if (state.datlocaleprovider !== 'icu')
return { daticurules: '' };
},
disabled: function(state) {
return state.datlocaleprovider !== 'icu';
},
min_version: 160000
}, {
id: 'datconnlimit', label: gettext('Connection limit'),
editable: false, type: 'int', group: gettext('Definition'),
min: -1,

View File

@ -0,0 +1,29 @@
{% if data %}
CREATE DATABASE {{ conn|qtIdent(data.name) }}
{% if data.datowner %}
WITH{% endif %}{% if data.datowner %}
OWNER = {{ conn|qtIdent(data.datowner) }}{% endif %}{% if data.template %}
TEMPLATE = {{ conn|qtIdent(data.template) }}{% endif %}{% if data.encoding %}
ENCODING = {{ data.encoding|qtLiteral(conn) }}{% endif %}{% if data.datstrategy %}
STRATEGY = {{ data.datstrategy|qtLiteral(conn) }}{% endif %}{% if data.datcollate %}
LC_COLLATE = {{ data.datcollate|qtLiteral(conn) }}{% endif %}{% if data.datctype %}
LC_CTYPE = {{ data.datctype|qtLiteral(conn) }}{% endif %}{% if data.daticulocale %}
ICU_LOCALE = {{ data.daticulocale|qtLiteral(conn) }}{% endif %}{% if data.datlocaleprovider %}
LOCALE_PROVIDER = {{ data.datlocaleprovider|qtLiteral(conn) }}{% endif %}{% if data.spcname %}
TABLESPACE = {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.datconnlimit %}
CONNECTION LIMIT = {{ data.datconnlimit }}{% endif %}{% if data.datoid %}
OID = {{ data.datoid }}{% endif %}
IS_TEMPLATE = {{ data.is_template }};
{% endif %}

View File

@ -0,0 +1 @@
SELECT colliculocale from pg_collation where collprovider = 'i'

View File

@ -0,0 +1,44 @@
SELECT
db.oid AS did, db.oid, db.datname AS name, db.dattablespace AS spcoid,
spcname, datallowconn, pg_catalog.pg_encoding_to_char(encoding) AS encoding,
pg_catalog.pg_get_userbyid(datdba) AS datowner,
(select pg_catalog.current_setting('lc_collate')) as datcollate,
(select pg_catalog.current_setting('lc_ctype')) as datctype,
CASE WHEN datlocprovider = 'i' THEN 'icu' ELSE 'libc' END datlocaleprovider,
daticulocale, datcollversion,
datconnlimit,
pg_catalog.has_database_privilege(db.oid, 'CREATE') AS cancreate,
pg_catalog.current_setting('default_tablespace') AS default_tablespace,
descr.description AS comments, db.datistemplate AS is_template,
{### Default ACL for Tables ###}
'' AS tblacl,
{### Default ACL for Sequnces ###}
'' AS seqacl,
{### Default ACL for Functions ###}
'' AS funcacl,
pg_catalog.array_to_string(datacl::text[], ', ') AS acl
FROM pg_catalog.pg_database db
LEFT OUTER JOIN pg_catalog.pg_tablespace ta ON db.dattablespace=ta.OID
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
db.oid=descr.objoid AND descr.classoid='pg_database'::regclass
)
WHERE
{% if show_user_defined_templates is defined %}
db.datistemplate = {{show_user_defined_templates}} AND
{% endif %}
{% if did %}
db.oid = {{ did|qtLiteral(conn) }}::OID
{% else %}
{% if name %}
db.datname = {{ name|qtLiteral(conn) }}::text
{% endif %}
{% endif %}
{% if db_restrictions %}
{% if did or name %}AND{% endif %}
db.datname in ({{db_restrictions}})
{% elif not did and not name%}
db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb')
{% endif %}
ORDER BY datname;

View File

@ -0,0 +1,31 @@
{% if data %}
CREATE DATABASE {{ conn|qtIdent(data.name) }}
{% if data.datowner %}
WITH{% endif %}{% if data.datowner %}
OWNER = {{ conn|qtIdent(data.datowner) }}{% endif %}{% if data.template %}
TEMPLATE = {{ conn|qtIdent(data.template) }}{% endif %}{% if data.encoding %}
ENCODING = {{ data.encoding|qtLiteral(conn) }}{% endif %}{% if data.datstrategy %}
STRATEGY = {{ data.datstrategy|qtLiteral(conn) }}{% endif %}{% if data.datcollate %}
LC_COLLATE = {{ data.datcollate|qtLiteral(conn) }}{% endif %}{% if data.datctype %}
LC_CTYPE = {{ data.datctype|qtLiteral(conn) }}{% endif %}{% if data.daticulocale %}
ICU_LOCALE = {{ data.daticulocale|qtLiteral(conn) }}{% endif %}{% if data.daticurules %}
ICU_RULES = {{ data.daticurules|qtLiteral(conn) }}{% endif %}{% if data.datlocaleprovider %}
LOCALE_PROVIDER = {{ data.datlocaleprovider|qtLiteral(conn) }}{% endif %}{% if data.spcname %}
TABLESPACE = {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.datconnlimit %}
CONNECTION LIMIT = {{ data.datconnlimit }}{% endif %}{% if data.datoid %}
OID = {{ data.datoid }}{% endif %}
IS_TEMPLATE = {{ data.is_template }};
{% endif %}

View File

@ -2,7 +2,8 @@ SELECT
db.oid AS did, db.oid, db.datname AS name, db.dattablespace AS spcoid,
spcname, datallowconn, pg_catalog.pg_encoding_to_char(encoding) AS encoding,
pg_catalog.pg_get_userbyid(datdba) AS datowner, db.datcollate, db.datctype,
datconnlimit,
datconnlimit, daticulocale, daticurules, datcollversion,
CASE WHEN datlocprovider = 'i' THEN 'icu' ELSE 'libc' END datlocaleprovider,
pg_catalog.has_database_privilege(db.oid, 'CREATE') AS cancreate,
pg_catalog.current_setting('default_tablespace') AS default_tablespace,
descr.description AS comments, db.datistemplate AS is_template,

View File

@ -0,0 +1,16 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,14 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,23 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON SEQUENCES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres
GRANT SELECT, USAGE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,21 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres
GRANT SELECT ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,24 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON SEQUENCES FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres
GRANT SELECT, USAGE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,15 @@
-- Database: test_database_icu_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_icu_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_icu_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
ICU_LOCALE = 'en-US'
LOCALE_PROVIDER = 'icu'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,13 @@
CREATE DATABASE "test_database_icu_$%{}[]()&*^!@""""""""'`\/#"
TEMPLATE = template0
ENCODING = 'UTF8'
ICU_LOCALE = 'en-US'
LOCALE_PROVIDER = 'icu'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,14 @@
-- Database: test_database_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,10 @@
CREATE DATABASE "test_database_$%{}[]()&*^!@""""""""'`\/#"
ENCODING = 'UTF8'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,363 @@
{
"scenarios": [
{
"type": "alter",
"name": "Alert default priviliges for functions",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_function.sql",
"expected_msql_file": "alter_default_db_privileges_function_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for tables",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "postgres",
"privileges": [
{"privilege_type":"D","privilege":true,"with_grant":false},
{"privilege_type":"w","privilege":true,"with_grant":false}
],
"acltype": "deftblacl"
}
],
"added": [
{
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
],
"grantor": "postgres"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_tables.sql"
},
{
"type": "alter",
"name": "Alert default privileges for sequences",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "postgres",
"privileges": [
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
],
"added":[
{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false},
{"privilege_type":"r","privilege":true,"with_grant":false}],"grantor":"postgres"}]
},
"deftblacl": {"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_sequences.sql",
"expected_msql_file": "alter_default_db_privileges_sequences_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for types",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_types.sql"
},
{
"type": "alter",
"name": "Alert default privileges reset all",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"postgres"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"postgres"}]},
"deftblacl":{"added":[{"grantee":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"grantor":"postgres"}],"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false,"cid":"nn626"},{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn627"},{"privilege_type":"w","privilege":true,"with_grant":false,"cid":"nn628"},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]},
"defseqacl":{"added":[{"grantee":"postgres","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"postgres"}],"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn673"},{"privilege_type":"U","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_reset_all.sql"
},
{
"type": "create",
"name": "Create Database with new options and libc",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"encoding": "UTF8",
"schema_res": [],
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_new_options_libc.sql",
"expected_msql_file": "create_database_new_options_libc_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "en-US",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu.sql",
"expected_msql_file": "create_database_icu_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,16 @@
-- Database: test_database_icu_rules_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
ICU_LOCALE = 'und'
ICU_RULES = '&V << w <<< W'
LOCALE_PROVIDER = 'icu'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,14 @@
CREATE DATABASE "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#"
TEMPLATE = template0
ENCODING = 'UTF8'
ICU_LOCALE = 'und'
ICU_RULES = '&V << w <<< W'
LOCALE_PROVIDER = 'icu'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,474 @@
{
"scenarios": [
{
"type": "alter",
"name": "Alert default priviliges for functions",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_function.sql",
"expected_msql_file": "alter_default_db_privileges_function_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for tables",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "postgres",
"privileges": [
{"privilege_type":"D","privilege":true,"with_grant":false},
{"privilege_type":"w","privilege":true,"with_grant":false}
],
"acltype": "deftblacl"
}
],
"added": [
{
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
],
"grantor": "postgres"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_tables.sql"
},
{
"type": "alter",
"name": "Alert default privileges for sequences",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "postgres",
"privileges": [
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
],
"added":[
{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false},
{"privilege_type":"r","privilege":true,"with_grant":false}],"grantor":"postgres"}]
},
"deftblacl": {"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_sequences.sql",
"expected_msql_file": "alter_default_db_privileges_sequences_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for types",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
{
"grantor": "postgres",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_types.sql"
},
{
"type": "alter",
"name": "Alert default privileges reset all",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"postgres"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"postgres"}]},
"deftblacl":{"added":[{"grantee":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"grantor":"postgres"}],"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false,"cid":"nn626"},{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn627"},{"privilege_type":"w","privilege":true,"with_grant":false,"cid":"nn628"},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]},
"defseqacl":{"added":[{"grantee":"postgres","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"postgres"}],"deleted":[{"grantor":"postgres","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn673"},{"privilege_type":"U","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_reset_all.sql"
},
{
"type": "create",
"name": "Create Database with new options and libc",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"encoding": "UTF8",
"schema_res": [],
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_new_options_libc.sql",
"expected_msql_file": "create_database_new_options_libc_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "en-US",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu.sql",
"expected_msql_file": "create_database_icu_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu rules options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_rules_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "und",
"daticurules": "&V << w <<< W",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu_rules.sql",
"expected_msql_file": "create_database_icu_rules_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_rules_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
}
]
}

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -7,6 +7,7 @@
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
@ -34,6 +35,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
@ -71,6 +73,7 @@
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
@ -102,6 +105,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
@ -129,6 +133,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"postgres"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"postgres"}]},

View File

@ -0,0 +1,16 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,14 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,23 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM enterprisedb;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON SEQUENCES FROM enterprisedb;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb
GRANT SELECT, USAGE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,21 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM enterprisedb;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb
GRANT SELECT ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,23 @@
-- Database: <TEST_DB_NAME>
-- DROP DATABASE IF EXISTS <TEST_DB_NAME>;
CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM enterprisedb;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON SEQUENCES FROM enterprisedb;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb
GRANT SELECT, USAGE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,15 @@
-- Database: test_database_icu_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_icu_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_icu_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
ICU_LOCALE = 'en-US'
LOCALE_PROVIDER = 'icu'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,13 @@
CREATE DATABASE "test_database_icu_$%{}[]()&*^!@""""""""'`\/#"
TEMPLATE = template0
ENCODING = 'UTF8'
ICU_LOCALE = 'en-US'
LOCALE_PROVIDER = 'icu'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,14 @@
-- Database: test_database_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
LOCALE_PROVIDER = 'libc'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,10 @@
CREATE DATABASE "test_database_$%{}[]()&*^!@""""""""'`\/#"
ENCODING = 'UTF8'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,363 @@
{
"scenarios": [
{
"type": "alter",
"name": "Alert default priviliges for functions",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_function.sql",
"expected_msql_file": "alter_default_db_privileges_function_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for tables",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "enterprisedb",
"privileges": [
{"privilege_type":"D","privilege":true,"with_grant":false},
{"privilege_type":"w","privilege":true,"with_grant":false}
],
"acltype": "deftblacl"
}
],
"added": [
{
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
],
"grantor": "enterprisedb"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_tables.sql"
},
{
"type": "alter",
"name": "Alert default privileges for sequences",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "enterprisedb",
"privileges": [
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
],
"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false},
{"privilege_type":"r","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]
},
"deftblacl": {"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_sequences.sql",
"expected_msql_file": "alter_default_db_privileges_sequences_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for types",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_types.sql"
},
{
"type": "alter",
"name": "Alert default privileges reset all",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},
"deftblacl":{"added":[{"grantee":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}],"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false,"cid":"nn626"},{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn627"},{"privilege_type":"w","privilege":true,"with_grant":false,"cid":"nn628"},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]},
"defseqacl":{"added":[{"grantee":"enterprisedb","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}],"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn673"},{"privilege_type":"U","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_reset_all.sql"
},
{
"type": "create",
"name": "Create Database with new options and libc",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"encoding": "UTF8",
"schema_res": [],
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_new_options_libc.sql",
"expected_msql_file": "create_database_new_options_libc_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "en-US",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu.sql",
"expected_msql_file": "create_database_icu_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,16 @@
-- Database: test_database_icu_rules_$%{}[]()&*^!@""""'`\/#
-- DROP DATABASE IF EXISTS "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#";
CREATE DATABASE "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#"
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
ICU_LOCALE = 'und'
ICU_RULES = '&V << w <<< W'
LOCALE_PROVIDER = 'icu'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -0,0 +1,14 @@
CREATE DATABASE "test_database_icu_rules_$%{}[]()&*^!@""""""""'`\/#"
TEMPLATE = template0
ENCODING = 'UTF8'
ICU_LOCALE = 'und'
ICU_RULES = '&V << w <<< W'
LOCALE_PROVIDER = 'icu'
IS_TEMPLATE = False;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON TABLES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES FOR ROLE enterprisedb REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;

View File

@ -0,0 +1,474 @@
{
"scenarios": [
{
"type": "alter",
"name": "Alert default priviliges for functions",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_function.sql",
"expected_msql_file": "alter_default_db_privileges_function_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for tables",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "enterprisedb",
"privileges": [
{"privilege_type":"D","privilege":true,"with_grant":false},
{"privilege_type":"w","privilege":true,"with_grant":false}
],
"acltype": "deftblacl"
}
],
"added": [
{
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
],
"grantor": "enterprisedb"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_tables.sql"
},
{
"type": "alter",
"name": "Alert default privileges for sequences",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "enterprisedb",
"privileges": [
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
],
"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false},
{"privilege_type":"r","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]
},
"deftblacl": {"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_sequences.sql",
"expected_msql_file": "alter_default_db_privileges_sequences_msql.sql"
},
{
"type": "alter",
"name": "Alert default privileges for types",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
{
"grantor": "enterprisedb",
"grantee": "PUBLIC",
"privileges": [
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
],
"acltype": "defaultacls"
}
]
}
},
"expected_sql_file": "alter_default_db_privileges_types.sql"
},
{
"type": "alter",
"name": "Alert default privileges reset all",
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},
"deftblacl":{"added":[{"grantee":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}],"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false,"cid":"nn626"},{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn627"},{"privilege_type":"w","privilege":true,"with_grant":false,"cid":"nn628"},{"privilege_type":"d","privilege":true,"with_grant":false},{"privilege_type":"D","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false},{"privilege_type":"t","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]},
"defseqacl":{"added":[{"grantee":"enterprisedb","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}],"deleted":[{"grantor":"enterprisedb","grantee":"PUBLIC","privileges":[{"privilege_type":"r","privilege":true,"with_grant":false,"cid":"nn673"},{"privilege_type":"U","privilege":true,"with_grant":false}],"acltype":"defaultacls"}]}
},
"expected_sql_file": "alter_default_db_privileges_reset_all.sql"
},
{
"type": "create",
"name": "Create Database with new options and libc",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"encoding": "UTF8",
"schema_res": [],
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_new_options_libc.sql",
"expected_msql_file": "create_database_new_options_libc_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "en-US",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu.sql",
"expected_msql_file": "create_database_icu_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Database with icu rules options",
"endpoint": "NODE-database.obj",
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql",
"REPLACE_LOCALE": true,
"data": {
"name": "test_database_icu_rules_$%{}[]()&*^!@\"\"\"\"'`\\/#",
"description": "This is a test comment",
"is_template": false,
"template": "template0",
"encoding": "UTF8",
"schema_res": [],
"datlocaleprovider": "icu",
"daticulocale": "und",
"daticurules": "&V << w <<< W",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "a",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_database_icu_rules.sql",
"expected_msql_file": "create_database_icu_rules_msql.sql"
},
{
"type": "delete",
"name": "Drop Database",
"endpoint": "NODE-database.delete_id",
"data": {
"name": "test_database_icu_rules_$%{}[]()&*^!@\"\"\"\"'`\\/#"
}
}
]
}

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -6,8 +6,8 @@ CREATE DATABASE <TEST_DB_NAME>
WITH
OWNER = enterprisedb
ENCODING = 'UTF8'
LC_COLLATE = 'C'
LC_CTYPE = 'C'
LC_COLLATE = '<LC_COLLATE>'
LC_CTYPE = '<LC_CTYPE>'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
IS_TEMPLATE = False;

View File

@ -7,6 +7,7 @@
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {
"deleted": [
@ -34,6 +35,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftblacl": {
"deleted": [
@ -71,6 +73,7 @@
"sql_endpoint": "NODE-database.sql_id",
"msql_endpoint": "NODE-database.msql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"defseqacl": {
"deleted": [
@ -102,6 +105,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deftypeacl": {
"deleted": [
@ -129,6 +133,7 @@
"endpoint": "NODE-database.obj_id",
"sql_endpoint": "NODE-database.sql_id",
"TEST_DB_NAME": "<TEST_DB_NAME>",
"REPLACE_LOCALE": true,
"data": {
"deffuncacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"X","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},
"deftypeacl": {"added":[{"grantee":"PUBLIC","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}],"grantor":"enterprisedb"}]},

View File

@ -33,7 +33,8 @@ class DatabaseAddTestCase(BaseTestGenerator):
server_response = server_utils.connect_server(self, self.server_id)
if server_response["info"] == "Server connected.":
db_owner = server_response['data']['user']['name']
self.data = database_utils.get_db_data(db_owner)
server_version = server_response['data']['version']
self.data = database_utils.get_db_data(db_owner, server_version)
self.data['template'] = 'template0'
self.db_name = self.data['name']
response = self.tester.post(self.url + str(utils.SERVER_GROUP) +

View File

@ -9,6 +9,7 @@
import json
import uuid
import secrets
from pgadmin.utils import server_utils
from regression.python_test_utils import test_utils as utils
@ -16,7 +17,7 @@ from regression.python_test_utils import test_utils as utils
DATABASE_CONNECT_URL = '/browser/database/connect/'
def get_db_data(db_owner):
def get_db_data(db_owner, version=None):
"""This function returns the database details in dict format"""
data = {
"datconnlimit": -1,
@ -77,6 +78,17 @@ def get_db_data(db_owner):
'is_template': False,
"schema_res": ["public", "sample"]
}
if version is not None and version >= 150000:
data['datstrategy'] = 'wal_log'
data['datlocaleprovider'] = 'icu'
data['daticulocale'] = 'und'
data['datoid'] = secrets.choice(range(17000, 999999))
if version is not None and version >= 160000:
data['daticurules'] = '&V << w <<< W'
data['datoid'] = secrets.choice(range(17000, 999999))
return data

View File

@ -109,7 +109,9 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
'pga_job_id': '<PGA_JOB_ID>',
'timestamptz_2': '<TIMESTAMPTZ_2>',
'db_name': '<TEST_DB_NAME>',
'db_driver': '<DB_DRIVER>'}
'db_driver': '<DB_DRIVER>',
'LC_COLLATE': '<LC_COLLATE>',
'LC_CTYPE': '<LC_CTYPE>'}
resql_module_list = create_resql_module_list(
BaseTestGenerator.re_sql_module_list,
@ -189,7 +191,12 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
elif arg == 'sid':
options['sid'] = int(self.server_information['server_id'])
elif arg == 'did':
options['did'] = int(self.server_information['db_id'])
# For database node object_id is the actual database id.
if endpoint.__contains__('NODE-database') and \
object_id is not None:
options['did'] = int(object_id)
else:
options['did'] = int(self.server_information['db_id'])
elif arg == 'scid':
# For schema node object_id is the actual schema id.
if endpoint.__contains__('NODE-schema') and \
@ -779,6 +786,31 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
sql = sql.replace(self.JSON_PLACEHOLDERS['db_name'],
self.server_information['test_db_name'])
# get the database connection
if 'REPLACE_LOCALE' in scenario:
self.get_db_connection()
pg_cursor = self.connection.cursor()
db_name = self.server_information['test_db_name']
# Database name if specify in scenario
if 'data' in scenario and 'name' in scenario['data'] and \
'db' in self.server:
db_name = self.server['db']
# Fetch the lc_collate and lc_ctype
pg_cursor.execute(
"SELECT datcollate as cname FROM pg_database WHERE datname = "
"'{0}'".format(db_name))
lc_collate = ''.join(pg_cursor.fetchone())
pg_cursor.execute(
"SELECT datctype as cname FROM pg_database WHERE datname = "
"'{0}'".format(db_name))
lc_ctype = ''.join(pg_cursor.fetchone())
pg_cursor.close()
sql = sql.replace(self.JSON_PLACEHOLDERS['LC_COLLATE'], lc_collate)
sql = sql.replace(self.JSON_PLACEHOLDERS['LC_CTYPE'], lc_ctype)
return sql
def replace_placeholder_with_id(self, value):