Added compression method option while creating a column. #6379

This commit is contained in:
Akshay Joshi 2023-09-14 11:56:00 +05:30
parent d69b4282c8
commit ffec77d50b
52 changed files with 2939 additions and 11 deletions

View File

@ -39,6 +39,10 @@ are disabled if inapplicable.)
a text value.
* Use the drop-down listbox next to *Collation* to apply a collation setting to
the column.
* Use the drop-down listbox next to *Compression* to set the compression method
for the column. Compression is supported only for variable-width data types,
and is used only when the column's storage mode is main or extended. This
option is available from v14 and above.
Click the *Constraints* tab to continue.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -20,8 +20,10 @@ Bundled PostgreSQL Utilities
New features
************
| `Issue #642 <https://github.com/pgadmin-org/pgadmin4/issues/642>`_ - Added support to select/deselect objects in the Backup dialog.
| `Issue #4805 <https://github.com/pgadmin-org/pgadmin4/issues/4805>`_ - Added all the new options of the 'WITH' clause in the subscription dialog.
| `Issue #6378 <https://github.com/pgadmin-org/pgadmin4/issues/6378>`_ - Added USING method while creating the table.
| `Issue #6379 <https://github.com/pgadmin-org/pgadmin4/issues/6379>`_ - Added compression method option while creating a column.
| `Issue #6383 <https://github.com/pgadmin-org/pgadmin4/issues/6383>`_ - Added Strategy, Locale Provider, ICU Locale, ICU Rules, and OID options while creating a database.
| `Issue #6400 <https://github.com/pgadmin-org/pgadmin4/issues/6400>`_ - Added USING method while creating the materialized view.
| `Issue #6736 <https://github.com/pgadmin-org/pgadmin4/issues/6736>`_ - Add support for additional ID token claim checks for OAuth 2 authentication.
@ -34,5 +36,8 @@ Housekeeping
Bug fixes
*********
| `Issue #6274 <https://github.com/pgadmin-org/pgadmin4/issues/6274>`_ - Fix an issue where user is not able to change the password when SMTP is not configured.
| `Issue #6704 <https://github.com/pgadmin-org/pgadmin4/issues/6704>`_ - Ensure user is redirected to login page after failed login.
| `Issue #6712 <https://github.com/pgadmin-org/pgadmin4/issues/6712>`_ - Ensure that Materialized view size fields in "Statistics" should be human-readable.
| `Issue #6730 <https://github.com/pgadmin-org/pgadmin4/issues/6730>`_ - Fix an issue where changing the password shows success but the new password is not working.
| `Issue #6738 <https://github.com/pgadmin-org/pgadmin4/issues/6738>`_ - Fix an issue where login form doesn't appear if internal auth source is removed.

View File

