From 17a76310540525454891ccf8bede83b68f8a030b Mon Sep 17 00:00:00 2001 From: Ashish Prasad <56514722+hash-16@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:28:24 +0530 Subject: [PATCH] Support SSMS scripting for Users and fix crash in SSMS while clicking permissions (#1869) (#1972) Added three new dummy views, sys.asymmetric_keys, sys.certificates and sys.database_permissions which are required by to script users, though empty views works fine here.Open a JIRA, BABEL-4440 for fully supporting it in future. Task: BABEL-3921, BABEL-3593 Signed-off-by: Ashish Prasad --- contrib/babelfishpg_tsql/sql/sys_views.sql | 63 +++++++++++++++++++ .../babelfishpg_tsql--2.6.0--2.7.0.sql | 63 +++++++++++++++++++ .../sys_asymmetric_keys-vu-cleanup.out | 11 ++++ .../sys_asymmetric_keys-vu-prepare.out | 18 ++++++ .../sys_asymmetric_keys-vu-verify.out | 31 +++++++++ .../expected/sys_certificates-vu-cleanup.out | 11 ++++ .../expected/sys_certificates-vu-prepare.out | 18 ++++++ .../expected/sys_certificates-vu-verify.out | 31 +++++++++ .../sys_database_permissions-vu-cleanup.out | 11 ++++ .../sys_database_permissions-vu-prepare.out | 18 ++++++ .../sys_database_permissions-vu-verify.out | 31 +++++++++ .../views/sys_asymmetric_keys-vu-cleanup.sql | 11 ++++ .../views/sys_asymmetric_keys-vu-prepare.sql | 18 ++++++ .../views/sys_asymmetric_keys-vu-verify.sql | 14 +++++ .../views/sys_certificates-vu-cleanup.sql | 11 ++++ .../views/sys_certificates-vu-prepare.sql | 18 ++++++ .../views/sys_certificates-vu-verify.sql | 14 +++++ .../sys_database_permissions-vu-cleanup.sql | 11 ++++ .../sys_database_permissions-vu-prepare.sql | 18 ++++++ .../sys_database_permissions-vu-verify.sql | 14 +++++ test/JDBC/upgrade/latest/schedule | 4 ++ test/python/SMO_script.ps1 | 5 +- test/python/expected/pyodbc/ddl_users.out | 9 +++ .../expected_dependency.out | 1 - test/python/input/ddl_users.sql | 41 ++++++++++++ test/python/input/ddl_views.sql | 2 +- 26 files changed, 494 insertions(+), 3 deletions(-) create mode 100644 test/JDBC/expected/sys_asymmetric_keys-vu-cleanup.out create mode 100644 test/JDBC/expected/sys_asymmetric_keys-vu-prepare.out create mode 100644 test/JDBC/expected/sys_asymmetric_keys-vu-verify.out create mode 100644 test/JDBC/expected/sys_certificates-vu-cleanup.out create mode 100644 test/JDBC/expected/sys_certificates-vu-prepare.out create mode 100644 test/JDBC/expected/sys_certificates-vu-verify.out create mode 100644 test/JDBC/expected/sys_database_permissions-vu-cleanup.out create mode 100644 test/JDBC/expected/sys_database_permissions-vu-prepare.out create mode 100644 test/JDBC/expected/sys_database_permissions-vu-verify.out create mode 100644 test/JDBC/input/views/sys_asymmetric_keys-vu-cleanup.sql create mode 100644 test/JDBC/input/views/sys_asymmetric_keys-vu-prepare.sql create mode 100644 test/JDBC/input/views/sys_asymmetric_keys-vu-verify.sql create mode 100644 test/JDBC/input/views/sys_certificates-vu-cleanup.sql create mode 100644 test/JDBC/input/views/sys_certificates-vu-prepare.sql create mode 100644 test/JDBC/input/views/sys_certificates-vu-verify.sql create mode 100644 test/JDBC/input/views/sys_database_permissions-vu-cleanup.sql create mode 100644 test/JDBC/input/views/sys_database_permissions-vu-prepare.sql create mode 100644 test/JDBC/input/views/sys_database_permissions-vu-verify.sql create mode 100644 test/python/expected/pyodbc/ddl_users.out create mode 100644 test/python/input/ddl_users.sql diff --git a/contrib/babelfishpg_tsql/sql/sys_views.sql b/contrib/babelfishpg_tsql/sql/sys_views.sql index 110601a85f..a278ada6e4 100644 --- a/contrib/babelfishpg_tsql/sql/sys_views.sql +++ b/contrib/babelfishpg_tsql/sql/sys_views.sql @@ -2917,6 +2917,53 @@ SELECT WHERE FALSE; GRANT SELECT ON sys.spatial_index_tessellations TO PUBLIC; +CREATE OR REPLACE VIEW sys.asymmetric_keys +AS +SELECT + CAST('' as sys.sysname) AS name + , CAST(0 as sys.int) AS principal_id + , CAST(0 as sys.int) AS asymmetric_key_id + , CAST('a' as sys.bpchar(2)) AS pvt_key_encryption_type + , CAST('' as sys.nvarchar(60)) AS pvt_key_encryption_type_desc + , CAST(null as sys.varbinary(32)) as thumbprint + , CAST('a' as sys.bpchar(2)) AS algorithm + , CAST('' as sys.nvarchar(60)) AS algorithm_desc + , CAST(0 as sys.int) AS key_length + , CAST(null as sys.varbinary(85)) as sid + , CAST('' as sys.nvarchar(128)) AS string_sid + , CAST(NULL as sys.varbinary(8000)) AS public_key + , CAST('' as sys.nvarchar(260)) AS attested_by + , CAST('' as sys.nvarchar(120)) AS provider_type + , CAST(NULL as sys.UNIQUEIDENTIFIER) as cryptographic_provider_guid + , CAST(NULL AS sys.sql_variant) AS cryptographic_provider_algid + +WHERE FALSE; +GRANT SELECT ON sys.asymmetric_keys TO PUBLIC; + +CREATE OR REPLACE VIEW sys.certificates +AS +SELECT + CAST('' as sys.sysname) AS name + , CAST(0 as sys.int) AS principal_id + , CAST(0 as sys.int) AS asymmetric_key_id + , CAST('a' as sys.bpchar(2)) AS pvt_key_encryption_type + , CAST('' as sys.nvarchar(60)) AS pvt_key_encryption_type_desc + , CAST(0 as sys.bit) AS is_active_for_begin_dialog + , CAST('' as sys.nvarchar(442)) AS issuer_name + , CAST('' as sys.nvarchar(64)) AS cert_serial_number + , CAST(null as sys.varbinary(85)) as sid + , CAST('' as sys.nvarchar(128)) AS string_sid + , CAST('' as sys.nvarchar(4000)) AS subject + , CAST('' as sys.datetime) AS expiry_date + , CAST('' as sys.datetime) AS start_date + , CAST(null as sys.varbinary(32)) as thumbprint + , CAST('' as sys.nvarchar(260)) as attested_by + , CAST('' as sys.datetime) AS pvt_key_last_backup_date + , CAST(0 AS sys.int) AS key_length + +WHERE FALSE; +GRANT SELECT ON sys.certificates TO PUBLIC; + CREATE OR REPLACE VIEW sys.all_parameters AS SELECT @@ -3093,3 +3140,19 @@ SELECT CAST(0 as sys.BIT) AS is_ambiguous WHERE FALSE; GRANT SELECT ON sys.sql_expression_dependencies TO PUBLIC; + +CREATE OR REPLACE VIEW sys.database_permissions +AS +SELECT + CAST(0 as sys.tinyint) AS class, + CAST('' as sys.NVARCHAR(60)) AS class_desc, + CAST(0 as sys.int) AS major_id, + CAST(0 as sys.int) AS minor_id, + CAST(0 as sys.int) AS grantee_principal_id, + CAST(0 as sys.int) AS grantor_principal_id, + CAST('a' as sys.BPCHAR(4)) AS type, + CAST('' as sys.NVARCHAR(128)) AS permission_name, + CAST('G' as sys.BPCHAR(1)) AS state, + CAST('' as sys.NVARCHAR(60)) AS state_desc +WHERE FALSE; +GRANT SELECT ON sys.database_permissions TO PUBLIC; diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--2.6.0--2.7.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--2.6.0--2.7.0.sql index 90b1855e91..e928e840ab 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--2.6.0--2.7.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--2.6.0--2.7.0.sql @@ -1691,6 +1691,69 @@ BEGIN END; $$; +CREATE OR REPLACE VIEW sys.asymmetric_keys +AS +SELECT + CAST('' as sys.sysname) AS name + , CAST(0 as sys.int) AS principal_id + , CAST(0 as sys.int) AS asymmetric_key_id + , CAST('a' as sys.bpchar(2)) AS pvt_key_encryption_type + , CAST('' as sys.nvarchar(60)) AS pvt_key_encryption_type_desc + , CAST(null as sys.varbinary(32)) as thumbprint + , CAST('a' as sys.bpchar(2)) AS algorithm + , CAST('' as sys.nvarchar(60)) AS algorithm_desc + , CAST(0 as sys.int) AS key_length + , CAST(null as sys.varbinary(85)) as sid + , CAST('' as sys.nvarchar(128)) AS string_sid + , CAST(NULL as sys.varbinary(8000)) AS public_key + , CAST('' as sys.nvarchar(260)) AS attested_by + , CAST('' as sys.nvarchar(120)) AS provider_type + , CAST(NULL as sys.UNIQUEIDENTIFIER) as cryptographic_provider_guid + , CAST(NULL AS sys.sql_variant) AS cryptographic_provider_algid + +WHERE FALSE; +GRANT SELECT ON sys.asymmetric_keys TO PUBLIC; + +CREATE OR REPLACE VIEW sys.certificates +AS +SELECT + CAST('' as sys.sysname) AS name + , CAST(0 as sys.int) AS principal_id + , CAST(0 as sys.int) AS asymmetric_key_id + , CAST('a' as sys.bpchar(2)) AS pvt_key_encryption_type + , CAST('' as sys.nvarchar(60)) AS pvt_key_encryption_type_desc + , CAST(0 as sys.bit) AS is_active_for_begin_dialog + , CAST('' as sys.nvarchar(442)) AS issuer_name + , CAST('' as sys.nvarchar(64)) AS cert_serial_number + , CAST(null as sys.varbinary(85)) as sid + , CAST('' as sys.nvarchar(128)) AS string_sid + , CAST('' as sys.nvarchar(4000)) AS subject + , CAST('' as sys.datetime) AS expiry_date + , CAST('' as sys.datetime) AS start_date + , CAST(null as sys.varbinary(32)) as thumbprint + , CAST('' as sys.nvarchar(260)) as attested_by + , CAST('' as sys.datetime) AS pvt_key_last_backup_date + , CAST(0 AS sys.int) AS key_length + +WHERE FALSE; +GRANT SELECT ON sys.certificates TO PUBLIC; + +CREATE OR REPLACE VIEW sys.database_permissions +AS +SELECT + CAST(0 as sys.tinyint) AS class, + CAST('' as sys.NVARCHAR(60)) AS class_desc, + CAST(0 as sys.int) AS major_id, + CAST(0 as sys.int) AS minor_id, + CAST(0 as sys.int) AS grantee_principal_id, + CAST(0 as sys.int) AS grantor_principal_id, + CAST('a' as sys.bpchar(4)) AS type, + CAST('' as sys.NVARCHAR(128)) AS permission_name, + CAST('G' as sys.bpchar(1)) AS state, + CAST('' as sys.NVARCHAR(60)) AS state_desc +WHERE FALSE; +GRANT SELECT ON sys.database_permissions TO PUBLIC; + -- Drops the temporary procedure used by the upgrade script. -- Please have this be one of the last statements executed in this upgrade script. DROP PROCEDURE sys.babelfish_drop_deprecated_object(varchar, varchar, varchar); diff --git a/test/JDBC/expected/sys_asymmetric_keys-vu-cleanup.out b/test/JDBC/expected/sys_asymmetric_keys-vu-cleanup.out new file mode 100644 index 0000000000..3a7726a947 --- /dev/null +++ b/test/JDBC/expected/sys_asymmetric_keys-vu-cleanup.out @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_asymmetric_keys_vu_prepare_view +GO + +DROP PROC sys_asymmetric_keys_vu_prepare_proc +GO + +DROP FUNCTION sys_asymmetric_keys_vu_prepare_func +GO diff --git a/test/JDBC/expected/sys_asymmetric_keys-vu-prepare.out b/test/JDBC/expected/sys_asymmetric_keys-vu-prepare.out new file mode 100644 index 0000000000..b344c237cd --- /dev/null +++ b/test/JDBC/expected/sys_asymmetric_keys-vu-prepare.out @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_asymmetric_keys_vu_prepare_view AS +SELECT * FROM sys.asymmetric_keys +GO + +CREATE PROC sys_asymmetric_keys_vu_prepare_proc AS +SELECT * FROM sys.asymmetric_keys +GO + +CREATE FUNCTION sys_asymmetric_keys_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.asymmetric_keys WHERE key_length= 0) +END +GO diff --git a/test/JDBC/expected/sys_asymmetric_keys-vu-verify.out b/test/JDBC/expected/sys_asymmetric_keys-vu-verify.out new file mode 100644 index 0000000000..fe7e470272 --- /dev/null +++ b/test/JDBC/expected/sys_asymmetric_keys-vu-verify.out @@ -0,0 +1,31 @@ +USE master +GO + +SELECT * FROM sys.asymmetric_keys +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#varbinary#!#char#!#nvarchar#!#int#!#varbinary#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#uniqueidentifier#!#sql_variant +~~END~~ + + +SELECT * FROM sys_asymmetric_keys_vu_prepare_view +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#varbinary#!#char#!#nvarchar#!#int#!#varbinary#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#uniqueidentifier#!#sql_variant +~~END~~ + + +EXEC sys_asymmetric_keys_vu_prepare_proc +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#varbinary#!#char#!#nvarchar#!#int#!#varbinary#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#uniqueidentifier#!#sql_variant +~~END~~ + + +SELECT sys_asymmetric_keys_vu_prepare_func() +GO +~~START~~ +int +0 +~~END~~ + diff --git a/test/JDBC/expected/sys_certificates-vu-cleanup.out b/test/JDBC/expected/sys_certificates-vu-cleanup.out new file mode 100644 index 0000000000..e3fc7bb825 --- /dev/null +++ b/test/JDBC/expected/sys_certificates-vu-cleanup.out @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_certificates_vu_prepare_view +GO + +DROP PROC sys_certificates_vu_prepare_proc +GO + +DROP FUNCTION sys_certificates_vu_prepare_func +GO diff --git a/test/JDBC/expected/sys_certificates-vu-prepare.out b/test/JDBC/expected/sys_certificates-vu-prepare.out new file mode 100644 index 0000000000..9bdf0789f0 --- /dev/null +++ b/test/JDBC/expected/sys_certificates-vu-prepare.out @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_certificates_vu_prepare_view AS +SELECT * FROM sys.certificates +GO + +CREATE PROC sys_certificates_vu_prepare_proc AS +SELECT * FROM sys.certificates +GO + +CREATE FUNCTION sys_certificates_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.certificates WHERE key_length = 0) +END +GO diff --git a/test/JDBC/expected/sys_certificates-vu-verify.out b/test/JDBC/expected/sys_certificates-vu-verify.out new file mode 100644 index 0000000000..3327a085be --- /dev/null +++ b/test/JDBC/expected/sys_certificates-vu-verify.out @@ -0,0 +1,31 @@ +USE master +GO + +SELECT * FROM sys.certificates +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#bit#!#nvarchar#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#datetime#!#datetime#!#varbinary#!#nvarchar#!#datetime#!#int +~~END~~ + + +SELECT * FROM sys_certificates_vu_prepare_view +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#bit#!#nvarchar#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#datetime#!#datetime#!#varbinary#!#nvarchar#!#datetime#!#int +~~END~~ + + +EXEC sys_certificates_vu_prepare_proc +GO +~~START~~ +varchar#!#int#!#int#!#char#!#nvarchar#!#bit#!#nvarchar#!#nvarchar#!#varbinary#!#nvarchar#!#nvarchar#!#datetime#!#datetime#!#varbinary#!#nvarchar#!#datetime#!#int +~~END~~ + + +SELECT sys_certificates_vu_prepare_func() +GO +~~START~~ +int +0 +~~END~~ + diff --git a/test/JDBC/expected/sys_database_permissions-vu-cleanup.out b/test/JDBC/expected/sys_database_permissions-vu-cleanup.out new file mode 100644 index 0000000000..fcb93d412c --- /dev/null +++ b/test/JDBC/expected/sys_database_permissions-vu-cleanup.out @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_database_permissions_vu_prepare_view +GO + +DROP PROC sys_database_permissions_vu_prepare_proc +GO + +DROP FUNCTION sys_database_permissions_vu_prepare_func +GO diff --git a/test/JDBC/expected/sys_database_permissions-vu-prepare.out b/test/JDBC/expected/sys_database_permissions-vu-prepare.out new file mode 100644 index 0000000000..0276a4581d --- /dev/null +++ b/test/JDBC/expected/sys_database_permissions-vu-prepare.out @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_database_permissions_vu_prepare_view AS +SELECT * FROM sys.database_permissions +GO + +CREATE PROC sys_database_permissions_vu_prepare_proc AS +SELECT * FROM sys.database_permissions +GO + +CREATE FUNCTION sys_database_permissions_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.database_permissions WHERE state='A') +END +GO diff --git a/test/JDBC/expected/sys_database_permissions-vu-verify.out b/test/JDBC/expected/sys_database_permissions-vu-verify.out new file mode 100644 index 0000000000..83fbd0207d --- /dev/null +++ b/test/JDBC/expected/sys_database_permissions-vu-verify.out @@ -0,0 +1,31 @@ +USE master +GO + +SELECT * FROM sys.database_permissions +GO +~~START~~ +tinyint#!#nvarchar#!#int#!#int#!#int#!#int#!#char#!#nvarchar#!#char#!#nvarchar +~~END~~ + + +SELECT * FROM sys_database_permissions_vu_prepare_view +GO +~~START~~ +tinyint#!#nvarchar#!#int#!#int#!#int#!#int#!#char#!#nvarchar#!#char#!#nvarchar +~~END~~ + + +EXEC sys_database_permissions_vu_prepare_proc +GO +~~START~~ +tinyint#!#nvarchar#!#int#!#int#!#int#!#int#!#char#!#nvarchar#!#char#!#nvarchar +~~END~~ + + +SELECT sys_database_permissions_vu_prepare_func() +GO +~~START~~ +int +0 +~~END~~ + diff --git a/test/JDBC/input/views/sys_asymmetric_keys-vu-cleanup.sql b/test/JDBC/input/views/sys_asymmetric_keys-vu-cleanup.sql new file mode 100644 index 0000000000..896611741f --- /dev/null +++ b/test/JDBC/input/views/sys_asymmetric_keys-vu-cleanup.sql @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_asymmetric_keys_vu_prepare_view +GO + +DROP PROC sys_asymmetric_keys_vu_prepare_proc +GO + +DROP FUNCTION sys_asymmetric_keys_vu_prepare_func +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_asymmetric_keys-vu-prepare.sql b/test/JDBC/input/views/sys_asymmetric_keys-vu-prepare.sql new file mode 100644 index 0000000000..5a6eebbb99 --- /dev/null +++ b/test/JDBC/input/views/sys_asymmetric_keys-vu-prepare.sql @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_asymmetric_keys_vu_prepare_view AS +SELECT * FROM sys.asymmetric_keys +GO + +CREATE PROC sys_asymmetric_keys_vu_prepare_proc AS +SELECT * FROM sys.asymmetric_keys +GO + +CREATE FUNCTION sys_asymmetric_keys_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.asymmetric_keys WHERE key_length= 0) +END +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_asymmetric_keys-vu-verify.sql b/test/JDBC/input/views/sys_asymmetric_keys-vu-verify.sql new file mode 100644 index 0000000000..3253bf2b95 --- /dev/null +++ b/test/JDBC/input/views/sys_asymmetric_keys-vu-verify.sql @@ -0,0 +1,14 @@ +USE master +GO + +SELECT * FROM sys.asymmetric_keys +GO + +SELECT * FROM sys_asymmetric_keys_vu_prepare_view +GO + +EXEC sys_asymmetric_keys_vu_prepare_proc +GO + +SELECT sys_asymmetric_keys_vu_prepare_func() +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_certificates-vu-cleanup.sql b/test/JDBC/input/views/sys_certificates-vu-cleanup.sql new file mode 100644 index 0000000000..b72014914a --- /dev/null +++ b/test/JDBC/input/views/sys_certificates-vu-cleanup.sql @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_certificates_vu_prepare_view +GO + +DROP PROC sys_certificates_vu_prepare_proc +GO + +DROP FUNCTION sys_certificates_vu_prepare_func +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_certificates-vu-prepare.sql b/test/JDBC/input/views/sys_certificates-vu-prepare.sql new file mode 100644 index 0000000000..640d322249 --- /dev/null +++ b/test/JDBC/input/views/sys_certificates-vu-prepare.sql @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_certificates_vu_prepare_view AS +SELECT * FROM sys.certificates +GO + +CREATE PROC sys_certificates_vu_prepare_proc AS +SELECT * FROM sys.certificates +GO + +CREATE FUNCTION sys_certificates_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.certificates WHERE key_length = 0) +END +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_certificates-vu-verify.sql b/test/JDBC/input/views/sys_certificates-vu-verify.sql new file mode 100644 index 0000000000..4211d6616b --- /dev/null +++ b/test/JDBC/input/views/sys_certificates-vu-verify.sql @@ -0,0 +1,14 @@ +USE master +GO + +SELECT * FROM sys.certificates +GO + +SELECT * FROM sys_certificates_vu_prepare_view +GO + +EXEC sys_certificates_vu_prepare_proc +GO + +SELECT sys_certificates_vu_prepare_func() +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_database_permissions-vu-cleanup.sql b/test/JDBC/input/views/sys_database_permissions-vu-cleanup.sql new file mode 100644 index 0000000000..f3fc7169ae --- /dev/null +++ b/test/JDBC/input/views/sys_database_permissions-vu-cleanup.sql @@ -0,0 +1,11 @@ +USE master +GO + +DROP VIEW sys_database_permissions_vu_prepare_view +GO + +DROP PROC sys_database_permissions_vu_prepare_proc +GO + +DROP FUNCTION sys_database_permissions_vu_prepare_func +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_database_permissions-vu-prepare.sql b/test/JDBC/input/views/sys_database_permissions-vu-prepare.sql new file mode 100644 index 0000000000..863addbcb3 --- /dev/null +++ b/test/JDBC/input/views/sys_database_permissions-vu-prepare.sql @@ -0,0 +1,18 @@ +USE master +GO + +CREATE VIEW sys_database_permissions_vu_prepare_view AS +SELECT * FROM sys.database_permissions +GO + +CREATE PROC sys_database_permissions_vu_prepare_proc AS +SELECT * FROM sys.database_permissions +GO + +CREATE FUNCTION sys_database_permissions_vu_prepare_func() +RETURNS INT +AS +BEGIN + RETURN (SELECT COUNT(*) FROM sys.database_permissions WHERE state='A') +END +GO \ No newline at end of file diff --git a/test/JDBC/input/views/sys_database_permissions-vu-verify.sql b/test/JDBC/input/views/sys_database_permissions-vu-verify.sql new file mode 100644 index 0000000000..3ca4edfd57 --- /dev/null +++ b/test/JDBC/input/views/sys_database_permissions-vu-verify.sql @@ -0,0 +1,14 @@ +USE master +GO + +SELECT * FROM sys.database_permissions +GO + +SELECT * FROM sys_database_permissions_vu_prepare_view +GO + +EXEC sys_database_permissions_vu_prepare_proc +GO + +SELECT sys_database_permissions_vu_prepare_func() +GO \ No newline at end of file diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index b51013071f..1f9ff2f097 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -414,3 +414,7 @@ BABEL_4330 Test_ISNULL BABEL-4410 #AUTO_ANALYZE #uncomment this test when preparing for new minor version +BABEL-4231 +sys_asymmetric_keys +sys_certificates +sys_database_permissions diff --git a/test/python/SMO_script.ps1 b/test/python/SMO_script.ps1 index 63d213e2d5..753ab495a3 100644 --- a/test/python/SMO_script.ps1 +++ b/test/python/SMO_script.ps1 @@ -17,6 +17,8 @@ $script_flag = $paramsArray[5] $schm = "sys" $dtb = "sysdatabases" $var_one = "1" +$schm1 = "dbo" +$schm2 = "guest" @@ -52,6 +54,7 @@ else $Objects += $db.UserDefinedFunctions $SubObjects += $db.Tables.Indexes $SubObjects += $db.Tables.Triggers + $SubObjects += $db.Users foreach ($CurrentObject in $Objects) { if ($CurrentObject.schema -ne $schm -and $CurrentObject.schema -ne $dtb -and $CurrentObject.schema -ne $null -and -not $CurrentObject.IsSystemObject ) @@ -67,7 +70,7 @@ else } foreach ($CurrentObject in $SubObjects) { - if (-not $CurrentObject.IsSystemObject ) + if (-not $CurrentObject.IsSystemObject -and $CurrentObject.Name -ne $schm1 -and $CurrentObject.Name -ne $schm2) { $Scripter = New-Object ('Microsoft.SqlServer.Management.Smo.Scripter') ($SmoServer) $Scripter.Options.DriAll = $True; diff --git a/test/python/expected/pyodbc/ddl_users.out b/test/python/expected/pyodbc/ddl_users.out new file mode 100644 index 0000000000..d46f90cbdb --- /dev/null +++ b/test/python/expected/pyodbc/ddl_users.out @@ -0,0 +1,9 @@ +CREATE USER [test_usr1] FOR LOGIN [test_pwd1] WITH DEFAULT_SCHEMA=[dbo] +GO + +CREATE USER [test_usr2] FOR LOGIN [test_pwd2] WITH DEFAULT_SCHEMA=[dbo] +GO + +CREATE USER [test_usr3] FOR LOGIN [test_pwd3] WITH DEFAULT_SCHEMA=[dbo] +GO + diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index 0f31f5234d..bb6b61cc11 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -935,7 +935,6 @@ Operator sys.^(smallint,smallint) Operator sys.^(sys.tinyint,sys.tinyint) Operator sys.~(NONE,sys."bit") Type sys."bigint" -Type sys."int" Type sys."real" Type sys.bbf_varbinary Type sys.cursor diff --git a/test/python/input/ddl_users.sql b/test/python/input/ddl_users.sql new file mode 100644 index 0000000000..8b77670d16 --- /dev/null +++ b/test/python/input/ddl_users.sql @@ -0,0 +1,41 @@ +/* This test files will check for scripting views only */ +DROP USER IF EXISTS test_usr1 +GO +DROP USER IF EXISTS test_usr2 +GO +DROP USER IF EXISTS test_usr3 +GO + +CREATE LOGIN test_pwd1 + WITH PASSWORD = '340$Uuxwp7Mcxo7Khy'; + +CREATE LOGIN test_pwd2 + WITH PASSWORD = '340$UuxwpMcxo7Khy'; + +CREATE LOGIN test_pwd3 + WITH PASSWORD = '340$Uuxwp7Mco7Khy'; + + + +CREATE USER test_usr1 FOR LOGIN test_pwd1; +GO + +CREATE USER test_usr2 FOR LOGIN test_pwd2; +GO + +CREATE USER test_usr3 FOR LOGIN test_pwd3; +GO + +--DROP +DROP LOGIN test_pwd1 +GO +DROP LOGIN test_pwd2 +GO +DROP LOGIN test_pwd3 +GO +DROP USER IF EXISTS test_usr1 +GO +DROP USER IF EXISTS test_usr2 +GO +DROP USER IF EXISTS test_usr3 +GO \ No newline at end of file diff --git a/test/python/input/ddl_views.sql b/test/python/input/ddl_views.sql index 155cce6b46..362575b6cb 100644 --- a/test/python/input/ddl_views.sql +++ b/test/python/input/ddl_views.sql @@ -29,4 +29,4 @@ GO DROP VIEW IF EXISTS sys_all_views_dep_view_vu_prepare GO DROP TABLE IF EXISTS sys_all_views_table_vu_prepare -GO \ No newline at end of file +GO