Add Reverse Engineered SQL tests for Schemas. Fixes #4575

This commit is contained in:
Akshay Joshi 2019-08-29 18:32:08 +05:30
parent d6da1cf25c
commit e0c53e7d1d
28 changed files with 807 additions and 5 deletions

View File

@ -16,6 +16,7 @@ New features
Housekeeping
************
| `Issue #4575 <https://redmine.postgresql.org/issues/4575>`_ - Add Reverse Engineered SQL tests for Schemas.
| `Issue #4576 <https://redmine.postgresql.org/issues/4576>`_ - Add Reverse Engineered SQL tests for Views.
| `Issue #4600 <https://redmine.postgresql.org/issues/4600>`_ - Add Reverse Engineered SQL tests for Rules.

View File

@ -20,4 +20,5 @@ FROM
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;
GROUP BY g.rolname, gt.rolname
ORDER BY grantee;

View File

@ -20,4 +20,5 @@ FROM
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;
GROUP BY g.rolname, gt.rolname
ORDER BY grantee;

View File

@ -20,4 +20,5 @@ FROM
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;
GROUP BY g.rolname, gt.rolname
ORDER BY grantee;

View File

@ -20,4 +20,5 @@ FROM
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;
GROUP BY g.rolname, gt.rolname
ORDER BY grantee;

View File

@ -0,0 +1,22 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION postgres;
GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,13 @@
GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,14 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION postgres;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;

View File

@ -0,0 +1,5 @@
REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
REVOKE ALL ON TYPES FROM PUBLIC;

View File

@ -0,0 +1,9 @@
-- SCHEMA: test_schema1_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION postgres;
COMMENT ON SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,2 @@
ALTER SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
RENAME TO "test_schema1_$%{}[]()&*^!@""""'`\/#";

View File

@ -0,0 +1,25 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION postgres;
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,18 @@
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,9 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION postgres;
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,4 @@
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,272 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Schema With All Options",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#",
"description": "This is a test comment",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"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": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_schema_all_options.sql",
"expected_msql_file": "create_schema_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop Schema with all options",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "create",
"name": "Create Schema with comments",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#",
"description": "This is a test comment"
},
"expected_sql_file": "create_schema_with_comment.sql",
"expected_msql_file": "create_schema_with_comment_msql.sql"
}, {
"type": "alter",
"name": "Alert Schema Name",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"name": "test_schema1_$%{}[]()&*^!@\"\"'`\\/#"
},
"expected_sql_file": "alter_schema_name.sql",
"expected_msql_file": "alter_schema_name_msql.sql"
},
{
"type": "delete",
"name": "Drop Schema",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema1_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "create",
"name": "Create Schema",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "alter",
"name": "Alert Schema Add Privileges",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"nspacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}]
}]
},
"deftblacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"defseqacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"deffuncacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}]
},
"deftypeacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
}
},
"expected_sql_file": "alter_schema_add_priv.sql",
"expected_msql_file": "alter_schema_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alert Schema Drop Privileges",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"nspacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}]
}]
},
"defseqacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"deftypeacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "postgres",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
}
},
"expected_sql_file": "alter_schema_drop_priv.sql",
"expected_msql_file": "alter_schema_drop_priv_msql.sql"
}, {
"type": "delete",
"name": "Drop Schema",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}
]
}

View File

@ -0,0 +1,22 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION enterprisedb;
GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,17 @@
GRANT CREATE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,14 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION enterprisedb;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT SELECT, UPDATE ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;

View File

@ -0,0 +1,7 @@
REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
REVOKE ALL ON SEQUENCES FROM PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
REVOKE ALL ON TYPES FROM PUBLIC;

View File

@ -0,0 +1,9 @@
-- SCHEMA: test_schema1_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION enterprisedb;
COMMENT ON SCHEMA "test_schema1_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,2 @@
ALTER SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
RENAME TO "test_schema1_$%{}[]()&*^!@""""'`\/#";

View File

@ -0,0 +1,25 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION enterprisedb;
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,18 @@
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';
GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON TABLES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT ALL ON SEQUENCES TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT EXECUTE ON FUNCTIONS TO PUBLIC;
ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
GRANT USAGE ON TYPES TO PUBLIC;

View File

@ -0,0 +1,9 @@
-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/#
-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ;
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
AUTHORIZATION enterprisedb;
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,4 @@
CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#";
COMMENT ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#"
IS 'This is a test comment';

View File

@ -0,0 +1,272 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Schema With All Options",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#",
"description": "This is a test comment",
"nspacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"seclabels": [],
"deftblacl": [{
"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": "d",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "D",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "x",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "t",
"privilege": true,
"with_grant": false
}]
}],
"defseqacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}],
"deffuncacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}],
"deftypeacl": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
},
"expected_sql_file": "create_schema_all_options.sql",
"expected_msql_file": "create_schema_all_options_msql.sql"
}, {
"type": "delete",
"name": "Drop Schema with all options",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "create",
"name": "Create Schema with comments",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#",
"description": "This is a test comment"
},
"expected_sql_file": "create_schema_with_comment.sql",
"expected_msql_file": "create_schema_with_comment_msql.sql"
}, {
"type": "alter",
"name": "Alert Schema Name",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"name": "test_schema1_$%{}[]()&*^!@\"\"'`\\/#"
},
"expected_sql_file": "alter_schema_name.sql",
"expected_msql_file": "alter_schema_name_msql.sql"
},
{
"type": "delete",
"name": "Drop Schema",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema1_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "create",
"name": "Create Schema",
"endpoint": "NODE-schema.obj",
"sql_endpoint": "NODE-schema.sql_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}, {
"type": "alter",
"name": "Alert Schema Add Privileges",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"nspacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}]
}]
},
"deftblacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"defseqacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"deffuncacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}]
}]
},
"deftypeacl": {
"added": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
}
},
"expected_sql_file": "alter_schema_add_priv.sql",
"expected_msql_file": "alter_schema_add_priv_msql.sql"
}, {
"type": "alter",
"name": "Alert Schema Drop Privileges",
"endpoint": "NODE-schema.obj_id",
"sql_endpoint": "NODE-schema.sql_id",
"msql_endpoint": "NODE-schema.msql_id",
"data": {
"nspacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "C",
"privilege": true,
"with_grant": false
}]
}]
},
"defseqacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}, {
"privilege_type": "w",
"privilege": true,
"with_grant": false
}]
}]
},
"deftypeacl": {
"deleted": [{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}]
}]
}
},
"expected_sql_file": "alter_schema_drop_priv.sql",
"expected_msql_file": "alter_schema_drop_priv_msql.sql"
}, {
"type": "delete",
"name": "Drop Schema",
"endpoint": "NODE-schema.obj_id",
"data": {
"name": "test_schema_$%{}[]()&*^!@\"\"'`\\/#"
}
}
]
}

View File

@ -168,7 +168,12 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator):
elif arg == 'did':
options['did'] = int(self.server_information['db_id'])
elif arg == 'scid':
options['scid'] = int(self.schema_id)
# For schema node object_id is the actual schema id.
if endpoint.__contains__('NODE-schema') and \
object_id is not None:
options['scid'] = int(object_id)
else:
options['scid'] = int(self.schema_id)
elif arg == 'tid' and self.table_id:
options['tid'] = int(self.table_id)
else: