From 0aba9703cd9db5a7f62d453ce6863aa60529a460 Mon Sep 17 00:00:00 2001
From: Pravesh Sharma <pravesh.sharma@enterprisedb.com>
Date: Thu, 14 Nov 2024 13:20:01 +0530
Subject: [PATCH] Added support for a builtin locale provider in the Database
 dialog. #8095

---
 docs/en_US/database_dialog.rst                |   7 +-
 .../servers/databases/__init__.py             |  27 +
 .../servers/databases/static/js/database.js   |   6 +
 .../databases/static/js/database.ui.js        |  49 +-
 .../databases/sql/17_plus/create.sql          |  33 +
 .../sql/17_plus/get_builtin_locale.sql        |   1 +
 .../databases/sql/17_plus/properties.sql      |   5 +-
 .../pg/17_plus/create_database_builtin.sql    |  15 +
 .../17_plus/create_database_builtin_msql.sql  |  13 +
 .../tests/pg/17_plus/test_database.json       | 585 ++++++++++++++++++
 11 files changed, 729 insertions(+), 12 deletions(-)
 create mode 100644 web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/create.sql
 create mode 100644 web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/get_builtin_locale.sql
 create mode 100644 web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin.sql
 create mode 100644 web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin_msql.sql
 create mode 100644 web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/test_database.json

diff --git a/docs/en_US/database_dialog.rst b/docs/en_US/database_dialog.rst
index 055deaa00ab..34059a0a7f9 100644
--- a/docs/en_US/database_dialog.rst
+++ b/docs/en_US/database_dialog.rst
@@ -44,8 +44,9 @@ Use the *Definition* tab to set properties for the database:
 * 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.
+  field to set the default collation for this database. Possible values are: icu, libc and builtin.
+  This option is available from v15 and above. **Note:** The icu and libc options are available
+  from v15 and builtin option is available from v17 onwards.
 * 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.
@@ -57,6 +58,8 @@ Use the *Definition* tab to set properties for the database:
 * 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.
+* Select the builtin locale from the drop-down listbox in the *Builtin Locale* if the
+  builtin locale provider is used. This option is available from v17 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.

diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 846a4c57c6c..669cbed5460 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -202,6 +202,10 @@ class DatabaseView(PGChildNodeView):
             {'get': 'get_icu_locale'},
             {'get': 'get_icu_locale'}
         ],
+        'get_builtin_locale': [
+            {'get': 'get_builtin_locale'},
+            {'get': 'get_builtin_locale'}
+        ],
         'vopts': [
             {}, {'get': 'variable_options'}
         ],
@@ -687,6 +691,29 @@ def get_icu_locale(self, gid, sid, did=None):
             status=200
         )
 
