mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Add Reverse Engineered and Modified SQL tests for Indexes. Fixes #4621
2) Fix modified SQL for Index when reset the value of Fill factor and Clustered?. Fixes #4702 3) Fix reversed engineered SQL for btree Index when provided sort order and NULLs. Fixes #4703
This commit is contained in:
parent
9eff2e9926
commit
8e4e8b3e5a
@ -23,6 +23,7 @@ Housekeeping
|
|||||||
| `Issue #4617 <https://redmine.postgresql.org/issues/4617>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Servers.
|
| `Issue #4617 <https://redmine.postgresql.org/issues/4617>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Servers.
|
||||||
| `Issue #4618 <https://redmine.postgresql.org/issues/4618>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Tables.
|
| `Issue #4618 <https://redmine.postgresql.org/issues/4618>`_ - Add Reverse Engineered and Modified SQL tests for Foreign Tables.
|
||||||
| `Issue #4619 <https://redmine.postgresql.org/issues/4619>`_ - Add Reverse Engineered and Modified SQL tests for FTS Templates.
|
| `Issue #4619 <https://redmine.postgresql.org/issues/4619>`_ - Add Reverse Engineered and Modified SQL tests for FTS Templates.
|
||||||
|
| `Issue #4621 <https://redmine.postgresql.org/issues/4621>`_ - Add Reverse Engineered and Modified SQL tests for Indexes.
|
||||||
| `Issue #4627 <https://redmine.postgresql.org/issues/4627>`_ - Add Reverse Engineered and Modified SQL tests for User Mappings.
|
| `Issue #4627 <https://redmine.postgresql.org/issues/4627>`_ - Add Reverse Engineered and Modified SQL tests for User Mappings.
|
||||||
| `Issue #4690 <https://redmine.postgresql.org/issues/4690>`_ - Add Modified SQL tests for Resource Group.
|
| `Issue #4690 <https://redmine.postgresql.org/issues/4690>`_ - Add Modified SQL tests for Resource Group.
|
||||||
|
|
||||||
@ -47,4 +48,6 @@ Bug fixes
|
|||||||
| `Issue #4657 <https://redmine.postgresql.org/issues/4657>`_ - Fix PGADMIN_SERVER_JSON_FILE environment variable support in the container.
|
| `Issue #4657 <https://redmine.postgresql.org/issues/4657>`_ - Fix PGADMIN_SERVER_JSON_FILE environment variable support in the container.
|
||||||
| `Issue #4663 <https://redmine.postgresql.org/issues/4663>`_ - Fix exception in query history for python 2.7.
|
| `Issue #4663 <https://redmine.postgresql.org/issues/4663>`_ - Fix exception in query history for python 2.7.
|
||||||
| `Issue #4674 <https://redmine.postgresql.org/issues/4674>`_ - Fix query tool launch error if user name contain html characters.
|
| `Issue #4674 <https://redmine.postgresql.org/issues/4674>`_ - Fix query tool launch error if user name contain html characters.
|
||||||
| `Issue #4681 <https://redmine.postgresql.org/issues/4681>`_ - Increase cache control max age for static files to improve performance over longer run.
|
| `Issue #4681 <https://redmine.postgresql.org/issues/4681>`_ - Increase cache control max age for static files to improve performance over longer run.
|
||||||
|
| `Issue #4702 <https://redmine.postgresql.org/issues/4702>`_ - Fix modified SQL for Index when reset the value of Fill factor and Clustered?.
|
||||||
|
| `Issue #4703 <https://redmine.postgresql.org/issues/4703>`_ - Fix reversed engineered SQL for btree Index when provided sort order and NULLs.
|
@ -505,8 +505,17 @@ class IndexesView(PGChildNodeView):
|
|||||||
'collspcname': row['collnspname'],
|
'collspcname': row['collnspname'],
|
||||||
'op_class': row['opcname'],
|
'op_class': row['opcname'],
|
||||||
}
|
}
|
||||||
if row['options'][0] == 'DESC':
|
|
||||||
cols_data['sort_order'] = True
|
# ASC/DESC and NULLS works only with btree indexes
|
||||||
|
if 'amname' in data and data['amname'] == 'btree':
|
||||||
|
cols_data['sort_order'] = False
|
||||||
|
if row['options'][0] == 'DESC':
|
||||||
|
cols_data['sort_order'] = True
|
||||||
|
|
||||||
|
cols_data['nulls'] = False
|
||||||
|
if row['options'][1].split(" ")[1] == 'FIRST':
|
||||||
|
cols_data['nulls'] = True
|
||||||
|
|
||||||
columns.append(cols_data)
|
columns.append(cols_data)
|
||||||
|
|
||||||
# We need same data as string to display in properties window
|
# We need same data as string to display in properties window
|
||||||
@ -516,8 +525,14 @@ class IndexesView(PGChildNodeView):
|
|||||||
cols_str += ' COLLATE ' + row['collnspname']
|
cols_str += ' COLLATE ' + row['collnspname']
|
||||||
if row['opcname']:
|
if row['opcname']:
|
||||||
cols_str += ' ' + row['opcname']
|
cols_str += ' ' + row['opcname']
|
||||||
if row['options'][0] == 'DESC':
|
|
||||||
cols_str += ' DESC'
|
# ASC/DESC and NULLS works only with btree indexes
|
||||||
|
if 'amname' in data and data['amname'] == 'btree':
|
||||||
|
# Append sort order
|
||||||
|
cols_str += ' ' + row['options'][0]
|
||||||
|
# Append nulls value
|
||||||
|
cols_str += ' ' + row['options'][1]
|
||||||
|
|
||||||
cols.append(cols_str)
|
cols.append(cols_str)
|
||||||
|
|
||||||
# Push as collection
|
# Push as collection
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
-- Index: Idx1_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx1_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING btree
|
||||||
|
(id DESC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS FIRST)
|
||||||
|
WITH (FILLFACTOR=10)
|
||||||
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
|
ALTER TABLE public.test_table_for_indexes
|
||||||
|
CLUSTER ON "Idx1_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,11 @@
|
|||||||
|
ALTER INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
RENAME TO "Idx1_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
ALTER INDEX public."Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
SET (FILLFACTOR=10);
|
||||||
|
|
||||||
|
ALTER TABLE public.test_table_for_indexes
|
||||||
|
CLUSTER ON "Idx1_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,11 @@
|
|||||||
|
-- Index: Idx1_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx1_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING btree
|
||||||
|
(id DESC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS FIRST)
|
||||||
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,5 @@
|
|||||||
|
ALTER INDEX public."Idx1_$%{}[]()&*^!@""'`\/#"
|
||||||
|
RESET (FILLFACTOR);
|
||||||
|
|
||||||
|
ALTER TABLE public.test_table_for_indexes
|
||||||
|
SET WITHOUT CLUSTER;
|
@ -0,0 +1,13 @@
|
|||||||
|
-- Index: Idx_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,13 @@
|
|||||||
|
-- Index: Idx_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,8 @@
|
|||||||
|
-- Index: Idx_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING btree
|
||||||
|
(id DESC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS FIRST)
|
||||||
|
TABLESPACE pg_default;
|
@ -0,0 +1,4 @@
|
|||||||
|
CREATE UNIQUE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING btree
|
||||||
|
(id DESC NULLS FIRST, name COLLATE pg_catalog."POSIX" text_pattern_ops DESC NULLS FIRST)
|
||||||
|
TABLESPACE pg_default;
|
@ -0,0 +1,13 @@
|
|||||||
|
-- Index: Idx_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -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)
|
||||||
|
TABLESPACE pg_default
|
||||||
|
WHERE id < 100;
|
||||||
|
|
||||||
|
COMMENT ON INDEX public."Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
IS 'Test Comment';
|
@ -0,0 +1,8 @@
|
|||||||
|
-- Index: Idx_$%{}[]()&*^!@"'`\/#
|
||||||
|
|
||||||
|
-- DROP INDEX public."Idx_$%{}[]()&*^!@""'`\/#";
|
||||||
|
|
||||||
|
CREATE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING hash
|
||||||
|
(id)
|
||||||
|
TABLESPACE pg_default;
|
@ -0,0 +1,4 @@
|
|||||||
|
CREATE INDEX "Idx_$%{}[]()&*^!@""'`\/#"
|
||||||
|
ON public.test_table_for_indexes USING hash
|
||||||
|
(id)
|
||||||
|
TABLESPACE pg_default;
|
@ -0,0 +1,251 @@
|
|||||||
|
{
|
||||||
|
"scenarios": [
|
||||||
|
{
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create Table for indexes",
|
||||||
|
"endpoint": "NODE-table.obj",
|
||||||
|
"sql_endpoint": "NODE-table.sql_id",
|
||||||
|
"data": {
|
||||||
|
"name": "test_table_for_indexes",
|
||||||
|
"columns": [{
|
||||||
|
"name": "id",
|
||||||
|
"cltype": "bigint",
|
||||||
|
"is_primary_key": true
|
||||||
|
}, {
|
||||||
|
"name": "name",
|
||||||
|
"cltype": "text"
|
||||||
|
}],
|
||||||
|
"is_partitioned": false,
|
||||||
|
"spcname": "pg_default",
|
||||||
|
"schema": "public"
|
||||||
|
},
|
||||||
|
"store_object_id": true
|
||||||
|
}, {
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create btree index with ASC and NULLS LAST",
|
||||||
|
"endpoint": "NODE-index.obj",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql",
|
||||||
|
"data": {
|
||||||
|
"name":"Idx_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"spcname":"pg_default",
|
||||||
|
"amname":"btree",
|
||||||
|
"columns":[{
|
||||||
|
"colname":"id",
|
||||||
|
"collspcname":"",
|
||||||
|
"op_class":"",
|
||||||
|
"sort_order":false,
|
||||||
|
"nulls":false,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}, {
|
||||||
|
"colname":"name",
|
||||||
|
"collspcname":"pg_catalog.\"POSIX\"",
|
||||||
|
"op_class":"text_pattern_ops",
|
||||||
|
"sort_order":false,
|
||||||
|
"nulls":false,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}],
|
||||||
|
"description":"Test Comment",
|
||||||
|
"fillfactor":"10",
|
||||||
|
"indisunique":true,
|
||||||
|
"indisclustered":false,
|
||||||
|
"isconcurrent":false,
|
||||||
|
"indconstraint":"id < 100"
|
||||||
|
},
|
||||||
|
"expected_sql_file": "create_btree_asc_null_last.sql",
|
||||||
|
"expected_msql_file": "create_btree_asc_null_last_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop index",
|
||||||
|
"endpoint": "NODE-index.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx_$%{}[]()&*^!@\"'`\\/#"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create btree index with ASC and NULLS FIRST",
|
||||||
|
"endpoint": "NODE-index.obj",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql",
|
||||||
|
"data": {
|
||||||
|
"name":"Idx_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"spcname":"pg_default",
|
||||||
|
"amname":"btree",
|
||||||
|
"columns":[{
|
||||||
|
"colname":"id",
|
||||||
|
"collspcname":"",
|
||||||
|
"op_class":"",
|
||||||
|
"sort_order":false,
|
||||||
|
"nulls":true,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}, {
|
||||||
|
"colname":"name",
|
||||||
|
"collspcname":"pg_catalog.\"POSIX\"",
|
||||||
|
"op_class":"text_pattern_ops",
|
||||||
|
"sort_order":false,
|
||||||
|
"nulls":true,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}],
|
||||||
|
"description":"Test Comment",
|
||||||
|
"fillfactor":"10",
|
||||||
|
"indisunique":true,
|
||||||
|
"indisclustered":false,
|
||||||
|
"isconcurrent":false,
|
||||||
|
"indconstraint":"id < 100"
|
||||||
|
},
|
||||||
|
"expected_sql_file": "create_btree_asc_null_first.sql",
|
||||||
|
"expected_msql_file": "create_btree_asc_null_first_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop index",
|
||||||
|
"endpoint": "NODE-index.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx_$%{}[]()&*^!@\"'`\\/#"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create btree index with DESC and NULLS LAST",
|
||||||
|
"endpoint": "NODE-index.obj",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql",
|
||||||
|
"data": {
|
||||||
|
"name":"Idx_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"spcname":"pg_default",
|
||||||
|
"amname":"btree",
|
||||||
|
"columns":[{
|
||||||
|
"colname":"id",
|
||||||
|
"collspcname":"",
|
||||||
|
"op_class":"",
|
||||||
|
"sort_order":true,
|
||||||
|
"nulls":false,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}, {
|
||||||
|
"colname":"name",
|
||||||
|
"collspcname":"pg_catalog.\"POSIX\"",
|
||||||
|
"op_class":"text_pattern_ops",
|
||||||
|
"sort_order":true,
|
||||||
|
"nulls":false,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}],
|
||||||
|
"description":"Test Comment",
|
||||||
|
"fillfactor":"10",
|
||||||
|
"indisunique":true,
|
||||||
|
"indisclustered":false,
|
||||||
|
"isconcurrent":false,
|
||||||
|
"indconstraint":"id < 100"
|
||||||
|
},
|
||||||
|
"expected_sql_file": "create_btree_desc_null_last.sql",
|
||||||
|
"expected_msql_file": "create_btree_desc_null_last_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop index",
|
||||||
|
"endpoint": "NODE-index.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx_$%{}[]()&*^!@\"'`\\/#"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create btree index with DESC and NULLS FIRST",
|
||||||
|
"endpoint": "NODE-index.obj",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql",
|
||||||
|
"data": {
|
||||||
|
"name":"Idx_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"spcname":"pg_default",
|
||||||
|
"amname":"btree",
|
||||||
|
"columns":[{
|
||||||
|
"colname":"id",
|
||||||
|
"collspcname":"",
|
||||||
|
"op_class":"",
|
||||||
|
"sort_order":true,
|
||||||
|
"nulls":true,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}, {
|
||||||
|
"colname":"name",
|
||||||
|
"collspcname":"pg_catalog.\"POSIX\"",
|
||||||
|
"op_class":"text_pattern_ops",
|
||||||
|
"sort_order":true,
|
||||||
|
"nulls":true,
|
||||||
|
"is_sort_nulls_applicable":true
|
||||||
|
}],
|
||||||
|
"indisunique":true,
|
||||||
|
"indisclustered":false,
|
||||||
|
"isconcurrent":false
|
||||||
|
},
|
||||||
|
"expected_sql_file": "create_btree_desc_null_first.sql",
|
||||||
|
"expected_msql_file": "create_btree_desc_null_first_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "alter",
|
||||||
|
"name": "Alter index name, fill factor, comment and clustered",
|
||||||
|
"endpoint": "NODE-index.obj_id",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx1_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"description":"Test Comment",
|
||||||
|
"fillfactor":"10",
|
||||||
|
"indisclustered":true
|
||||||
|
},
|
||||||
|
"expected_sql_file": "alter_name_fillfactor_comment.sql",
|
||||||
|
"expected_msql_file": "alter_name_fillfactor_comment_msql.sql"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "alter",
|
||||||
|
"name": "Alter reset fill factor and cluster",
|
||||||
|
"endpoint": "NODE-index.obj_id",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql_id",
|
||||||
|
"data": {
|
||||||
|
"fillfactor": "",
|
||||||
|
"indisclustered": false
|
||||||
|
},
|
||||||
|
"expected_sql_file": "alter_reset_fillfactor_cluster.sql",
|
||||||
|
"expected_msql_file": "alter_reset_fillfactor_cluster_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop index",
|
||||||
|
"endpoint": "NODE-index.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx1_$%{}[]()&*^!@\"'`\\/#"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "create",
|
||||||
|
"name": "Create hash index",
|
||||||
|
"endpoint": "NODE-index.obj",
|
||||||
|
"sql_endpoint": "NODE-index.sql_id",
|
||||||
|
"msql_endpoint": "NODE-index.msql",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx_$%{}[]()&*^!@\"'`\\/#",
|
||||||
|
"spcname": "pg_default",
|
||||||
|
"amname": "hash",
|
||||||
|
"columns": [{
|
||||||
|
"colname": "id",
|
||||||
|
"collspcname": "",
|
||||||
|
"op_class": "",
|
||||||
|
"sort_order": false,
|
||||||
|
"nulls": false,
|
||||||
|
"is_sort_nulls_applicable": false
|
||||||
|
}],
|
||||||
|
"indisunique": false,
|
||||||
|
"indisclustered": false,
|
||||||
|
"isconcurrent": false
|
||||||
|
},
|
||||||
|
"expected_sql_file": "create_hash_index.sql",
|
||||||
|
"expected_msql_file": "create_hash_index_msql.sql"
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop hash index",
|
||||||
|
"endpoint": "NODE-index.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "Idx_$%{}[]()&*^!@\"'`\\/#"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "delete",
|
||||||
|
"name": "Drop Table",
|
||||||
|
"endpoint": "NODE-table.delete_id",
|
||||||
|
"data": {
|
||||||
|
"name": "test_table_for_indexes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -2,9 +2,9 @@ SELECT
|
|||||||
i.indexrelid,
|
i.indexrelid,
|
||||||
CASE i.indoption[i.attnum - 1]
|
CASE i.indoption[i.attnum - 1]
|
||||||
WHEN 0 THEN ARRAY['ASC', 'NULLS LAST']
|
WHEN 0 THEN ARRAY['ASC', 'NULLS LAST']
|
||||||
WHEN 1 THEN ARRAY['DESC', 'NULLS FIRST']
|
WHEN 1 THEN ARRAY['DESC', 'NULLS LAST']
|
||||||
WHEN 2 THEN ARRAY['ASC', 'NULLS FIRST']
|
WHEN 2 THEN ARRAY['ASC', 'NULLS FIRST']
|
||||||
WHEN 3 THEN ARRAY['DESC', 'NULLS ']
|
WHEN 3 THEN ARRAY['DESC', 'NULLS FIRST']
|
||||||
ELSE ARRAY['UNKNOWN OPTION' || i.indoption[i.attnum - 1]::text, '']
|
ELSE ARRAY['UNKNOWN OPTION' || i.indoption[i.attnum - 1]::text, '']
|
||||||
END::text[] AS options,
|
END::text[] AS options,
|
||||||
i.attnum,
|
i.attnum,
|
||||||
|
@ -21,5 +21,5 @@ FIRST{% else %}LAST{% endif %}{% endif %}{% endfor %})
|
|||||||
WITH (FILLFACTOR={{data.fillfactor}})
|
WITH (FILLFACTOR={{data.fillfactor}})
|
||||||
{% endif %}{% if data.spcname %}
|
{% endif %}{% if data.spcname %}
|
||||||
TABLESPACE {{conn|qtIdent(data.spcname)}}{% endif %}{% if data.indconstraint %}
|
TABLESPACE {{conn|qtIdent(data.spcname)}}{% endif %}{% if data.indconstraint %}
|
||||||
WHERE {{data.indconstraint}}
|
|
||||||
{% endif %};
|
WHERE {{data.indconstraint}}{% endif %};
|
||||||
|
@ -2,9 +2,9 @@ SELECT
|
|||||||
i.indexrelid,
|
i.indexrelid,
|
||||||
CASE i.indoption[i.attnum - 1]
|
CASE i.indoption[i.attnum - 1]
|
||||||
WHEN 0 THEN ARRAY['ASC', 'NULLS LAST']
|
WHEN 0 THEN ARRAY['ASC', 'NULLS LAST']
|
||||||
WHEN 1 THEN ARRAY['DESC', 'NULLS FIRST']
|
WHEN 1 THEN ARRAY['DESC', 'NULLS LAST']
|
||||||
WHEN 2 THEN ARRAY['ASC', 'NULLS FIRST']
|
WHEN 2 THEN ARRAY['ASC', 'NULLS FIRST']
|
||||||
WHEN 3 THEN ARRAY['DESC', 'NULLS ']
|
WHEN 3 THEN ARRAY['DESC', 'NULLS FIRST']
|
||||||
ELSE ARRAY['UNKNOWN OPTION' || i.indoption[i.attnum - 1]::text, '']
|
ELSE ARRAY['UNKNOWN OPTION' || i.indoption[i.attnum - 1]::text, '']
|
||||||
END::text[] AS options,
|
END::text[] AS options,
|
||||||
i.attnum,
|
i.attnum,
|
||||||
|
@ -15,5 +15,5 @@ FIRST{% else %}LAST{% endif %}{% endif %}{% endfor %})
|
|||||||
WITH (FILLFACTOR={{data.fillfactor}})
|
WITH (FILLFACTOR={{data.fillfactor}})
|
||||||
{% endif %}{% if data.spcname %}
|
{% endif %}{% if data.spcname %}
|
||||||
TABLESPACE {{conn|qtIdent(data.spcname)}}{% endif %}{% if data.indconstraint %}
|
TABLESPACE {{conn|qtIdent(data.spcname)}}{% endif %}{% if data.indconstraint %}
|
||||||
WHERE {{data.indconstraint}}
|
|
||||||
{% endif %};
|
WHERE {{data.indconstraint}}{% endif %};
|
||||||
|
@ -2,23 +2,37 @@
|
|||||||
{% if data.name and o_data.name != data.name %}
|
{% if data.name and o_data.name != data.name %}
|
||||||
ALTER INDEX {{conn|qtIdent(data.schema, o_data.name)}}
|
ALTER INDEX {{conn|qtIdent(data.schema, o_data.name)}}
|
||||||
RENAME TO {{conn|qtIdent(data.name)}};
|
RENAME TO {{conn|qtIdent(data.name)}};
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{## Changes fillfactor ##}
|
{## Changes fillfactor ##}
|
||||||
{% if data.fillfactor and o_data.fillfactor != data.fillfactor %}
|
{% if data.fillfactor and o_data.fillfactor != data.fillfactor %}
|
||||||
ALTER INDEX {{conn|qtIdent(data.schema, data.name)}}
|
ALTER INDEX {{conn|qtIdent(data.schema, data.name)}}
|
||||||
SET (FILLFACTOR={{data.fillfactor}});
|
SET (FILLFACTOR={{data.fillfactor}});
|
||||||
|
|
||||||
|
{% elif data.fillfactor == '' and o_data.fillfactor|default('', 'true') != data.fillfactor %}
|
||||||
|
ALTER INDEX {{conn|qtIdent(data.schema, data.name)}}
|
||||||
|
RESET (FILLFACTOR);
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{## Changes tablespace ##}
|
{## Changes tablespace ##}
|
||||||
{% if data.spcname and o_data.spcname != data.spcname %}
|
{% if data.spcname and o_data.spcname != data.spcname %}
|
||||||
ALTER INDEX {{conn|qtIdent(data.schema, data.name)}}
|
ALTER INDEX {{conn|qtIdent(data.schema, data.name)}}
|
||||||
SET TABLESPACE {{conn|qtIdent(data.spcname)}};
|
SET TABLESPACE {{conn|qtIdent(data.spcname)}};
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{## Alter index to use cluster type ##}
|
{## Alter index to use cluster type ##}
|
||||||
{% if data.indisclustered is defined and o_data.indisclustered != data.indisclustered %}
|
{% if data.indisclustered is defined and o_data.indisclustered != data.indisclustered %}
|
||||||
|
{% if data.indisclustered %}
|
||||||
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||||
CLUSTER ON {{conn|qtIdent(data.name)}};
|
CLUSTER ON {{conn|qtIdent(data.name)}};
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||||
|
SET WITHOUT CLUSTER;
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{## Changes description ##}
|
{## Changes description ##}
|
||||||
{% if data.description is defined and o_data.description != data.description %}
|
{% if data.description is defined and o_data.description != data.description %}
|
||||||
COMMENT ON INDEX {{conn|qtIdent(data.schema, data.name)}}
|
COMMENT ON INDEX {{conn|qtIdent(data.schema, data.name)}}
|
||||||
IS {{data.description|qtLiteral}};{% endif %}
|
IS {{data.description|qtLiteral}};{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user