Skip to content

Commit ab48397

Browse files
Add support for 'ONLY' predicate in Index creation dialog. #6386
1 parent 965a27d commit ab48397

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ export default class IndexSchema extends BaseUISchema {
364364
amname: undefined,
365365
fastupdate: false,
366366
autosummarize: false,
367+
indisonly: false,
367368
columns: [],
368369
...initValues
369370
});
@@ -522,7 +523,20 @@ export default class IndexSchema extends BaseUISchema {
522523
mode: ['create', 'edit', 'properties']
523524
},
524525
{
525-
type: 'nested-fieldset', label: gettext('With'), group: gettext('Definition'),
526+
id: 'indisonly', label: gettext('Only Table?'),
527+
type: 'switch', group: gettext('Definition'),
528+
disabled: () => {
529+
// ONLY is only applicable to partitioned or inherited tables
530+
// Disable if not a partitioned table or if viewing in schema (view mode)
531+
return inSchema(indexSchemaObj.node_info) ||
532+
!indexSchemaObj.node_info?.table?.is_partitioned;
533+
},
534+
mode: ['create'],
535+
min_version: 110000,
536+
helpMessage: gettext('When enabled, the index will only be created on this table, not on its partitions.'),
537+
},
538+
{
539+
type: 'nested-fieldset', label: gettext('With'), group: gettext('With'),
526540
schema: this.withSchema,
527541
},{
528542
id: 'indisunique', label: gettext('Unique?'), cell: 'string',

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/11_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/13_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/15_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE{% if data.indisunique %} UNIQUE{% endif %} INDEX{% if add_not_exists_clause %} IF NOT EXISTS{% endif %}{% if data.isconcurrent %} CONCURRENTLY{% endif %}{% if data.name %} {{conn|qtIdent(data.name)}}{% endif %}
22

3-
ON {{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
3+
ON {% if data.indisonly %}ONLY {% endif %}{{conn|qtIdent(data.schema, data.table)}} {% if data.amname %}USING {{conn|qtIdent(data.amname)}}{% endif %}
44

55
{% if mode == 'create' %}
66
({% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{% if c.is_exp %}({{c.colname}}){% else %}{{conn|qtIdent(c.colname)}}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.op_class %}

0 commit comments

Comments
 (0)