+    @check_precondition(action="get_builtin_locale")
+    def get_builtin_locale(self, gid, sid, did=None):
+        """
+        This function is used to get the list of builtin locale
+        """
+        res = []
+        SQL = render_template(
+            "/".join([self.template_path, 'get_builtin_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['collbuiltinlocale'],
+                 'value': row['collbuiltinlocale']})
+
+        return make_json_response(
+            data=res,
+            status=200
+        )
+
     @check_precondition(action="create")
     def create(self, gid, sid):
         """Create the database."""
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index 2f5b4b739cf..f1823a2acfa 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -336,6 +336,10 @@ define('pgadmin.node.database', [
           cacheLevel: 'server',
         });
 
+        let builtin_locale = ()=>getNodeAjaxOptions('get_builtin_locale', this, treeNodeInfo, itemNodeData, {
+          cacheLevel: 'server',
+        });
+
         return new DatabaseSchema(
           ()=>getNodeVariableSchema(this, treeNodeInfo, itemNodeData, false, true),
           (privileges)=>getNodePrivilegeRoleSchema(this, treeNodeInfo, itemNodeData, privileges),
@@ -365,7 +369,9 @@ define('pgadmin.node.database', [
             datcollate: c_types,
             datctype: c_types,
             daticulocale: icu_locale,
+            datbuiltinlocale: builtin_locale
           },
+          treeNodeInfo,
           {
             datowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,
           }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.ui.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.ui.js
index f13c4d7c438..fe188ca35e4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.ui.js
@@ -48,7 +48,7 @@ export class DefaultPrivSchema extends BaseUISchema {
 }
 
 export default class DatabaseSchema extends BaseUISchema {
-  constructor(getVariableSchema, getPrivilegeRoleSchema, fieldOptions={}, initValues={}) {
+  constructor(getVariableSchema, getPrivilegeRoleSchema, fieldOptions={}, nodeInfo={}, initValues={}) {
     super({
       name: undefined,
       owner: undefined,
@@ -76,6 +76,7 @@ export default class DatabaseSchema extends BaseUISchema {
     });
     this.getVariableSchema = getVariableSchema;
     this.getPrivilegeRoleSchema = getPrivilegeRoleSchema;
+    this.nodeInfo = nodeInfo;
     this.fieldOptions = {
       role: [],
       encoding: [],
@@ -84,6 +85,7 @@ export default class DatabaseSchema extends BaseUISchema {
       datcollate: [],
       datctype: [],
       daticulocale: [],
+      datbuiltinlocale: [],
       ...fieldOptions,
     };
   }
@@ -148,13 +150,21 @@ export default class DatabaseSchema extends BaseUISchema {
         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',
-        }],
+        options: function() {
+          let options = [{
+            label: gettext('icu'),
+            value: 'icu',
+          }, {
+            label: gettext('libc'),
+            value: 'libc',
+          }];
+          if(obj.getServerVersion() >= 170000) {
+            options.push({
+              label: gettext('builtin'), value: 'builtin',
+            });
+          }
+          return Promise.resolve(options);
+        },
         min_version: 150000
       },{
         id: 'datcollate', label: gettext('Collation'),
@@ -213,6 +223,20 @@ export default class DatabaseSchema extends BaseUISchema {
           return state.datlocaleprovider !== 'icu';
         },
         min_version: 160000
+      }, {
+        id: 'datbuiltinlocale', label: gettext('Builtin Locale'),
+        editable: false, type: 'select', group: gettext('Definition'),
+        readonly: function(state) {return !obj.isNew(state); },
+        options: this.fieldOptions.datbuiltinlocale,
+        deps: ['datlocaleprovider'],
+        depChange: (state)=>{
+          if (state.datlocaleprovider !== 'builtin')
+            return { datbuiltinlocale: '' };
+        },
+        disabled: function(state) {
+          return state.datlocaleprovider !== 'builtin';
+        },
+        min_version: 170000
       }, {
         id: 'datconnlimit', label: gettext('Connection limit'),
         editable: false, type: 'int', group: gettext('Definition'),
@@ -295,4 +319,13 @@ export default class DatabaseSchema extends BaseUISchema {
       },
     ];
   }
+
+  validate(state, setError) {
+    if (state.datlocaleprovider && this.isNew(state) &&
+        (state.datlocaleprovider == 'builtin' && !state.datbuiltinlocale)) {
+      setError('datbuiltinlocale', gettext('Please specify Builtin Locale.'));
+      return true;
+    }
+    return false;
+  }
 }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/create.sql
new file mode 100644
index 00000000000..d9dbf3beebd
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/create.sql
@@ -0,0 +1,33 @@
+{% 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 and data.datlocaleprovider == 'icu' %}
+
+    ICU_LOCALE = {{ data.daticulocale|qtLiteral(conn) }}{% elif data.datbuiltinlocale and data.datlocaleprovider == 'builtin' %}
+
+    BUILTIN_LOCALE = {{ data.datbuiltinlocale|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 %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/get_builtin_locale.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/get_builtin_locale.sql
new file mode 100644
index 00000000000..cd846efe339
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/get_builtin_locale.sql
@@ -0,0 +1 @@
+SELECT colllocale as collbuiltinlocale from pg_collation where collprovider = 'b';
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/properties.sql
index 7ff6262fdaa..864441e6626 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/17_plus/properties.sql
@@ -2,8 +2,9 @@ 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, datlocale AS daticulocale, daticurules, datcollversion,
-    CASE WHEN datlocprovider = 'i' THEN 'icu' ELSE 'libc' END datlocaleprovider,
+    datconnlimit, datlocale AS daticulocale, datlocale AS datbuiltinlocale, daticurules, datcollversion,
+    CASE WHEN datlocprovider = 'i' THEN 'icu' WHEN datlocprovider = 'b' THEN 'builtin'
+    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,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin.sql b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin.sql
new file mode 100644
index 00000000000..beef0a2e32b
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin.sql
@@ -0,0 +1,15 @@
+-- Database: test_database_builtin_$%{}[]()&*^!@""""'`\/#
+
+-- DROP DATABASE IF EXISTS "test_database_builtin_$%{}[]()&*^!@""""""""'`\/#";
+
+CREATE DATABASE "test_database_builtin_$%{}[]()&*^!@""""""""'`\/#"
+    WITH
+    OWNER = postgres
+    ENCODING = 'UTF8'
+    LC_COLLATE = '<LC_COLLATE>'
+    LC_CTYPE = '<LC_CTYPE>'
+    BUILTIN_LOCALE = 'C.UTF-8'
+    LOCALE_PROVIDER = 'builtin'
+    TABLESPACE = pg_default
+    CONNECTION LIMIT = -1
+    IS_TEMPLATE = False;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin_msql.sql
new file mode 100644
index 00000000000..366ba5adbb2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/create_database_builtin_msql.sql
@@ -0,0 +1,13 @@
+CREATE DATABASE "test_database_builtin_$%{}[]()&*^!@""""""""'`\/#"
+
+    TEMPLATE = template0
+    ENCODING = 'UTF8'
+    BUILTIN_LOCALE = 'C.UTF-8'
+    LOCALE_PROVIDER = 'builtin'
+    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;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/test_database.json b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/test_database.json
new file mode 100644
index 00000000000..12bcdbea65f
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/pg/17_plus/test_database.json
@@ -0,0 +1,585 @@
+{
+    "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_$%{}[]()&*^!@\"\"\"\"'`\\/#"
+        }
+      },
+      {
+        "type": "create",
+        "name": "Create Database with builtin option",
+        "endpoint": "NODE-database.obj",
+        "sql_endpoint": "NODE-database.sql_id",
+        "msql_endpoint": "NODE-database.msql",
+        "REPLACE_LOCALE": true,
+        "data": {
+          "name": "test_database_builtin_$%{}[]()&*^!@\"\"\"\"'`\\/#",
+          "description": "This is a test comment",
+          "is_template": false,
+          "template": "template0",
+          "encoding": "UTF8",
+          "schema_res": [],
+          "datlocaleprovider": "builtin",
+          "datbuiltinlocale": "C.UTF-8",
+          "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_builtin.sql",
+        "expected_msql_file": "create_database_builtin_msql.sql"
+      },
+      {
+        "type": "delete",
+        "name": "Drop Database",
+        "endpoint": "NODE-database.delete_id",
+        "data": {
+          "name": "test_database_builtin_$%{}[]()&*^!@\"\"\"\"'`\\/#"
+        }
+      }
+    ]
+  }
+  
\ No newline at end of file
