From d286bada5cad95d2b42c9190ab3fcb4eccafa65d Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 1 Apr 2019 09:47:17 +0100 Subject: [PATCH] Fix custom autovacuum configuration for Materialized Views. Fixes #4110 --- docs/en_US/release_notes_4_4.rst | 1 + .../databases/schemas/static/js/schema.js | 52 ++++++++++++- .../partition/sql/gpdb/5_plus/properties.sql | 12 +-- .../partition/sql/pg/10_plus/properties.sql | 12 +-- .../partition/sql/ppas/10_plus/properties.sql | 12 +-- .../table/sql/10_plus/properties.sql | 12 +-- .../table/sql/9.1_plus/properties.sql | 12 +-- .../table/sql/default/properties.sql | 12 +-- .../templates/table/sql/default/update.sql | 76 ++++++++++++------- .../table/sql/gpdb_5.0_plus/properties.sql | 12 +-- .../servers/databases/schemas/tables/utils.py | 36 +++++++++ .../databases/schemas/views/__init__.py | 15 ++++ .../mview/pg/9.3_plus/sql/properties.sql | 14 ++-- .../mview/pg/9.3_plus/sql/update.sql | 15 ++-- .../mview/pg/9.4_plus/sql/properties.sql | 14 ++-- .../mview/pg/9.4_plus/sql/update.sql | 15 ++-- .../mview/ppas/9.3_plus/sql/properties.sql | 14 ++-- .../mview/ppas/9.3_plus/sql/update.sql | 15 ++-- 18 files changed, 225 insertions(+), 126 deletions(-) diff --git a/docs/en_US/release_notes_4_4.rst b/docs/en_US/release_notes_4_4.rst index b147f26eb..875bb7d79 100644 --- a/docs/en_US/release_notes_4_4.rst +++ b/docs/en_US/release_notes_4_4.rst @@ -67,3 +67,4 @@ Bug fixes | `Bug #4100 `_ - Ensure sequences can be created with increment, start, minimum and maximum options set. | `Bug #4105 `_ - Fix an issue where JSON data would not be rendered in the Query Tool. | `Bug #4109 `_ - Ensure View/Materialized View node should be visible after updating any property. +| `Bug #4110 `_ - Fix custom autovacuum configuration for Materialized Views. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js index 6c6c73172..5f4be0e32 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js @@ -81,10 +81,11 @@ define('pgadmin.node.schema', [ var grid = self.grid = new Backgrid.Grid({ columns: self.grid_columns, collection: self.model.get(self.field.get('name')), - className: 'backgrid table-bordered table-noouter-border table-hover', + className: 'backgrid table table-bordered table-noouter-border table-hover', }); // render grid + self.$el.addClass('mb-0'); self.$el.append($(gridBody).append(grid.render().$el)); return self; @@ -158,6 +159,14 @@ define('pgadmin.node.schema', [ disabled: function(m) { if(!m.top.inSchema.apply(this, [m]) && m.get('autovacuum_custom') == true) { + + // If reloptions is null then set the autovacuum_enabled to true. + if (!_.isUndefined(m.get('reloptions')) && + _.isNull(m.get('reloptions'))) { + setTimeout(function() { + m.set('autovacuum_enabled', true); + }, 10); + } return false; } @@ -167,6 +176,22 @@ define('pgadmin.node.schema', [ }, 10); return true; }, + control: Backform.SwitchControl.extend({ + onChange: function() { + Backform.SwitchControl.prototype.onChange.apply(this, arguments); + + let m = this.model; + // If value of autovacuum_enabled is false and reloptions is null + // then we should set the value of autovacuum_custom to false, as + // there is no query to run. + if (!m.get('autovacuum_enabled') && !_.isUndefined(m.get('reloptions')) + && _.isNull(m.get('reloptions'))) { + setTimeout(function() { + m.set('autovacuum_custom', false); + }, 10); + } + }, + }), },{ id: 'vacuum_table', label: '', model: Backform.VacuumTableModel, editable: false, type: 'collection', @@ -222,6 +247,15 @@ define('pgadmin.node.schema', [ // If in schema & in create mode then enable it if(!m.top.inSchema.apply(this, [m]) && m.get('toast_autovacuum') === true) { + + // If reloptions is null then set the autovacuum_enabled to true. + if (!_.isUndefined(m.get('toast_reloptions')) && + _.isNull(m.get('toast_reloptions'))) { + setTimeout(function() { + m.set('toast_autovacuum_enabled', true); + }, 10); + } + return false; } @@ -233,6 +267,22 @@ define('pgadmin.node.schema', [ } return true; }, + control: Backform.SwitchControl.extend({ + onChange: function() { + Backform.SwitchControl.prototype.onChange.apply(this, arguments); + + let m = this.model; + // If value of autovacuum_enabled is false and reloptions is null + // then we should set the value of autovacuum_custom to false, as + // there is no query to run. + if (!m.get('toast_autovacuum_enabled') && !_.isUndefined(m.get('toast_reloptions')) + && _.isNull(m.get('toast_reloptions'))) { + setTimeout(function() { + m.set('toast_autovacuum', false); + }, 10); + } + }, + }), },{ id: 'vacuum_toast', label: '', model: Backform.VacuumTableModel, type: 'collection', editable: function(m) { diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/gpdb/5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/gpdb/5_plus/properties.sql index 5bf108130..10daab06f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/gpdb/5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/gpdb/5_plus/properties.sql @@ -33,9 +33,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -44,9 +44,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -58,8 +58,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, NULL AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, -- Added for partition table diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/pg/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/pg/10_plus/properties.sql index 51c119876..daa102f5a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/pg/10_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/pg/10_plus/properties.sql @@ -30,9 +30,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -41,9 +41,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -55,8 +55,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, (SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/ppas/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/ppas/10_plus/properties.sql index 51c119876..daa102f5a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/ppas/10_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/ppas/10_plus/properties.sql @@ -30,9 +30,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -41,9 +41,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -55,8 +55,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, (SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql index 8bba0afbf..e9bb22827 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/10_plus/properties.sql @@ -30,9 +30,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -41,9 +41,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -56,8 +56,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, (SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql index 3dc29051e..d153b0edf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql @@ -29,9 +29,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -40,9 +40,9 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r (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_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_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, @@ -55,8 +55,8 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, (SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/properties.sql index 5096a8ab0..932e7ffa5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/properties.sql @@ -32,9 +32,9 @@ FROM ( (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_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_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, @@ -43,9 +43,9 @@ FROM ( (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_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_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, @@ -57,8 +57,8 @@ FROM ( typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, ARRAY[]::varchar[] AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/update.sql index fa22b89bf..c8bf6db94 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/update.sql @@ -69,6 +69,12 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} {###############################} {## Table AutoVacuum settings ##} {###############################} +{% if data.vacuum_table is defined and data.vacuum_table.set_values|length > 0 %} +{% set has_vacuum_set = true %} +{% endif %} +{% if data.vacuum_table is defined and data.vacuum_table.reset_values|length > 0 %} +{% set has_vacuum_reset = true %} +{% endif %} {% if o_data.autovacuum_custom and data.autovacuum_custom == false %} ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( autovacuum_enabled, @@ -82,27 +88,30 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( autovacuum_freeze_min_age, autovacuum_freeze_table_age ); -{% elif data.autovacuum_enabled != o_data.autovacuum_enabled %} -{% if data.autovacuum_enabled and o_data.autovacuum_enabled == false %} -ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( - autovacuum_enabled = true{% elif data.autovacuum_enabled == false and o_data.autovacuum_enabled %} -ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( - autovacuum_enabled = false{% endif %} -{% if (data.autovacuum_enabled or o_data.autovacuum_enabled )and data.vacuum_table and data.vacuum_table.changed|length > 0 %} -{% for opt in data.vacuum_table.changed %}{% if opt.name and opt.value %} -{% if flag or (data.autovacuum_enabled and o_data.autovacuum_enabled == false) or (data.autovacuum_enabled == false and o_data.autovacuum_enabled) %} -, {% else %} +{% if data.autovacuum_enabled is defined or has_vacuum_set %} ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( -{% set flag = true %} +{% if data.autovacuum_enabled is defined and data.autovacuum_enabled != o_data.autovacuum_enabled %} + autovacuum_enabled = {% if data.autovacuum_enabled %}true{% else %}false{% endif %}{% if has_vacuum_set %}, +{% endif %} +{% endif %} +{% if has_vacuum_set %} +{% for opt in data.vacuum_table.set_values %}{% if opt.name and opt.value %} + {{opt.name}} = {{opt.value}}{% if not loop.last %}, +{% endif %} +{% endif %} +{% endfor %} {% endif %} - {{opt.name}} = {{opt.value}}{% endif %} -{% if loop.index == data.vacuum_table.changed|length and (flag or (data.autovacuum_enabled and o_data.autovacuum_enabled == false) or (data.autovacuum_enabled == false and o_data.autovacuum_enabled))%} ); {% endif %} +{% if has_vacuum_reset %} +ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( +{% for opt in data.vacuum_table.reset_values %}{% if opt.name %} + {{opt.name}}{% if not loop.last %}, +{% endif %} +{% endif %} {% endfor %} -{% elif (data.autovacuum_enabled and o_data.autovacuum_enabled == false) or (data.autovacuum_enabled == false and o_data.autovacuum_enabled) %} ); {% endif %} @@ -110,6 +119,12 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( {#####################################} {## Toast table AutoVacuum settings ##} {#####################################} +{% if data.vacuum_toast is defined and data.vacuum_toast.set_values|length > 0 %} +{% set has_vacuum_toast_set = true %} +{% endif %} +{% if data.vacuum_toast is defined and data.vacuum_toast.reset_values|length > 0 %} +{% set has_vacuum_toast_reset = true %} +{% endif %} {% if o_data.toast_autovacuum and data.toast_autovacuum == false %} ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( toast.autovacuum_enabled, @@ -123,27 +138,30 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( toast.autovacuum_analyze_threshold, toast.autovacuum_analyze_scale_factor ); -{% elif data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} -{% if data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false %} -ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( - toast.autovacuum_enabled = true{% elif data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled %} -ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( - toast.autovacuum_enabled = false{% endif %} -{% if (data.toast_autovacuum_enabled or o_data.toast_autovacuum_enabled )and data.vacuum_toast and data.vacuum_toast.changed|length > 0 %} -{% for opt in data.vacuum_toast.changed %}{% if opt.name and opt.value %} -{% if flag or (data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false) or (data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled) %} -, {% else %} +{% if data.toast_autovacuum_enabled is defined or has_vacuum_toast_set %} ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} SET ( -{% set flag = true %} +{% if data.toast_autovacuum_enabled is defined and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} + toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled %}true{% else %}false{% endif %}{% if has_vacuum_toast_set %}, +{% endif %} +{% endif %} +{% if has_vacuum_toast_set %} +{% for opt in data.vacuum_toast.set_values %}{% if opt.name and opt.value %} + toast.{{opt.name}} = {{opt.value}}{% if not loop.last %}, +{% endif %} +{% endif %} +{% endfor %} {% endif %} - toast.{{opt.name}} = {{opt.value}}{% endif %} -{% if loop.index == data.vacuum_toast.changed|length and (flag or (data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false) or (data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled))%} ); {% endif %} +{% if has_vacuum_toast_reset %} +ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} RESET ( +{% for opt in data.vacuum_toast.reset_values %}{% if opt.name %} + toast.{{opt.name}}{% if not loop.last %}, +{% endif %} +{% endif %} {% endfor %} -{% elif (data.toast_autovacuum_enabled and o_data.toast_autovacuum_enabled == false) or (data.toast_autovacuum_enabled == false and o_data.toast_autovacuum_enabled) %} ); {% endif %} @@ -198,4 +216,4 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endfor %} {% endif %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/gpdb_5.0_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/gpdb_5.0_plus/properties.sql index 5701ff9db..c690a1b84 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/gpdb_5.0_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/gpdb_5.0_plus/properties.sql @@ -38,9 +38,9 @@ FROM ( (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_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_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, @@ -49,9 +49,9 @@ FROM ( (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_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_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, @@ -63,8 +63,8 @@ FROM ( typ.typrelid AS typoid, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, -- Added for pgAdmin4 - (CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, + (CASE WHEN array_length(rel.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND rel.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum, ARRAY[]::varchar[] AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, 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 9dbd1fe98..78b250477 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 @@ -1712,6 +1712,11 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): set(data['coll_inherits']) ) + # Update the vacuum table settings. + self.update_vacuum_settings('vacuum_table', old_data, data) + # Update the vacuum toast table settings. + self.update_vacuum_settings('vacuum_toast', old_data, data) + SQL = render_template( "/".join([self.table_template_path, 'update.sql']), o_data=old_data, data=data, conn=self.conn @@ -2454,3 +2459,34 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): return costrnt["idxname"] return None + + def update_vacuum_settings(self, vacuum_key, old_data, data): + """ + This function iterate the vacuum and vacuum toast table and create + two new dictionaries. One for set parameter and another for reset. + + :param vacuum_key: Key to be checked. + :param old_data: Old data + :param data: New data + :return: + """ + + # Iterate vacuum table + if vacuum_key in data and 'changed' in data[vacuum_key] \ + and vacuum_key in old_data: + set_values = [] + reset_values = [] + for data_row in data[vacuum_key]['changed']: + for old_data_row in old_data[vacuum_key]: + if data_row['name'] == old_data_row['name']: + if data_row['value'] is not None: + set_values.append(data_row) + elif data_row['value'] is None and \ + 'value' in old_data_row: + reset_values.append(data_row) + + if len(set_values) > 0: + data[vacuum_key]['set_values'] = set_values + + if len(reset_values) > 0: + data[vacuum_key]['reset_values'] = reset_values diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 7616aaefe..d5ac0df07 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -1595,6 +1595,21 @@ class MViewNode(ViewNode, VacuumSettings): for item in result['vacuum_toast'] if 'value' in item.keys() and item['value'] is not None] + if 'autovacuum_custom' in result and result['autovacuum_custom']: + vacuum_table.append( + { + 'name': 'autovacuum_enabled', + 'value': str(result['autovacuum_enabled']) + } + ) + if 'toast_autovacuum' in result and result['toast_autovacuum']: + vacuum_table.append( + { + 'name': 'toast.autovacuum_enabled', + 'value': str(result['toast_autovacuum_enabled']) + } + ) + # add vacuum_toast dict to vacuum_data only if # toast's autovacuum is enabled if ( diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/properties.sql index eb36c918b..efc4b78db 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/properties.sql @@ -29,11 +29,11 @@ SELECT substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor, + FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_analyze_scale_factor, + FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, substring(array_to_string(c.reloptions, ',') @@ -49,11 +49,11 @@ SELECT 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, + 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, + 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, ',') @@ -66,10 +66,8 @@ SELECT FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, c.reloptions AS reloptions, tst.reloptions AS toast_reloptions, (CASE WHEN c.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (CASE WHEN (substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS toast_autovacuum + (CASE WHEN array_length(c.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND c.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum FROM pg_class c LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql index 89d8e7e5a..e7ab7ab07 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql @@ -79,8 +79,7 @@ REFRESH MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} WITH{{ ' NO (data.toast_autovacuum is defined and data.toast_autovacuum|lower == 'false') ) %} {% if data.autovacuum_custom|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( autovacuum_enabled, autovacuum_vacuum_threshold, autovacuum_analyze_threshold, @@ -108,8 +107,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% endif %} {% if data.toast_autovacuum|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( toast.autovacuum_enabled, toast.autovacuum_vacuum_threshold, toast.autovacuum_analyze_threshold, @@ -139,8 +137,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% else %} {% if data['vacuum_data']['reset']|length == 0 and data['vacuum_data']['changed']|length == 0 and data['settings']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} SET( {% for field in data['settings'] %} {{ field }} = {{ data['settings'][field]|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %} @@ -148,8 +145,7 @@ SET( {% endif %} {% if(data['vacuum_data']['changed']|length > 0) %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% for field in data['vacuum_data']['changed'] %} {% if field.value != None %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} @@ -158,8 +154,7 @@ SET( ); {% endif %} {% if data['vacuum_data']['reset']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( {% for field in data['vacuum_data']['reset'] %} {{ field.name }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/properties.sql index eb36c918b..efc4b78db 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/properties.sql @@ -29,11 +29,11 @@ SELECT substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor, + FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_analyze_scale_factor, + FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, substring(array_to_string(c.reloptions, ',') @@ -49,11 +49,11 @@ SELECT 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, + 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, + 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, ',') @@ -66,10 +66,8 @@ SELECT FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, c.reloptions AS reloptions, tst.reloptions AS toast_reloptions, (CASE WHEN c.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (CASE WHEN (substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS toast_autovacuum + (CASE WHEN array_length(c.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND c.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum FROM pg_class c LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql index 89d8e7e5a..e7ab7ab07 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql @@ -79,8 +79,7 @@ REFRESH MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} WITH{{ ' NO (data.toast_autovacuum is defined and data.toast_autovacuum|lower == 'false') ) %} {% if data.autovacuum_custom|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( autovacuum_enabled, autovacuum_vacuum_threshold, autovacuum_analyze_threshold, @@ -108,8 +107,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% endif %} {% if data.toast_autovacuum|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( toast.autovacuum_enabled, toast.autovacuum_vacuum_threshold, toast.autovacuum_analyze_threshold, @@ -139,8 +137,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% else %} {% if data['vacuum_data']['reset']|length == 0 and data['vacuum_data']['changed']|length == 0 and data['settings']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} SET( {% for field in data['settings'] %} {{ field }} = {{ data['settings'][field]|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %} @@ -148,8 +145,7 @@ SET( {% endif %} {% if(data['vacuum_data']['changed']|length > 0) %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% for field in data['vacuum_data']['changed'] %} {% if field.value != None %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} @@ -158,8 +154,7 @@ SET( ); {% endif %} {% if data['vacuum_data']['reset']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( {% for field in data['vacuum_data']['reset'] %} {{ field.name }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/properties.sql index eb36c918b..efc4b78db 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/properties.sql @@ -29,11 +29,11 @@ SELECT substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_vacuum_scale_factor, + FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_analyze_scale_factor=([0-9]*[.][0-9]*)') AS autovacuum_analyze_scale_factor, + FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, substring(array_to_string(c.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, substring(array_to_string(c.reloptions, ',') @@ -49,11 +49,11 @@ SELECT 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, + 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, + 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, ',') @@ -66,10 +66,8 @@ SELECT FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, c.reloptions AS reloptions, tst.reloptions AS toast_reloptions, (CASE WHEN c.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (CASE WHEN (substring(array_to_string(c.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS autovacuum_custom, - (CASE WHEN (substring(array_to_string(tst.reloptions, ',') - FROM 'autovacuum_enabled=([a-z|0-9]*)')) = 'true' THEN true ELSE false END) AS toast_autovacuum + (CASE WHEN array_length(c.reloptions, 1) > 0 THEN true ELSE false END) AS autovacuum_custom, + (CASE WHEN array_length(tst.reloptions, 1) > 0 AND c.reltoastrelid != 0 THEN true ELSE false END) AS toast_autovacuum FROM pg_class c LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql index 89d8e7e5a..e7ab7ab07 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql @@ -79,8 +79,7 @@ REFRESH MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} WITH{{ ' NO (data.toast_autovacuum is defined and data.toast_autovacuum|lower == 'false') ) %} {% if data.autovacuum_custom|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( autovacuum_enabled, autovacuum_vacuum_threshold, autovacuum_analyze_threshold, @@ -108,8 +107,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% endif %} {% if data.toast_autovacuum|lower == 'false' %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( toast.autovacuum_enabled, toast.autovacuum_vacuum_threshold, toast.autovacuum_analyze_threshold, @@ -139,8 +137,7 @@ ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% else %} {% if data['vacuum_data']['reset']|length == 0 and data['vacuum_data']['changed']|length == 0 and data['settings']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} SET( {% for field in data['settings'] %} {{ field }} = {{ data['settings'][field]|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %} @@ -148,8 +145,7 @@ SET( {% endif %} {% if(data['vacuum_data']['changed']|length > 0) %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} -SET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} SET( {% for field in data['vacuum_data']['changed'] %} {% if field.value != None %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %},{% endif %}{{ '\r' }} @@ -158,8 +154,7 @@ SET( ); {% endif %} {% if data['vacuum_data']['reset']|length > 0 %} -ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} -RESET( +ALTER MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} RESET( {% for field in data['vacuum_data']['reset'] %} {{ field.name }}{% if not loop.last %},{% endif %}{{ '\r' }} {% endfor %}