Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added all supported index storage parameters while creating an index. #6374 #6534

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions docs/en_US/index_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,22 @@ Use the fields in the *Definition* tab to define the index:
* Use the *Fill Factor* field to specify a fill factor for the index. The fill
factor specifies how full the selected method will try to fill each index
page.
* Move the *Unique?* switch to the *Yes* position to check for duplicate values
in the table when the index is created and when data is added. The default is
*No*.
* Move the *NULLs not distinct?* switch to the *Yes* position to treat null values as not distinct. The default is
*No*. This option is available only on PostgreSQL 15 and above.
* Use the *Gin pending list limit* field to specify the maximum size of a GIN index's pending list, which is used
when fastupdate is enabled. This value is specified in kilobytes.
* Use the *Pages per range* field to specify the number of table blocks that make up one block range
for each entry of a BRIN index.
* Select *Buffering* to specify whether the buffering build technique is used to build the index. The default is
*Auto*
* Move the switch next to *Deduplicate items?* towards the *right position* to control usage of the B-tree
deduplication technique. The default is *Yes*. This option is available only on PostgreSQL 13 and above.
* Move the switch next to *Fast update?* towards the *right position* to control usage of the fast update technique.
The default is *Yes*.
* Move the switch next to *Autosummarize* towards the *right position* to define whether a summarization run is
queued for the previous page range whenever an insertion is detected on the next one. The default is *No*
* Move the switch next to *Unique?* towards the *right position* to check for duplicate values
in the table when the index is created and when data is added. The default is *No*.
* Move the switch next to *NULLs not distinct?* towards the *right position* to treat null values as not distinct.
The default is*No*. This option is available only on PostgreSQL 15 and above.
* Move the *Clustered?* switch to the *Yes* position to instruct the server to
cluster the table.
* Move the *Concurrent build?* switch to the *Yes* position to build the index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ def create(self, gid, sid, did, scid, tid):
# Adding parent into data dict, will be using it while creating sql
data['schema'] = self.schema
data['table'] = self.table
data["storage_parameters"] = {}

storage_params = index_utils.get_storage_params(data['amname'])

for param in storage_params:
if param in data and data[param] != '':
data["storage_parameters"].update({param: data[param]})

if len(data['table']) == 0:
return gone(gettext(self.not_found_error_msg('Table')))

Expand Down Expand Up @@ -819,6 +827,15 @@ def msql(self, gid, sid, did, scid, tid, idx=None):
data['schema'] = self.schema
data['table'] = self.table

if data.get('amname', None):
data["storage_parameters"] = {}

storage_params = index_utils.get_storage_params(data['amname'])

for param in storage_params:
if param in data and data[param] != '':
data["storage_parameters"].update({param: data[param]})

