Skip to content

Commit 1eb7c9d

Browse files
authored
Added support for builtin locale provider while creating Collation. pgadmin-org#8931
1 parent a4c5e56 commit 1eb7c9d

22 files changed

Lines changed: 264 additions & 23 deletions

docs/en_US/collation_dialog.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ settings:
4040
as the existing one, but will be an independent object. If you choose to copy
4141
an existing collation, you cannot modify the collation properties displayed on
4242
this tab.
43+
* Use the drop-down listbox next to *Provider* to select a locale services associated
44+
with the collation. Possible values are: icu, libc and builtin.
45+
**Note:** The builtin option is available from v17 onwards.
4346
* Use the *Locale* field to specify a locale; a locale specifies language and
4447
language formatting characteristics. If you specify this, you cannot specify
4548
either of the following parameters. To view a list of locales supported by
@@ -50,8 +53,6 @@ settings:
5053
* Use the *LC_CTYPE* field to specify a locale with specified character
5154
classification. The locale must be applicable to the current database encoding.
5255
(See CREATE DATABASE for details.)
53-
* Use the drop-down listbox next to *Locale Provider* to select a locale services associated
54-
with the collation. Possible values are: icu, libc. libc is the default.
5556
* Move the switch next to *Deterministic* to *YES* to specify whether the collation should use
5657
deterministic comparisons. By default, this option is set to true. In a
5758
deterministic comparison, strings that are not byte-wise equal are considered
49 KB
Loading

docs/en_US/release_notes_9_7.rst

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

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ define('pgadmin.node.collation', [
7979
{
8080
owner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,
8181
schema: ('schema' in treeNodeInfo)? treeNodeInfo.schema.label : ''
82-
}
82+
},
83+
treeNodeInfo
8384
);
8485
}
8586
});

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import gettext from 'sources/gettext';
1212
import { isEmptyString } from 'sources/validators';
1313

1414
export default class CollationSchema extends BaseUISchema {
15-
constructor(fieldOptions = {},initValues={}) {
15+
constructor(fieldOptions = {}, initValues={}, nodeInfo={}) {
1616
super({
1717
name: undefined,
1818
oid: undefined,
@@ -30,6 +30,7 @@ export default class CollationSchema extends BaseUISchema {
3030
this.schemaList = fieldOptions.schemaList;
3131
this.ownerList = fieldOptions.rolesList;
3232
this.collationsList = fieldOptions.collationsList;
33+
this.nodeInfo = nodeInfo;
3334
}
3435

3536
get idAttribute() {
@@ -86,16 +87,24 @@ export default class CollationSchema extends BaseUISchema {
8687
deps: ['locale', 'lc_collate', 'lc_type'],
8788
},
8889
{
89-
id: 'provider', label: gettext('Locale Provider'),
90+
id: 'provider', label: gettext('Provider'),
9091
editable: false, type: 'select',mode: ['create'], group: gettext('Definition'),
9192
readonly: function (state) { return !obj.isNew(state); },
92-
options: [{
93-
label: gettext('icu'),
94-
value: 'icu',
95-
}, {
96-
label: gettext('libc'),
97-
value: 'libc',
98-
}],
93+
options: function() {
94+
let options = [{
95+
label: gettext('icu'),
96+
value: 'icu',
97+
}, {
98+
label: gettext('libc'),
99+
value: 'libc',
100+
}];
101+
if(obj.getServerVersion() >= 170000) {
102+
options.push({
103+
label: gettext('builtin'), value: 'builtin',
104+
});
105+
}
106+
return Promise.resolve(options);
107+
},
99108
min_version: 110000,
100109
deps: ['copy_collation'],
101110
depChange: (state)=>{
@@ -110,7 +119,7 @@ export default class CollationSchema extends BaseUISchema {
110119
}
111120
},
112121
{
113-
id: 'provider', label: gettext('Locale Provider'),
122+
id: 'provider', label: gettext('Provider'),
114123
type: 'text',mode: ['properties', 'edit'], group: gettext('Definition'),
115124
readonly: true,
116125
min_version: 110000,

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/12_plus/properties.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
22
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collisdeterministic AS is_deterministic, c.collversion AS version,
3-
c.collprovider AS provider, des.description, n.nspname AS schema
4-
3+
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
4+
des.description, n.nspname AS schema
55
FROM pg_catalog.pg_collation c
66
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
77
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/15_plus/properties.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
22
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
3-
c.collprovider AS provider,
3+
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
44
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
55
FROM pg_catalog.pg_collation c
66
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/16_plus/properties.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
22
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
3-
c.collprovider AS provider, c.collicurules AS rules,
3+
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider, c.collicurules AS rules,
44
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
55
FROM pg_catalog.pg_collation c
66
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/17_plus/properties.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colllocale) AS lc_collate,
22
COALESCE(c.collctype, c.colllocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
3-
c.collprovider AS provider, c.collicurules AS rules,
3+
CASE WHEN c.collprovider = 'i' THEN 'icu' WHEN c.collprovider = 'b' THEN 'builtin'
4+
ELSE 'libc' END provider, c.collicurules AS rules,
45
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
56
FROM pg_catalog.pg_collation c
67
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace

web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/pg/16_plus/alter_collation.sql renamed to web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/pg/13_plus/alter_collation.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a";
44

55
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
6-
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'c', DETERMINISTIC = true);
6+
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
77

88
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
99
OWNER TO <OWNER>;

0 commit comments

Comments
 (0)