mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Reverted fix for #5569 due to a couple of issues.
This commit is contained in:
parent
e6edf40048
commit
d3eaac8609
@ -31,7 +31,6 @@ Bug fixes
|
||||
| `Issue #5463 <https://redmine.postgresql.org/issues/5463>`_ - Fixed an issue where CSV download quotes numeric columns.
|
||||
| `Issue #5470 <https://redmine.postgresql.org/issues/5470>`_ - Fixed backgrid row hover issue where on hover background color is set for edit and delete cell only.
|
||||
| `Issue #5530 <https://redmine.postgresql.org/issues/5530>`_ - Ensure that the referenced table should be displayed on foreign key constraints.
|
||||
| `Issue #5569 <https://redmine.postgresql.org/issues/5569>`_ - Fixed reverse engineered SQL for partitions when storage parameters are specified.
|
||||
| `Issue #5621 <https://redmine.postgresql.org/issues/5621>`_ - Remove extra brackets from reverse engineering SQL of RLS Policy.
|
||||
| `Issue #5629 <https://redmine.postgresql.org/issues/5629>`_ - Fixed an issue where the user is able to edit properties when some of the collection nodes are selected.
|
||||
| `Issue #5630 <https://redmine.postgresql.org/issues/5630>`_ - Fixed an issue where installation of pgadmin4 not working on 32-bit Windows.
|
||||
|
@ -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
|
||||
|
@ -356,25 +356,6 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
JSON of selected table node
|
||||
"""
|
||||
|
||||
status, res = self._fetch_properties(did, scid, tid, ptid)
|
||||
|
||||
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,
|
||||
@ -384,16 +365,11 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("The specified table could not be found."))
|
||||
return gone(gettext(
|
||||
"The specified partitioned 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
|
||||
return super(PartitionsView, self).properties(
|
||||
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))
|
||||
|
||||
|
@ -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'),
|
||||
|
@ -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');
|
@ -1,2 +0,0 @@
|
||||
CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#"
|
||||
FOR VALUES FROM (0) TO (1000);
|
@ -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';
|
@ -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';
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
@ -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');
|
@ -1,2 +0,0 @@
|
||||
CREATE TABLE public."test_part_$%{}[]()&*^!@""""""""'`\/#" PARTITION OF public."test_table_$%{}[]()&*^!@""""'`\/#"
|
||||
FOR VALUES FROM (0) TO (1000);
|
@ -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';
|
@ -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';
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
@ -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,
|
||||
|
@ -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 %}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 %}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user