diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index d18696cbd..22849a1f6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -716,11 +716,17 @@ function( },{ id: 'fillfactor', label: gettext('Fill factor'), type: 'int', mode: ['create', 'edit'], min: 10, max: 100, - disabled: 'inSchema',group: gettext('Advanced'), + group: gettext('Advanced'), + disabled: function(m) { + if(m.get('is_partitioned')) { + return true; + } + return m.inSchema(); + }, },{ id: 'relhasoids', label: gettext('Has OIDs?'), cell: 'switch', type: 'switch', mode: ['properties', 'create', 'edit'], - disabled: 'inSchema', group: gettext('Advanced'), + disabled: true, group: gettext('Advanced'), },{ id: 'relpersistence', label: gettext('Unlogged?'), cell: 'switch', type: 'switch', mode: ['properties', 'create', 'edit'], diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index cf8b36700..d091106fb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -777,7 +777,13 @@ define('pgadmin.node.table', [ },{ id: 'fillfactor', label: gettext('Fill factor'), type: 'int', mode: ['create', 'edit'], min: 10, max: 100, - disabled: 'inSchema', group: gettext('advanced'), + group: gettext('advanced'), + disabled: function(m) { + if(m.get('is_partitioned')) { + return true; + } + return m.inSchema(); + }, },{ id: 'relhasoids', label: gettext('Has OIDs?'), cell: 'switch', type: 'switch', mode: ['properties', 'create', 'edit'], diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql index 01f9bfbab..365be1d00 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql @@ -21,6 +21,29 @@ 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 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 add_comma = true%} + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_custom %} +{% if add_comma %}, +{% endif %} + 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 %}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 %} + +){% endif %} {### SQL for Tablespace ###} {% if data.spcname %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql index 6db5452b5..279ff99ab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql @@ -20,6 +20,29 @@ 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 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 add_comma = true%} + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_custom %} +{% if add_comma %}, +{% endif %} + 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 %}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 %} + +){% endif %} {### SQL for Tablespace ###} {% if data.spcname %} 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 99db573a1..9d841e5ca 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 @@ -1137,14 +1137,19 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): partitions_oid['created'] = created partitions_oid['attached'] = attached - icon = self.get_icon_css_class(res['rows'][0]) - - if 'relkind' in res['rows'][0] and \ - res['rows'][0]['relkind'] == 'p': - is_partitioned = True + if 'is_partitioned' in res['rows'][0]: + is_partitioned = res['rows'][0]['is_partitioned'] else: is_partitioned = False + # If partitioned_table_name in result set then get partition + # icon css class else table icon. + if 'partitioned_table_name' in res['rows'][0]: + res['rows'][0]['is_sub_partitioned'] = is_partitioned + icon = self.get_partition_icon_css_class(res['rows'][0]) + else: + icon = self.get_icon_css_class(res['rows'][0]) + return jsonify( node=self.blueprint.generate_browser_node( tid,