Added all like options while creating a table. #6377

This commit is contained in:
Pravesh Sharma 2023-08-07 11:20:04 +05:30 committed by GitHub
parent ac50b4d80b
commit 27c7ea2ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 9584 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -418,13 +418,21 @@ not-null constraints; after saving the new or modified table, any changes to
the original table will not be applied to the new table. the original table will not be applied to the new table.
* Use the drop-down listbox next to *Relation* to select a reference table. * Use the drop-down listbox next to *Relation* to select a reference table.
* Move the *With default values?* switch to the *Yes* position to copy default * Move the switch next to *With default values?* towards the *right position* to copy default
values. values.
* Move the *With constraints?* switch to the *Yes* position to copy table and * Move the switch next to *With constraints?* towards the *right position* to copy table and
column constraints. column constraints.
* Move the *With indexes?* switch to the *Yes* position to copy indexes. * Move the switch next to *With indexes?* towards the *right position* to copy indexes.
* Move the *With storage?* switch to the *Yes* position to copy storage settings. * Move the switch next to *With storage?* towards the *right position* to copy storage settings.
* Move the *With comments?* switch to the *Yes* position to copy comments. * Move the switch next to *With comments?* towards the *right position* to copy comments.
* Move the switch next to *With compression?* towards the *right position* to copy
compression method. This option is available only on PostgreSQL 14 and above.
* Move the switch next to *With generated?* towards the *right position* to copy
generation expressions of copied column. This option is available only on PostgreSQL 12 and above.
* Move the switch next to *With identity?* towards the *right position* to copy
any identity specifications of copied column.
* Move the switch next to *With statistics?* towards the *right position* to copy
extended statistics.
With PostgreSQL 10 forward, the *Partition* tab will be visible. With PostgreSQL 10 forward, the *Partition* tab will be visible.

View File

@ -231,6 +231,10 @@ export class LikeSchema extends BaseUISchema {
like_indexes: false, like_indexes: false,
like_storage: false, like_storage: false,
like_comments: false, like_comments: false,
like_compression: false,
like_generated: false,
like_identity: false,
like_statistics: false
}; };
} }
} }
@ -256,22 +260,46 @@ export class LikeSchema extends BaseUISchema {
id: 'like_default_value', label: gettext('With default values?'), id: 'like_default_value', label: gettext('With default values?'),
type: 'switch', mode: ['create'], deps: ['like_relation'], type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args), disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{ },{
id: 'like_constraints', label: gettext('With constraints?'), id: 'like_constraints', label: gettext('With constraints?'),
type: 'switch', mode: ['create'], deps: ['like_relation'], type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args), disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{ },{
id: 'like_indexes', label: gettext('With indexes?'), id: 'like_indexes', label: gettext('With indexes?'),
type: 'switch', mode: ['create'], deps: ['like_relation'], type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args), disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{ },{
id: 'like_storage', label: gettext('With storage?'), id: 'like_storage', label: gettext('With storage?'),
type: 'switch', mode: ['create'], deps: ['like_relation'], type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args), disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{ },{
id: 'like_comments', label: gettext('With comments?'), id: 'like_comments', label: gettext('With comments?'),
type: 'switch', mode: ['create'], deps: ['like_relation'], type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args), disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{
id: 'like_compression', label: gettext('With compression?'),
type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
min_version: 140000, inlineNext: true,
},{
id: 'like_generated', label: gettext('With generated?'),
type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
min_version: 120000, inlineNext: true,
},{
id: 'like_identity', label: gettext('With identity?'),
type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
inlineNext: true,
},{
id: 'like_statistics', label: gettext('With statistics?'),
type: 'switch', mode: ['create'], deps: ['like_relation'],
disabled: this.isRelationDisable, depChange: (...args)=>obj.resetVals(...args),
} }
]; ];
} }

View File