@ -341,6 +341,23 @@ export default class ColumnSchema extends BaseUISchema {
},{
id: 'max_val_attprecision', skipChange: true, visible: false, type: '',
},{
id: 'attcompression', label: gettext('Compression'),
group: gettext('Definition'), type: 'select', deps: ['cltype'],
controlProps: { placeholder: gettext('Select compression'), allowClear: false},
options: [
{label: 'PGLZ', value: 'pglz'},
{label: 'LZ4', value: 'lz4'}
],
disabled: function(state) {
return !obj.attlenRange(state);
},
depChange: (state)=>{
if(!obj.attlenRange(state)) {
return { attcompression: '' };
}
},
min_version: 140000,
}, {
id: 'collspcname', label: gettext('Collation'), cell: 'select',
type: 'select', group: gettext('Definition'),
deps: ['cltype'], options: this.collspcnameOptions,

View File

@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION lz4;

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_comp_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_comp_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION lz4;

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION pglz;

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_comp_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_comp_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION pglz;

View File

@ -0,0 +1,926 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Table for testing column node (v.12+)",
"endpoint": "NODE-table.obj",
"sql_endpoint": "NODE-table.sql_id",
"data": {
"name": "table_3_$%{}[]()&*^!@\"'`\\/#",
"is_partitioned": false,
"columns": [],
"schema": "testschema"
},
"store_object_id": true
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_1_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
},
"expected_sql_file": "create_column_int.sql",
"expected_msql_file": "create_column_int.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 1,
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"cltype": "real",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_int.sql",
"expected_msql_file": "alter_column_int.msql"
},
{
"type": "alter",
"name": "Alter Column (Privilege change)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 1,
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
"attacl": {
"changed": [
{
"grantee": "postgres",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_alt_privilege.sql",
"expected_msql_file": "alter_column_alt_privilege.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Character type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_2_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "character varying",
"collspcname": "pg_catalog.\"C\"",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "50",
"attprecision": "",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_char.sql",
"expected_msql_file": "create_column_char.msql"
},
{
"type": "alter",
"name": "Alter Column (Character type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 2,
"name": "new_col_2_$%{}[]()&*^!@\"'`\\/#",
"attlen": "",
"attstattarget": "5",
"attstorage": "p",
"description": "Comment for alter",
"cltype": "character",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_char.sql",
"expected_msql_file": "alter_column_char.msql"
},
{
"type": "delete",
"name": "Drop Column (Character type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_2_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with identity",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"attidentity": "a",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "99999",
"seqcache": "10",
"seqcycle": true,
"colconstype": "i"
},
"expected_sql_file": "create_column_int_identity.sql",
"expected_msql_file": "create_column_int_identity.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with identity",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"name": "new_col_3_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_identity.sql",
"expected_msql_file": "alter_column_identity.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) drop identity",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"colconstype": "n"
},
"expected_sql_file": "alter_column_drop_identity.sql",
"expected_msql_file": "alter_column_drop_identity.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_3_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with Generated feature",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_4_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "g",
"genexpr": "1 + 2 + 3",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_int_generated.sql",
"expected_msql_file": "create_column_int_generated.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with Generated feature",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 4,
"name": "new_col_4_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_generated.sql",
"expected_msql_file": "alter_column_generated.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_4_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_5_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"min_val": 0,
"max_val": 1000,
"cltype": "numeric",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "10",
"attprecision": "5",
"attidentity": "a",
"attoptions": [
{
"name": "n_distinct",
"value": "1"
}
],
"seclabels": []
},
"expected_sql_file": "create_column_numeric.sql",
"expected_msql_file": "create_column_numeric.msql"
},
{
"type": "alter",
"name": "Alter Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "new_col_5_$%{}[]()&*^!@\"'`\\/#",
"attnum": 5,
"attlen": "15",
"attprecision": "6",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_numeric.sql",
"expected_msql_file": "alter_column_numeric.msql"
},
{
"type": "alter",
"name": "Alter Column (Remove Length)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"attlen": ""
},
"expected_sql_file": "alter_column_remove_length.sql",
"expected_msql_file": "alter_column_remove_length.msql"
},
{
"type": "delete",
"name": "Drop Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_5_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Dummy Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "dummy1",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
}
},
{
"type": "create",
"name": "Create Dummy Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "dummy2",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_8_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "g",
"genexpr": "dummy1 + dummy2",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_int_generated_with_existing_columns.sql",
"expected_msql_file": "create_column_int_generated_with_existing_columns.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 8,
"name": "new_col_8_$%{}[]()&*^!@\"'`\\/#",
"genexpr": "dummy1 - dummy2",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_generated_with_existing_columns.sql",
"expected_msql_file": "alter_column_generated_with_existing_columns.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_8_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with identity (Generated by default)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_9_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"attidentity": "d",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "99999",
"seqcache": "10",
"seqcycle": true,
"colconstype": "i"
},
"expected_sql_file": "create_column_int_identity_by_default.sql",
"expected_msql_file": "create_column_int_identity_by_default.msql"
},
{
"type": "alter",
"name": "Alter Column with identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"name": "new_col_9_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"seqincrement": "2",
"seqmax": "200",
"seqcache": "2",
"seqcycle": true,
"seqmin": "1"
},
"expected_sql_file": "alter_column_identity_by_default.sql",
"expected_msql_file": "alter_column_identity_by_default.msql"
},
{
"type": "alter",
"name": "Alter Column with drop identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"colconstype": "n"
},
"expected_sql_file": "alter_column_drop_identity_by_default.sql",
"expected_msql_file": "alter_column_drop_identity_by_default.msql"
},
{
"type": "delete",
"name": "Drop Column Column with identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_9_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_6_$%{}[]()&*^!@\"'`\\/#",
"cltype": "bigint",
"attacl": [],
"description": "demo comments",
"is_primary_key": false,
"attnotnull": true,
"attlen": null,
"attprecision": null,
"attidentity": "d",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "10",
"seqcache": "1",
"seqcycle": true,
"colconstype": "i",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_identity_for_restart_seq.sql",
"expected_msql_file": "create_column_identity_for_restart_seq.msql"
},
{
"type": "alter",
"name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnotnull": true,
"attidentity": "a",
"seqstart": 2,
"seqcycle": false
},
"expected_sql_file": "alter_column_identity_for_restart_seq.sql",
"expected_msql_file": "alter_column_identity_for_restart_seq.msql"
},
{
"type": "alter",
"name": "Alter identity Column (ALWAYS) for combination of identity options & Update START",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"attidentity": "a",
"seqincrement": "3",
"seqstart": "3",
"seqmin": "3",
"seqmax": "30",
"seqcache": "3",
"seqcycle": true
},
"expected_sql_file": "alter_column_identity_for_comb_start_seq.sql",
"expected_msql_file": "alter_column_identity_for_comb_start_seq.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col_6_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with text & default value",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#",
"cltype": "text",
"attacl": [],
"description": "test comment",
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": [],
"defval": "'xyz'"
},
"expected_sql_file": "create_column_text_with_default_value.sql",
"expected_msql_file": "create_column_text_with_default_value.msql"
},
{
"type": "alter",
"name": "Alter Column with text & update default value",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#",
"defval": "'changed default value'",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_text_with_default_value.sql",
"expected_msql_file": "alter_column_text_with_default_value.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with time with time zone & default value using function",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#",
"cltype": "time with time zone",
"attacl": [],
"description": "test comment",
"min_val_attlen": 0,
"max_val_attlen": 6,
"is_primary_key": false,
"attnotnull": false,
"attlen": "4",
"attprecision": null,
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": [],
"defval": "now()"
},
"expected_sql_file": "create_column_timestamp_with_default_value_using_function.sql",
"expected_msql_file": "create_column_timestamp_with_default_value_using_function.msql"
},
{
"type": "alter",
"name": "Alter Column with time with time zone & update length",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#",
"attlen": "6",
"attnotnull": true,
"description": "test comment modification"
},
"expected_sql_file": "alter_column_timestamp_with_default_value_using_function.sql",
"expected_msql_file": "alter_column_timestamp_with_default_value_using_function.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with interger_array and options",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#",
"cltype": "integer[]",
"attacl": [],
"description": "comment",
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "n",
"attoptions": [
{
"name": "n_distinct",
"value": "1"
}
],
"seclabels": []
},
"expected_sql_file": "create_column_with_interger_array_and_options.sql",
"expected_msql_file": "create_column_with_interger_array_and_options.msql"
},
{
"type": "alter",
"name": "Alter Column with interger_array and options",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#",
"attoptions": {
"changed": [
{
"name": "n_distinct",
"value": "2"
}
]
}
},
"expected_sql_file": "alter_column_with_interger_array_and_options.sql",
"expected_msql_file": "alter_column_with_interger_array_and_options.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with compression",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#",
"cltype": "character varying",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attcompression": "pglz",
"attoptions": [],
"seclabels": [],
"defval": "1"
},
"expected_sql_file": "create_column_comp.sql",
"expected_msql_file": "create_column_comp.msql"
},
{
"type": "alter",
"name": "Alter Column compression type",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#",
"attcompression": "lz4"
},
"expected_sql_file": "alter_column_compression.sql",
"expected_msql_file": "alter_column_compression.msql"
},
{
"type": "delete",
"name": "Drop Column with compression",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,4 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__1_$%{}[]()&*^!@""'`\/#" SET DEFAULT 'changed default value';
GRANT SELECT("col__1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,11 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__1_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__1_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__1_$%{}[]()&*^!@""'`\/#" text COLLATE pg_catalog."default" DEFAULT 'changed default value'::text;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__1_$%{}[]()&*^!@""'`\/#"
IS 'test comment';
GRANT SELECT("col__1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -0,0 +1,7 @@
ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__2_$%{}[]()&*^!@""'`\/#" TYPE time(6) with time zone ;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__2_$%{}[]()&*^!@""'`\/#" SET NOT NULL;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
IS 'test comment modification';

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__2_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__2_$%{}[]()&*^!@""'`\/#" time(6) with time zone NOT NULL DEFAULT now();
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
IS 'test comment modification';

View File

@ -0,0 +1,3 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__3_$%{}[]()&*^!@""'`\/#"
SET (n_distinct=2);

View File

@ -0,0 +1,13 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__3_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__3_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__3_$%{}[]()&*^!@""'`\/#" integer[] NOT NULL;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__3_$%{}[]()&*^!@""'`\/#"
IS 'comment';
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__3_$%{}[]()&*^!@""'`\/#"
SET (n_distinct=2);

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__1_$%{}[]()&*^!@""'`\/#" text DEFAULT 'xyz';
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__1_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__1_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__1_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__1_$%{}[]()&*^!@""'`\/#" text COLLATE pg_catalog."default" DEFAULT 'xyz'::text;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__1_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__2_$%{}[]()&*^!@""'`\/#" time(4) with time zone DEFAULT now();
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__2_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__2_$%{}[]()&*^!@""'`\/#" time(4) with time zone DEFAULT now();
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__2_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,9 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__3_$%{}[]()&*^!@""'`\/#" integer[] NOT NULL;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__3_$%{}[]()&*^!@""'`\/#"
IS 'comment';
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__3_$%{}[]()&*^!@""'`\/#"
SET (n_distinct=1);

View File

@ -0,0 +1,13 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__3_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col__3_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col__3_$%{}[]()&*^!@""'`\/#" integer[] NOT NULL;
COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col__3_$%{}[]()&*^!@""'`\/#"
IS 'comment';
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col__3_$%{}[]()&*^!@""'`\/#"
SET (n_distinct=1);

View File

@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION lz4;

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_comp_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_comp_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION lz4;

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION pglz;

View File

@ -0,0 +1,9 @@
-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_comp_$%{}[]()&*^!@""'`\/#"
-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_comp_$%{}[]()&*^!@""'`\/#";
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ADD COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" character varying COLLATE pg_catalog."default" NOT NULL DEFAULT 1;
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN "col_comp_$%{}[]()&*^!@""'`\/#" SET COMPRESSION pglz;

View File

@ -0,0 +1,926 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Table for testing column node (v.12+)",
"endpoint": "NODE-table.obj",
"sql_endpoint": "NODE-table.sql_id",
"data": {
"name": "table_3_$%{}[]()&*^!@\"'`\\/#",
"is_partitioned": false,
"columns": [],
"schema": "testschema"
},
"store_object_id": true
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_1_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
},
"expected_sql_file": "create_column_int.sql",
"expected_msql_file": "create_column_int.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 1,
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"cltype": "real",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_int.sql",
"expected_msql_file": "alter_column_int.msql"
},
{
"type": "alter",
"name": "Alter Column (Privilege change)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 1,
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
"attacl": {
"changed": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_alt_privilege.sql",
"expected_msql_file": "alter_column_alt_privilege.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Character type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_2_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "character varying",
"collspcname": "pg_catalog.\"C\"",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "50",
"attprecision": "",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_char.sql",
"expected_msql_file": "create_column_char.msql"
},
{
"type": "alter",
"name": "Alter Column (Character type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 2,
"name": "new_col_2_$%{}[]()&*^!@\"'`\\/#",
"attlen": null,
"attstattarget": "5",
"attstorage": "p",
"description": "Comment for alter",
"cltype": "character",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_char.sql",
"expected_msql_file": "alter_column_char.msql"
},
{
"type": "delete",
"name": "Drop Column (Character type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_2_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with identity",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"attidentity": "a",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "99999",
"seqcache": "10",
"seqcycle": true,
"colconstype": "i"
},
"expected_sql_file": "create_column_int_identity.sql",
"expected_msql_file": "create_column_int_identity.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with identity",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"name": "new_col_3_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_identity.sql",
"expected_msql_file": "alter_column_identity.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) drop identity",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"colconstype": "n"
},
"expected_sql_file": "alter_column_drop_identity.sql",
"expected_msql_file": "alter_column_drop_identity.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_3_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with Generated feature",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_4_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "g",
"genexpr": "1 + 2 + 3",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_int_generated.sql",
"expected_msql_file": "create_column_int_generated.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with Generated feature",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 4,
"name": "new_col_4_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_generated.sql",
"expected_msql_file": "alter_column_generated.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_4_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_5_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"min_val": 0,
"max_val": 1000,
"cltype": "numeric",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "10",
"attprecision": "5",
"attidentity": "a",
"attoptions": [
{
"name": "n_distinct",
"value": "1"
}
],
"seclabels": []
},
"expected_sql_file": "create_column_numeric.sql",
"expected_msql_file": "create_column_numeric.msql"
},
{
"type": "alter",
"name": "Alter Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "new_col_5_$%{}[]()&*^!@\"'`\\/#",
"attnum": 5,
"attlen": "15",
"attprecision": "6",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_numeric.sql",
"expected_msql_file": "alter_column_numeric.msql"
},
{
"type": "alter",
"name": "Alter Column (Remove Length)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 3,
"attlen": ""
},
"expected_sql_file": "alter_column_remove_length.sql",
"expected_msql_file": "alter_column_remove_length.msql"
},
{
"type": "delete",
"name": "Drop Column (Numeric type with Length Precision & Variables)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_5_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Dummy Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "dummy1",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
}
},
{
"type": "create",
"name": "Create Dummy Column (Integer/Numeric type)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "dummy2",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"defval": "1"
}
},
{
"type": "create",
"name": "Create Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_8_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "g",
"genexpr": "dummy1 + dummy2",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_int_generated_with_existing_columns.sql",
"expected_msql_file": "create_column_int_generated_with_existing_columns.msql"
},
{
"type": "alter",
"name": "Alter Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 8,
"name": "new_col_8_$%{}[]()&*^!@\"'`\\/#",
"genexpr": "dummy1 - dummy2",
"description": "Comment for alter",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_generated_with_existing_columns.sql",
"expected_msql_file": "alter_column_generated_with_existing_columns.msql"
},
{
"type": "delete",
"name": "Drop Column (Integer/Numeric type) with Generated feature with columns",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_8_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with identity (Generated by default)",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_9_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for create",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attoptions": [],
"seclabels": [],
"attidentity": "d",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "99999",
"seqcache": "10",
"seqcycle": true,
"colconstype": "i"
},
"expected_sql_file": "create_column_int_identity_by_default.sql",
"expected_msql_file": "create_column_int_identity_by_default.msql"
},
{
"type": "alter",
"name": "Alter Column with identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"name": "new_col_9_$%{}[]()&*^!@\"'`\\/#",
"description": "Comment for alter",
"seqincrement": "2",
"seqmax": "200",
"seqcache": "2",
"seqcycle": true,
"seqmin": "1"
},
"expected_sql_file": "alter_column_identity_by_default.sql",
"expected_msql_file": "alter_column_identity_by_default.msql"
},
{
"type": "alter",
"name": "Alter Column with drop identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"colconstype": "n"
},
"expected_sql_file": "alter_column_drop_identity_by_default.sql",
"expected_msql_file": "alter_column_drop_identity_by_default.msql"
},
{
"type": "delete",
"name": "Drop Column Column with identity (Generated by default)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "new_col_9_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_6_$%{}[]()&*^!@\"'`\\/#",
"cltype": "bigint",
"attacl": [],
"description": "demo comments",
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attidentity": "d",
"seqincrement": "1",
"seqstart": "1",
"seqmin": "1",
"seqmax": "10",
"seqcache": "1",
"seqcycle": true,
"colconstype": "i",
"attoptions": [],
"seclabels": []
},
"expected_sql_file": "create_column_identity_for_restart_seq.sql",
"expected_msql_file": "create_column_identity_for_restart_seq.msql"
},
{
"type": "alter",
"name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnotnull": true,
"attidentity": "a",
"seqstart": 2,
"seqcycle": false
},
"expected_sql_file": "alter_column_identity_for_restart_seq.sql",
"expected_msql_file": "alter_column_identity_for_restart_seq.msql"
},
{
"type": "alter",
"name": "Alter identity Column (ALWAYS) for combination of identity options & Update START",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"attnum": 9,
"attidentity": "a",
"seqincrement": "3",
"seqstart": "3",
"seqmin": "3",
"seqmax": "30",
"seqcache": "3",
"seqcycle": true
},
"expected_sql_file": "alter_column_identity_for_comb_start_seq.sql",
"expected_msql_file": "alter_column_identity_for_comb_start_seq.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col_6_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with text & default value",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#",
"cltype": "text",
"attacl": [],
"description": "test comment",
"is_primary_key": false,
"attnotnull": false,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": [],
"defval": "'xyz'"
},
"expected_sql_file": "create_column_text_with_default_value.sql",
"expected_msql_file": "create_column_text_with_default_value.msql"
},
{
"type": "alter",
"name": "Alter Column with text & update default value",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#",
"defval": "'changed default value'",
"attacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_column_text_with_default_value.sql",
"expected_msql_file": "alter_column_text_with_default_value.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__1_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with time with time zone & default value using function",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#",
"cltype": "time with time zone",
"attacl": [],
"description": "test comment",
"min_val_attlen": 0,
"max_val_attlen": 6,
"is_primary_key": false,
"attnotnull": false,
"attlen": "4",
"attprecision": null,
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": [],
"defval": "now()"
},
"expected_sql_file": "create_column_timestamp_with_default_value_using_function.sql",
"expected_msql_file": "create_column_timestamp_with_default_value_using_function.msql"
},
{
"type": "alter",
"name": "Alter Column with time with time zone & update length",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#",
"attlen": "6",
"attnotnull": true,
"description": "test comment modification"
},
"expected_sql_file": "alter_column_timestamp_with_default_value_using_function.sql",
"expected_msql_file": "alter_column_timestamp_with_default_value_using_function.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__2_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with interger_array and options",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#",
"cltype": "integer[]",
"attacl": [],
"description": "comment",
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attidentity": "a",
"colconstype": "n",
"attoptions": [
{
"name": "n_distinct",
"value": "1"
}
],
"seclabels": []
},
"expected_sql_file": "create_column_with_interger_array_and_options.sql",
"expected_msql_file": "create_column_with_interger_array_and_options.msql"
},
{
"type": "alter",
"name": "Alter Column with interger_array and options",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#",
"attoptions": {
"changed": [
{
"name": "n_distinct",
"value": "2"
}
]
}
},
"expected_sql_file": "alter_column_with_interger_array_and_options.sql",
"expected_msql_file": "alter_column_with_interger_array_and_options.msql"
},
{
"type": "delete",
"name": "Drop Column with identity (ALWAYS)",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col__3_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Column with compression",
"endpoint": "NODE-column.obj",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#",
"cltype": "character varying",
"attacl": [],
"is_primary_key": false,
"attnotnull": true,
"attlen": "",
"attprecision": "",
"attcompression": "pglz",
"attoptions": [],
"seclabels": [],
"defval": "1"
},
"expected_sql_file": "create_column_comp.sql",
"expected_msql_file": "create_column_comp.msql"
},
{
"type": "alter",
"name": "Alter Column compression type",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"msql_endpoint": "NODE-column.msql_id",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#",
"attcompression": "lz4"
},
"expected_sql_file": "alter_column_compression.sql",
"expected_msql_file": "alter_column_compression.msql"
},
{
"type": "delete",
"name": "Drop Column with compression",
"endpoint": "NODE-column.obj_id",
"sql_endpoint": "NODE-column.sql_id",
"data": {
"name": "col_comp_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,66 @@
{% import 'columns/macros/security.macros' as SECLABEL %}
{% import 'columns/macros/privilege.macros' as PRIVILEGE %}
{% import 'macros/variable.macros' as VARIABLE %}
{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %}
{### Add column ###}
{% if data.name and data.cltype %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ADD COLUMN {{conn|qtIdent(data.name)}} {% if is_sql %}{{data.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, data.cltype, data.attlen, data.attprecision, data.hasSqrBracket) }}{% endif %}{% if data.collspcname %}
COLLATE {{data.collspcname}}{% endif %}{% if data.attnotnull %}
NOT NULL{% endif %}{% if data.defval is defined and data.defval is not none and data.defval != '' and data.colconstype != 'g' %}
DEFAULT {{data.defval}}{% endif %}{% if data.colconstype == 'i' %}{% if data.attidentity and data.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif data.attidentity and data.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %}
{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %}
{% if data.seqcycle is defined and data.seqcycle %}
CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %}
INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%}
START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%}
MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%}
MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%}
CACHE {{data.seqcache|int}} {% endif %}
{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %}
{% endif %}{% endif %}{% if data.colconstype == 'g' and data.genexpr and data.genexpr != '' %} GENERATED ALWAYS AS ({{data.genexpr}}) STORED{% endif %};
{### Add comments ###}
{% if data and data.description and data.description != None %}
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
IS {{data.description|qtLiteral(conn)}};
{% endif %}
{### Add variables to column ###}
{% if data.attoptions %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
{{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }}
{% endif %}
{### Alter column statistics value ###}
{% if data.attstattarget is defined and data.attstattarget > -1 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {{conn|qtTypeIdent(data.name)}} SET STATISTICS {{data.attstattarget}};
{% endif %}
{### Alter column storage value ###}
{% if data.attstorage is defined and data.attstorage != data.defaultstorage %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {{conn|qtTypeIdent(data.name)}} SET STORAGE {%if data.attstorage == 'p' %}
PLAIN{% elif data.attstorage == 'm'%}MAIN{% elif data.attstorage == 'e'%}
EXTERNAL{% elif data.attstorage == 'x'%}EXTENDED{% endif %};
{% endif %}
{### Alter column compression value ###}
{% if data.attcompression is defined and data.attcompression is not none and data.attcompression != '' %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {{conn|qtTypeIdent(data.name)}} SET COMPRESSION {{data.attcompression}};
{% endif %}
{### ACL ###}
{% if data.attacl %}
{% for priv in data.attacl %}
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% endfor %}
{% endif %}
{### Security Lables ###}
{% if data.seclabels %}
{% for r in data.seclabels %}
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% endfor %}
{% endif %}

View File

@ -0,0 +1,43 @@
SELECT DISTINCT ON (att.attnum) att.attname as name, att.atttypid, att.attlen, att.attnum, att.attndims,
att.atttypmod, att.attacl, att.attnotnull, att.attoptions, att.attstattarget,
att.attstorage, att.attidentity,
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
pg_catalog.format_type(ty.oid,NULL) AS typname,
pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname,
pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype,
CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid,
(SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = ty.typnamespace) as typnspname,
ty.typstorage AS defaultstorage,
description, pi.indkey,
(SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup,
CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN
pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname))
ELSE '' END AS collspcname,
EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk,
(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels,
(CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column,
(CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' WHEN (att.attgenerated in ('s')) THEN 'g' ELSE 'n' END) AS colconstype,
(CASE WHEN (att.attgenerated in ('s')) THEN pg_catalog.pg_get_expr(def.adbin, def.adrelid) END) AS genexpr, tab.relname as relname,
(CASE WHEN tab.relkind = 'v' THEN true ELSE false END) AS is_view_only,
(CASE WHEN att.attcompression = 'p' THEN 'pglz' WHEN att.attcompression = 'l' THEN 'lz4' END) AS attcompression,
seq.*
FROM pg_catalog.pg_attribute att
JOIN pg_catalog.pg_type ty ON ty.oid=atttypid
LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN (pg_catalog.pg_depend dep JOIN pg_catalog.pg_class cs ON dep.classid='pg_class'::regclass AND dep.objid=cs.oid AND cs.relkind='S') ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary
LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid
LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid
LEFT OUTER JOIN pg_catalog.pg_sequence seq ON cs.oid=seq.seqrelid
LEFT OUTER JOIN pg_catalog.pg_class tab on tab.oid = att.attrelid
WHERE att.attrelid = {{tid}}::oid
{% if clid %}
AND att.attnum = {{clid}}::int
{% endif %}
{### To show system objects ###}
{% if not show_sys_objects %}
AND att.attnum > 0
{% endif %}
AND att.attisdropped IS FALSE
ORDER BY att.attnum;

View File

@ -0,0 +1,215 @@
{% import 'columns/macros/security.macros' as SECLABEL %}
{% import 'columns/macros/privilege.macros' as PRIVILEGE %}
{% import 'macros/variable.macros' as VARIABLE %}
{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %}
{### Rename column name ###}
{% if data.name and data.name != o_data.name %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
RENAME {{conn|qtIdent(o_data.name)}} TO {{conn|qtIdent(data.name)}};
{% endif %}
{### Alter column type and collation ###}
{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname) or data.col_type_conversion is defined %}
{% if data.col_type_conversion is defined and data.col_type_conversion == False %}
-- WARNING:
-- The SQL statement below would normally be used to alter the datatype for the {{o_data.name}} column, however,
-- the current datatype cannot be cast to the target datatype so this conversion cannot be made automatically.
{% endif %}
{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %}
COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %};
{% endif %}
{### Alter column default value ###}
{% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %}
ALTER VIEW {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}};
{% elif data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}};
{% endif %}
{### Drop column default value ###}
{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT;
{% endif %}
{### Alter column not null value ###}
{% if 'attnotnull' in data and data.attnotnull != o_data.attnotnull %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attnotnull %}SET{% else %}DROP{% endif %} NOT NULL;
{% endif %}
{% if data.seqincrement or (data.seqcycle or (data.seqcycle == False and data.seqcycle != o_data.seqcycle)) or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}
{% set attidentity_params = true %}{% else %}
{% set attidentity_params = false %}{% endif %}
{### Alter column - add identity ###}
{% if data.colconstype == 'i' and 'attidentity' in data and o_data.attidentity == '' and data.attidentity != o_data.attidentity %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attidentity == 'a' %}ADD GENERATED ALWAYS AS IDENTITY{% else%}ADD GENERATED BY DEFAULT AS IDENTITY{% endif %}
{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %}
{% if data.seqcycle is defined and data.seqcycle %}
CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %}
INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%}
START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%}
MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%}
MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%}
CACHE {{data.seqcache|int}} {% endif %}
{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %};
{### Alter column - change identity - sequence options ###}
{% elif 'attidentity' in data or attidentity_params %}
{% if 'attidentity' in data and data.attidentity != '' and o_data.attidentity != '' and data.attidentity != o_data.attidentity %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET GENERATED {% if data.attidentity == 'a' %}ALWAYS{% else%}BY DEFAULT{% endif %}{% if attidentity_params == false %};{% endif %}
{% elif attidentity_params %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %}{% endif %}
{% if data.seqcycle %} SET CYCLE{% elif (data.seqcycle == False and o_data.seqcycle and data.seqcycle != o_data.seqcycle) %} SET NO CYCLE{% endif %}
{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} SET INCREMENT {{data.seqincrement|int}}{% endif %}
{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} RESTART SET START {{data.seqstart|int}}{% endif %}
{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} SET MINVALUE {{data.seqmin|int}}{% endif %}
{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} SET MAXVALUE {{data.seqmax|int}}{% endif %}
{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} SET CACHE {{data.seqcache|int}}{% endif %}{% if attidentity_params == true %};{% endif %}
{% endif %}
{### Alter column - drop identity when column constraint is changed###}
{% if 'colconstype' in data and data.colconstype == 'n' and 'colconstype' in o_data and o_data.colconstype == 'i' %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP IDENTITY;
{% endif %}
{### Alter column statistics value ###}
{% if data.attstattarget is defined and data.attstattarget != o_data.attstattarget %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STATISTICS {{data.attstattarget}};
{% endif %}
{### Alter column storage value ###}
{% if data.attstorage is defined and data.attstorage != o_data.attstorage %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STORAGE {%if data.attstorage == 'p' %}
PLAIN{% elif data.attstorage == 'm'%}MAIN{% elif data.attstorage == 'e'%}
EXTERNAL{% elif data.attstorage == 'x'%}EXTENDED{% endif %};
{% endif %}
{### Alter column compression value ###}
{% if data.attcompression is defined and data.attcompression is not none and data.attcompression != '' %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET COMPRESSION {{data.attcompression}};
{% endif %}
{% if data.description is defined and data.description != None %}
{% if data.name %}
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}}
{% else %}
COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, o_data.name)}}
{% endif %}
IS {{data.description|qtLiteral(conn)}};
{% endif %}
{### Update column variables ###}
{% if 'attoptions' in data and data.attoptions != None and data.attoptions|length > 0 %}
{% set variables = data.attoptions %}
{% if 'deleted' in variables and variables.deleted|length > 0 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
{% if data.name %}
{{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }}
{% else %}
{{ VARIABLE.UNSET(conn, 'COLUMN', o_data.name, variables.deleted) }}
{% endif %}
{% endif %}
{% if 'added' in variables and variables.added|length > 0 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
{% if data.name %}
{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }}
{% else %}
{{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.added) }}
{% endif %}
{% endif %}
{% if 'changed' in variables and variables.changed|length > 0 %}
ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}}
{% if data.name %}
{{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }}
{% else %}
{{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.changed) }}
{% endif %}
{% endif %}
{% endif %}
{### Update column privileges ###}
{# Change the privileges #}
{% if data.attacl %}
{% if 'deleted' in data.attacl %}
{% for priv in data.attacl.deleted %}
{% if data.name %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
{% else %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
{% endif %}
{% endfor %}
{% endif %}
{% if 'changed' in data.attacl %}
{% for priv in data.attacl.changed %}
{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %}
{% if data.name %}
{% if is_grantee_changed %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }}
{% else %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
{% endif %}
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% else %}
{% if is_grantee_changed %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }}
{% else %}
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
{% endif %}
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% endif %}
{% endfor %}
{% endif %}
{% if 'added' in data.attacl %}
{% for priv in data.attacl.added %}
{% if data.name %}
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% else %}
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{### Uppdate tablespace securitylabel ###}
{# The SQL generated below will change Security Label #}
{% if data.seclabels and data.seclabels|length > 0 %}
{% set seclabels = data.seclabels %}
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
{% for r in seclabels.deleted %}
{% if data.name %}
{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }}
{% else %}
{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, o_data.name, r.provider) }}
{% endif %}
{% endfor %}
{% endif %}
{% if 'added' in seclabels and seclabels.added|length > 0 %}
{% for r in seclabels.added %}
{% if data.name %}
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% else %}
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }}
{% endif %}
{% endfor %}
{% endif %}
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
{% for r in seclabels.changed %}
{% if data.name %}
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
{% else %}
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}

View File

@ -54,7 +54,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists
{% 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.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.attcompression is defined and c.attcompression is not none and c.attcompression != '' %} COMPRESSION {{c.attcompression}}{% 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 %}

View File

@ -1657,6 +1657,14 @@
"expected_sql_file": "create_table_with_partition.sql",
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
@ -1808,6 +1816,14 @@
"expected_sql_file": "create_table_with_range_partition.sql",
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with hash partition",
@ -1958,6 +1974,14 @@
"expected_sql_file": "create_table_with_hash_partition.sql",
"expected_msql_file": "create_table_with_hash_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with hash partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
@ -2111,6 +2135,14 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -1658,6 +1658,14 @@
"expected_sql_file": "create_table_with_partition.sql",
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
@ -1810,6 +1818,14 @@
"expected_sql_file": "create_table_with_range_partition.sql",
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with hash partition",
@ -1960,6 +1976,14 @@
"expected_sql_file": "create_table_with_hash_partition.sql",
"expected_msql_file": "create_table_with_hash_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with hash partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
@ -2114,6 +2138,14 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION lz4 COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION pglz,
col6 bigint
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to postgres;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col4 SET COMPRESSION lz4;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col5 SET COMPRESSION pglz;

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION lz4 COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION pglz,
col6 character varying COMPRESSION lz4 COLLATE pg_catalog."default"
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to postgres;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,4 @@
ALTER TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col6 TYPE character varying;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col6 SET COMPRESSION lz4;

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION pglz COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION lz4,
col6 bigint
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to postgres;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,12 @@
CREATE TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION pglz,
col5 bit COMPRESSION lz4,
col6 bigint
);
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to postgres;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -1663,6 +1663,14 @@
"expected_sql_file": "create_table_with_partition.sql",
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
@ -1816,6 +1824,14 @@
"expected_sql_file": "create_table_with_range_partition.sql",
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with hash partition",
@ -1966,6 +1982,14 @@
"expected_sql_file": "create_table_with_hash_partition.sql",
"expected_msql_file": "create_table_with_hash_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with hash partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
@ -2121,6 +2145,139 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with compression columns",
"endpoint": "NODE-table.obj",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"relowner": "postgres",
"relacl": [],
"description": "test comment",
"coll_inherits": "[]",
"hastoasttable": true,
"toast_autovacuum_enabled": "x",
"autovacuum_enabled": "x",
"primary_key": [],
"partitions": [],
"is_partitioned": false,
"schema": "public",
"columns": [
{
"name": "col4",
"cltype": "character varying",
"attacl": [],
"min_val_attlen": 1,
"max_val_attlen": 2147483647,
"is_primary_key": false,
"attnotnull": false,
"attlen": 30,
"attprecision": null,
"attidentity": "a",
"attcompression": "pglz",
"colconstype": "n",
"attoptions": [],
"seclabels": []
},
{
"name": "col5",
"cltype": "bit",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attidentity": "a",
"attcompression": "lz4",
"colconstype": "n",
"attoptions": [],
"seclabels": []
},
{
"name": "col6",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": []
}
],
"foreign_key": [],
"check_constraint": [],
"unique_constraint": [],
"exclude_constraint": [],
"partition_keys": []
},
"store_object_id": true,
"expected_sql_file": "create_table_with_column_compression.sql",
"expected_msql_file": "create_table_with_column_compression_msql.sql"
},
{
"type": "alter",
"name": "Alter Table to change column compression type",
"endpoint": "NODE-table.obj_id",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"columns": {
"changed": [
{
"attnum": 1,
"attcompression": "lz4"
},
{
"attnum": 2,
"attcompression": "pglz"
}
]
}
},
"store_object_id": true,
"expected_sql_file": "alter_table_change_col_comp.sql",
"expected_msql_file": "alter_table_change_col_comp_msql.sql"
},
{
"type": "alter",
"name": "Alter Table to change column data type and compression type",
"endpoint": "NODE-table.obj_id",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"columns": {
"changed": [
{
"attnum": 3,
"cltype": "character varying",
"attcompression": "lz4"
}
]
}
},
"store_object_id": true,
"expected_sql_file": "alter_table_change_col_type_comp.sql",
"expected_msql_file": "alter_table_change_col_type_comp_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -1,5 +1,5 @@
{
"scenarios": [
"scenarios": [
{
"type": "create",
"name": "Create Table without primary key",
@ -513,7 +513,7 @@
"data": {
"name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#"
}
},
},
{
"type": "create",
"name": "Create Table with pk & check constraint",
@ -1654,6 +1654,14 @@
"expected_sql_file": "create_table_with_partition.sql",
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
@ -1805,6 +1813,14 @@
"expected_sql_file": "create_table_with_range_partition.sql",
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
@ -1958,6 +1974,14 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -1666,6 +1666,14 @@
"expected_sql_file": "create_table_with_partition.sql",
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
@ -1818,6 +1826,14 @@
"expected_sql_file": "create_table_with_range_partition.sql",
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with hash partition",
@ -1971,6 +1987,14 @@
"expected_sql_file": "create_table_with_hash_partition.sql",
"expected_msql_file": "create_table_with_hash_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with hash partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
@ -2125,6 +2149,14 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION lz4 COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION pglz,
col6 bigint
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,5 @@
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col4 SET COMPRESSION lz4;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col5 SET COMPRESSION pglz;

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION lz4 COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION pglz,
col6 character varying COMPRESSION lz4 COLLATE pg_catalog."default"
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,4 @@
ALTER TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col6 TYPE character varying;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
ALTER COLUMN col6 SET COMPRESSION lz4;

View File

@ -0,0 +1,18 @@
-- Table: public.simple_table_comp_$%{}[]()&*^!@"'`\/#
-- DROP TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#";
CREATE TABLE IF NOT EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION pglz COLLATE pg_catalog."default",
col5 bit(1) COMPRESSION lz4,
col6 bigint
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -0,0 +1,12 @@
CREATE TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
(
col4 character varying(30) COMPRESSION pglz,
col5 bit COMPRESSION lz4,
col6 bigint
);
ALTER TABLE IF EXISTS public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
OWNER to enterprisedb;
COMMENT ON TABLE public."simple_table_comp_$%{}[]()&*^!@""'`\/#"
IS 'test comment';

View File

@ -1675,6 +1675,14 @@
"expected_msql_file": "create_table_with_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with list partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition",
"endpoint": "NODE-table.obj",
@ -1828,6 +1836,14 @@
"expected_msql_file": "create_table_with_range_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with range partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with hash partition",
"endpoint": "NODE-table.obj",
@ -1982,6 +1998,14 @@
"expected_msql_file": "create_table_with_hash_partition_msql.sql"
},
{
"type": "delete",
"name": "Delete Table with hash partition",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#"
}
},
{
"type": "create",
"name": "Create Table with range partition with collate and opclass",
"endpoint": "NODE-table.obj",
@ -2136,7 +2160,139 @@
"store_object_id": true,
"expected_sql_file": "create_partition_table_with_collate.sql",
"expected_msql_file": "create_partition_table_with_collate_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#"
}
},
{
"type": "create",
"name": "Create Table with compression columns",
"endpoint": "NODE-table.obj",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"relowner": "enterprisedb",
"relacl": [],
"description": "test comment",
"coll_inherits": "[]",
"hastoasttable": true,
"toast_autovacuum_enabled": "x",
"autovacuum_enabled": "x",
"primary_key": [],
"partitions": [],
"is_partitioned": false,
"schema": "public",
"columns": [
{
"name": "col4",
"cltype": "character varying",
"attacl": [],
"min_val_attlen": 1,
"max_val_attlen": 2147483647,
"is_primary_key": false,
"attnotnull": false,
"attlen": 30,
"attprecision": null,
"attidentity": "a",
"attcompression": "pglz",
"colconstype": "n",
"attoptions": [],
"seclabels": []
},
{
"name": "col5",
"cltype": "bit",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attidentity": "a",
"attcompression": "lz4",
"colconstype": "n",
"attoptions": [],
"seclabels": []
},
{
"name": "col6",
"cltype": "bigint",
"attacl": [],
"is_primary_key": false,
"attnotnull": false,
"attidentity": "a",
"colconstype": "n",
"attoptions": [],
"seclabels": []
}
],
"foreign_key": [],
"check_constraint": [],
"unique_constraint": [],
"exclude_constraint": [],
"partition_keys": []
},
"store_object_id": true,
"expected_sql_file": "create_table_with_column_compression.sql",
"expected_msql_file": "create_table_with_column_compression_msql.sql"
},
{
"type": "alter",
"name": "Alter Table to change column compression type",
"endpoint": "NODE-table.obj_id",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"columns": {
"changed": [
{
"attnum": 1,
"attcompression": "lz4"
},
{
"attnum": 2,
"attcompression": "pglz"
}
]
}
},
"store_object_id": true,
"expected_sql_file": "alter_table_change_col_comp.sql",
"expected_msql_file": "alter_table_change_col_comp_msql.sql"
},
{
"type": "alter",
"name": "Alter Table to change column data type and compression type",
"endpoint": "NODE-table.obj_id",
"sql_endpoint": "NODE-table.sql_id",
"msql_endpoint": "NODE-table.msql_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#",
"columns": {
"changed": [
{
"attnum": 3,
"cltype": "character varying",
"attcompression": "lz4"
}
]
}
},
"store_object_id": true,
"expected_sql_file": "alter_table_change_col_type_comp.sql",
"expected_msql_file": "alter_table_change_col_type_comp_msql.sql"
},
{
"type": "delete",
"name": "Delete Table ",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "simple_table_comp_$%{}[]()&*^!@\"'`\\/#"
}
}
]
}

