Added support for builtin locale provider while creating Collation. #8931

pull/9038/head
Akshay Joshi 2025-08-11 11:42:14 +05:30 committed by GitHub
parent a4c5e5683c
commit 1eb7c9d3e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 264 additions and 23 deletions

View File

@ -40,6 +40,9 @@ settings:
as the existing one, but will be an independent object. If you choose to copy
an existing collation, you cannot modify the collation properties displayed on
this tab.
* Use the drop-down listbox next to *Provider* to select a locale services associated
with the collation. Possible values are: icu, libc and builtin.
**Note:** The builtin option is available from v17 onwards.
* Use the *Locale* field to specify a locale; a locale specifies language and
language formatting characteristics. If you specify this, you cannot specify
either of the following parameters. To view a list of locales supported by
@ -50,8 +53,6 @@ settings:
* Use the *LC_CTYPE* field to specify a locale with specified character
classification. The locale must be applicable to the current database encoding.
(See CREATE DATABASE for details.)
* Use the drop-down listbox next to *Locale Provider* to select a locale services associated
with the collation. Possible values are: icu, libc. libc is the default.
* Move the switch next to *Deterministic* to *YES* to specify whether the collation should use
deterministic comparisons. By default, this option is set to true. In a
deterministic comparison, strings that are not byte-wise equal are considered

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -23,6 +23,7 @@ New features
| `Issue #5766 <https://github.com/pgadmin-org/pgadmin4/issues/5766>`_ - Add support for automatic updates in the pgAdmin 4 Desktop application on macOS.
| `Issue #6456 <https://github.com/pgadmin-org/pgadmin4/issues/6456>`_ - Added GENERIC_PLAN, MEMORY, SERIALIZE option to EXPLAIN/EXPLAIN ANALYZE command.
| `Issue #8917 <https://github.com/pgadmin-org/pgadmin4/issues/8917>`_ - Add support for server tag-based filtering in the Object Explorer.
| `Issue #8931 <https://github.com/pgadmin-org/pgadmin4/issues/8931>`_ - Added support for builtin locale provider while creating Collation.
| `Issue #8935 <https://github.com/pgadmin-org/pgadmin4/issues/8935>`_ - Added all new connection string parameters introduced in PostgreSQL 16 and later.
Housekeeping

View File

@ -79,7 +79,8 @@ define('pgadmin.node.collation', [
{
owner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,
schema: ('schema' in treeNodeInfo)? treeNodeInfo.schema.label : ''
}
},
treeNodeInfo
);
}
});

View File