@ -34,7 +34,11 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
INCLUDING STORAGE{% endif %}{% if data.like_comments %} INCLUDING STORAGE{% endif %}{% if data.like_comments %}
INCLUDING COMMENTS{% endif %}{% if data.columns|length > 0 %}, INCLUDING COMMENTS{% endif %}{% if data.like_identity %}
INCLUDING IDENTITY{% endif %}{% if data.like_statistics %}
INCLUDING STATISTICS{% endif %}{% if data.columns|length > 0 %},
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -38,7 +38,13 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
INCLUDING STORAGE{% endif %}{% if data.like_comments %} INCLUDING STORAGE{% endif %}{% if data.like_comments %}
INCLUDING COMMENTS{% endif %}{% if data.columns|length > 0 %}, INCLUDING COMMENTS{% endif %}{% if data.like_generated %}
INCLUDING GENERATED{% endif %}{% if data.like_identity %}
INCLUDING IDENTITY{% endif %}{% if data.like_statistics %}
INCLUDING STATISTICS{% endif %}{% if data.columns|length > 0 %},
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -0,0 +1,235 @@
{% import 'macros/schemas/security.macros' as SECLABEL %}
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% import 'macros/variable.macros' as VARIABLE %}
{% import 'columns/macros/security.macros' as COLUMN_SECLABEL %}
{% import 'columns/macros/privilege.macros' as COLUMN_PRIVILEGE %}
{% import 'tables/sql/macros/constraints.macro' as CONSTRAINTS %}
{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %}
{#===========================================#}
{#====== MAIN TABLE TEMPLATE STARTS HERE ======#}
{#===========================================#}
{#
If user has not provided any details but only name then
add empty bracket with table name
#}
{% set empty_bracket = ""%}
{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %}
{% set empty_bracket = "\n(\n)"%}
{% endif %}
{% set with_clause = false%}
{% if data.fillfactor or data.parallel_workers or data.toast_tuple_target or (data.autovacuum_custom and data.add_vacuum_settings_in_sql) or data.autovacuum_enabled in ('t', 'f') or (data.toast_autovacuum and data.add_vacuum_settings_in_sql) or data.toast_autovacuum_enabled in ('t', 'f') %}
{% set with_clause = true%}
{% endif %}
CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
{% if data.typname %}
OF {{ data.typname }}
{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %}
(
{% endif %}
{% if data.like_relation %}
LIKE {{ data.like_relation }}{% if data.like_default_value %}
INCLUDING DEFAULTS{% endif %}{% if data.like_constraints %}
INCLUDING CONSTRAINTS{% endif %}{% if data.like_indexes %}
INCLUDING INDEXES{% endif %}{% if data.like_storage %}
INCLUDING STORAGE{% endif %}{% if data.like_comments %}
INCLUDING COMMENTS{% endif %}{% if data.like_compression %}
INCLUDING COMPRESSION{% endif %}{% if data.like_generated %}
INCLUDING GENERATED{% endif %}{% if data.like_identity %}
INCLUDING IDENTITY{% endif %}{% if data.like_statistics %}
INCLUDING STATISTICS{% endif %}{% if data.columns|length > 0 %},
{% endif %}
{% endif %}
{### Add columns ###}
{% if data.columns and data.columns|length > 0 %}
{% for c in data.columns %}
{% if c.name and c.cltype %}
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' and c.colconstype != 'g' %} DEFAULT {{c.defval}}{% endif %}
{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %}
{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %}
{% if c.seqcycle is defined and c.seqcycle %}
CYCLE {% endif %}{% if c.seqincrement is defined and c.seqincrement|int(-1) > -1 %}
INCREMENT {{c.seqincrement|int}} {% endif %}{% if c.seqstart is defined and c.seqstart|int(-1) > -1%}
START {{c.seqstart|int}} {% endif %}{% if c.seqmin is defined and c.seqmin|int(-1) > -1%}
MINVALUE {{c.seqmin|int}} {% endif %}{% if c.seqmax is defined and c.seqmax|int(-1) > -1%}
MAXVALUE {{c.seqmax|int}} {% endif %}{% if c.seqcache is defined and c.seqcache|int(-1) > -1%}
CACHE {{c.seqcache|int}} {% endif %}
{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %}){% endif %}
{% endif %}
{% if c.colconstype == 'g' and c.genexpr and c.genexpr != '' %} GENERATED ALWAYS AS ({{c.genexpr}}) STORED{% endif %}
{% if not loop.last %},
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{# Macro to render for constraints #}
{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %}
{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %}
{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %}
{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %}
{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %}
{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %}
{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %}
){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }}{% endif %}
{% if not data.coll_inherits and not data.spcname and not with_clause %};{% endif %}
{### If we are inheriting it from another table(s) ###}
{% if data.coll_inherits %}
INHERITS ({% for val in data.coll_inherits %}{% if loop.index != 1 %}, {% endif %}{{val}}{% endfor %}){% if not data.spcname and not with_clause %};{% endif %}
{% endif %}
{% if with_clause %}
{% set ns = namespace(add_comma=false) %}
WITH (
{% if data.fillfactor %}{% set ns.add_comma = true%}
FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.parallel_workers %}
{% if ns.add_comma %},
{% endif %}
parallel_workers = {{ data.parallel_workers }}{% set ns.add_comma = true%}{% endif %}{% if data.toast_tuple_target %}
{% if ns.add_comma %},
{% endif %}
toast_tuple_target = {{ data.toast_tuple_target }}{% set ns.add_comma = true%}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %}
{% if ns.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 %},
{% endif %}
toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.autovacuum_custom %}
{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %}
{% if ns.add_comma %},
{% endif %}
{{opt.name}} = {{opt.value}}{% set ns.add_comma = true%}{% endif %}
{% endfor %}{% endif %}{% if data.toast_autovacuum %}
{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %}
{% if ns.add_comma %},
{% endif %}
toast.{{opt.name}} = {{opt.value}}{% set ns.add_comma = true%}{% endif %}
{% endfor %}{% endif %}
{% if data.spcname %}){% else %});{% endif %}
{% endif %}
{### SQL for Tablespace ###}
{% if data.spcname %}
TABLESPACE {{ conn|qtIdent(data.spcname) }};
{% endif %}
{### Alter SQL for Owner ###}
{% if data.relowner %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
OWNER to {{conn|qtIdent(data.relowner)}};
{% endif %}
{#####################################################}
{## Enable Row Level Security Policy on table ##}
{#####################################################}
{% if data.rlspolicy %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
ENABLE ROW LEVEL SECURITY;
{% endif %}
{#####################################################}
{## Force Enable Row Level Security Policy on table ##}
{#####################################################}
{% if data.forcerlspolicy %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
FORCE ROW LEVEL SECURITY;
{% endif %}
{### Security Labels on Table ###}
{% if data.seclabels and data.seclabels|length > 0 %}
{% for r in data.seclabels %}
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
{% endfor %}
{% endif %}
{### ACL on Table ###}
{% if data.revoke_all %}
{% for priv in data.revoke_all %}
{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}}
{% endfor %}
{% endif %}
{% if data.relacl %}
{% for priv in data.relacl %}
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}
{% endfor %}
{% endif %}
{### SQL for COMMENT ###}
{% if data.description %}
COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
IS {{data.description|qtLiteral(conn)}};
{% endif %}
{#===========================================#}
{#====== MAIN TABLE TEMPLATE ENDS HERE ======#}
{#===========================================#}
{#===========================================#}
{# COLUMN SPECIFIC TEMPLATES STARTS HERE #}
{#===========================================#}
{% if data.columns and data.columns|length > 0 %}
{% for c in data.columns %}
{% if c.description %}
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}}
IS {{c.description|qtLiteral(conn)}};
{% endif %}
{### Add variables to column ###}
{% if c.attoptions and c.attoptions|length > 0 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
{{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }}
{% endif %}
{### Alter column statistics value ###}
{% if c.attstattarget is defined and c.attstattarget > -1 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STATISTICS {{c.attstattarget}};
{% endif %}
{### Alter column storage value ###}
{% if c.attstorage is defined and c.attstorage != c.defaultstorage %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}}
ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STORAGE {%if c.attstorage == 'p' %}
PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%}
EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %};
{% endif %}
{### ACL ###}
{% if c.attacl and c.attacl|length > 0 %}
{% for priv in c.attacl %}
{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% endfor %}
{% endif %}
{### Security Lables ###}
{% if c.seclabels and c.seclabels|length > 0 %}
{% for r in c.seclabels %}
{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{#===========================================#}
{# COLUMN SPECIFIC TEMPLATES ENDS HERE #}
{#===========================================#}
{#======================================#}
{# CONSTRAINTS SPECIFIC TEMPLATES #}
{#======================================#}
{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.primary_key)}}
{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.unique_constraint)}}
{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.foreign_key)}}
{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.check_constraint)}}
{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.exclude_constraint)}}

View File

@ -34,7 +34,11 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
INCLUDING STORAGE{% endif %}{% if data.like_comments %} INCLUDING STORAGE{% endif %}{% if data.like_comments %}
INCLUDING COMMENTS{% endif %}{% if data.columns|length > 0 %}, INCLUDING COMMENTS{% endif %}{% if data.like_identity %}
INCLUDING IDENTITY{% endif %}{% if data.like_statistics %}
INCLUDING STATISTICS{% endif %}{% if data.columns|length > 0 %},
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -22,7 +22,8 @@ COMMENT ON TABLE public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public.cust_arr_small PARTITION OF public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#" CREATE TABLE public.cust_arr_small PARTITION OF public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
FOR VALUES FROM ('20') TO ('25'); FOR VALUES FROM ('20') TO ('25')
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.cust_arr_small ALTER TABLE IF EXISTS public.cust_arr_small
OWNER to postgres; OWNER to postgres;

View File

@ -22,7 +22,8 @@ COMMENT ON TABLE public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public.cust_part11 PARTITION OF public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#" CREATE TABLE public.cust_part11 PARTITION OF public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#"
FOR VALUES WITH (modulus 2, remainder 1); FOR VALUES WITH (modulus 2, remainder 1)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.cust_part11 ALTER TABLE IF EXISTS public.cust_part11
OWNER to postgres; OWNER to postgres;

View File

@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#
ON UPDATE NO ACTION ON UPDATE NO ACTION
ON DELETE NO ACTION ON DELETE NO ACTION
DEFERRABLE, DEFERRABLE,
CONSTRAINT ex_constr EXCLUDE USING gist ( CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>) col1 WITH =)
) )

View File

@ -1,3 +1,3 @@
ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT ex_constr EXCLUDE USING gist ( ADD CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>); col1 WITH =);

View File

@ -18,9 +18,9 @@ ALTER TABLE IF EXISTS public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#"
REVOKE ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" FROM PUBLIC; REVOKE ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;
GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO postgres;
GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC; GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO postgres;
COMMENT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" COMMENT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#"
IS 'test comment'; IS 'test comment';

View File

@ -18,7 +18,8 @@ COMMENT ON TABLE public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public.cust_arr_small PARTITION OF public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#" CREATE TABLE public.cust_arr_small PARTITION OF public."partition_table_with_collate_$%{}[]()&*^!@""'`\/#"
FOR VALUES FROM ('20') TO ('25'); FOR VALUES FROM ('20') TO ('25')
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.cust_arr_small ALTER TABLE IF EXISTS public.cust_arr_small
OWNER to postgres; OWNER to postgres;

View File

@ -18,7 +18,8 @@ COMMENT ON TABLE public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public.cust_part11 PARTITION OF public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#" CREATE TABLE public.cust_part11 PARTITION OF public."table_with_hash_patition_$%{}[]()&*^!@\""'`\\/#"
FOR VALUES WITH (modulus 2, remainder 1); FOR VALUES WITH (modulus 2, remainder 1)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.cust_part11 ALTER TABLE IF EXISTS public.cust_part11
OWNER to postgres; OWNER to postgres;

View File

@ -6,6 +6,9 @@ CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
INCLUDING INDEXES INCLUDING INDEXES
INCLUDING STORAGE INCLUDING STORAGE
INCLUDING COMMENTS INCLUDING COMMENTS
INCLUDING GENERATED
INCLUDING IDENTITY
INCLUDING STATISTICS
); );

View File

@ -18,7 +18,8 @@ COMMENT ON TABLE public."table_with_patition_$%{}[]()&*^!@""'`\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public.cust_active PARTITION OF public."table_with_patition_$%{}[]()&*^!@""'`\/#" CREATE TABLE public.cust_active PARTITION OF public."table_with_patition_$%{}[]()&*^!@""'`\/#"
FOR VALUES IN ('ACTIVE'); FOR VALUES IN ('ACTIVE')
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.cust_active ALTER TABLE IF EXISTS public.cust_active
OWNER to postgres; OWNER to postgres;

View File

@ -15,7 +15,8 @@ ALTER TABLE IF EXISTS public."table_with_range_patition_$%{}[]()&*^!@""'`\/#"
-- Partitions SQL -- Partitions SQL
CREATE TABLE public."cust_arr_small PARTITION" PARTITION OF public."table_with_range_patition_$%{}[]()&*^!@""'`\/#" CREATE TABLE public."cust_arr_small PARTITION" PARTITION OF public."table_with_range_patition_$%{}[]()&*^!@""'`\/#"
FOR VALUES FROM ('20') TO ('25'); FOR VALUES FROM ('20') TO ('25')
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."cust_arr_small PARTITION" ALTER TABLE IF EXISTS public."cust_arr_small PARTITION"
OWNER to postgres; OWNER to postgres;

View File

@ -0,0 +1,20 @@
CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
(
LIKE public.like_tbl
INCLUDING DEFAULTS
INCLUDING CONSTRAINTS
INCLUDING INDEXES
INCLUDING STORAGE
INCLUDING COMMENTS
INCLUDING COMPRESSION
INCLUDING GENERATED
INCLUDING IDENTITY
INCLUDING STATISTICS
);
ALTER TABLE IF EXISTS public."table_like_tbl$%{}[]()&*^!@""'`\/#"
OWNER to postgres;
COMMENT ON TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
IS 'test ';

View File

@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#
ON UPDATE NO ACTION ON UPDATE NO ACTION
ON DELETE NO ACTION ON DELETE NO ACTION
DEFERRABLE, DEFERRABLE,
CONSTRAINT ex_constr EXCLUDE USING gist ( CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>) col1 WITH =)
) )
WITH ( WITH (

View File

@ -1,3 +1,3 @@
ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT ex_constr EXCLUDE USING gist ( ADD CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>); col1 WITH =);

View File

@ -16,6 +16,8 @@ TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#"
OWNER to postgres; OWNER to postgres;
REVOKE ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;
GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC; GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO postgres; GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO postgres;

View File

@ -6,6 +6,8 @@ CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
INCLUDING INDEXES INCLUDING INDEXES
INCLUDING STORAGE INCLUDING STORAGE
INCLUDING COMMENTS INCLUDING COMMENTS
INCLUDING IDENTITY
INCLUDING STATISTICS
) )
WITH ( WITH (

View File

@ -171,7 +171,9 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_without_primary_key.sql", "expected_sql_file": "create_table_without_primary_key.sql",
@ -397,7 +399,9 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_with_pk.sql", "expected_sql_file": "create_table_with_pk.sql",
@ -650,7 +654,9 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_with_pk_chk.sql", "expected_sql_file": "create_table_with_pk_chk.sql",
@ -923,7 +929,9 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false
}, },
"store_object_id": true, "store_object_id": true,
"preprocess_data": true, "preprocess_data": true,
@ -974,14 +982,14 @@
"added": [ "added": [
{ {
"name": "ex_constr", "name": "ex_constr",
"amname": "gist", "amname": "btree",
"columns": [ "columns": [
{ {
"column": "col1", "column": "col1",
"is_exp": false, "is_exp": false,
"order": false, "order": false,
"nulls_order": false, "nulls_order": false,
"operator": "<>", "operator": "=",
"is_sort_nulls_applicable": false "is_sort_nulls_applicable": false
} }
], ],
@ -1126,6 +1134,8 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"autovacuum_custom": true "autovacuum_custom": true
}, },
"store_object_id": true, "store_object_id": true,
@ -1304,6 +1314,8 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"rlspolicy": true "rlspolicy": true
}, },
"store_object_id": true, "store_object_id": true,
@ -1478,6 +1490,8 @@
"like_indexes": true, "like_indexes": true,
"like_storage": true, "like_storage": true,
"like_comments": true, "like_comments": true,
"like_identity": true,
"like_statistics": true,
"like_relation": "public.like_tbl" "like_relation": "public.like_tbl"
}, },
"store_object_id": true, "store_object_id": true,
@ -1636,6 +1650,8 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,
@ -1785,6 +1801,8 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,
@ -1937,6 +1955,8 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,

View File

@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#
ON UPDATE NO ACTION ON UPDATE NO ACTION
ON DELETE NO ACTION ON DELETE NO ACTION
DEFERRABLE, DEFERRABLE,
CONSTRAINT ex_constr EXCLUDE USING gist ( CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>) col1 WITH =)
) )

View File

@ -1,3 +1,3 @@
ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT ex_constr EXCLUDE USING gist ( ADD CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>); col1 WITH =);

View File

@ -6,6 +6,9 @@ CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
INCLUDING INDEXES INCLUDING INDEXES
INCLUDING STORAGE INCLUDING STORAGE
INCLUDING COMMENTS INCLUDING COMMENTS
INCLUDING GENERATED
INCLUDING IDENTITY
INCLUDING STATISTICS
); );