try:
sql, name = index_utils.get_sql(
self.conn, data=data, did=did, tid=tid, idx=idx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ define('pgadmin.node.index', [
node_info: treeNodeInfo
},
{
amname: 'btree'
amname: 'btree',
deduplicate_items: treeNodeInfo.server.version >= 130000 ? true : undefined,
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,109 @@ export class ColumnSchema extends BaseUISchema {
}
}

export class WithSchema extends BaseUISchema {
constructor(node_info) {
super({});
this.node_info = node_info;
}

get baseFields() {
let withSchemaObj = this;
return [
{
id: 'fillfactor', label: gettext('Fill factor'), deps: ['amname'], cell: 'string',
type: 'int', disabled: (state) => {
return !_.includes(['btree', 'hash', 'gist', 'spgist'], state.amname) || inSchema(withSchemaObj.node_info);
},
mode: ['create', 'edit', 'properties'],
min: 10, max:100, group: gettext('Definition'),
depChange: state => {
if (!_.includes(['btree', 'hash', 'gist', 'spgist'], state.amname)) {
return {fillfactor: ''};
}
}
},{
id: 'gin_pending_list_limit', label: gettext('Gin pending list limit'), cell: 'string',
type: 'int', deps: ['amname'], disabled: state => state.amname !== 'gin' || inSchema(withSchemaObj.node_info),
mode: ['create', 'edit', 'properties'],
group: gettext('Definition'), min: 64, max: 2147483647,
depChange: state => {
if (state.amname !== 'gin') {
return {gin_pending_list_limit: ''};
}
}, helpMessage: gettext('This value is specified in kilobytes.')
},{
id: 'pages_per_range', label: gettext('Pages per range'), cell: 'string',
type: 'int', deps: ['amname'], disabled: state => state.amname !== 'brin' || inSchema(withSchemaObj.node_info),
mode: ['create', 'edit', 'properties'],
group: gettext('Definition'), depChange: state => {
if (state.amname !== 'brin') {
return {pages_per_range: ''};
}
}, helpMessage: gettext('Number of table blocks that make up one block range for each entry of a BRIN index.')
},{
id: 'buffering', label: gettext('Buffering'), cell: 'string', group: gettext('Definition'),
type: 'select', deps: ['amname'], mode: ['create', 'edit', 'properties'], options: [
{
label: gettext('Auto'),
value: 'auto',
},
{
label: gettext('On'),
value: 'on',
},
{
label: gettext('Off'),
value: 'off',
}], disabled: state => state.amname !== 'gist' || inSchema(withSchemaObj.node_info),
depChange: (state, source) => {
if (state.amname !== 'gist') {
return {buffering: ''};
} else if (state.amname === 'gist' && source[0] !== 'buffering') {
return {buffering: 'auto'};
}
}
},{
id: 'deduplicate_items', label: gettext('Deduplicate items?'), cell: 'string',
type: 'switch', deps:['amname'], mode: ['create', 'edit', 'properties'], disabled: (state) => {
return state.amname !== 'btree' || inSchema(withSchemaObj.node_info);
},
depChange: (state, source) => {
if (state.amname !== 'btree') {
return {deduplicate_items:undefined};
} else if (state.amname === 'btree' && source[0] !== 'deduplicate_items') {
return {deduplicate_items: true};
}
}, min_version: 130000,
group: gettext('Definition'),
},{
id: 'fastupdate', label: gettext('Fast update?'), cell: 'string',
type: 'switch', deps:['amname'], mode: ['create', 'edit', 'properties'], disabled: (state) => {
return state.amname !== 'gin' || inSchema(withSchemaObj.node_info);
},
depChange: (state, source) => {
if (state.amname !== 'gin') {
return {fastupdate:undefined};
} else if (state.amname === 'gin' && source[0] !== 'fastupdate') {
return {fastupdate: true};
}
},
group: gettext('Definition'),
},{
id: 'autosummarize', label: gettext('Autosummarize?'), cell: 'string',
type: 'switch', deps:['amname'], mode: ['create', 'edit', 'properties'], disabled: state => {
return state.amname !== 'brin' || inSchema(withSchemaObj.node_info);
}, group: gettext('Definition'),
depChange: (state) => {
if (state.amname !== 'brin') {
return {autosummarize:undefined};
}
}
}
];
}
}

function inSchema(node_info) {
return node_info && 'catalog' in node_info;
}
Expand All @@ -209,6 +312,8 @@ export default class IndexSchema extends BaseUISchema {
tabname: undefined,
spcname: undefined,
amname: undefined,
fastupdate: false,
autosummarize: false,
columns: [],
...initValues
});
Expand All @@ -222,6 +327,7 @@ export default class IndexSchema extends BaseUISchema {
...nodeData.node_info
};
this.getColumnSchema = columnSchema;
this.withSchema = new WithSchema(this.node_info);
}

get idAttribute() {
Expand Down Expand Up @@ -353,10 +459,8 @@ export default class IndexSchema extends BaseUISchema {
},
node:'column',
},{
id: 'fillfactor', label: gettext('Fill factor'), cell: 'string',
type: 'int', disabled: () => inSchema(indexSchemaObj.node_info),
mode: ['create', 'edit', 'properties'],
min: 10, max:100, group: gettext('Definition'),
type: 'nested-fieldset', label: gettext('With'), group: gettext('Definition'),
schema: this.withSchema,
},{
id: 'indisunique', label: gettext('Unique?'), cell: 'string',
type: 'switch', deps:['amname'], disabled: (state) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Index: Idx_$%{}[]()&*^!@"'`\/#

-- DROP INDEX IF EXISTS public."Idx_$%{}[]()&*^!@""'`\/#";

CREATE UNIQUE INDEX IF NOT EXISTS "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id ASC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops ASC NULLS FIRST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE UNIQUE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id ASC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops ASC NULLS FIRST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Index: Idx_$%{}[]()&*^!@"'`\/#

-- DROP INDEX IF EXISTS public."Idx_$%{}[]()&*^!@""'`\/#";

CREATE UNIQUE INDEX IF NOT EXISTS "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id ASC NULLS LAST, name COLLATE pg_catalog."POSIX" text_pattern_ops ASC NULLS LAST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE UNIQUE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id ASC NULLS LAST, name COLLATE pg_catalog."POSIX" text_pattern_ops ASC NULLS LAST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Index: Idx_$%{}[]()&*^!@"'`\/#

-- DROP INDEX IF EXISTS public."Idx_$%{}[]()&*^!@""'`\/#";

CREATE UNIQUE INDEX IF NOT EXISTS "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id DESC NULLS LAST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS LAST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE UNIQUE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
ON public.test_table_for_indexes USING btree
(id DESC NULLS LAST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS LAST)
WITH (fillfactor=10, deduplicate_items=False)
TABLESPACE pg_default
WHERE id < 100;

COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
IS 'Test Comment';
Loading
Loading