@ -12,7 +12,7 @@ import gettext from 'sources/gettext';
import { isEmptyString } from 'sources/validators';
export default class CollationSchema extends BaseUISchema {
constructor(fieldOptions = {},initValues={}) {
constructor(fieldOptions = {}, initValues={}, nodeInfo={}) {
super({
name: undefined,
oid: undefined,
@ -30,6 +30,7 @@ export default class CollationSchema extends BaseUISchema {
this.schemaList = fieldOptions.schemaList;
this.ownerList = fieldOptions.rolesList;
this.collationsList = fieldOptions.collationsList;
this.nodeInfo = nodeInfo;
}
get idAttribute() {
@ -86,16 +87,24 @@ export default class CollationSchema extends BaseUISchema {
deps: ['locale', 'lc_collate', 'lc_type'],
},
{
id: 'provider', label: gettext('Locale Provider'),
id: 'provider', label: gettext('Provider'),
editable: false, type: 'select',mode: ['create'], group: gettext('Definition'),
readonly: function (state) { return !obj.isNew(state); },
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: 110000,
deps: ['copy_collation'],
depChange: (state)=>{
@ -110,7 +119,7 @@ export default class CollationSchema extends BaseUISchema {
}
},
{
id: 'provider', label: gettext('Locale Provider'),
id: 'provider', label: gettext('Provider'),
type: 'text',mode: ['properties', 'edit'], group: gettext('Definition'),
readonly: true,
min_version: 110000,

View File

@ -1,7 +1,7 @@
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collisdeterministic AS is_deterministic, c.collversion AS version,
c.collprovider AS provider, des.description, n.nspname AS schema
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
des.description, n.nspname AS schema
FROM pg_catalog.pg_collation c
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)

View File

@ -1,6 +1,6 @@
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
c.collprovider AS provider,
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
FROM pg_catalog.pg_collation c
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

View File

@ -1,6 +1,6 @@
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
c.collprovider AS provider, c.collicurules AS rules,
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider, c.collicurules AS rules,
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
FROM pg_catalog.pg_collation c
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

View File

@ -1,6 +1,7 @@
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colllocale) AS lc_collate,
COALESCE(c.collctype, c.colllocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
c.collprovider AS provider, c.collicurules AS rules,
CASE WHEN c.collprovider = 'i' THEN 'icu' WHEN c.collprovider = 'b' THEN 'builtin'
ELSE 'libc' END provider, c.collicurules AS rules,
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
FROM pg_catalog.pg_collation c
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

View File

@ -3,7 +3,7 @@
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'c', DETERMINISTIC = true);
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
OWNER TO <OWNER>;

View File

@ -3,7 +3,7 @@
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'c', DETERMINISTIC = true);
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
OWNER TO <OWNER>;

View File

@ -3,7 +3,7 @@
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'i', DETERMINISTIC = true, VERSION = '1');
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'icu', DETERMINISTIC = true, VERSION = '1');
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
OWNER TO <OWNER>;

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true, VERSION = '1');
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
IS 'libc';

View File

@ -33,12 +33,12 @@
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a"
}
},
{
"type": "create",
"name": "Create Collation with extra parameters",
"name": "Create Collation with icu provider",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
@ -53,6 +53,40 @@
},
"store_object_id": true,
"expected_sql_file": "create_collation_with_extra_params.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
}
},
{
"type": "create",
"name": "Create Collation with libc provider",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
"schema": "testschema",
"owner": "postgres",
"description": "libc",
"locale": "C",
"provider": "libc",
"is_deterministic": true,
"version": "1"
},
"store_object_id": true,
"expected_sql_file": "create_collation_with_libc.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
}
}
]
}

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#a;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
IS 'Description for alter';

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
IS 'Description';

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'builtin', DETERMINISTIC = true, VERSION = '1');
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
IS 'builtin';

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'icu', DETERMINISTIC = true, VERSION = '1');
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
IS 'Description for extra params';

View File

@ -0,0 +1,12 @@
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
OWNER TO <OWNER>;
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
IS 'libc';

View File

@ -0,0 +1,5 @@
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
IS 'Description for alter';
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
RENAME TO "Cl1_$%{}[]()&*^!@""'`\/#a";

View File

@ -0,0 +1,117 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Collation",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#",
"schema": "testschema",
"copy_collation": "pg_catalog.\"C\"",
"description": "Description"
},
"store_object_id": true,
"expected_sql_file": "create_collation.sql"
},
{
"type": "alter",
"name": "Alter Collation",
"endpoint": "NODE-collation.obj_id",
"sql_endpoint": "NODE-collation.sql_id",
"msql_endpoint": "NODE-collation.msql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a",
"schema": "testschema",
"description": "Description for alter"
},
"expected_sql_file": "alter_collation.sql",
"expected_msql_file": "msql_collation.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a"
}
},
{
"type": "create",
"name": "Create Collation with icu provider",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
"schema": "testschema",
"owner": "postgres",
"description": "Description for extra params",
"locale": "locale",
"provider": "icu",
"is_deterministic": true,
"version": "1"
},
"store_object_id": true,
"expected_sql_file": "create_collation_with_extra_params.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
}
},
{
"type": "create",
"name": "Create Collation with libc provider",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
"schema": "testschema",
"owner": "postgres",
"description": "libc",
"locale": "C",
"provider": "libc",
"is_deterministic": true
},
"store_object_id": true,
"expected_sql_file": "create_collation_with_libc.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
}
},
{
"type": "create",
"name": "Create Collation with builtin provider",
"endpoint": "NODE-collation.obj",
"sql_endpoint": "NODE-collation.sql_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
"schema": "testschema",
"owner": "postgres",
"description": "builtin",
"locale": "C",
"provider": "builtin",
"is_deterministic": true,
"version": "1"
},
"store_object_id": true,
"expected_sql_file": "create_collation_with_builtin.sql"
},
{
"type": "delete",
"name": "Drop Collation",
"endpoint": "NODE-collation.delete_id",
"data": {
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
}
}
]
}