View File

@ -171,7 +171,10 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_without_primary_key.sql", "expected_sql_file": "create_table_without_primary_key.sql",
@ -397,7 +400,10 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_with_pk.sql", "expected_sql_file": "create_table_with_pk.sql",
@ -650,7 +656,10 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false
}, },
"store_object_id": true, "store_object_id": true,
"expected_sql_file": "create_table_with_pk_chk.sql", "expected_sql_file": "create_table_with_pk_chk.sql",
@ -923,7 +932,10 @@
"like_constraints": false, "like_constraints": false,
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false
}, },
"store_object_id": true, "store_object_id": true,
"preprocess_data": true, "preprocess_data": true,
@ -974,14 +986,14 @@
"added": [ "added": [
{ {
"name": "ex_constr", "name": "ex_constr",
"amname": "gist", "amname": "btree",
"columns": [ "columns": [
{ {
"column": "col1", "column": "col1",
"is_exp": false, "is_exp": false,
"order": false, "order": false,
"nulls_order": false, "nulls_order": false,
"operator": "<>", "operator": "=",
"is_sort_nulls_applicable": false "is_sort_nulls_applicable": false
} }
], ],
@ -1126,6 +1138,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"autovacuum_custom": true "autovacuum_custom": true
}, },
"store_object_id": true, "store_object_id": true,
@ -1304,6 +1319,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"rlspolicy": true "rlspolicy": true
}, },
"store_object_id": true, "store_object_id": true,
@ -1478,6 +1496,9 @@
"like_indexes": true, "like_indexes": true,
"like_storage": true, "like_storage": true,
"like_comments": true, "like_comments": true,
"like_generated": true,
"like_identity": true,
"like_statistics": true,
"like_relation": "public.like_tbl" "like_relation": "public.like_tbl"
}, },
"store_object_id": true, "store_object_id": true,
@ -1636,6 +1657,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,
@ -1785,6 +1809,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,
@ -1935,6 +1962,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,
@ -2087,6 +2117,9 @@
"like_indexes": false, "like_indexes": false,
"like_storage": false, "like_storage": false,
"like_comments": false, "like_comments": false,
"like_identity": false,
"like_statistics": false,
"like_generated": false,
"autovacuum_custom": false "autovacuum_custom": false
}, },
"store_object_id": true, "store_object_id": true,

