mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added support for column storage syntax while creating table. #6450
This commit is contained in:
parent
4c5324bd99
commit
3de19f66f2
@ -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.
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 66 KiB |
@ -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'],
|
||||
|
@ -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": [
|
||||
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#"
|
||||
ALTER COLUMN "col_1111_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -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 %}
|
@ -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 %}
|
@ -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)}}
|
@ -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';
|
@ -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';
|
File diff suppressed because it is too large
Load Diff
@ -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';
|
@ -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';
|
File diff suppressed because it is too large
Load Diff
@ -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": [
|
||||
|
Loading…
Reference in New Issue
Block a user