diff --git a/docs/en_US/column_dialog.rst b/docs/en_US/column_dialog.rst index 7f4f9501e..92f4e4c32 100644 --- a/docs/en_US/column_dialog.rst +++ b/docs/en_US/column_dialog.rst @@ -43,6 +43,8 @@ are disabled if inapplicable.) 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. +* Use the drop-down listbox next to *Storage* to set the storage mode for the + column. This option is available from v16 and above. Click the *Constraints* tab to continue. diff --git a/docs/en_US/images/column_definition.png b/docs/en_US/images/column_definition.png index 2d753aaf6..68ec04af2 100644 Binary files a/docs/en_US/images/column_definition.png and b/docs/en_US/images/column_definition.png differ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js index 4473c2aab..ef7c0fd4a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js @@ -384,17 +384,38 @@ export default class ColumnSchema extends BaseUISchema { group: gettext('Definition'), },{ id: 'attstorage', label: gettext('Storage'), group: gettext('Definition'), - type: 'select', mode: ['properties', 'edit'], + type: 'select', mode: ['properties', 'edit', 'create'], cell: 'select', readonly: obj.inSchemaWithColumnCheck, controlProps: { placeholder: gettext('Select storage'), allowClear: false, }, - options: [ - {label: 'PLAIN', value: 'p'}, - {label: 'MAIN', value: 'm'}, - {label: 'EXTERNAL', value: 'e'}, - {label: 'EXTENDED', value: 'x'}, - ], + options: function() { + let options = [{ + label: gettext('PLAIN'), value: 'p' + },{ + label: gettext('MAIN'), value: 'm' + },{ + label: gettext('EXTERNAL'), value: 'e' + },{ + label: gettext('EXTENDED'), value: 'x' + }]; + + if (obj.getServerVersion() >= 160000) { + options.push({ + label: gettext('DEFAULT'), value: 'd', + }); + } + return options; + }, + visible: (state) => { + if (obj.getServerVersion() >= 160000) { + return true; + } else if (obj.isNew(state)) { + return false; + } else { + return true; + } + }, },{ id: 'defval', label: gettext('Default'), cell: 'text', type: 'text', group: gettext('Constraints'), deps: ['cltype', 'colconstype'], diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/column_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/column_test_data.json index 17560d3a7..601138fe7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/column_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/column_test_data.json @@ -201,6 +201,35 @@ "error_msg": "Mocked Internal Server Error", "test_result_data": {} } + }, + { + "name": "Create: Add column with storage", + "is_positive_test": true, + "inventory_data": {}, + "test_data": { + "server_min_version": 160000, + "skip_msg": "Creating column with storage is supported by EPAS/PG 16.0 and above.", + "name": "test_column_add_", + "cltype": "character varying", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attstorage": "e", + "description": { + "comment": "jsoncomment" + } + }, + "mocking_required": false, + "mock_data": {}, + "expected_data": { + "status_code": 200, + "error_msg": null, + "test_result_data": {} + } } ], "column_delete": [ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.msql new file mode 100644 index 000000000..14be4f161 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.msql @@ -0,0 +1,2 @@ +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.sql new file mode 100644 index 000000000..af753a1ae --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/alter_column_storage.sql @@ -0,0 +1,12 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1111_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.msql new file mode 100644 index 000000000..fb39bac4f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.msql @@ -0,0 +1,8 @@ +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE MAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.sql new file mode 100644 index 000000000..463c0c646 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/create_column_with_storage.sql @@ -0,0 +1,12 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1111_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE MAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/test.json new file mode 100644 index 000000000..f397ec12d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/16_plus/test.json @@ -0,0 +1,972 @@ +{ + "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_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with storage", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": "50", + "attstorage": "m", + "attprecision": "", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_with_storage.sql", + "expected_msql_file": "create_column_with_storage.msql" + }, + { + "type": "alter", + "name": "Alter Column storage type", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#", + "attstorage": "p" + }, + "expected_sql_file": "alter_column_storage.sql", + "expected_msql_file": "alter_column_storage.msql" + }, + { + "type": "delete", + "name": "Drop Column with storage", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#" + } + } + ] + } + \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.msql new file mode 100644 index 000000000..14be4f161 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.msql @@ -0,0 +1,2 @@ +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.sql new file mode 100644 index 000000000..af753a1ae --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/alter_column_storage.sql @@ -0,0 +1,12 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1111_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.msql new file mode 100644 index 000000000..fb39bac4f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.msql @@ -0,0 +1,8 @@ +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE MAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.sql new file mode 100644 index 000000000..463c0c646 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/create_column_with_storage.sql @@ -0,0 +1,12 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1111_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1111_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE MAIN; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/test.json new file mode 100644 index 000000000..8e1b40802 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/16_plus/test.json @@ -0,0 +1,972 @@ +{ + "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_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with storage", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": "50", + "attstorage": "m", + "attprecision": "", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_with_storage.sql", + "expected_msql_file": "create_column_with_storage.msql" + }, + { + "type": "alter", + "name": "Alter Column storage type", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#", + "attstorage": "p" + }, + "expected_sql_file": "alter_column_storage.sql", + "expected_msql_file": "alter_column_storage.msql" + }, + { + "type": "delete", + "name": "Drop Column with storage", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_1111_$%{}[]()&*^!@\"'`\\/#" + } + } + ] + } + \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/create.sql new file mode 100644 index 000000000..89ac8fe62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/create.sql @@ -0,0 +1,67 @@ +{% 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{% elif data.attstorage == 'd' %} +DEFAULT{% 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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql new file mode 100644 index 000000000..df61aed45 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql @@ -0,0 +1,216 @@ +{% 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{% elif data.attstorage == 'd'%} +DEFAULT{% 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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/16_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/16_plus/create.sql new file mode 100644 index 000000000..93ea6ecee --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/16_plus/create.sql @@ -0,0 +1,233 @@ +{% import 'macros/schemas/security.macros' as SECLABEL %} +{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} +{% import 'macros/variable.macros' as VARIABLE %} +{% import 'columns/macros/security.macros' as COLUMN_SECLABEL %} +{% import 'columns/macros/privilege.macros' as COLUMN_PRIVILEGE %} +{% import 'tables/sql/macros/constraints.macro' as CONSTRAINTS %} +{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} +{#===========================================#} +{#====== MAIN TABLE TEMPLATE STARTS HERE ======#} +{#===========================================#} +{# + If user has not provided any details but only name then + add empty bracket with table name +#} +{% set empty_bracket = ""%} +{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %} +{% set empty_bracket = "\n(\n)"%} +{% endif %} +{% set with_clause = false%} +{% if data.fillfactor or data.parallel_workers or data.toast_tuple_target or (data.autovacuum_custom and data.add_vacuum_settings_in_sql) or data.autovacuum_enabled in ('t', 'f') or (data.toast_autovacuum and data.add_vacuum_settings_in_sql) or data.toast_autovacuum_enabled in ('t', 'f') %} +{% set with_clause = true%} +{% endif %} +CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}} +{% if data.typname %} + OF {{ data.typname }} +{% endif %} +{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} +( +{% endif %} +{% if data.like_relation %} + LIKE {{ data.like_relation }}{% if data.like_default_value %} + + INCLUDING DEFAULTS{% endif %}{% if data.like_constraints %} + + INCLUDING CONSTRAINTS{% endif %}{% if data.like_indexes %} + + INCLUDING INDEXES{% endif %}{% if data.like_storage %} + + INCLUDING STORAGE{% endif %}{% if data.like_comments %} + + INCLUDING COMMENTS{% endif %}{% if data.like_compression %} + + INCLUDING COMPRESSION{% endif %}{% if data.like_generated %} + + INCLUDING GENERATED{% endif %}{% if data.like_identity %} + + INCLUDING IDENTITY{% endif %}{% if data.like_statistics %} + + INCLUDING STATISTICS{% endif %}{% if data.columns|length > 0 %}, +{% endif %} + +{% endif %} +{### Add columns ###} +{% if data.columns and data.columns|length > 0 %} +{% for c in data.columns %} +{% if c.name and c.cltype %} + {% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{%if c.attstorage is defined and c.attstorage != c.defaultstorage%} STORAGE {%if c.attstorage == 'p' %}PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%}EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% elif c.attstorage == 'd'%}DEFAULT{% endif %}{% 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 %} +{% if c.seqcycle is defined and c.seqcycle %} +CYCLE {% endif %}{% if c.seqincrement is defined and c.seqincrement|int(-1) > -1 %} +INCREMENT {{c.seqincrement|int}} {% endif %}{% if c.seqstart is defined and c.seqstart|int(-1) > -1%} +START {{c.seqstart|int}} {% endif %}{% if c.seqmin is defined and c.seqmin|int(-1) > -1%} +MINVALUE {{c.seqmin|int}} {% endif %}{% if c.seqmax is defined and c.seqmax|int(-1) > -1%} +MAXVALUE {{c.seqmax|int}} {% endif %}{% if c.seqcache is defined and c.seqcache|int(-1) > -1%} +CACHE {{c.seqcache|int}} {% endif %} +{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %}){% endif %} +{% endif %} +{% if c.colconstype == 'g' and c.genexpr and c.genexpr != '' %} GENERATED ALWAYS AS ({{c.genexpr}}) STORED{% endif %} +{% if not loop.last %}, +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# Macro to render for constraints #} +{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %} +{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %} +{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %} +{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %} +{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %} +{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %} +{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} + +){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }}{% endif %} +{% if not data.coll_inherits and not data.spcname and not with_clause and not data.amname %};{% endif %} + +{### If we are inheriting it from another table(s) ###} +{% if data.coll_inherits %} + INHERITS ({% for val in data.coll_inherits %}{% if loop.index != 1 %}, {% endif %}{{val}}{% endfor %}){% if not data.spcname and not with_clause and not data.amname %};{% endif %} +{% endif %} + +{% if data.default_amname and data.default_amname != data.amname and data.amname is not none %} +USING {{data.amname}} +{% elif data.amname and not data.default_amname %} +USING {{data.amname}}{% if not data.spcname and not with_clause %};{% endif %} +{% endif %} + +{% if with_clause %} +{% set ns = namespace(add_comma=false) %} +WITH ( +{% if data.fillfactor %}{% set ns.add_comma = true%} + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.parallel_workers %} +{% if ns.add_comma %}, +{% endif %} + parallel_workers = {{ data.parallel_workers }}{% set ns.add_comma = true%}{% endif %}{% if data.toast_tuple_target %} +{% if ns.add_comma %}, +{% endif %} + toast_tuple_target = {{ data.toast_tuple_target }}{% set ns.add_comma = true%}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %} +{% if ns.add_comma %}, +{% endif %} + autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %} +{% if ns.add_comma %}, +{% endif %} + toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.autovacuum_custom %} +{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %} +{% if ns.add_comma %}, +{% endif %} + {{opt.name}} = {{opt.value}}{% set ns.add_comma = true%}{% endif %} +{% endfor %}{% endif %}{% if data.toast_autovacuum %} +{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %} +{% if ns.add_comma %}, +{% endif %} + toast.{{opt.name}} = {{opt.value}}{% set ns.add_comma = true%}{% endif %} +{% endfor %}{% endif %} + +{% if data.spcname %}){% else %});{% endif %} + +{% endif %} +{### SQL for Tablespace ###} +{% if data.spcname %} +TABLESPACE {{ conn|qtIdent(data.spcname) }}; +{% endif %} +{### Alter SQL for Owner ###} +{% if data.relowner %} + +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + OWNER to {{conn|qtIdent(data.relowner)}}; +{% endif %} + +{#####################################################} +{## Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.rlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + ENABLE ROW LEVEL SECURITY; +{% endif %} + +{#####################################################} +{## Force Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.forcerlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + FORCE ROW LEVEL SECURITY; +{% endif %} + +{### Security Labels on Table ###} +{% if data.seclabels and data.seclabels|length > 0 %} + +{% for r in data.seclabels %} +{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} +{% endfor %} +{% endif %} +{### ACL on Table ###} +{% if data.revoke_all %} +{% for priv in data.revoke_all %} +{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}} +{% endfor %} +{% endif %} +{% if data.relacl %} + +{% for priv in data.relacl %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} +{% endfor %} +{% endif %} +{### SQL for COMMENT ###} +{% if data.description %} +COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} + IS {{data.description|qtLiteral(conn)}}; +{% endif %} +{#===========================================#} +{#====== MAIN TABLE TEMPLATE ENDS HERE ======#} +{#===========================================#} +{#===========================================#} +{# COLUMN SPECIFIC TEMPLATES STARTS HERE #} +{#===========================================#} +{% if data.columns and data.columns|length > 0 %} +{% for c in data.columns %} +{% if c.description %} + +COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}} + IS {{c.description|qtLiteral(conn)}}; +{% endif %} +{### Add variables to column ###} +{% if c.attoptions and c.attoptions|length > 0 %} + +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + {{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }} + +{% endif %} +{### Alter column statistics value ###} +{% if c.attstattarget is defined and c.attstattarget > -1 %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STATISTICS {{c.attstattarget}}; + +{% endif %} +{### ACL ###} +{% if c.attacl and c.attacl|length > 0 %} + +{% for priv in c.attacl %} +{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }} +{% endfor %} +{% endif %} +{### Security Lables ###} +{% if c.seclabels and c.seclabels|length > 0 %} + +{% for r in c.seclabels %} +{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }} +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} +{#===========================================#} +{# COLUMN SPECIFIC TEMPLATES ENDS HERE #} +{#===========================================#} +{#======================================#} +{# CONSTRAINTS SPECIFIC TEMPLATES #} +{#======================================#} +{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.primary_key)}} +{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.unique_constraint)}} +{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.foreign_key)}} +{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.check_constraint)}} +{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.exclude_constraint)}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage.sql new file mode 100644 index 000000000..06d16132a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage.sql @@ -0,0 +1,16 @@ +-- Table: public.simple_table_storage_$%{}[]()&*^!@"'`\/# + +-- DROP TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#"; + +CREATE TABLE IF NOT EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" +( + col4 character varying(30) STORAGE EXTERNAL COLLATE pg_catalog."default" +) + +TABLESPACE pg_default; + +ALTER TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + OWNER to postgres; + +COMMENT ON TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage_msql.sql new file mode 100644 index 000000000..d386e8c16 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/create_table_with_column_storage_msql.sql @@ -0,0 +1,10 @@ +CREATE TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" +( + col4 character varying(30) STORAGE EXTERNAL +); + +ALTER TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + OWNER to postgres; + +COMMENT ON TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/test.json new file mode 100644 index 000000000..e60271b4a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/16_plus/test.json @@ -0,0 +1,2339 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table without primary key", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col3", + "cltype": "boolean", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "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", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col5", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": 20, + "attprecision": 10, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col6", + "cltype": "timestamp with time zone", + "attacl": [], + "min_val_attlen": 0, + "max_val_attlen": 6, + "is_primary_key": false, + "attnotnull": false, + "attlen": 5, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_without_primary_key.sql", + "expected_msql_file": "create_table_without_primary_key_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table to change column data types", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "cltype": "bigint" + }, + { + "attnum": 2, + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "cltype": "character varying" + }, + { + "attnum": 6, + "attlen": null, + "cltype": "time without time zone" + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_change_col_data_type.sql", + "expected_msql_file": "alter_table_change_col_data_type_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add pk", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "attnotnull": true, + "is_primary_key": true + } + ] + }, + "primary_key": { + "added": [ + { + "columns": [ + { + "column": "col1" + } + ], + "include": [] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_pk_not_null_constraint.sql", + "expected_msql_file": "alter_table_add_pk_not_null_constraint_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add null constraint, rename column", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "name": "col1_rename", + "is_primary_key": false + }, + { + "attnum": 4, + "attnotnull": true + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_null_constraint_rename_col.sql", + "expected_msql_file": "alter_table_add_null_constraint_rename_col_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table add pk", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with primary key", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [ + { + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "integer", + "attacl": [], + "is_primary_key": true, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "json", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_pk.sql", + "expected_msql_file": "create_table_with_pk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add columns", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "columns": { + "added": [ + { + "name": "col3_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": 10, + "attprecision": 5, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col4_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_cols.sql", + "expected_msql_file": "alter_table_add_cols_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table delete columns", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "columns": { + "deleted": [ + { + "attoptions": [], + "attacl": [], + "seclabels": [], + "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", + "atttypid": 114, + "attnum": 2, + "cltype": "json", + "collspcname": "", + "description": null, + "edit_types": [ + "json", + "jsonb" + ], + "is_primary_key": false, + "attstattarget": -1, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attndims": 0, + "atttypmod": -1, + "attstorage": "x", + "defval": null, + "typname": "json", + "displaytypname": "json", + "elemoid": 114, + "typnspname": "pg_catalog", + "defaultstorage": "x", + "indkey": "1", + "isdup": false, + "is_fk": false, + "is_sys_column": false, + "relname": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "is_view_only": false, + "is_pk": false, + "old_attidentity": "a" + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_delete_cols.sql", + "expected_msql_file": "alter_table_delete_cols_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table delete columns", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with pk & check constraint", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "create table comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [ + { + "name": "custom_pk", + "comment": "custom pk created", + "fillfactor": "11", + "condeferrable": true, + "condeferred": true, + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "time with time zone", + "attacl": [], + "min_val_attlen": 0, + "max_val_attlen": 6, + "is_primary_key": false, + "attnotnull": false, + "attlen": 5, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "character", + "attacl": [], + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "is_primary_key": false, + "attnotnull": false, + "attlen": 12, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [ + { + "name": "chk_const", + "consrc": "col2 != null", + "convalidated": false, + "comment": "chk const comment" + } + ], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_pk_chk.sql", + "expected_msql_file": "create_table_with_pk_chk_msql.sql" + }, { + "type": "alter", + "name": "Alter Table add unique constraint", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "unique_constraint": { + "added": [ + { + "name": "unique", + "fillfactor": "13", + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ] + } + }, + "expected_sql_file": "alter_table_add_unique_const.sql", + "expected_msql_file": "alter_table_add_unique_const_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table delete constraints", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "check_constraint": { + "deleted": [ + { + "name": "chk_const", + "consrc": "col2 <> NULL::bpchar", + "connoinherit": false, + "convalidated": false, + "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "nspname": "public", + "comment": "chk const comment", + "conislocal": true + } + ] + }, + "unique_constraint": { + "deleted": [ + { + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" + } + ], + "name": "unique", + "comment": null, + "spcname": "pg_default", + "fillfactor": "13", + "condeferrable": false, + "condeferred": false, + "include": [], + "col_count": 1, + "conislocal": true + } + ] + } + }, + "expected_sql_file": "alter_table_delete_constraints.sql", + "expected_msql_file": "alter_table_delete_constraints_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with pk & chk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table for FK reference", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "fk_reference_tbl", + "columns": [ + { + "name": "id", + "cltype": "integer", + "is_primary_key": true + }, + { + "name": "name", + "cltype": "bigint" + } + ], + "primary_key": [ + { + "columns": [ + { + "column": "id" + } + ], + "include": [] + } + ], + "unique_constraint": [ + { + "name": "", + "columns": [ + { + "column": "name" + } + ], + "include": [] + } + ], + "is_partitioned": false, + "schema": "public", + "spcname": "pg_default" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Table with fk constraint", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col3", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [ + { + "name": "fk_test", + "comment": "fk comment", + "condeferrable": true, + "confmatchtype": true, + "columns": [ + { + "local_column": "col1", + "references": "", + "referenced": "id" + } + ], + "confupdtype": "a", + "confdeltype": "a", + "autoindex": false, + "coveringindex": null + } + ], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "create_table_with_fk.sql", + "expected_msql_file": "create_table_with_fk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add one more fk", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "foreign_key": { + "added": [ + { + "name": "fk2", + "columns": [ + { + "local_column": "col2", + "references": "", + "referenced": "name" + } + ], + "confupdtype": "a", + "confdeltype": "a", + "autoindex": false, + "coveringindex": null + } + ] + } + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "alter_table_add_another_fk.sql", + "expected_msql_file": "alter_table_add_another_fk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add exclude constraint", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "exclude_constraint": { + "added": [ + { + "name": "ex_constr", + "amname": "btree", + "columns": [ + { + "column": "col1", + "is_exp": false, + "order": false, + "nulls_order": false, + "operator": "=", + "is_sort_nulls_applicable": false + } + ], + "include": [] + } + ] + } + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "alter_table_add_exclude_constraint.sql", + "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with fk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with custom auto-vacuum", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "custom auto vacuum", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "t", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "character varying[]", + "attacl": [], + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "is_primary_key": false, + "attnotnull": false, + "attlen": 10, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "date", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor", + "value": 0.2 + }, + { + "name": "autovacuum_analyze_threshold", + "value": 55 + }, + { + "name": "autovacuum_freeze_max_age", + "value": 20000000 + }, + { + "name": "autovacuum_vacuum_cost_delay", + "value": 25 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 10 + }, + { + "name": "autovacuum_vacuum_scale_factor", + "value": 0.3 + }, + { + "name": "autovacuum_vacuum_threshold", + "value": 60 + }, + { + "name": "autovacuum_freeze_min_age", + "value": 500000 + }, + { + "name": "autovacuum_freeze_table_age", + "value": 1300000 + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "autovacuum_custom": true + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_custom_autovacuum.sql", + "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add toast table", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", + "autovacuum_enabled": "x", + "toast_autovacuum": true, + "toast_autovacuum_enabled": "f", + "vacuum_table": { + "changed": [ + { + "name": "autovacuum_analyze_threshold", + "value": 60 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 100 + } + ] + }, + "vacuum_toast": { + "changed": [ + { + "name": "autovacuum_freeze_max_age", + "value": 2000000 + }, + { + "name": "autovacuum_vacuum_cost_delay", + "value": 50 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 13 + }, + { + "name": "autovacuum_vacuum_threshold", + "value": 70 + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_with_toast_table.sql", + "expected_msql_file": "alter_table_with_toast_table_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with fk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with advanced options", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "relhasoids": true, + "description": "test comment", + "relpersistence": true, + "fillfactor": "50", + "parallel_workers": "", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "double precision", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "numrange", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": true, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "rlspolicy": true + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_advanced_options.sql", + "expected_msql_file": "create_table_with_advanced_options_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table update grants", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", + "rlspolicy": false, + "forcerlspolicy": false, + "relacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_update_grants.sql", + "expected_msql_file": "alter_table_update_grants_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with advanced options", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" + } + },{ + "type": "create", + "name": "Create Table for like table", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "like_tbl", + "columns": [ + { + "name": "id", + "cltype": "integer", + "is_primary_key": true + }, + { + "name": "name", + "cltype": "text" + } + ], + "primary_key": [ + { + "columns": [ + { + "column": "id" + } + ], + "include": [] + } + ], + "unique_constraint": [ + { + "name": "", + "columns": [ + { + "column": "name" + } + ], + "include": [] + } + ], + "is_partitioned": false, + "schema": "public", + "spcname": "pg_default" + }, + "store_object_id": true + },{ + "type": "create", + "name": "Create Table using like table", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "test ", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": true, + "like_constraints": true, + "like_indexes": true, + "like_storage": true, + "like_comments": true, + "like_identity": true, + "like_statistics": true, + "like_generated": true, + "like_compression": true, + "like_relation": "public.like_tbl" + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "create_table_with_lik_tbl.sql", + "expected_msql_file": "create_table_with_lik_tbl_msql.sql" + },{ + "type": "delete", + "name": "Delete Table with advanced options", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" + } + },{ + "type": "create", + "name": "Create Table with list partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_active", + "values_in": "'ACTIVE'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "list", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_partition.sql", + "expected_msql_file": "create_table_with_partition_msql.sql" + }, + { + "type": "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", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small PARTITION", + "values_from": "20", + "values_to": "25", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "arr" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "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", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#", + "relowner": "postgres", + "relacl": [], + "description": "hash partition", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_part11", + "values_modulus": "2", + "values_remainder": "1", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "hash", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "name", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "id" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_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", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small", + "values_from": "'20'", + "values_to": "'25'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status", + "collationame": "\"C\"", + "op_class": "text_pattern_ops" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "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_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with column storage", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_storage_$%{}[]()&*^!@\"'`\\/#", + "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", + "attstorage": "e", + "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_storage.sql", + "expected_msql_file": "create_table_with_column_storage_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table ", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_storage_$%{}[]()&*^!@\"'`\\/#" + } + } + ] + } + \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage.sql new file mode 100644 index 000000000..696985d2c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage.sql @@ -0,0 +1,16 @@ +-- Table: public.simple_table_storage_$%{}[]()&*^!@"'`\/# + +-- DROP TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#"; + +CREATE TABLE IF NOT EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" +( + col4 character varying(30) STORAGE EXTERNAL COLLATE pg_catalog."default" +) + +TABLESPACE pg_default; + +ALTER TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + OWNER to enterprisedb; + +COMMENT ON TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage_msql.sql new file mode 100644 index 000000000..94f540598 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/create_table_with_column_storage_msql.sql @@ -0,0 +1,10 @@ +CREATE TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" +( + col4 character varying(30) STORAGE EXTERNAL +); + +ALTER TABLE IF EXISTS public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + OWNER to enterprisedb; + +COMMENT ON TABLE public."simple_table_storage_$%{}[]()&*^!@""'`\/#" + IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/test.json new file mode 100644 index 000000000..a8f526937 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/16_plus/test.json @@ -0,0 +1,2353 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table without primary key", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col3", + "cltype": "boolean", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "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", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col5", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": 20, + "attprecision": 10, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col6", + "cltype": "timestamp with time zone", + "attacl": [], + "min_val_attlen": 0, + "max_val_attlen": 6, + "is_primary_key": false, + "attnotnull": false, + "attlen": 5, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_without_primary_key.sql", + "expected_msql_file": "create_table_without_primary_key_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table to change column data types", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "cltype": "bigint" + }, + { + "attnum": 2, + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "cltype": "character varying" + }, + { + "attnum": 6, + "attlen": null, + "cltype": "time without time zone" + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_change_col_data_type.sql", + "expected_msql_file": "alter_table_change_col_data_type_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add pk", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "attnotnull": true, + "is_primary_key": true + } + ] + }, + "primary_key": { + "added": [ + { + "columns": [ + { + "column": "col1" + } + ], + "include": [] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_pk_not_null_constraint.sql", + "expected_msql_file": "alter_table_add_pk_not_null_constraint_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add null constraint, rename column", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", + "columns": { + "changed": [ + { + "attnum": 1, + "name": "col1_rename", + "is_primary_key": false + }, + { + "attnum": 4, + "attnotnull": true + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_null_constraint_rename_col.sql", + "expected_msql_file": "alter_table_add_null_constraint_rename_col_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table add pk", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with primary key", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [ + { + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "integer", + "attacl": [], + "is_primary_key": true, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "json", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_pk.sql", + "expected_msql_file": "create_table_with_pk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add columns", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "columns": { + "added": [ + { + "name": "col3_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": 10, + "attprecision": 5, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col4_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_add_cols.sql", + "expected_msql_file": "alter_table_add_cols_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table delete columns", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "columns": { + "deleted": [ + { + "attoptions": [], + "attacl": [], + "seclabels": [], + "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", + "atttypid": 114, + "attnum": 2, + "cltype": "json", + "collspcname": "", + "description": null, + "edit_types": [ + "json", + "jsonb" + ], + "is_primary_key": false, + "attstattarget": -1, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attndims": 0, + "atttypmod": -1, + "attstorage": "x", + "defval": null, + "typname": "json", + "displaytypname": "json", + "elemoid": 114, + "typnspname": "pg_catalog", + "defaultstorage": "x", + "indkey": "1", + "isdup": false, + "is_fk": false, + "is_sys_column": false, + "relname": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", + "is_view_only": false, + "is_pk": false, + "old_attidentity": "a" + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_delete_cols.sql", + "expected_msql_file": "alter_table_delete_cols_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table delete columns", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with pk & check constraint", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "create table comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [ + { + "name": "custom_pk", + "comment": "custom pk created", + "fillfactor": "11", + "condeferrable": true, + "condeferred": true, + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", + "cltype": "time with time zone", + "attacl": [], + "min_val_attlen": 0, + "max_val_attlen": 6, + "is_primary_key": false, + "attnotnull": false, + "attlen": 5, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "character", + "attacl": [], + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "is_primary_key": false, + "attnotnull": false, + "attlen": 12, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [ + { + "name": "chk_const", + "consrc": "col2 != null", + "convalidated": false, + "comment": "chk const comment" + } + ], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_pk_chk.sql", + "expected_msql_file": "create_table_with_pk_chk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add unique constraint", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "unique_constraint": { + "added": [ + { + "name": "unique", + "fillfactor": "13", + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" + } + ], + "include": [] + } + ] + } + }, + "expected_sql_file": "alter_table_add_unique_const.sql", + "expected_msql_file": "alter_table_add_unique_const_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table delete constraints", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "check_constraint": { + "deleted": [ + { + "name": "chk_const", + "consrc": "col2 <> NULL::bpchar", + "connoinherit": false, + "convalidated": false, + "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", + "nspname": "public", + "comment": "chk const comment", + "conislocal": true + } + ] + }, + "unique_constraint": { + "deleted": [ + { + "columns": [ + { + "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" + } + ], + "name": "unique", + "comment": null, + "spcname": "pg_default", + "fillfactor": "13", + "condeferrable": false, + "condeferred": false, + "include": [], + "col_count": 1, + "conislocal": true + } + ] + } + }, + "expected_sql_file": "alter_table_delete_constraints.sql", + "expected_msql_file": "alter_table_delete_constraints_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with pk & chk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table for FK reference", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "fk_reference_tbl", + "columns": [ + { + "name": "id", + "cltype": "integer", + "is_primary_key": true + }, + { + "name": "name", + "cltype": "bigint" + } + ], + "primary_key": [ + { + "columns": [ + { + "column": "id" + } + ], + "include": [] + } + ], + "unique_constraint": [ + { + "name": "", + "columns": [ + { + "column": "name" + } + ], + "include": [] + } + ], + "is_partitioned": false, + "schema": "public", + "spcname": "pg_default" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Table with fk constraint", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "test comment", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col3", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [ + { + "name": "fk_test", + "comment": "fk comment", + "condeferrable": true, + "confmatchtype": true, + "columns": [ + { + "local_column": "col1", + "references": "", + "referenced": "id" + } + ], + "confupdtype": "a", + "confdeltype": "a", + "autoindex": false, + "coveringindex": null + } + ], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "create_table_with_fk.sql", + "expected_msql_file": "create_table_with_fk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add one more fk", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "foreign_key": { + "added": [ + { + "name": "fk2", + "columns": [ + { + "local_column": "col2", + "references": "", + "referenced": "name" + } + ], + "confupdtype": "a", + "confdeltype": "a", + "autoindex": false, + "coveringindex": null + } + ] + } + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "alter_table_add_another_fk.sql", + "expected_msql_file": "alter_table_add_another_fk_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add exclude constraint", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", + "exclude_constraint": { + "added": [ + { + "name": "ex_constr", + "amname": "btree", + "columns": [ + { + "column": "col1", + "is_exp": false, + "order": false, + "nulls_order": false, + "operator": "=", + "is_sort_nulls_applicable": false + } + ], + "include": [] + } + ] + } + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "alter_table_add_exclude_constraint.sql", + "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with fk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with custom auto-vacuum", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "custom auto vacuum", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "t", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "character varying[]", + "attacl": [], + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "is_primary_key": false, + "attnotnull": false, + "attlen": 10, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "date", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor", + "value": 0.2 + }, + { + "name": "autovacuum_analyze_threshold", + "value": 55 + }, + { + "name": "autovacuum_freeze_max_age", + "value": 20000000 + }, + { + "name": "autovacuum_vacuum_cost_delay", + "value": 25 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 10 + }, + { + "name": "autovacuum_vacuum_scale_factor", + "value": 0.3 + }, + { + "name": "autovacuum_vacuum_threshold", + "value": 60 + }, + { + "name": "autovacuum_freeze_min_age", + "value": 500000 + }, + { + "name": "autovacuum_freeze_table_age", + "value": 1300000 + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": true + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_custom_autovacuum.sql", + "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table add toast table", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", + "autovacuum_enabled": "x", + "toast_autovacuum": true, + "toast_autovacuum_enabled": "f", + "vacuum_table": { + "changed": [ + { + "name": "autovacuum_analyze_threshold", + "value": 60 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 100 + } + ] + }, + "vacuum_toast": { + "changed": [ + { + "name": "autovacuum_freeze_max_age", + "value": 2000000 + }, + { + "name": "autovacuum_vacuum_cost_delay", + "value": 50 + }, + { + "name": "autovacuum_vacuum_cost_limit", + "value": 13 + }, + { + "name": "autovacuum_vacuum_threshold", + "value": 70 + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_with_toast_table.sql", + "expected_msql_file": "alter_table_with_toast_table_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with fk constraints", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with advanced options", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "relhasoids": true, + "description": "test comment", + "relpersistence": true, + "fillfactor": "50", + "parallel_workers": "", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [ + { + "name": "col1", + "cltype": "double precision", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "col2", + "cltype": "numrange", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": true, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "rlspolicy": true + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_advanced_options.sql", + "expected_msql_file": "create_table_with_advanced_options_msql.sql" + }, + { + "type": "alter", + "name": "Alter Table update grants", + "endpoint": "NODE-table.obj_id", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql_id", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", + "rlspolicy": false, + "forcerlspolicy": false, + "relacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "store_object_id": true, + "expected_sql_file": "alter_table_update_grants.sql", + "expected_msql_file": "alter_table_update_grants_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with advanced options", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table for like table", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "like_tbl", + "columns": [ + { + "name": "id", + "cltype": "integer", + "is_primary_key": true + }, + { + "name": "name", + "cltype": "text" + } + ], + "primary_key": [ + { + "columns": [ + { + "column": "id" + } + ], + "include": [] + } + ], + "unique_constraint": [ + { + "name": "", + "columns": [ + { + "column": "name" + } + ], + "include": [] + } + ], + "is_partitioned": false, + "schema": "public", + "spcname": "pg_default" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Table using like table", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "test ", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [], + "partition_type": "range", + "is_partitioned": false, + "schema": "public", + "columns": [], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": true, + "like_constraints": true, + "like_indexes": true, + "like_storage": true, + "like_comments": true, + "like_generated": true, + "like_identity": true, + "like_statistics": true, + "like_compression": true, + "like_relation": "public.like_tbl" + }, + "store_object_id": true, + "preprocess_data": true, + "expected_sql_file": "create_table_with_lik_tbl.sql", + "expected_msql_file": "create_table_with_lik_tbl_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table with advanced options", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with list partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_active", + "values_in": "'ACTIVE'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "list", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_partition.sql", + "expected_msql_file": "create_table_with_partition_msql.sql" + }, + { + "type": "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", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small PARTITION", + "values_from": "20", + "values_to": "25", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "arr" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "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", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "hash partition", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_part11", + "values_modulus": "2", + "values_remainder": "1", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "hash", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "name", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "id" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "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", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small", + "values_from": "'20'", + "values_to": "'25'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status", + "collationame": "\"C\"", + "op_class": "text_pattern_ops" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "like_identity": false, + "like_statistics": false, + "like_generated": false, + "like_compression": false, + "autovacuum_custom": false + }, + "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_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Table with column storage", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "simple_table_storage_$%{}[]()&*^!@\"'`\\/#", + "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", + "attstorage": "e", + "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_storage.sql", + "expected_msql_file": "create_table_with_column_storage_msql.sql" + }, + { + "type": "delete", + "name": "Delete Table ", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "simple_table_storage_$%{}[]()&*^!@\"'`\\/#" + } + } + ] + } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/table_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/table_test_data.json index 0c9301ba8..b0777413a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/table_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/table_test_data.json @@ -733,6 +733,42 @@ "error_msg": null, "test_result_data": {} } + }, + { + "name": "Create: Add Table with column storage.", + "is_positive_test": true, + "inventory_data": { + "server_min_version": 160000, + "skip_msg": "Creating table with column storage is not supported by PPAS/PG 16.0 and below." + }, + "test_data": { + "description": "Create Table API Test", + "columns": [ + { + "name": "col1", + "cltype": "character varying", + "attacl": [], + "min_val_attlen": 1, + "max_val_attlen": 2147483647, + "is_primary_key": false, + "attnotnull": false, + "attlen": 30, + "attprecision": null, + "attidentity": "a", + "attstorage": "e", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ] + }, + "mocking_required": false, + "mock_data": {}, + "expected_data": { + "status_code": 200, + "error_msg": null, + "test_result_data": {} + } } ], "table_delete": [