diff --git a/docs/en_US/release_notes_4_24.rst b/docs/en_US/release_notes_4_24.rst index 371826e95..3995cbc2c 100644 --- a/docs/en_US/release_notes_4_24.rst +++ b/docs/en_US/release_notes_4_24.rst @@ -31,7 +31,6 @@ Bug fixes | `Issue #5463 `_ - Fixed an issue where CSV download quotes numeric columns. | `Issue #5470 `_ - Fixed backgrid row hover issue where on hover background color is set for edit and delete cell only. | `Issue #5530 `_ - Ensure that the referenced table should be displayed on foreign key constraints. -| `Issue #5569 `_ - Fixed reverse engineered SQL for partitions when storage parameters are specified. | `Issue #5621 `_ - Remove extra brackets from reverse engineering SQL of RLS Policy. | `Issue #5629 `_ - Fixed an issue where the user is able to edit properties when some of the collection nodes are selected. | `Issue #5630 `_ - Fixed an issue where installation of pgadmin4 not working on 32-bit Windows. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index e7bea6faa..ff69e1afc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -621,8 +621,41 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings, return False, gone( gettext("The specified table could not be found.")) - # Update autovacuum properties - self.update_autovacuum_properties(res['rows'][0]) + # Set value based on + # x: No set, t: true, f: false + res['rows'][0]['autovacuum_enabled'] = 'x' \ + if res['rows'][0]['autovacuum_enabled'] is None else \ + {True: 't', False: 'f'}[res['rows'][0]['autovacuum_enabled']] + + res['rows'][0]['toast_autovacuum_enabled'] = 'x' \ + if res['rows'][0]['toast_autovacuum_enabled'] is None else \ + {True: 't', False: 'f'}[res['rows'][0]['toast_autovacuum_enabled']] + + # Enable custom autovaccum only if one of the options is set + # or autovacuum is set + res['rows'][0]['autovacuum_custom'] = any([ + res['rows'][0]['autovacuum_vacuum_threshold'], + res['rows'][0]['autovacuum_vacuum_scale_factor'], + res['rows'][0]['autovacuum_analyze_threshold'], + res['rows'][0]['autovacuum_analyze_scale_factor'], + res['rows'][0]['autovacuum_vacuum_cost_delay'], + res['rows'][0]['autovacuum_vacuum_cost_limit'], + res['rows'][0]['autovacuum_freeze_min_age'], + res['rows'][0]['autovacuum_freeze_max_age'], + res['rows'][0]['autovacuum_freeze_table_age']]) \ + or res['rows'][0]['autovacuum_enabled'] in ('t', 'f') + + res['rows'][0]['toast_autovacuum'] = any([ + res['rows'][0]['toast_autovacuum_vacuum_threshold'], + res['rows'][0]['toast_autovacuum_vacuum_scale_factor'], + res['rows'][0]['toast_autovacuum_analyze_threshold'], + res['rows'][0]['toast_autovacuum_analyze_scale_factor'], + res['rows'][0]['toast_autovacuum_vacuum_cost_delay'], + res['rows'][0]['toast_autovacuum_vacuum_cost_limit'], + res['rows'][0]['toast_autovacuum_freeze_min_age'], + res['rows'][0]['toast_autovacuum_freeze_max_age'], + res['rows'][0]['toast_autovacuum_freeze_table_age']]) \ + or res['rows'][0]['toast_autovacuum_enabled'] in ('t', 'f') # We will check the threshold set by user before executing # the query because that can cause performance issues diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py index af788459d..e6b79494f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py @@ -356,44 +356,20 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings, JSON of selected table node """ - status, res = self._fetch_properties(did, scid, tid, ptid) + SQL = render_template("/".join([self.partition_template_path, + 'properties.sql']), + did=did, scid=scid, tid=tid, + ptid=ptid, datlastsysoid=self.datlastsysoid) + status, res = self.conn.execute_dict(SQL) + if not status: + return internal_server_error(errormsg=res) if len(res['rows']) == 0: return gone(gettext( "The specified partitioned table could not be found.")) return super(PartitionsView, self).properties( - gid, sid, did, scid, ptid, res=res) - - def _fetch_properties(self, did, scid, tid, ptid=None): - - """ - This function is used to fetch the properties of the specified object - :param did: - :param scid: - :param tid: - :return: - """ - try: - SQL = render_template("/".join([self.partition_template_path, - 'properties.sql']), - did=did, scid=scid, tid=tid, - ptid=ptid, datlastsysoid=self.datlastsysoid) - status, res = self.conn.execute_dict(SQL) - if not status: - return internal_server_error(errormsg=res) - - if len(res['rows']) == 0: - return False, gone( - gettext("The specified table could not be found.")) - - # Update autovacuum properties - self.update_autovacuum_properties(res['rows'][0]) - - except Exception as e: - return False, internal_server_error(errormsg=str(e)) - - return True, res + gid, sid, did, scid, ptid, res) @BaseTableView.check_precondition def fetch_objects_to_compare(self, sid, did, scid, tid, ptid=None): @@ -468,7 +444,13 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings, """ main_sql = [] - status, res = self._fetch_properties(did, scid, tid, ptid) + SQL = render_template("/".join([self.partition_template_path, + 'properties.sql']), + did=did, scid=scid, tid=tid, + ptid=ptid, datlastsysoid=self.datlastsysoid) + status, res = self.conn.execute_dict(SQL) + if not status: + return internal_server_error(errormsg=res) if len(res['rows']) == 0: return gone(gettext( @@ -645,7 +627,13 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings, data[k] = v if ptid is not None: - status, res = self._fetch_properties(did, scid, tid, ptid) + SQL = render_template("/".join([self.partition_template_path, + 'properties.sql']), + did=did, scid=scid, tid=tid, + ptid=ptid, datlastsysoid=self.datlastsysoid) + status, res = self.conn.execute_dict(SQL) + if not status: + return internal_server_error(errormsg=res) SQL, name = self.get_sql(did, scid, ptid, data, res) SQL = re.sub('\n{2,}', '\n\n', SQL) @@ -686,10 +674,16 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings, data[k] = v try: - status, res = self._fetch_properties(did, scid, tid, ptid) + SQL = render_template("/".join([self.partition_template_path, + 'properties.sql']), + did=did, scid=scid, tid=tid, + ptid=ptid, datlastsysoid=self.datlastsysoid) + status, res = self.conn.execute_dict(SQL) + if not status: + return internal_server_error(errormsg=res) return super(PartitionsView, self).update( - gid, sid, did, scid, ptid, data=data, res=res, parent_id=tid) + gid, sid, did, scid, ptid, data, res, parent_id=tid) except Exception as e: return internal_server_error(errormsg=str(e)) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index 50d2f0769..a944c5fff 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -995,16 +995,6 @@ function( id: 'vacuum_settings_str', label: gettext('Storage settings'), type: 'multiline', group: gettext('Advanced'), mode: ['properties'], }], - sessChanged: function() { - /* If only custom autovacuum option is enabled then check if the options table is also changed. */ - if(_.size(this.sessAttrs) == 2 && this.sessAttrs['autovacuum_custom'] && this.sessAttrs['toast_autovacuum']) { - return this.get('vacuum_table').sessChanged() || this.get('vacuum_toast').sessChanged(); - } - if(_.size(this.sessAttrs) == 1 && (this.sessAttrs['autovacuum_custom'] || this.sessAttrs['toast_autovacuum'])) { - return this.get('vacuum_table').sessChanged() || this.get('vacuum_toast').sessChanged(); - } - return pgBrowser.DataModel.prototype.sessChanged.apply(this); - }, validate: function(keys) { var msg, name = this.get('name'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition.sql deleted file mode 100644 index ad9c2f44b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Table: public.test_table_$%{}[]()&*^!@""'`\/# - --- DROP TABLE public."test_table_$%{}[]()&*^!@""""'`\/#"; - -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) -WITH ( - OIDS = FALSE -) -TABLESPACE pg_default; - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; - --- Partitions SQL - -CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#" - FOR VALUES FROM ('0') TO ('1000'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition_msql.sql deleted file mode 100644 index 30c1610f5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/alter_table_add_partition_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#" - FOR VALUES FROM (0) TO (1000); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition.sql deleted file mode 100644 index 794355c7b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Table: public.test_table_$%{}[]()&*^!@""'`\/# - --- DROP TABLE public."test_table_$%{}[]()&*^!@""""'`\/#"; - -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) -WITH ( - OIDS = FALSE -) -TABLESPACE pg_default; - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition_msql.sql deleted file mode 100644 index 8aff6d38c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/create_table_with_partition_msql.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) -WITH ( - OIDS = FALSE -); - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/test_partitions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/test_partitions.json deleted file mode 100644 index 4683ecbf9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/10_plus/test_partitions.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "test_table_$%{}[]()&*^!@\"\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "comment_01", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "m_col", - "cltype": "bigint", - "attacl": [], - "is_primary_key": true, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "m_col" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "alter", - "name": "Alert Table - Add Partition", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "partitions": { - "added": [ - { - "is_attach": false, - "partition_name": "test_part_$%{}[]()&*^!@\"\"\"\"'`\\/#", - "values_from": "0", - "values_to": "1000", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_partition.sql", - "expected_msql_file": "alter_table_add_partition_msql.sql", - "store_object_id": true - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition.sql deleted file mode 100644 index 60002ba7f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition.sql +++ /dev/null @@ -1,19 +0,0 @@ --- Table: public.test_table_$%{}[]()&*^!@""'`\/# - --- DROP TABLE public."test_table_$%{}[]()&*^!@""""'`\/#"; - -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) ; - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; - --- Partitions SQL - -CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#" - FOR VALUES FROM ('0') TO ('1000'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition_msql.sql deleted file mode 100644 index 30c1610f5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/alter_table_add_partition_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#" - FOR VALUES FROM (0) TO (1000); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition.sql deleted file mode 100644 index 38b4b02e7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Table: public.test_table_$%{}[]()&*^!@""'`\/# - --- DROP TABLE public."test_table_$%{}[]()&*^!@""""'`\/#"; - -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) ; - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition_msql.sql deleted file mode 100644 index efca50484..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/create_table_with_partition_msql.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" -( - m_col bigint -) PARTITION BY RANGE (m_col) ; - -ALTER TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."test_table_$%{}[]()&*^!@""""'`\/#" - IS 'comment_01'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/test_partitions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/test_partitions.json deleted file mode 100644 index 4683ecbf9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/tests/pg/11_plus/test_partitions.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "test_table_$%{}[]()&*^!@\"\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "comment_01", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "m_col", - "cltype": "bigint", - "attacl": [], - "is_primary_key": true, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "m_col" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "alter", - "name": "Alert Table - Add Partition", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "partitions": { - "added": [ - { - "is_attach": false, - "partition_name": "test_part_$%{}[]()&*^!@\"\"\"\"'`\\/#", - "values_from": "0", - "values_to": "1000", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_partition.sql", - "expected_msql_file": "alter_table_add_partition_msql.sql", - "store_object_id": true - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/gpdb/5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/gpdb/5_plus/properties.sql index adeb48b54..c2cfd974a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/gpdb/5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/gpdb/5_plus/properties.sql @@ -30,7 +30,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, false AS relpersistence, substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS autovacuum_enabled, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, @@ -40,7 +41,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS toast_autovacuum_enabled, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql index 9ebc6b260..365be1d00 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql @@ -21,28 +21,26 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data {{ data.partition_value }}{% if data.is_partitioned is defined and data.is_partitioned %} PARTITION BY {{ data.partition_scheme }}{% endif %} -{% if data.fillfactor or data.autovacuum_custom or data.autovacuum_enabled in ('t', 'f') or data.toast_autovacuum or data.toast_autovacuum_enabled in ('t', 'f') or (data.autovacuum_enabled in ('t', 'f') and data.vacuum_table|length > 0) or (data.toast_autovacuum_enabled in ('t', 'f') and data.vacuum_toast|length > 0) %} -{% set ns = namespace(add_comma=false) %} +{% if data.fillfactor or data.autovacuum_custom or data.autovacuum_enabled or data.toast_autovacuum or data.toast_autovacuum_enabled or (data.autovacuum_enabled and data.vacuum_table|length > 0) or (data.toast_autovacuum_enabled and data.vacuum_toast|length > 0) %} +{% set add_comma = false%} WITH ( -{% if data.fillfactor %}{% set ns.add_comma = true%} - FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, +{% if data.fillfactor %}{% set add_comma = true%} + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_custom %} +{% if add_comma %}, {% endif %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, + autovacuum_enabled = {% if data.autovacuum_enabled %}TRUE{% else %}FALSE{% endif %}{% set add_comma = true%}{% endif %}{% if data.toast_autovacuum %} +{% if add_comma %}, {% endif %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %} -{% if data.autovacuum_custom and data.vacuum_table|length > 0 %} -{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %} -{% if ns.add_comma %}, -{% endif %} - {{opt.name}} = {{opt.value}}{% endif %}{% if opt.name and opt.value is defined %}{% set ns.add_comma = true%}{% endif %} -{% endfor %}{% endif %} -{% if data.toast_autovacuum and data.vacuum_toast|length > 0 %} -{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %} + toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled %}TRUE{% else %}FALSE{% endif %} +{% endif %}{% if data.autovacuum_enabled and data.vacuum_table|length > 0 %} +{% for opt in data.vacuum_table %}{% if opt.name and opt.value %} , - toast.{{opt.name}} = {{opt.value}}{% endif %}{% if opt.name and opt.value is defined %}{% set ns.add_comma = true%}{% endif %} + {{opt.name}} = {{opt.value}}{% endif %} +{% endfor %}{% endif %}{% if data.toast_autovacuum_enabled and data.vacuum_toast|length > 0 %} +{% for opt in data.vacuum_toast %}{% if opt.name and opt.value %} +, + toast.{{opt.name}} = {{opt.value}}{% endif %} {% endfor %}{% endif %} ){% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql index a357ae9d1..f8297873f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql @@ -7,37 +7,11 @@ SELECT rel.oid, rel.relname AS name, (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned, (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_sub_partitioned, (CASE WHEN rel.relkind = 'p' THEN pg_get_partkeydef(rel.oid::oid) ELSE '' END) AS partition_scheme, - (CASE WHEN rel.relkind = 'p' THEN pg_get_partkeydef(rel.oid::oid) ELSE '' END) AS sub_partition_scheme, - (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, - substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, typ.typname, - typ.typrelid AS typoid + (CASE WHEN rel.relkind = 'p' THEN pg_get_partkeydef(rel.oid::oid) ELSE '' END) AS sub_partition_scheme FROM (SELECT * FROM pg_inherits WHERE inhparent = {{ tid }}::oid) inh LEFT JOIN pg_class rel ON inh.inhrelid = rel.oid LEFT JOIN pg_namespace nsp ON rel.relnamespace = nsp.oid - LEFT OUTER JOIN pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_type typ ON rel.reloftype=typ.oid WHERE rel.relispartition {% if ptid %} AND rel.oid = {{ ptid }}::OID {% endif %} ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql index eed03bbaa..48e6248d1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql @@ -27,7 +27,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS autovacuum_enabled, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, @@ -37,7 +38,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS toast_autovacuum_enabled, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql index 9de83f353..c2c8e4274 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql @@ -27,7 +27,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS autovacuum_enabled, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, @@ -37,7 +38,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS toast_autovacuum_enabled, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql index 725ed5242..279ff99ab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql @@ -21,24 +21,23 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data PARTITION BY {{ data.partition_scheme }}{% endif %} {% if data.fillfactor or data.autovacuum_custom or data.autovacuum_enabled or data.toast_autovacuum or data.toast_autovacuum_enabled or (data.autovacuum_enabled and data.vacuum_table|length > 0) or (data.toast_autovacuum_enabled and data.vacuum_toast|length > 0) %} -{% set ns = namespace(add_comma=false) %} +{% set add_comma = false%} WITH ( -{% if data.fillfactor %}{% set ns.add_comma = true%} - FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, +{% if data.fillfactor %}{% set add_comma = true%} + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_custom %} +{% if add_comma %}, {% endif %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, + autovacuum_enabled = {% if data.autovacuum_enabled %}TRUE{% else %}FALSE{% endif %}{% set add_comma = true%}{% endif %}{% if data.toast_autovacuum %} +{% if add_comma %}, {% endif %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %} -{% if data.autovacuum_custom and data.vacuum_table|length > 0 %} -{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %} -{% if ns.add_comma %}, -{% endif %} - {{opt.name}} = {{opt.value}}{% endif %}{% if opt.name and opt.value is defined %}{% set ns.add_comma = true%}{% endif %} -{% endfor %}{% endif %}{% if data.toast_autovacuum and data.vacuum_toast|length > 0 %} -{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %} + toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled %}TRUE{% else %}FALSE{% endif %} +{% endif %}{% if data.autovacuum_enabled and data.vacuum_table|length > 0 %} +{% for opt in data.vacuum_table %}{% if opt.name and opt.value %} +, + {{opt.name}} = {{opt.value}}{% endif %} +{% endfor %}{% endif %}{% if data.toast_autovacuum_enabled and data.vacuum_toast|length > 0 %} +{% for opt in data.vacuum_toast %}{% if opt.name and opt.value %} , toast.{{opt.name}} = {{opt.value}}{% endif %} {% endfor %}{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql index eed03bbaa..48e6248d1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql @@ -27,7 +27,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS autovacuum_enabled, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, @@ -37,7 +38,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS toast_autovacuum_enabled, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql index 9de83f353..c2c8e4274 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql @@ -27,7 +27,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, substring(array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS autovacuum_enabled, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, @@ -37,7 +38,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)') = 'true') + THEN true ELSE false END) AS toast_autovacuum_enabled, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql index 42fdcb196..925f313d1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql @@ -69,7 +69,7 @@ CACHE {{c.seqcache|int}} {% endif %} {{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %} {% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} -){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }}{% endif %} +){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }} {% endif %} {### If we are inheriting it from another table(s) ###} {% if data.coll_inherits %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py index 149e608ee..7e9aa6531 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py @@ -680,57 +680,6 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): part_data['is_partitioned'] = row['is_partitioned'] part_data['partition_scheme'] = row['partition_scheme'] - self.update_autovacuum_properties(row) - - part_data['fillfactor'] = row['fillfactor'] - part_data['autovacuum_custom'] = row['autovacuum_custom'] - part_data['autovacuum_enabled'] = row['autovacuum_enabled'] - part_data['autovacuum_vacuum_threshold'] = row[ - 'autovacuum_vacuum_threshold'] - part_data['autovacuum_vacuum_scale_factor'] = row[ - 'autovacuum_vacuum_scale_factor'] - part_data['autovacuum_analyze_threshold'] = row[ - 'autovacuum_analyze_threshold'] - part_data['autovacuum_analyze_scale_factor'] = row[ - 'autovacuum_analyze_scale_factor'] - part_data['autovacuum_vacuum_cost_delay'] = row[ - 'autovacuum_vacuum_cost_delay'] - part_data['autovacuum_vacuum_cost_limit'] = row[ - 'autovacuum_vacuum_cost_limit'] - part_data['autovacuum_freeze_min_age'] = row[ - 'autovacuum_freeze_min_age'] - part_data['autovacuum_freeze_max_age'] = row[ - 'autovacuum_freeze_max_age'] - part_data['autovacuum_freeze_table_age'] = row[ - 'autovacuum_freeze_table_age'] - part_data['toast_autovacuum'] = row['toast_autovacuum'] - part_data['toast_autovacuum_enabled'] = row[ - 'toast_autovacuum_enabled'] - part_data['toast_autovacuum_vacuum_threshold'] = row[ - 'toast_autovacuum_vacuum_threshold'] - part_data['toast_autovacuum_vacuum_scale_factor'] = row[ - 'toast_autovacuum_vacuum_scale_factor'] - part_data['toast_autovacuum_analyze_threshold'] = row[ - 'toast_autovacuum_analyze_threshold'] - part_data['toast_autovacuum_analyze_scale_factor'] = row[ - 'toast_autovacuum_analyze_scale_factor'] - part_data['toast_autovacuum_vacuum_cost_delay'] = row[ - 'toast_autovacuum_vacuum_cost_delay'] - part_data['toast_autovacuum_vacuum_cost_limit'] = row[ - 'toast_autovacuum_vacuum_cost_limit'] - part_data['toast_autovacuum_freeze_min_age'] = row[ - 'toast_autovacuum_freeze_min_age'] - part_data['toast_autovacuum_freeze_max_age'] = row[ - 'toast_autovacuum_freeze_max_age'] - part_data['toast_autovacuum_freeze_table_age'] = row[ - 'toast_autovacuum_freeze_table_age'] - - # We will add Auto vacuum defaults with out result for grid - part_data['vacuum_table'] = copy.deepcopy( - self.parse_vacuum_data(self.conn, row, 'table')) - part_data['vacuum_toast'] = copy.deepcopy( - self.parse_vacuum_data(self.conn, row, 'toast')) - partition_sql += render_template("/".join( [self.partition_template_path, 'create.sql']), data=part_data, conn=self.conn) @@ -1679,46 +1628,3 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): if len(reset_values) > 0: data[vacuum_key]['reset_values'] = reset_values - - def update_autovacuum_properties(self, res): - """ - This function sets the appropriate value for autovacuum_enabled and - autovacuum_custom for table & toast table both. - :param res: - :return: - """ - # Set value based on - # x: No set, t: true, f: false - if res is not None: - res['autovacuum_enabled'] = 'x' \ - if res['autovacuum_enabled'] is None else \ - {True: 't', False: 'f'}[res['autovacuum_enabled']] - res['toast_autovacuum_enabled'] = 'x' \ - if res['toast_autovacuum_enabled'] is None else \ - {True: 't', False: 'f'}[ - res['toast_autovacuum_enabled']] - # Enable custom autovaccum only if one of the options is set - # or autovacuum is set - res['autovacuum_custom'] = any([ - res['autovacuum_vacuum_threshold'], - res['autovacuum_vacuum_scale_factor'], - res['autovacuum_analyze_threshold'], - res['autovacuum_analyze_scale_factor'], - res['autovacuum_vacuum_cost_delay'], - res['autovacuum_vacuum_cost_limit'], - res['autovacuum_freeze_min_age'], - res['autovacuum_freeze_max_age'], - res['autovacuum_freeze_table_age']]) or \ - res['autovacuum_enabled'] in ('t', 'f') - - res['toast_autovacuum'] = any([ - res['toast_autovacuum_vacuum_threshold'], - res['toast_autovacuum_vacuum_scale_factor'], - res['toast_autovacuum_analyze_threshold'], - res['toast_autovacuum_analyze_scale_factor'], - res['toast_autovacuum_vacuum_cost_delay'], - res['toast_autovacuum_vacuum_cost_limit'], - res['toast_autovacuum_freeze_min_age'], - res['toast_autovacuum_freeze_max_age'], - res['toast_autovacuum_freeze_table_age']]) or \ - res['toast_autovacuum_enabled'] in ('t', 'f')