View File

@ -0,0 +1,20 @@
CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
(
LIKE public.like_tbl
INCLUDING DEFAULTS
INCLUDING CONSTRAINTS
INCLUDING INDEXES
INCLUDING STORAGE
INCLUDING COMMENTS
INCLUDING COMPRESSION
INCLUDING GENERATED
INCLUDING IDENTITY
INCLUDING STATISTICS
);
ALTER TABLE IF EXISTS public."table_like_tbl$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb;
COMMENT ON TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
IS 'test ';

View File

@ -17,8 +17,8 @@ CREATE TABLE IF NOT EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#
ON UPDATE NO ACTION ON UPDATE NO ACTION
ON DELETE NO ACTION ON DELETE NO ACTION
DEFERRABLE, DEFERRABLE,
CONSTRAINT ex_constr EXCLUDE USING gist ( CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>) col1 WITH =)
) )
WITH ( WITH (

View File

@ -1,3 +1,3 @@
ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_fk_constraints$%{}[]()&*^!@""'`\/#"
ADD CONSTRAINT ex_constr EXCLUDE USING gist ( ADD CONSTRAINT ex_constr EXCLUDE USING btree (
col1 WITH <>); col1 WITH =);

View File

@ -16,6 +16,8 @@ TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb; OWNER to enterprisedb;
REVOKE ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;
GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC; GRANT SELECT ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO enterprisedb; GRANT ALL ON TABLE public."table_with_advanced_options_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -6,6 +6,8 @@ CREATE TABLE public."table_like_tbl$%{}[]()&*^!@""'`\/#"
INCLUDING INDEXES INCLUDING INDEXES
INCLUDING STORAGE INCLUDING STORAGE
INCLUDING COMMENTS INCLUDING COMMENTS
INCLUDING IDENTITY
INCLUDING STATISTICS
) )
WITH ( WITH (

View File

@ -974,14 +974,14 @@
"added": [ "added": [
{ {
"name": "ex_constr", "name": "ex_constr",
"amname": "gist", "amname": "btree",
"columns": [ "columns": [
{ {
"column": "col1", "column": "col1",
"is_exp": false, "is_exp": false,
"order": false, "order": false,
"nulls_order": false, "nulls_order": false,
"operator": "<>", "operator": "=",
"is_sort_nulls_applicable": false "is_sort_nulls_applicable": false
} }
], ],
@ -1478,6 +1478,8 @@
"like_indexes": true, "like_indexes": true,
"like_storage": true, "like_storage": true,
"like_comments": true, "like_comments": true,
"like_identity": true,
"like_statistics": true,
"like_relation": "public.like_tbl" "like_relation": "public.like_tbl"
}, },
"store_object_id": true, "store_object_id": true,

View File

@ -608,6 +608,131 @@
"error_msg": "Mocked Internal Server Error", "error_msg": "Mocked Internal Server Error",
"test_result_data": {} "test_result_data": {}
} }
},
{
"name": "Create: Add Table for like table",
"is_positive_test": true,
"inventory_data": {},
"test_data": {
"name": "like_tbl",
"columns": [
{
"name": "id",
"cltype": "integer",
"is_primary_key": true
},
{
"name": "name",
"cltype": "text"
}
],
"primary_key": [
{
"columns": [
{
"column": "id"
}
],
"include": []
}
],
"unique_constraint": [
{
"name": "",
"columns": [
{
"column": "name"
}
],
"include": []
}
]
},
"mocking_required": false,
"mock_data": {},
"expected_data": {
"status_code": 200,
"error_msg": null,
"test_result_data": {}
}
},
{
"name": "Create: Add Table with like option",
"is_positive_test": true,
"inventory_data": {},
"test_data": {
"columns": [],
"like_default_value": true,
"like_constraints": true,
"like_indexes": true,
"like_storage": true,
"like_comments": true,
"like_identity": true,
"like_statistics": true,
"like_relation": "public.like_tbl"
},
"mocking_required": false,
"mock_data": {},
"expected_data": {
"status_code": 200,
"error_msg": null,
"test_result_data": {}
}
},
{
"name": "Create: Add Table with like option 12 plus",
"is_positive_test": true,
"inventory_data": {
"server_min_version": 120000,
"skip_msg": "Like generated is not supported by PPAS/PG 11.0 and below"
},
"test_data": {
"columns": [],
"like_default_value": true,
"like_constraints": true,
"like_indexes": true,
"like_storage": true,
"like_comments": true,
"like_identity": true,
"like_statistics": true,
"like_generated": true,
"like_relation": "public.like_tbl"
},
"mocking_required": false,
"mock_data": {},
"expected_data": {
"status_code": 200,
"error_msg": null,
"test_result_data": {}
}
},
{
"name": "Create: Add Table with like option 14 plus",
"is_positive_test": true,
"inventory_data": {
"server_min_version": 140000,
"skip_msg": "Like compression is not supported by PPAS/PG 14.0 and below"
},
"test_data": {
"columns": [],
"like_default_value": true,
"like_constraints": true,
"like_indexes": true,
"like_storage": true,
"like_comments": true,
"like_identity": true,
"like_statistics": true,
"like_generated": true,
"like_compression": true,
"like_relation": "public.like_tbl"
},
"mocking_required": false,
"mock_data": {},
"expected_data": {
"status_code": 200,
"error_msg": null,
"test_result_data": {}
}
} }
], ],
"table_delete": [ "table_delete": [

View File

@ -95,6 +95,10 @@ describe('TableSchema', ()=>{
like_indexes: false, like_indexes: false,
like_storage: false, like_storage: false,
like_comments: false, like_comments: false,
like_compression: false,
like_generated: false,
like_identity: false,
like_statistics: false
}); });
}); });