View File

@ -5,4 +5,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = p, disable_on_error = false, , run_as_owner = false, password_required = true, origin = 'none');
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = p, disable_on_error = false, run_as_owner = true, password_required = true, origin = 'none');

View File

@ -1,2 +1,2 @@
ALTER SUBSCRIPTION test_create_subscription
SET (synchronous_commit = 'off', binary = false, streaming = 'False', disable_on_error = false, run_as_owner = false, origin = 'none');
SET (synchronous_commit = 'off', binary = false, streaming = 'False', disable_on_error = false, origin = 'none');

View File

@ -45,7 +45,6 @@
"binary": false,
"streaming": false,
"disable_on_error": false,
"run_as_owner": false,
"origin": "none"
},
"expected_sql_file": "alter_parameters.sql",

View File

@ -29,9 +29,6 @@ const useStyles = makeStyles((theme) => ({
flexDirection: 'column',
flex: 1,
},
selectedNode: {
background: theme.otherVars.stepBg,
},
focusedNode: {
background: theme.palette.primary.light,
},
@ -139,7 +136,7 @@ function Node({ node, style, tree, hasCheckbox, onNodeSelectionChange}) {
};
return (
<div style={style} className={clsx(node.isFocused ? classes.focusedNode : '', node.isSelected ? classes.selectedNode : '')} onClick={(e) => {
<div style={style} className={clsx(node.isFocused ? classes.focusedNode : '')} onClick={(e) => {
node.focus();
e.stopPropagation();
}}>