diff --git a/contrib/babelfishpg_tsql/sql/ownership.sql b/contrib/babelfishpg_tsql/sql/ownership.sql index ee3a5446a4..b4180aaebd 100644 --- a/contrib/babelfishpg_tsql/sql/ownership.sql +++ b/contrib/babelfishpg_tsql/sql/ownership.sql @@ -14,17 +14,6 @@ CREATE TABLE sys.babelfish_sysdatabases ( GRANT SELECT on sys.babelfish_sysdatabases TO PUBLIC; --- BABELFISH_SCHEMA_PERMISSIONS -CREATE TABLE sys.babelfish_schema_permissions ( - dbid smallint NOT NULL, - schema_name NAME NOT NULL, - object_name NAME NOT NULL, - permission NAME NOT NULL, - grantee NAME NOT NULL, - object_type NAME, - PRIMARY KEY(dbid, schema_name, object_name, permission, grantee) -); - -- BABELFISH_FUNCTION_EXT CREATE TABLE sys.babelfish_function_ext ( nspname NAME NOT NULL, diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql index fe14153457..2a70b44c35 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--3.3.0--3.4.0.sql @@ -782,7 +782,6 @@ $BODY$ LANGUAGE plpgsql IMMUTABLE; - CREATE OR REPLACE FUNCTION sys.DATETRUNC(IN datepart PG_CATALOG.TEXT, IN date ANYELEMENT) RETURNS ANYELEMENT AS $body$ DECLARE @@ -889,17 +888,6 @@ END; $body$ LANGUAGE plpgsql STABLE; --- BABELFISH_SCHEMA_PERMISSIONS -CREATE TABLE IF NOT EXISTS sys.babelfish_schema_permissions ( - dbid smallint NOT NULL, - schema_name NAME NOT NULL, - object_name NAME NOT NULL, - permission NAME NOT NULL, - grantee NAME NOT NULL, - object_type NAME, - PRIMARY KEY(dbid, schema_name, object_name, permission, grantee) -); - create or replace function sys.babelfish_timezone_mapping(IN tmz text) returns text AS 'babelfishpg_tsql', 'timezone_mapping' LANGUAGE C IMMUTABLE ; diff --git a/contrib/babelfishpg_tsql/src/catalog.c b/contrib/babelfishpg_tsql/src/catalog.c index 8f1f9bdc2a..1032acfb90 100644 --- a/contrib/babelfishpg_tsql/src/catalog.c +++ b/contrib/babelfishpg_tsql/src/catalog.c @@ -83,12 +83,6 @@ Oid bbf_servers_def_idx_oid; Oid bbf_function_ext_oid; Oid bbf_function_ext_idx_oid; -/***************************************** - * SCHEMA - *****************************************/ -Oid bbf_schema_perms_oid; -Oid bbf_schema_perms_idx_oid; - /***************************************** * DOMAIN MAPPING *****************************************/ @@ -1441,29 +1435,6 @@ clean_up_bbf_function_ext(int16 dbid) table_close(bbf_function_ext_rel, RowExclusiveLock); } - -/***************************************** - * SCHEMA - *****************************************/ - -Oid -get_bbf_schema_perms_oid() -{ - if (!OidIsValid(bbf_schema_perms_oid)) - bbf_schema_perms_oid = get_relname_relid(BBF_SCHEMA_PERMS_TABLE_NAME, - get_namespace_oid("sys", false)); - return bbf_schema_perms_oid; -} - -Oid -get_bbf_schema_perms_idx_oid() -{ - if (!OidIsValid(bbf_schema_perms_idx_oid)) - bbf_schema_perms_idx_oid = get_relname_relid(BBF_SCHEMA_PERMS_IDX_NAME, - get_namespace_oid("sys", false)); - return bbf_schema_perms_idx_oid; -} - /***************************************** * DOMAIN MAPPING *****************************************/ @@ -2828,346 +2799,6 @@ rename_procfunc_update_bbf_catalog(RenameStmt *stmt) table_close(bbf_func_ext_rel, RowExclusiveLock); } -/* Add a catalog entry. */ -void -add_entry_to_bbf_schema(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee, - const char *object_type) -{ - Relation bbf_schema_rel; - TupleDesc bbf_schema_dsc; - HeapTuple tuple_bbf_schema; - Datum new_record_bbf_schema[BBF_SCHEMA_PERMS_NUM_OF_COLS]; - bool new_record_nulls_bbf_schema[BBF_SCHEMA_PERMS_NUM_OF_COLS]; - int16 dbid = get_cur_db_id(); - - /* Fetch the relation */ - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - RowExclusiveLock); - bbf_schema_dsc = RelationGetDescr(bbf_schema_rel); - - /* Build a tuple to insert */ - MemSet(new_record_bbf_schema, 0, sizeof(new_record_bbf_schema)); - MemSet(new_record_nulls_bbf_schema, false, sizeof(new_record_nulls_bbf_schema)); - - new_record_bbf_schema[BBF_SCHEMA_PERMS_DBID] = Int16GetDatum(dbid); - new_record_bbf_schema[BBF_SCHEMA_PERMS_SCHEMA_NAME] = CStringGetDatum(pstrdup(schema_name)); - new_record_bbf_schema[BBF_SCHEMA_PERMS_OBJECT_NAME] = CStringGetDatum(pstrdup(object_name)); - new_record_bbf_schema[BBF_SCHEMA_PERMS_PERMISSION] = CStringGetDatum(pstrdup(permission)); - new_record_bbf_schema[BBF_SCHEMA_PERMS_GRANTEE] = CStringGetDatum(pstrdup(grantee)); - if (object_type != NULL) - new_record_bbf_schema[BBF_SCHEMA_PERMS_OBJECT_TYPE] = CStringGetDatum(pstrdup(object_type)); - else - new_record_nulls_bbf_schema[BBF_SCHEMA_PERMS_OBJECT_TYPE] = true; - - tuple_bbf_schema = heap_form_tuple(bbf_schema_dsc, - new_record_bbf_schema, - new_record_nulls_bbf_schema); - - /* Insert new record in the bbf_authid_user_ext table */ - CatalogTupleInsert(bbf_schema_rel, tuple_bbf_schema); - - /* Close bbf_authid_user_ext, but keep lock till commit */ - table_close(bbf_schema_rel, RowExclusiveLock); - - /* Advance cmd counter to make the insert visible */ - CommandCounterIncrement(); -} - -/* Check if the catalog entry exists. */ -bool -check_bbf_schema_for_entry(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee) -{ - Relation bbf_schema_rel; - HeapTuple tuple_bbf_schema; - ScanKeyData key[5]; - TableScanDesc scan; - bool catalog_entry_exists = false; - int16 dbid = get_cur_db_id(); - - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - AccessShareLock); - ScanKeyInit(&key[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&key[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - ScanKeyInit(&key[2], - Anum_bbf_schema_perms_object_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(object_name)); - ScanKeyInit(&key[3], - Anum_bbf_schema_perms_permission, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(permission)); - ScanKeyInit(&key[4], - Anum_bbf_schema_perms_grantee, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(grantee)); - - scan = table_beginscan_catalog(bbf_schema_rel, 5, key); - - tuple_bbf_schema = heap_getnext(scan, ForwardScanDirection); - if (HeapTupleIsValid(tuple_bbf_schema)) - catalog_entry_exists = true; - - table_endscan(scan); - table_close(bbf_schema_rel, AccessShareLock); - return catalog_entry_exists; -} - -bool -check_bbf_schema_for_schema(const char *schema_name, - const char *object_name, - const char *permission) -{ - Relation bbf_schema_rel; - HeapTuple tuple_bbf_schema; - ScanKeyData key[4]; - TableScanDesc scan; - bool catalog_entry_exists = false; - int16 dbid = get_cur_db_id(); - - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - AccessShareLock); - ScanKeyInit(&key[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&key[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - ScanKeyInit(&key[2], - Anum_bbf_schema_perms_object_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(object_name)); - ScanKeyInit(&key[3], - Anum_bbf_schema_perms_permission, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(permission)); - - scan = table_beginscan_catalog(bbf_schema_rel, 4, key); - - tuple_bbf_schema = heap_getnext(scan, ForwardScanDirection); - if (HeapTupleIsValid(tuple_bbf_schema)) - catalog_entry_exists = true; - - table_endscan(scan); - table_close(bbf_schema_rel, AccessShareLock); - return catalog_entry_exists; -} - -void -del_from_bbf_schema(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee) -{ - Relation bbf_schema_rel; - HeapTuple tuple_bbf_schema; - ScanKeyData key[5]; - TableScanDesc scan; - int16 dbid = get_cur_db_id(); - - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - RowExclusiveLock); - ScanKeyInit(&key[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&key[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - ScanKeyInit(&key[2], - Anum_bbf_schema_perms_object_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(object_name)); - ScanKeyInit(&key[3], - Anum_bbf_schema_perms_permission, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(permission)); - ScanKeyInit(&key[4], - Anum_bbf_schema_perms_grantee, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(grantee)); - - scan = table_beginscan_catalog(bbf_schema_rel, 5, key); - - tuple_bbf_schema = heap_getnext(scan, ForwardScanDirection); - - if (HeapTupleIsValid(tuple_bbf_schema)) - CatalogTupleDelete(bbf_schema_rel, &tuple_bbf_schema->t_self); - - table_endscan(scan); - table_close(bbf_schema_rel, RowExclusiveLock); - - CommandCounterIncrement(); -} - -void -clean_up_bbf_schema(const char *schema_name, - const char *object_name, - bool is_schema) -{ - SysScanDesc scan; - Relation bbf_schema_rel; - HeapTuple tuple_bbf_schema; - int16 dbid = get_cur_db_id(); - - /* Fetch the relation */ - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - RowExclusiveLock); - - if (is_schema) - { - ScanKeyData scanKey[2]; - ScanKeyInit(&scanKey[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&scanKey[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - scan = systable_beginscan(bbf_schema_rel, - get_bbf_schema_perms_idx_oid(), - true, NULL, 2, scanKey); - } - else - { - ScanKeyData scanKey[3]; - ScanKeyInit(&scanKey[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&scanKey[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - ScanKeyInit(&scanKey[2], - Anum_bbf_schema_perms_object_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(object_name)); - scan = systable_beginscan(bbf_schema_rel, - get_bbf_schema_perms_idx_oid(), - true, NULL, 3, scanKey); - } - - while ((tuple_bbf_schema = systable_getnext(scan)) != NULL) - { - if (HeapTupleIsValid(tuple_bbf_schema)) - CatalogTupleDelete(bbf_schema_rel, - &tuple_bbf_schema->t_self); - } - - systable_endscan(scan); - table_close(bbf_schema_rel, RowExclusiveLock); -} - -void -grant_perms_to_objects_in_schema(const char *schema_name, - const char *permission, - const char *grantee) -{ - TableScanDesc scan; - Relation bbf_schema_rel; - HeapTuple tuple_bbf_schema; - const char *object_name; - const char *object_type; - ScanKeyData scanKey[4]; - int16 dbid = get_cur_db_id(); - const char *db_name = get_cur_db_name(); - - /* Fetch the relation */ - bbf_schema_rel = table_open(get_bbf_schema_perms_oid(), - AccessShareLock); - ScanKeyInit(&scanKey[0], - Anum_bbf_schema_perms_dbid, - BTEqualStrategyNumber, F_INT2EQ, - Int16GetDatum(dbid)); - ScanKeyInit(&scanKey[1], - Anum_bbf_schema_perms_schema_name, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(schema_name)); - ScanKeyInit(&scanKey[2], - Anum_bbf_schema_perms_permission, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(permission)); - ScanKeyInit(&scanKey[3], - Anum_bbf_schema_perms_grantee, - BTEqualStrategyNumber, F_NAMEEQ, - CStringGetDatum(grantee)); - - scan = table_beginscan_catalog(bbf_schema_rel, 4, scanKey); - tuple_bbf_schema = heap_getnext(scan, ForwardScanDirection); - - while (HeapTupleIsValid(tuple_bbf_schema)) - { - Form_bbf_schema_perms schemaform; - schemaform = (Form_bbf_schema_perms) GETSTRUCT(tuple_bbf_schema); - object_name = pstrdup(NameStr(schemaform->object_name)); - object_type = pstrdup(NameStr(schemaform->object_type)); - - /* For each object, grant the permission explicitly. */ - if (strcmp(object_name, "ALL") != 0) - { - StringInfoData query; - char *schema; - List *res; - Node *res_stmt; - PlannedStmt *wrapper; - - schema = get_physical_schema_name((char *)db_name, schema_name); - initStringInfo(&query); - if (strcmp(permission, "execute") != 0) - appendStringInfo(&query, "GRANT \"%s\" ON \"%s\".\"%s\" TO \"%s\"; ", permission, schema, object_name, grantee); - else - { - if (object_type != NULL && strcmp(object_type, "f") == 0) - appendStringInfo(&query, "GRANT \"%s\" ON FUNCTION \"%s\".\"%s\" TO \"%s\"; ", permission, schema, object_name, grantee); - else - appendStringInfo(&query, "GRANT \"%s\" ON PROCEDURE \"%s\".\"%s\" TO \"%s\"; ", permission, schema, object_name, grantee); - } - res = raw_parser(query.data, RAW_PARSE_DEFAULT); - res_stmt = ((RawStmt *) linitial(res))->stmt; - - /* need to make a wrapper PlannedStmt */ - wrapper = makeNode(PlannedStmt); - wrapper->commandType = CMD_UTILITY; - wrapper->canSetTag = false; - wrapper->utilityStmt = res_stmt; - wrapper->stmt_location = 0; - wrapper->stmt_len = 1; - - /* do this step */ - ProcessUtility(wrapper, - "(GRANT STATEMENT )", - false, - PROCESS_UTILITY_SUBCOMMAND, - NULL, - NULL, - None_Receiver, - NULL); - - /* make sure later steps can see the object created here */ - CommandCounterIncrement(); - } - tuple_bbf_schema = heap_getnext(scan, ForwardScanDirection); - } - table_endscan(scan); - table_close(bbf_schema_rel, AccessShareLock); -} - PG_FUNCTION_INFO_V1(update_user_catalog_for_guest_schema); Datum update_user_catalog_for_guest_schema(PG_FUNCTION_ARGS) diff --git a/contrib/babelfishpg_tsql/src/catalog.h b/contrib/babelfishpg_tsql/src/catalog.h index 7b8ad195c2..558969b758 100644 --- a/contrib/babelfishpg_tsql/src/catalog.h +++ b/contrib/babelfishpg_tsql/src/catalog.h @@ -280,71 +280,6 @@ typedef struct FormData_bbf_function_ext typedef FormData_bbf_function_ext *Form_bbf_function_ext; -/***************************************** - * SCHEMA_PERMISSIONS - *****************************************/ -#define BBF_SCHEMA_PERMS_TABLE_NAME "babelfish_schema_permissions" -#define BBF_SCHEMA_PERMS_IDX_NAME "babelfish_schema_permissions_pkey" -#define BBF_SCHEMA_PERMS_NUM_OF_COLS 6 -#define BBF_SCHEMA_PERMS_DBID 0 -#define BBF_SCHEMA_PERMS_SCHEMA_NAME 1 -#define BBF_SCHEMA_PERMS_OBJECT_NAME 2 -#define BBF_SCHEMA_PERMS_PERMISSION 3 -#define BBF_SCHEMA_PERMS_GRANTEE 4 -#define BBF_SCHEMA_PERMS_OBJECT_TYPE 5 -#define Anum_bbf_schema_perms_dbid 1 -#define Anum_bbf_schema_perms_schema_name 2 -#define Anum_bbf_schema_perms_object_name 3 -#define Anum_bbf_schema_perms_permission 4 -#define Anum_bbf_schema_perms_grantee 5 -#define Anum_bbf_schema_perms_object_type 6 - -extern Oid bbf_schema_perms_oid; -extern Oid bbf_schema_perms_idx_oid; - -extern Oid get_bbf_schema_perms_oid(void); -extern Oid get_bbf_schema_perms_idx_oid(void); - -typedef struct FormData_bbf_schema_perms -{ - int16 dbid; - NameData schema_name; - NameData object_name; - NameData permission; - NameData grantee; - NameData object_type; -} FormData_bbf_schema_perms; - -typedef FormData_bbf_schema_perms *Form_bbf_schema_perms; - -extern void add_entry_to_bbf_schema(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee, - const char *object_type); - -extern bool check_bbf_schema_for_entry(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee); - -extern void del_from_bbf_schema(const char *schema_name, - const char *object_name, - const char *permission, - const char *grantee); - -extern bool check_bbf_schema_for_schema(const char *schema_name, - const char *object_name, - const char *permission); - -extern void clean_up_bbf_schema(const char *schema_name, - const char *object_name, - bool is_schema); - -extern void grant_perms_to_objects_in_schema(const char *schema_name, - const char *permission, - const char *grantee); - /***************************************** * DOMAIN MAPPING *****************************************/ diff --git a/contrib/babelfishpg_tsql/src/codegen.c b/contrib/babelfishpg_tsql/src/codegen.c index c25fb924e2..745152d1dd 100644 --- a/contrib/babelfishpg_tsql/src/codegen.c +++ b/contrib/babelfishpg_tsql/src/codegen.c @@ -301,7 +301,6 @@ stmt_default_act(Walker_context *ctx, PLtsql_stmt *stmt) case PLTSQL_STMT_USEDB: case PLTSQL_STMT_GRANTDB: case PLTSQL_STMT_CHANGE_DBOWNER: - case PLTSQL_STMT_GRANTSCHEMA: case PLTSQL_STMT_FULLTEXTINDEX: case PLTSQL_STMT_INSERT_BULK: case PLTSQL_STMT_DBCC: diff --git a/contrib/babelfishpg_tsql/src/dbcmds.c b/contrib/babelfishpg_tsql/src/dbcmds.c index 3254ce6805..837e1afab2 100644 --- a/contrib/babelfishpg_tsql/src/dbcmds.c +++ b/contrib/babelfishpg_tsql/src/dbcmds.c @@ -154,7 +154,7 @@ gen_createdb_subcmds(const char *schema, const char *dbo, const char *db_owner, update_CreateRoleStmt(stmt, dbo, NULL, db_owner); stmt = parsetree_nth_stmt(res, i++); - update_GrantStmt(stmt, get_database_name(MyDatabaseId), NULL, dbo, NULL); + update_GrantStmt(stmt, get_database_name(MyDatabaseId), NULL, dbo); if (guest) { @@ -181,7 +181,7 @@ gen_createdb_subcmds(const char *schema, const char *dbo, const char *db_owner, stmt = parsetree_nth_stmt(res, i++); update_AlterTableStmt(stmt, schema, db_owner); - + if (guest) { stmt = parsetree_nth_stmt(res, i++); @@ -261,7 +261,7 @@ gen_dropdb_subcmds(const char *schema, update_DropOwnedStmt(stmt, list_make2(pstrdup(db_owner), pstrdup(dbo))); stmt = parsetree_nth_stmt(stmt_list, i++); - update_GrantStmt(stmt, get_database_name(MyDatabaseId), NULL, dbo, NULL); + update_GrantStmt(stmt, get_database_name(MyDatabaseId), NULL, dbo); stmt = parsetree_nth_stmt(stmt_list, i++); update_DropRoleStmt(stmt, db_owner); diff --git a/contrib/babelfishpg_tsql/src/iterative_exec.c b/contrib/babelfishpg_tsql/src/iterative_exec.c index c5af008265..b992b8c769 100644 --- a/contrib/babelfishpg_tsql/src/iterative_exec.c +++ b/contrib/babelfishpg_tsql/src/iterative_exec.c @@ -808,15 +808,6 @@ dispatch_stmt(PLtsql_execstate *estate, PLtsql_stmt *stmt) errmsg("Showing Estimated Execution Plan for ALTER AUTHORIZATION statement is not yet supported"))); } exec_stmt_change_dbowner(estate, (PLtsql_stmt_change_dbowner *) stmt); - break; - case PLTSQL_STMT_GRANTSCHEMA: - if (pltsql_explain_only) - { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Showing Estimated Execution Plan for GRANT DB statment is not yet supported"))); - } - exec_stmt_grantschema(estate, (PLtsql_stmt_grantschema *) stmt); break; case PLTSQL_STMT_FULLTEXTINDEX: if (pltsql_explain_only) diff --git a/contrib/babelfishpg_tsql/src/pl_exec-2.c b/contrib/babelfishpg_tsql/src/pl_exec-2.c index 4e948a0be0..8cab47c3ec 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec-2.c +++ b/contrib/babelfishpg_tsql/src/pl_exec-2.c @@ -53,7 +53,6 @@ static int exec_run_dml_with_output(PLtsql_execstate *estate, PLtsql_stmt_push_r static int exec_stmt_usedb(PLtsql_execstate *estate, PLtsql_stmt_usedb *stmt); static int exec_stmt_usedb_explain(PLtsql_execstate *estate, PLtsql_stmt_usedb *stmt, bool shouldRestoreDb); static int exec_stmt_grantdb(PLtsql_execstate *estate, PLtsql_stmt_grantdb *stmt); -static int exec_stmt_grantschema(PLtsql_execstate *estate, PLtsql_stmt_grantschema *stmt); static int exec_stmt_fulltextindex(PLtsql_execstate *estate, PLtsql_stmt_fulltextindex *stmt); static int exec_stmt_insert_execute_select(PLtsql_execstate *estate, PLtsql_expr *expr); static int exec_stmt_insert_bulk(PLtsql_execstate *estate, PLtsql_stmt_insert_bulk *expr); @@ -3675,106 +3674,6 @@ get_insert_bulk_kilobytes_per_batch() return insert_bulk_kilobytes_per_batch; } -static int -exec_stmt_grantschema(PLtsql_execstate *estate, PLtsql_stmt_grantschema *stmt) -{ - List *parsetree_list; - ListCell *parsetree_item; - char *dbname = get_cur_db_name(); - char *login = GetUserNameFromId(GetSessionUserId(), false); - bool login_is_db_owner; - Oid datdba; - char *rolname; - char *schema_name; - ListCell *lc; - ListCell *lc1; - Oid schemaOid; - - /* - * If the login is not the db owner or the login is not the member of - * sysadmin or login is not the schema owner, then it doesn't have the permission to GRANT/REVOKE. - */ - login_is_db_owner = 0 == strncmp(login, get_owner_of_db(dbname), NAMEDATALEN); - datdba = get_role_oid("sysadmin", false); - schema_name = get_physical_schema_name(dbname, stmt->schema_name); - schemaOid = LookupExplicitNamespace(schema_name, true); - - if (!OidIsValid(schemaOid)) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("schema \"%s\" does not exist", - schema_name))); - - if (!is_member_of_role(GetSessionUserId(), datdba) && !login_is_db_owner && !pg_namespace_ownercheck(schemaOid, GetUserId())) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("Cannot find the schema \"%s\", because it does not exist or you do not have permission.", stmt->schema_name))); - - foreach(lc1, stmt->privileges) - { - char *priv_name = (char *) lfirst(lc1); - foreach(lc, stmt->grantees) - { - char *grantee_name = (char *) lfirst(lc); - Oid role_oid; - bool grantee_is_db_owner; - rolname = get_physical_user_name(dbname, grantee_name); - role_oid = get_role_oid(rolname, true); - grantee_is_db_owner = 0 == strncmp(grantee_name, get_owner_of_db(dbname), NAMEDATALEN); - - - if (role_oid == InvalidOid) - ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("Cannot find the principal '%s', because it does not exist or you do not have permission.", grantee_name))); - - if (pg_namespace_ownercheck(schemaOid, role_oid) || is_member_of_role(role_oid, datdba) || grantee_is_db_owner) - ereport(ERROR, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself."))); - - parsetree_list = gen_grantschema_subcmds(schema_name, rolname, stmt->is_grant, stmt->with_grant_option, priv_name); - /* Run all subcommands */ - foreach(parsetree_item, parsetree_list) - { - Node *stmt = ((RawStmt *) lfirst(parsetree_item))->stmt; - PlannedStmt *wrapper; - - /* need to make a wrapper PlannedStmt */ - wrapper = makeNode(PlannedStmt); - wrapper->commandType = CMD_UTILITY; - wrapper->canSetTag = false; - wrapper->utilityStmt = stmt; - wrapper->stmt_location = 0; - wrapper->stmt_len = 0; - - /* do this step */ - ProcessUtility(wrapper, - "(GRANT SCHEMA )", - false, - PROCESS_UTILITY_SUBCOMMAND, - NULL, - NULL, - None_Receiver, - NULL); - - /* make sure later steps can see the object created here */ - CommandCounterIncrement(); - } - /* Add entry for each grant statement. */ - if (stmt->is_grant && !check_bbf_schema_for_entry(stmt->schema_name, "ALL", priv_name, rolname)) - add_entry_to_bbf_schema(stmt->schema_name, "ALL", priv_name, rolname, NULL); - /* Remove entry for each revoke statement. */ - if (!stmt->is_grant && check_bbf_schema_for_entry(stmt->schema_name, "ALL", priv_name, rolname)) - { - /* If any object in the schema has the OBJECT level permission. Then, internally grant that permission back. */ - grant_perms_to_objects_in_schema(stmt->schema_name, priv_name, rolname); - del_from_bbf_schema(stmt->schema_name, "ALL", priv_name, rolname); - } - } - } - return PLTSQL_RC_OK; -} - /* * ALTER AUTHORIZATION ON DATABASE::dbname TO loginname */ @@ -3936,4 +3835,4 @@ exec_stmt_fulltextindex(PLtsql_execstate *estate, PLtsql_stmt_fulltextindex *stm */ exec_utility_cmd_helper(query_str); return PLTSQL_RC_OK; -} \ No newline at end of file +} diff --git a/contrib/babelfishpg_tsql/src/pl_funcs-2.c b/contrib/babelfishpg_tsql/src/pl_funcs-2.c index 6ec9d93652..80352240b6 100644 --- a/contrib/babelfishpg_tsql/src/pl_funcs-2.c +++ b/contrib/babelfishpg_tsql/src/pl_funcs-2.c @@ -484,7 +484,6 @@ free_stmt2(PLtsql_stmt *stmt) case PLTSQL_STMT_INSERT_BULK: case PLTSQL_STMT_GRANTDB: case PLTSQL_STMT_CHANGE_DBOWNER: - case PLTSQL_STMT_GRANTSCHEMA: case PLTSQL_STMT_FULLTEXTINDEX: case PLTSQL_STMT_SET_EXPLAIN_MODE: { diff --git a/contrib/babelfishpg_tsql/src/pl_handler.c b/contrib/babelfishpg_tsql/src/pl_handler.c index 10297b0c90..cd63122e8d 100644 --- a/contrib/babelfishpg_tsql/src/pl_handler.c +++ b/contrib/babelfishpg_tsql/src/pl_handler.c @@ -3235,7 +3235,6 @@ bbf_ProcessUtility(PlannedStmt *pstmt, List *res; GrantStmt *stmt; PlannedStmt *wrapper; - RoleSpec *rolspec = create_schema->authrole; if (strcmp(queryString, "(CREATE LOGICAL DATABASE )") == 0 && context == PROCESS_UTILITY_SUBCOMMAND) @@ -3284,45 +3283,7 @@ bbf_ProcessUtility(PlannedStmt *pstmt, NULL); CommandCounterIncrement(); - /* Grant all privileges to the user.*/ - if (rolspec && strcmp(queryString, "(CREATE LOGICAL DATABASE )") != 0) - { - char *permissions[] = {"select", "insert", "update", "references", "delete", "execute"}; - List *parsetree_list; - ListCell *parsetree_item; - int i; - for (i = 0; i < 6; i++) - { - parsetree_list = gen_grantschema_subcmds(create_schema->schemaname, rolspec->rolename, true, false, permissions[i]); - /* Run all subcommands */ - foreach(parsetree_item, parsetree_list) - { - Node *stmt = ((RawStmt *) lfirst(parsetree_item))->stmt; - PlannedStmt *wrapper; - - /* need to make a wrapper PlannedStmt */ - wrapper = makeNode(PlannedStmt); - wrapper->commandType = CMD_UTILITY; - wrapper->canSetTag = false; - wrapper->utilityStmt = stmt; - wrapper->stmt_location = 0; - wrapper->stmt_len = 0; - - /* do this step */ - ProcessUtility(wrapper, - "(GRANT SCHEMA )", - false, - PROCESS_UTILITY_SUBCOMMAND, - NULL, - NULL, - None_Receiver, - NULL); - - /* make sure later steps can see the object created here */ - CommandCounterIncrement(); - } - } - } + return; } else @@ -3336,6 +3297,7 @@ bbf_ProcessUtility(PlannedStmt *pstmt, { if (sql_dialect == SQL_DIALECT_TSQL) bbf_ExecDropStmt(drop_stmt); + break; } @@ -3347,11 +3309,10 @@ bbf_ProcessUtility(PlannedStmt *pstmt, * database command. */ const char *schemaname = strVal(lfirst(list_head(drop_stmt->objects))); - char *cur_db = get_cur_db_name(); - const char *logicalschema = get_logical_schema_name(schemaname, true); if (strcmp(queryString, "(DROP DATABASE )") != 0) { + char *cur_db = get_cur_db_name(); char *guest_schema_name = get_physical_schema_name(cur_db, "guest"); if (strcmp(schemaname, guest_schema_name) == 0) @@ -3364,8 +3325,6 @@ bbf_ProcessUtility(PlannedStmt *pstmt, bbf_ExecDropStmt(drop_stmt); del_ns_ext_info(schemaname, drop_stmt->missing_ok); - if (logicalschema != NULL) - clean_up_bbf_schema(logicalschema, NULL, true); if (prev_ProcessUtility) prev_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, @@ -3603,233 +3562,6 @@ bbf_ProcessUtility(PlannedStmt *pstmt, } break; } - case T_GrantStmt: - { - GrantStmt *grant = (GrantStmt *) parsetree; - char *dbname = get_cur_db_name(); - const char *current_user = GetUserNameFromId(GetUserId(), false); - /* Ignore when GRANT statement has no specific named object. */ - if (sql_dialect != SQL_DIALECT_TSQL || grant->targtype != ACL_TARGET_OBJECT) - break; - Assert(list_length(grant->objects) == 1); - if (grant->objtype == OBJECT_SCHEMA) - break; - else if (grant->objtype == OBJECT_TABLE) - { - /* Ignore CREATE database subcommands */ - if (strcmp("(CREATE LOGICAL DATABASE )", queryString) != 0) - { - RangeVar *rv = (RangeVar *) linitial(grant->objects); - const char *logical_schema = NULL; - char *obj = rv->relname; - ListCell *lc; - ListCell *lc1; - const char *obj_type = "r"; - if (rv->schemaname != NULL) - logical_schema = get_logical_schema_name(rv->schemaname, true); - else - logical_schema = get_authid_user_ext_schema_name(dbname, current_user); - /* If ALL PRIVILEGES is granted/revoked. */ - if (list_length(grant->privileges) == 0) - { - if (grant->is_grant) - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - int i = 0; - char *permissions[] = {"select", "insert", "update", "references", "delete"}; - for(i = 0; i < 5; i++) - { - if ((rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logical_schema, obj, permissions[i], rol_spec->rolename)) - add_entry_to_bbf_schema(logical_schema, obj, permissions[i], rol_spec->rolename, obj_type); - } - } - break; - } - else - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - int i = 0; - bool has_schema_perms = false; - char *permissions[] = {"select", "insert", "update", "references", "delete"}; - for(i = 0; i < 5; i++) - { - if ((rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logical_schema, "ALL", permissions[i], rol_spec->rolename) && !has_schema_perms) - has_schema_perms = true; - if ((rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logical_schema, obj, permissions[i], rol_spec->rolename)) - del_from_bbf_schema(logical_schema, obj, permissions[i], rol_spec->rolename); - } - if (has_schema_perms) - return; - } - break; - } - } - foreach(lc1, grant->privileges) - { - AccessPriv *ap = (AccessPriv *) lfirst(lc1); - if (grant->is_grant) - { - /* - * 1. Execute the GRANT statement. - * 2. Add its corresponding entry in the catalog, if doesn't exist already. - * 3. Don't add an entry, if the permission is granted on column list. - */ - if (prev_ProcessUtility) - prev_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - else - standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - if ((ap->cols == NULL) && (rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logical_schema, obj, ap->priv_name, rol_spec->rolename)) - add_entry_to_bbf_schema(logical_schema, obj, ap->priv_name, rol_spec->rolename, obj_type); - } - } - else - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - /* - * 1. If GRANT on schema does not exist, execute REVOKE statement and remove the catalog entry if exists. - * 2. If GRANT on schema exist, only remove the entry from the catalog if exists. - */ - if ((logical_schema != NULL) && (rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logical_schema, "ALL", ap->priv_name, rol_spec->rolename)) - { - if (prev_ProcessUtility) - prev_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - else - standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - } - if ((ap->cols == NULL) && (rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logical_schema, obj, ap->priv_name, rol_spec->rolename)) - del_from_bbf_schema(logical_schema, obj, ap->priv_name, rol_spec->rolename); - } - } - } - return; - } - } - else if ((grant->objtype == OBJECT_PROCEDURE) || (grant->objtype == OBJECT_FUNCTION)) - { - ObjectWithArgs *ob = (ObjectWithArgs *) linitial(grant->objects); - ListCell *lc; - ListCell *lc1; - const char *logicalschema = NULL; - char *funcname = NULL; - const char *obj_type = NULL; - if (grant->objtype == OBJECT_FUNCTION) - obj_type = "f"; - else - obj_type = "p"; - if (list_length(ob->objname) == 1) - { - Node *func = (Node *) linitial(ob->objname); - funcname = strVal(func); - logicalschema = get_authid_user_ext_schema_name(dbname, current_user); - } - else - { - Node *schema = (Node *) linitial(ob->objname); - char *schemaname = strVal(schema); - Node *func = (Node *) lsecond(ob->objname); - logicalschema = get_logical_schema_name(schemaname, true); - funcname = strVal(func); - } - /* - * Case: When ALL PRIVILEGES is revoked internally during create function. - * Check if schema entry exists in the catalog, do not revoke any permission if exists. - */ - if (pstmt->stmt_len == 0 && list_length(grant->privileges) == 0) - { - if(check_bbf_schema_for_schema(logicalschema, "ALL", "execute")) - return; - break; - } - /* If ALL PRIVILEGES is granted/revoked. */ - if (list_length(grant->privileges) == 0) - { - if (grant->is_grant) - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - if ((rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logicalschema, funcname, "execute", rol_spec->rolename)) - add_entry_to_bbf_schema(logicalschema, funcname, "execute", rol_spec->rolename, obj_type); - } - break; - } - else - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - bool has_schema_perms = false; - if ((rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logicalschema, "ALL", "execute", rol_spec->rolename) && !has_schema_perms) - has_schema_perms = true; - if ((rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logicalschema, funcname, "execute", rol_spec->rolename)) - del_from_bbf_schema(logicalschema, funcname, "execute", rol_spec->rolename); - if (has_schema_perms) - return; - } - break; - } - } - foreach(lc1, grant->privileges) - { - AccessPriv *ap = (AccessPriv *) lfirst(lc1); - if (grant->is_grant) - { - /* Execute the GRANT statement. */ - if (prev_ProcessUtility) - prev_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - else - standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - /* Add entry to the catalog if it doesn't exist already. */ - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - /* Don't store a row in catalog, if permission is granted for column */ - if ((rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logicalschema, funcname, ap->priv_name, rol_spec->rolename)) - add_entry_to_bbf_schema(logicalschema, funcname, ap->priv_name, rol_spec->rolename, obj_type); - } - } - else - { - foreach(lc, grant->grantees) - { - RoleSpec *rol_spec = (RoleSpec *) lfirst(lc); - /* - * 1. If GRANT on schema does not exist, execute REVOKE statement and remove the catalog entry if exists. - * 2. If GRANT on schema exist, only remove the entry from the catalog if exists. - */ - if ((rol_spec->rolename != NULL) && !check_bbf_schema_for_entry(logicalschema, "ALL", ap->priv_name, rol_spec->rolename)) - { - /* Execute REVOKE statement. */ - if (prev_ProcessUtility) - prev_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - else - standard_ProcessUtility(pstmt, queryString, readOnlyTree, context, params, - queryEnv, dest, qc); - } - if ((rol_spec->rolename != NULL) && check_bbf_schema_for_entry(logicalschema, funcname, ap->priv_name, rol_spec->rolename)) - del_from_bbf_schema(logicalschema, funcname, ap->priv_name, rol_spec->rolename); - } - } - } - return; - } - } default: break; } @@ -5919,7 +5651,6 @@ bbf_ExecDropStmt(DropStmt *stmt) Relation relation = NULL; Oid schema_oid; ListCell *cell; - const char *logicalschema = NULL; db_id = get_cur_db_id(); @@ -5960,8 +5691,6 @@ bbf_ExecDropStmt(DropStmt *stmt) schema_oid = get_object_namespace(&address); if (OidIsValid(schema_oid)) schema_name = get_namespace_name(schema_oid); - if (schema_name != NULL) - logicalschema = get_logical_schema_name(schema_name, true); if (schema_name && major_name) { @@ -5987,8 +5716,6 @@ bbf_ExecDropStmt(DropStmt *stmt) major_name, NULL); } } - if (logicalschema != NULL) - clean_up_bbf_schema(logicalschema, major_name, false); } } else if (stmt->removeType == OBJECT_PROCEDURE || @@ -6032,8 +5759,6 @@ bbf_ExecDropStmt(DropStmt *stmt) schema_oid = get_object_namespace(&address); if (OidIsValid(schema_oid)) schema_name = get_namespace_name(schema_oid); - if (schema_name != NULL) - logicalschema = get_logical_schema_name(schema_name, true); if (schema_name && major_name) { @@ -6047,8 +5772,6 @@ bbf_ExecDropStmt(DropStmt *stmt) delete_extended_property(db_id, type, schema_name, major_name, NULL); } - if (logicalschema != NULL) - clean_up_bbf_schema(logicalschema, major_name, false); } } } diff --git a/contrib/babelfishpg_tsql/src/pltsql.h b/contrib/babelfishpg_tsql/src/pltsql.h index ae94b0ddf1..782bdbc4eb 100644 --- a/contrib/babelfishpg_tsql/src/pltsql.h +++ b/contrib/babelfishpg_tsql/src/pltsql.h @@ -194,7 +194,6 @@ typedef enum PLtsql_stmt_type PLTSQL_STMT_GRANTDB, PLTSQL_STMT_CHANGE_DBOWNER, PLTSQL_STMT_DBCC, - PLTSQL_STMT_GRANTSCHEMA, PLTSQL_STMT_FULLTEXTINDEX, } PLtsql_stmt_type; @@ -1052,20 +1051,6 @@ typedef struct PLtsql_stmt_change_dbowner char *new_owner_name; /* Login name for new owner */ } PLtsql_stmt_change_dbowner; -/* - * Grant on schema stmt - */ -typedef struct PLtsql_stmt_grantschema -{ - PLtsql_stmt_type cmd_type; - int lineno; - bool is_grant; - List *privileges; /* list of privileges */ - List *grantees; /* list of users */ - bool with_grant_option; - char *schema_name; /* schema name */ -} PLtsql_stmt_grantschema; - /* * Fulltext Index stmt */ @@ -2048,7 +2033,6 @@ extern void pltsql_scanner_finish(void); extern int pltsql_yyparse(void); /* functions in pltsql_utils.c */ -extern List *gen_grantschema_subcmds(const char *schema, const char *db_user, bool is_grant, bool with_grant_option, const char *privilege); extern char *gen_createfulltextindex_cmds(const char *table_name, const char *schema_name, const List *column_name, const char *index_name); extern char *gen_dropfulltextindex_cmds(const char *index_name, const char *schema_name); extern char *get_fulltext_index_name(Oid relid, const char *table_name); @@ -2093,8 +2077,7 @@ extern void update_DropOwnedStmt(Node *n, List *role_list); extern void update_DropRoleStmt(Node *n, const char *role); extern void update_DropStmt(Node *n, const char *object); extern void update_GrantRoleStmt(Node *n, List *privs, List *roles); -extern void update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee, const char *priv); -extern void update_AlterDefaultPrivilegesStmt(Node *n, const char *object, const char *grantee, const char *priv); +extern void update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee); extern void update_RenameStmt(Node *n, const char *old_name, const char *new_name); extern void update_ViewStmt(Node *n, const char *view_schema); extern void pltsql_check_or_set_default_typmod(TypeName *typeName, int32 *typmod, bool is_cast); diff --git a/contrib/babelfishpg_tsql/src/pltsql_utils.c b/contrib/babelfishpg_tsql/src/pltsql_utils.c index df3c57df71..ed8cce8deb 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_utils.c +++ b/contrib/babelfishpg_tsql/src/pltsql_utils.c @@ -1017,7 +1017,7 @@ update_GrantRoleStmt(Node *n, List *privs, List *roles) } void -update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee, const char *priv) +update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char *grantee) { GrantStmt *stmt = (GrantStmt *) n; @@ -1039,39 +1039,6 @@ update_GrantStmt(Node *n, const char *object, const char *obj_schema, const char tmp->rolename = pstrdup(grantee); } - - if (priv && stmt->privileges) - { - AccessPriv *tmp = (AccessPriv *) llast(stmt->privileges); - - tmp->priv_name = pstrdup(priv); - } -} - -void -update_AlterDefaultPrivilegesStmt(Node *n, const char *object, const char *grantee, const char *priv) -{ - AlterDefaultPrivilegesStmt *stmt = (AlterDefaultPrivilegesStmt *) n; - - ListCell *lc; - - if (!IsA(stmt, AlterDefaultPrivilegesStmt)) - ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("query is not a AlterDefaultPrivilegesStmt"))); - - if (grantee && priv && stmt->action) - { - update_GrantStmt((Node *)(stmt->action), NULL, NULL, grantee, priv); - } - - foreach(lc, stmt->options) - { - if (object) - { - DefElem *tmp = (DefElem *) lfirst(lc); - tmp->defname = pstrdup("schemas"); - tmp->arg = (Node *)list_make1(makeString((char *)object)); - } - } } void @@ -1731,71 +1698,6 @@ Oid get_sysadmin_oid(void) return sysadmin_oid; } -List -*gen_grantschema_subcmds(const char *schema, const char *rolname, bool is_grant, bool with_grant_option, const char *privilege) -{ - StringInfoData query; - List *stmt_list; - Node *stmt; - int expected_stmts = 2; - int i = 0; - initStringInfo(&query); - if (is_grant) - { - if (strcmp(privilege, "execute") == 0) - { - if (with_grant_option) - { - appendStringInfo(&query, "GRANT dummy ON ALL FUNCTIONS IN SCHEMA dummy TO dummy WITH GRANT OPTION; "); - appendStringInfo(&query, "GRANT dummy ON ALL PROCEDURES IN SCHEMA dummy TO dummy WITH GRANT OPTION; "); - } - else - { - appendStringInfo(&query, "GRANT dummy ON ALL FUNCTIONS IN SCHEMA dummy TO dummy; "); - appendStringInfo(&query, "GRANT dummy ON ALL PROCEDURES IN SCHEMA dummy TO dummy; "); - } - } - else - { - if (with_grant_option) - appendStringInfo(&query, "GRANT dummy ON ALL TABLES IN SCHEMA dummy TO dummy WITH GRANT OPTION; "); - else - appendStringInfo(&query, "GRANT dummy ON ALL TABLES IN SCHEMA dummy TO dummy; "); - appendStringInfo(&query, "ALTER DEFAULT PRIVILEGES IN SCHEMA dummy GRANT dummy ON TABLES TO dummy; "); - } - } - else - { - if (strcmp(privilege, "execute") == 0) - { - appendStringInfo(&query, "REVOKE dummy ON ALL FUNCTIONS IN SCHEMA dummy FROM dummy; "); - appendStringInfo(&query, "REVOKE dummy ON ALL PROCEDURES IN SCHEMA dummy FROM dummy; "); - } - else - { - appendStringInfo(&query, "REVOKE dummy ON ALL TABLES IN SCHEMA dummy FROM dummy; "); - appendStringInfo(&query, "ALTER DEFAULT PRIVILEGES IN SCHEMA dummy REVOKE dummy ON TABLES FROM dummy; "); - } - } - stmt_list = raw_parser(query.data, RAW_PARSE_DEFAULT); - if (list_length(stmt_list) != expected_stmts) - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Expected %d statements, but got %d statements after parsing", - expected_stmts, list_length(stmt_list)))); - /* Replace dummy elements in parsetree with real values */ - stmt = parsetree_nth_stmt(stmt_list, i++); - update_GrantStmt(stmt, schema, NULL, rolname, privilege); - - stmt = parsetree_nth_stmt(stmt_list, i++); - if (strcmp(privilege, "execute") == 0) - update_GrantStmt(stmt, schema, NULL, rolname, privilege); - else - update_AlterDefaultPrivilegesStmt(stmt, schema, rolname, privilege); - - return stmt_list; -} - /* * Generates the schema name for fulltext index statements * depending on whether it's master schema or not diff --git a/contrib/babelfishpg_tsql/src/stmt_walker.c b/contrib/babelfishpg_tsql/src/stmt_walker.c index e41ec44e76..6d996059d8 100644 --- a/contrib/babelfishpg_tsql/src/stmt_walker.c +++ b/contrib/babelfishpg_tsql/src/stmt_walker.c @@ -108,7 +108,6 @@ stmt_walker(PLtsql_stmt *stmt, WalkerFunc walker, void *context) case PLTSQL_STMT_SET_EXPLAIN_MODE: case PLTSQL_STMT_GRANTDB: case PLTSQL_STMT_CHANGE_DBOWNER: - case PLTSQL_STMT_GRANTSCHEMA: case PLTSQL_STMT_FULLTEXTINDEX: case PLTSQL_STMT_DBCC: break; @@ -211,7 +210,6 @@ general_walker_func(PLtsql_stmt *stmt, void *context) DISPATCH(GRANTDB, grantdb) DISPATCH(CHANGE_DBOWNER, change_dbowner) DISPATCH(DBCC, dbcc) - DISPATCH(GRANTSCHEMA, grantschema) DISPATCH(FULLTEXTINDEX, fulltextindex) /* TSQL-only executable node */ diff --git a/contrib/babelfishpg_tsql/src/stmt_walker.h b/contrib/babelfishpg_tsql/src/stmt_walker.h index 96e58e89eb..885f0058a5 100644 --- a/contrib/babelfishpg_tsql/src/stmt_walker.h +++ b/contrib/babelfishpg_tsql/src/stmt_walker.h @@ -89,7 +89,6 @@ typedef bool (*Stmt_set_explain_mode) ACTION_SIGNITURE(set_explain_mode); typedef bool (*Stmt_grantdb_act) ACTION_SIGNITURE(grantdb); typedef bool (*Stmt_change_dbowner_act) ACTION_SIGNITURE(change_dbowner); typedef bool (*Stmt_dbcc_act) ACTION_SIGNITURE(dbcc); -typedef bool (*Stmt_grantschema_act) ACTION_SIGNITURE(grantschema); typedef bool (*Stmt_fulltextindex_act) ACTION_SIGNITURE(fulltextindex); /* TSQL-only executable node */ @@ -143,7 +142,6 @@ typedef struct Walker_context Stmt_grantdb_act grantdb_act; Stmt_change_dbowner_act change_dbowner_act; Stmt_dbcc_act dbcc_act; - Stmt_grantschema_act grantschema_act; Stmt_fulltextindex_act fulltextindex_act; /* TSQL-only executable node */ diff --git a/contrib/babelfishpg_tsql/src/tsqlIface.cpp b/contrib/babelfishpg_tsql/src/tsqlIface.cpp index 695b28dc46..3c560021c6 100644 --- a/contrib/babelfishpg_tsql/src/tsqlIface.cpp +++ b/contrib/babelfishpg_tsql/src/tsqlIface.cpp @@ -1910,52 +1910,6 @@ class tsqlBuilder : public tsqlCommonMutator } } } - else if (ctx->grant_statement() && ctx->grant_statement()->ON() && ctx->grant_statement()->permission_object() - && ctx->grant_statement()->permission_object()->object_type() && ctx->grant_statement()->permission_object()->object_type()->SCHEMA()) - { - if (ctx->grant_statement()->TO() && ctx->grant_statement()->principals() && ctx->grant_statement()->permissions()) - { - for (auto perm: ctx->grant_statement()->permissions()->permission()) - { - auto single_perm = perm->single_permission(); - if (single_perm->EXECUTE() - || single_perm->EXEC() - || single_perm->SELECT() - || single_perm->INSERT() - || single_perm->UPDATE() - || single_perm->DELETE() - || single_perm->REFERENCES()) - { - clear_rewritten_query_fragment(); - return; - } - } - } - } - - else if (ctx->revoke_statement() && ctx->revoke_statement()->ON() && ctx->revoke_statement()->permission_object() - && ctx->revoke_statement()->permission_object()->object_type() && ctx->revoke_statement()->permission_object()->object_type()->SCHEMA()) - { - if (ctx->revoke_statement()->FROM() && ctx->revoke_statement()->principals() && ctx->revoke_statement()->permissions()) - { - for (auto perm: ctx->revoke_statement()->permissions()->permission()) - { - auto single_perm = perm->single_permission(); - if (single_perm->EXECUTE() - || single_perm->EXEC() - || single_perm->SELECT() - || single_perm->INSERT() - || single_perm->UPDATE() - || single_perm->DELETE() - || single_perm->REFERENCES()) - { - clear_rewritten_query_fragment(); - return; - } - } - } - } - PLtsql_stmt_execsql *stmt = (PLtsql_stmt_execsql *) getPLtsql_fragment(ctx); Assert(stmt); @@ -5561,108 +5515,6 @@ makeGrantdbStatement(TSqlParser::Security_statementContext *ctx) } } } - if (ctx->grant_statement() && ctx->grant_statement()->ON() && ctx->grant_statement()->permission_object() - && ctx->grant_statement()->permission_object()->object_type() && ctx->grant_statement()->permission_object()->object_type()->SCHEMA()) - { - if (ctx->grant_statement()->TO() && ctx->grant_statement()->principals() && ctx->grant_statement()->permissions()) - { - PLtsql_stmt_grantschema *result = (PLtsql_stmt_grantschema *) palloc0(sizeof(PLtsql_stmt_grantschema)); - result->cmd_type = PLTSQL_STMT_GRANTSCHEMA; - result->lineno = getLineNo(ctx->grant_statement()); - result->is_grant = true; - std::string schema_name; - if (ctx->grant_statement()->permission_object()->full_object_name()->object_name) - { - schema_name = stripQuoteFromId(ctx->grant_statement()->permission_object()->full_object_name()->object_name); - result->schema_name = pstrdup(downcase_truncate_identifier(schema_name.c_str(), schema_name.length(), true)); - } - List *grantee_list = NIL; - for (auto prin : ctx->grant_statement()->principals()->principal_id()) - { - if (prin->id()) - { - std::string id_str = ::getFullText(prin->id()); - char *grantee_name = pstrdup(downcase_truncate_identifier(id_str.c_str(), id_str.length(), true)); - grantee_list = lappend(grantee_list, grantee_name); - } - } - List *privilege_list = NIL; - for (auto perm: ctx->grant_statement()->permissions()->permission()) - { - auto single_perm = perm->single_permission(); - if (single_perm->EXECUTE()) - privilege_list = lappend(privilege_list, (void *)"execute"); - if (single_perm->EXEC()) - privilege_list = lappend(privilege_list, (void *)"execute"); - if (single_perm->SELECT()) - privilege_list = lappend(privilege_list, (void *)"select"); - if (single_perm->INSERT()) - privilege_list = lappend(privilege_list, (void *)"insert"); - if (single_perm->UPDATE()) - privilege_list = lappend(privilege_list, (void *)"update"); - if (single_perm->DELETE()) - privilege_list = lappend(privilege_list, (void *)"delete"); - if (single_perm->REFERENCES()) - privilege_list = lappend(privilege_list, (void *)"references"); - } - result->privileges = privilege_list; - if (ctx->grant_statement()->WITH()) - result->with_grant_option = true; - result->grantees = grantee_list; - return (PLtsql_stmt *) result; - } - } - - if (ctx->revoke_statement() && ctx->revoke_statement()->ON() && ctx->revoke_statement()->permission_object() - && ctx->revoke_statement()->permission_object()->object_type() && ctx->revoke_statement()->permission_object()->object_type()->SCHEMA()) - { - if (ctx->revoke_statement()->FROM() && ctx->revoke_statement()->principals() && ctx->revoke_statement()->permissions()) - { - PLtsql_stmt_grantschema *result = (PLtsql_stmt_grantschema *) palloc0(sizeof(PLtsql_stmt_grantschema)); - result->cmd_type = PLTSQL_STMT_GRANTSCHEMA; - result->lineno = getLineNo(ctx->revoke_statement()); - result->is_grant = false; - std::string schema_name; - if (ctx->revoke_statement()->permission_object()->full_object_name()->object_name) - { - schema_name = stripQuoteFromId(ctx->revoke_statement()->permission_object()->full_object_name()->object_name); - result->schema_name = pstrdup(downcase_truncate_identifier(schema_name.c_str(), schema_name.length(), true)); - } - List *grantee_list = NIL; - for (auto prin : ctx->revoke_statement()->principals()->principal_id()) - { - if (prin->id()) - { - std::string id_str = ::getFullText(prin->id()); - char *grantee_name = pstrdup(downcase_truncate_identifier(id_str.c_str(), id_str.length(), true)); - grantee_list = lappend(grantee_list, grantee_name); - } - } - List *privilege_list = NIL; - for (auto perm: ctx->revoke_statement()->permissions()->permission()) - { - auto single_perm = perm->single_permission(); - if (single_perm->EXECUTE()) - privilege_list = lappend(privilege_list, (void *)"execute"); - if (single_perm->EXEC()) - privilege_list = lappend(privilege_list, (void *)"execute"); - if (single_perm->SELECT()) - privilege_list = lappend(privilege_list, (void *)"select"); - if (single_perm->INSERT()) - privilege_list = lappend(privilege_list, (void *)"insert"); - if (single_perm->UPDATE()) - privilege_list = lappend(privilege_list, (void *)"update"); - if (single_perm->DELETE()) - privilege_list = lappend(privilege_list, (void *)"delete"); - if (single_perm->REFERENCES()) - privilege_list = lappend(privilege_list, (void *)"references"); - } - result->privileges = privilege_list; - result->grantees = grantee_list; - return (PLtsql_stmt *) result; - } - } - PLtsql_stmt *result; result = makeExecSql(ctx); attachPLtsql_fragment(ctx, result); diff --git a/contrib/babelfishpg_tsql/src/tsqlNodes.h b/contrib/babelfishpg_tsql/src/tsqlNodes.h index 27c6869442..e41e61ca87 100644 --- a/contrib/babelfishpg_tsql/src/tsqlNodes.h +++ b/contrib/babelfishpg_tsql/src/tsqlNodes.h @@ -51,7 +51,6 @@ typedef enum pltsql_stmt_type PLTSQL_STMT_GRANTDB, PLTSQL_STMT_CHANGE_DBOWNER, PLTSQL_STMT_DBCC, - PLTSQL_STMT_GRANTSCHEMA PLTSQL_STMT_FULLTEXTINDEX } PLtsql_stmt_type; diff --git a/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp b/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp index 29cdc5ac32..ee3cf57a8b 100644 --- a/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp +++ b/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp @@ -1707,6 +1707,7 @@ void TsqlUnsupportedFeatureHandlerImpl::checkSupportedGrantStmt(TSqlParser::Gran unsupported_feature = "GRANT PERMISSION " + perm->getText(); handle(INSTR_UNSUPPORTED_TSQL_REVOKE_STMT, unsupported_feature.c_str(), getLineAndPos(perm)); } + } } @@ -1714,9 +1715,7 @@ void TsqlUnsupportedFeatureHandlerImpl::checkSupportedGrantStmt(TSqlParser::Gran { auto perm_obj = grant->permission_object(); auto obj_type = perm_obj->object_type(); - if (grant->ALL() && obj_type && obj_type->SCHEMA()) - throw PGErrorWrapperException(ERROR, ERRCODE_FEATURE_NOT_SUPPORTED, "The all permission has been deprecated and is not available for this class of entity.", getLineAndPos(grant)); - if (obj_type && !(obj_type->OBJECT() || obj_type->SCHEMA())) + if (obj_type && !obj_type->OBJECT()) { unsupported_feature = "GRANT ON " + obj_type->getText(); handle(INSTR_UNSUPPORTED_TSQL_REVOKE_STMT, unsupported_feature.c_str(), getLineAndPos(obj_type)); @@ -1801,6 +1800,7 @@ void TsqlUnsupportedFeatureHandlerImpl::checkSupportedRevokeStmt(TSqlParser::Rev unsupported_feature = "REVOKE PERMISSION " + perm->getText(); handle(INSTR_UNSUPPORTED_TSQL_REVOKE_STMT, unsupported_feature.c_str(), getLineAndPos(perm)); } + } } @@ -1808,9 +1808,7 @@ void TsqlUnsupportedFeatureHandlerImpl::checkSupportedRevokeStmt(TSqlParser::Rev { auto perm_obj = revoke->permission_object(); auto obj_type = perm_obj->object_type(); - if (revoke->ALL() && obj_type && obj_type->SCHEMA()) - throw PGErrorWrapperException(ERROR, ERRCODE_FEATURE_NOT_SUPPORTED, "The all permission has been deprecated and is not available for this class of entity.", getLineAndPos(revoke)); - if (obj_type && !(obj_type->OBJECT() || obj_type->SCHEMA())) + if (obj_type && !obj_type->OBJECT()) { unsupported_feature = "REVOKE ON " + obj_type->getText(); handle(INSTR_UNSUPPORTED_TSQL_REVOKE_STMT, unsupported_feature.c_str(), getLineAndPos(obj_type)); diff --git a/test/JDBC/expected/AUTO_ANALYZE-vu-prepare.out b/test/JDBC/expected/AUTO_ANALYZE-vu-prepare.out index d569a9922d..a555156370 100644 --- a/test/JDBC/expected/AUTO_ANALYZE-vu-prepare.out +++ b/test/JDBC/expected/AUTO_ANALYZE-vu-prepare.out @@ -22,7 +22,6 @@ babelfish_extended_properties babelfish_function_ext babelfish_helpcollation babelfish_namespace_ext -babelfish_schema_permissions babelfish_server_options babelfish_sysdatabases babelfish_syslanguages diff --git a/test/JDBC/expected/BABEL-CROSS-DB.out b/test/JDBC/expected/BABEL-CROSS-DB.out index 2273c92e4f..bf13b5f26f 100644 --- a/test/JDBC/expected/BABEL-CROSS-DB.out +++ b/test/JDBC/expected/BABEL-CROSS-DB.out @@ -522,12 +522,6 @@ DROP PROCEDURE p1 GO -- tsql -USE db1; -GO - -DROP TABLE db1_t1; -GO - USE master; GO diff --git a/test/JDBC/expected/BABEL-GRANT.out b/test/JDBC/expected/BABEL-GRANT.out index d3f48b241f..7847a64156 100644 --- a/test/JDBC/expected/BABEL-GRANT.out +++ b/test/JDBC/expected/BABEL-GRANT.out @@ -20,10 +20,6 @@ GO --- --- Prepare Objects --- ----- SCHEMA -CREATE SCHEMA scm; -GO - ---- TABLE CREATE TABLE t1 ( a int, b int); GO @@ -61,18 +57,6 @@ GO --- --- Basic Grant / Revoke --- -GRANT SELECT ON SCHEMA::scm TO guest; -GO - -GRANT SELECT ON SCHEMA::scm TO PUBLIC; -GO - -REVOKE SELECT ON SCHEMA::scm FROM PUBLIC; -GO - -GRANT INSERT ON SCHEMA::scm TO guest; -GO - GRANT ALL ON OBJECT::t1 TO guest WITH GRANT OPTION; GO @@ -171,9 +155,6 @@ GO ~~ERROR (Message: 'REVOKE ALL on Database' is not currently supported in Babelfish)~~ -REVOKE SELECT ON SCHEMA::scm FROM guest; -GO - GRANT SHOWPLAN ON OBJECT::t1 TO guest; -- unsupported permission GO ~~ERROR (Code: 33557097)~~ @@ -192,14 +173,14 @@ GRANT ALL ON SCHEMA::scm TO guest; -- unsupported class GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: The all permission has been deprecated and is not available for this class of entity.)~~ +~~ERROR (Message: 'GRANT ON SCHEMA' is not currently supported in Babelfish)~~ REVOKE ALL ON SCHEMA::scm TO guest; -- unsupported class GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: The all permission has been deprecated and is not available for this class of entity.)~~ +~~ERROR (Message: 'REVOKE ON SCHEMA' is not currently supported in Babelfish)~~ GRANT ALL ON OBJECT::t1 TO guest WITH GRANT OPTION AS superuser; @@ -232,9 +213,6 @@ GO --- --- Clean Up --- -DROP SCHEMA scm; -GO - DROP VIEW IF EXISTS my_view; GO diff --git a/test/JDBC/expected/BABEL-SESSION.out b/test/JDBC/expected/BABEL-SESSION.out index 6e9888edd5..87d51024a5 100644 --- a/test/JDBC/expected/BABEL-SESSION.out +++ b/test/JDBC/expected/BABEL-SESSION.out @@ -153,21 +153,6 @@ USE master; GO -- tsql -USE db1; -GO - -DROP TABLE tb1; -GO - -DROP TABLE janedoe_schema.t1; -GO - -DROP SCHEMA janedoe_schema; -GO - -USE master; -go - DROP DATABASE db1; GO diff --git a/test/JDBC/expected/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.out b/test/JDBC/expected/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.out index 9b95434b99..d2a093dc2e 100644 --- a/test/JDBC/expected/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.out +++ b/test/JDBC/expected/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.out @@ -1,44 +1,49 @@ -EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases"; + +SET NOCOUNT ON +DECLARE @sp_columns_managed_var table(a nvarchar(128), b nvarchar(128), c nvarchar(128), d nvarchar(128), e int, f nvarchar(4000), g nvarchar(3), h nvarchar(128), i int, j int, k int, l int, m int, n int, o nvarchar(128), p nvarchar(128), q nvarchar(128), r nvarchar(128), s int, t int, u int) +INSERT INTO @sp_columns_managed_var EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases" +SELECT * FROM @sp_columns_managed_var ORDER BY a, b, c, d, e +SET NOCOUNT OFF +SET NOCOUNT ON +DECLARE @sp_columns_managed_var1 table(a nvarchar(128), b nvarchar(128), c nvarchar(128), d nvarchar(128), e int, f nvarchar(4000), g nvarchar(3), h nvarchar(128), i int, j int, k int, l int, m int, n int, o nvarchar(128), p nvarchar(128), q nvarchar(128), r nvarchar(128), s int, t int, u int) +INSERT INTO @sp_columns_managed_var1 EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "SYSDATABASES" +SELECT * FROM @sp_columns_managed_var1 ORDER BY a, b, c, d, e +SET NOCOUNT OFF +EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases", "name"; GO ~~START~~ nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int#!#int#!#int#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int -master#!#dbo#!#sysdatabases#!#name#!#1#!##!#YES#!#text#!#2147483647#!#2147483647#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#category#!#9#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#cmptlevel#!#10#!##!#YES#!#tinyint#!##!##!#3#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#crdate#!#7#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#dbid#!#2#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#sid#!#3#!##!#YES#!#varbinary#!#85#!#85#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#filename#!#11#!##!#YES#!#nvarchar#!#260#!#520#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#mode#!#4#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#name#!#1#!##!#YES#!#text#!#2147483647#!#2147483647#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#reserved#!#8#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#sid#!#3#!##!#YES#!#varbinary#!#85#!#85#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#status#!#5#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#status2#!#6#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#crdate#!#7#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#reserved#!#8#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#category#!#9#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#cmptlevel#!#10#!##!#YES#!#tinyint#!##!##!#3#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#filename#!#11#!##!#YES#!#nvarchar#!#260#!#520#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#version#!#12#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 ~~END~~ - -EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "SYSDATABASES"; -GO ~~START~~ nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int#!#int#!#int#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int -master#!#dbo#!#sysdatabases#!#name#!#1#!##!#YES#!#text#!#2147483647#!#2147483647#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#category#!#9#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#cmptlevel#!#10#!##!#YES#!#tinyint#!##!##!#3#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#crdate#!#7#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#dbid#!#2#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#sid#!#3#!##!#YES#!#varbinary#!#85#!#85#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#filename#!#11#!##!#YES#!#nvarchar#!#260#!#520#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#mode#!#4#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#name#!#1#!##!#YES#!#text#!#2147483647#!#2147483647#!##!##!##!##!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#reserved#!#8#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 +master#!#dbo#!#sysdatabases#!#sid#!#3#!##!#YES#!#varbinary#!#85#!#85#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#status#!#5#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#status2#!#6#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#crdate#!#7#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#reserved#!#8#!##!#YES#!#datetime#!##!##!##!##!##!#3#!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#category#!#9#!##!#YES#!#int#!##!##!#10#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#cmptlevel#!#10#!##!#YES#!#tinyint#!##!##!#3#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 -master#!#dbo#!#sysdatabases#!#filename#!#11#!##!#YES#!#nvarchar#!#260#!#520#!##!##!##!##!##!##!##!##!#0#!#0#!#0 master#!#dbo#!#sysdatabases#!#version#!#12#!##!#YES#!#smallint#!##!##!#5#!#10#!#0#!##!##!##!##!##!#0#!#0#!#0 ~~END~~ - -EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases", "name"; -GO ~~START~~ nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int#!#int#!#int#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#nvarchar#!#int#!#int#!#int master#!#dbo#!#sysdatabases#!#name#!#1#!##!#YES#!#text#!#2147483647#!#2147483647#!##!##!##!##!##!##!##!##!#0#!#0#!#0 diff --git a/test/JDBC/expected/GRANT_SCHEMA-vu-cleanup.out b/test/JDBC/expected/GRANT_SCHEMA-vu-cleanup.out deleted file mode 100644 index af83d2ea36..0000000000 --- a/test/JDBC/expected/GRANT_SCHEMA-vu-cleanup.out +++ /dev/null @@ -1,75 +0,0 @@ --- tsql --- Drop objects -use grant_schema_d1; -go - -drop table grant_schema_s1.grant_schema_t1; -go - -drop table grant_schema_s1.grant_schema_t2; -go - -drop table grant_schema_s1.grant_schema_t3; -go - -drop view grant_schema_s1.grant_schema_v1; -go - -drop view grant_schema_s1.grant_schema_v2; -go - -drop proc grant_schema_s1.grant_schema_p1; -go - -drop proc grant_schema_s1.grant_schema_p2; -go - -drop function grant_schema_s1.grant_schema_f1; -go - -drop function grant_schema_s1.grant_schema_f2; -go - -drop schema grant_schema_s1; -go - -drop table grant_schema_s2.grant_schema_t1; -go - -drop table grant_schema_s2.grant_schema_t2; -go - -drop schema grant_schema_s2; -go - -drop user grant_schema_u1; -go - -use master; -go - -drop database grant_schema_d1; -go - --- psql --- Need to terminate active session before cleaning up the login -SELECT pg_terminate_backend(pid) FROM pg_stat_get_activity(NULL) -WHERE sys.suser_name(usesysid) = 'grant_schema_l1' AND backend_type = 'client backend' AND usesysid IS NOT NULL; -go -~~START~~ -bool -~~END~~ - - --- Wait to sync with another session -SELECT pg_sleep(1); -go -~~START~~ -void - -~~END~~ - - --- tsql -drop login grant_schema_l1; -go diff --git a/test/JDBC/expected/GRANT_SCHEMA-vu-prepare.out b/test/JDBC/expected/GRANT_SCHEMA-vu-prepare.out deleted file mode 100644 index 069a323b57..0000000000 --- a/test/JDBC/expected/GRANT_SCHEMA-vu-prepare.out +++ /dev/null @@ -1,74 +0,0 @@ --- tsql --- create objects -create database grant_schema_d1; -go - -use grant_schema_d1; -go - -create login grant_schema_l1 with password = '12345678' -go - -create user grant_schema_u1 for login grant_schema_l1; -go - -create schema grant_schema_s1; -go - -create table grant_schema_s1.grant_schema_t1(a int); -go - -create table grant_schema_s1.grant_schema_t2(b int); -go - -create table grant_schema_s1.grant_schema_t3(c int); -go - -create view grant_schema_s1.grant_schema_v1 as select 2; -go - -create view grant_schema_s1.grant_schema_v2 as select 2; -go - -create proc grant_schema_s1.grant_schema_p1 as select 2; -go - -create proc grant_schema_s1.grant_schema_p2 as select 2; -go - -CREATE FUNCTION grant_schema_s1.grant_schema_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - -CREATE FUNCTION grant_schema_s1.grant_schema_f2() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - -create schema grant_schema_s2; -go - -create table grant_schema_s2.grant_schema_t1(a int); -go - -create table grant_schema_s2.grant_schema_t2(a int); -go - --- GRANT OBJECT privilege -grant select on grant_schema_s1.grant_schema_t1 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_t3 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_v1 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_v2 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_p1 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_p2 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_f1 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_f2 to grant_schema_u1; -go -grant select on grant_schema_s2.grant_schema_t1 to grant_schema_u1; -go -grant select on grant_schema_s2.grant_schema_t2 to grant_schema_u1; -go diff --git a/test/JDBC/expected/GRANT_SCHEMA-vu-verify.out b/test/JDBC/expected/GRANT_SCHEMA-vu-verify.out deleted file mode 100644 index 16a45233e2..0000000000 --- a/test/JDBC/expected/GRANT_SCHEMA-vu-verify.out +++ /dev/null @@ -1,291 +0,0 @@ --- tsql user=grant_schema_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go -~~START~~ -int -~~END~~ - - -select * from grant_schema_s1.grant_schema_t2; -- case 1: has no permission -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table grant_schema_t2)~~ - - -select * from grant_schema_s1.grant_schema_v1; -go -~~START~~ -int -2 -~~END~~ - - -exec grant_schema_s1.grant_schema_p1; -go -~~START~~ -int -2 -~~END~~ - - -select * from grant_schema_s1.grant_schema_f1(); -go -~~START~~ -int -10 -~~END~~ - - --- tsql --- REVOKE OBJECT privilege -use grant_schema_d1; -go -revoke select on grant_schema_s1.grant_schema_t1 from grant_schema_u1; -go -revoke select on grant_schema_s1.grant_schema_v1 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_p1 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_f1 from grant_schema_u1; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has no privileges, should not be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table grant_schema_t1)~~ - - -select * from grant_schema_s1.grant_schema_v1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for view grant_schema_v1)~~ - - -exec grant_schema_s1.grant_schema_p1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for procedure grant_schema_p1)~~ - - -select * from grant_schema_s1.grant_schema_f1(); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for function grant_schema_f1)~~ - - --- tsql --- GRANT SCHEMA privilege -use grant_schema_d1; -go -grant select, execute on schema::grant_schema_s1 to grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go -~~START~~ -int -~~END~~ - - -select * from grant_schema_s1.grant_schema_t2; -go -~~START~~ -int -~~END~~ - - -select * from grant_schema_s1.grant_schema_v1; -go -~~START~~ -int -2 -~~END~~ - - -exec grant_schema_s1.grant_schema_p1; -go -~~START~~ -int -2 -~~END~~ - - -select * from grant_schema_s1.grant_schema_f1(); -go -~~START~~ -int -11 -~~END~~ - - --- User has OBJECT and SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t3; -go -~~START~~ -int -~~END~~ - - -select * from grant_schema_s1.grant_schema_v2; -go -~~START~~ -int -2 -~~END~~ - - -exec grant_schema_s1.grant_schema_p2; -go -~~START~~ -int -2 -~~END~~ - - -select * from grant_schema_s1.grant_schema_f2(); -go -~~START~~ -int -11 -~~END~~ - - --- tsql --- Case 6: User has SCHEMA privilege, REVOKE OBJECT privilege -use grant_schema_d1; -go -revoke select on grant_schema_s1.grant_schema_t3 from grant_schema_u1; -go -revoke select on grant_schema_s1.grant_schema_v2 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_p2 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_f2 from grant_schema_u1; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t3; -go -~~START~~ -int -~~END~~ - - -select * from grant_schema_s1.grant_schema_v2; -go -~~START~~ -int -2 -~~END~~ - - -exec grant_schema_s1.grant_schema_p2; -go -~~START~~ -int -2 -~~END~~ - - -select * from grant_schema_s1.grant_schema_f2(); -go -~~START~~ -int -11 -~~END~~ - - --- tsql --- User has OBJECT privilege, REVOKE OBJECT privilege --- case 7: User has no privileges, should not be accessible. -use grant_schema_d1; -go -revoke select on grant_schema_s2.grant_schema_t2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t2; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table grant_schema_t2)~~ - - --- tsql --- User has OBJECT privilege, REVOKE SCHEMA privilege --- case 8: User has OBJECT privileges, would not be accessible. -use grant_schema_d1; -go -revoke select on schema::grant_schema_s2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table grant_schema_t1)~~ - - --- tsql --- User has OBJECT privilege, GRANT and REVOKE SCHEMA privilege --- case 5: User has OBJECT privileges, would not be accessible. -use grant_schema_d1; -go -grant select on schema::grant_schema_s2 to grant_schema_u1; -go - -revoke select on schema::grant_schema_s2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table grant_schema_t1)~~ - - diff --git a/test/JDBC/expected/GRANT_SCHEMA.out b/test/JDBC/expected/GRANT_SCHEMA.out deleted file mode 100644 index 1891d68597..0000000000 --- a/test/JDBC/expected/GRANT_SCHEMA.out +++ /dev/null @@ -1,631 +0,0 @@ --- tsql --- create objects -create database babel_4344_d1; -go - -use babel_4344_d1; -go - -create login babel_4344_l1 with password = '12345678' -go - -create user babel_4344_u1 for login babel_4344_l1; -go - -create schema babel_4344_s1; -go - -create schema babel_4344_s2 authorization babel_4344_u1; -go - -create table babel_4344_t1(a int); -go - -create table babel_4344_s1.babel_4344_t1(a int); -go - -create table babel_4344_s2.babel_4344_t1(a int); -go - -create table babel_4344_t3(a int, b int); -go - -create table babel_4344_s1.babel_4344_t3(a int, b int); -go - -create view babel_4344_v1 as select 1; -go - -create view babel_4344_s1.babel_4344_v1 as select 2; -go - -create proc babel_4344_p1 as select 1; -go - -create proc babel_4344_s1.babel_4344_p1 as select 2; -go - -CREATE FUNCTION babel_4344_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.tables) END -go - -CREATE FUNCTION babel_4344_s1.babel_4344_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - --- tsql user=babel_4344_l1 password=12345678 -use babel_4344_d1; -go - --- User doesn't have any privileges, objects should not be accessible -select * from babel_4344_t1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t1)~~ - -select * from babel_4344_s1.babel_4344_t1 -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t1)~~ - -insert into babel_4344_s1.babel_4344_t1 values(1); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t1)~~ - -select * from babel_4344_v1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for view babel_4344_v1)~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for view babel_4344_v1)~~ - -exec babel_4344_p1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for procedure babel_4344_p1)~~ - -exec babel_4344_s1.babel_4344_p1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for procedure babel_4344_p1)~~ - -select * from babel_4344_f1(); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for function babel_4344_f1)~~ - -select * from babel_4344_s1.babel_4344_f1(); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for function babel_4344_f1)~~ - -use master; -go - --- tsql --- GRANT OBJECT privilege -use babel_4344_d1; -go -grant select on babel_4344_t1 to babel_4344_u1; -go -grant select on babel_4344_s1.babel_4344_t1 to babel_4344_u1; -go -grant all on babel_4344_s1.babel_4344_t1 to babel_4344_u1; -go -grant select on babel_4344_t3(a) to babel_4344_u1; -- column privilege -go -grant select on babel_4344_s1.babel_4344_t3(a) to babel_4344_u1; -- column privilege -go -grant select on babel_4344_v1 to babel_4344_u1; -go -grant select on babel_4344_s1.babel_4344_v1 to babel_4344_u1; -go -grant execute on babel_4344_p1 to babel_4344_u1; -go -grant execute on babel_4344_s1.babel_4344_p1 to babel_4344_u1; -go -grant execute on babel_4344_f1 to babel_4344_u1; -go -grant execute on babel_4344_s1.babel_4344_f1 to babel_4344_u1; -go --- Grant schema permission to its owner, should fail -grant select on schema::babel_4344_s2 to babel_4344_u1; -- should fail -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.)~~ - -grant select on schema::babel_4344_s2 to jdbc_user; -- should fail -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Cannot find the principal 'jdbc_user', because it does not exist or you do not have permission.)~~ - -grant select on schema::babel_4344_s2 to guest; -- should pass -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_t1; -go -~~START~~ -int -~~END~~ - -select * from babel_4344_s1.babel_4344_t1 -go -~~START~~ -int -~~END~~ - -insert into babel_4344_s1.babel_4344_t1 values(2); -go -~~ROW COUNT: 1~~ - -select * from babel_4344_t3; -- not accessible, only column privilege is granted -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t3)~~ - -select * from babel_4344_s1.babel_4344_t3 -- not accessible, only column privilege is granted -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t3)~~ - -select * from babel_4344_v1; -go -~~START~~ -int -1 -~~END~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~START~~ -int -2 -~~END~~ - -exec babel_4344_p1; -go -~~START~~ -int -1 -~~END~~ - -exec babel_4344_s1.babel_4344_p1; -go -~~START~~ -int -2 -~~END~~ - -select * from babel_4344_f1(); -go -~~START~~ -int -3 -~~END~~ - -select * from babel_4344_s1.babel_4344_f1(); -go -~~START~~ -int -9 -~~END~~ - --- Grant schema permission to its owner -grant select on schema::babel_4344_s2 to babel_4344_u1; -- should fail -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Cannot grant, deny, or revoke permissions to sa, dbo, entity owner, information_schema, sys, or yourself.)~~ - -grant select on schema::babel_4344_s2 to guest; -- should pass -go -grant select on schema::babel_4344_s1 to babel_4344_u1; -- should fail -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Cannot find the schema "babel_4344_s1", because it does not exist or you do not have permission.)~~ - -use master; -go - --- tsql --- GRANT SCHEMA privilege -use babel_4344_d1; -go -grant select, insert, execute on schema::babel_4344_s1 to babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT and SCHEMA privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -~~START~~ -int -2 -~~END~~ - -insert into babel_4344_s1.babel_4344_t1 values(3); -go -~~ROW COUNT: 1~~ - -select * from babel_4344_s1.babel_4344_t3 -go -~~START~~ -int#!#int -~~END~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~START~~ -int -2 -~~END~~ - -exec babel_4344_s1.babel_4344_p1; -go -~~START~~ -int -2 -~~END~~ - -select * from babel_4344_s1.babel_4344_f1(); -go -~~START~~ -int -10 -~~END~~ - -use master; -go - --- tsql --- REVOKE SCHEMA privilege -use babel_4344_d1; -go -revoke select, insert, execute on schema::babel_4344_s1 from babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -~~START~~ -int -2 -3 -~~END~~ - -insert into babel_4344_s1.babel_4344_t1 values(3); -go -~~ROW COUNT: 1~~ - -select * from babel_4344_s1.babel_4344_t3 -- not accessible -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t3)~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~START~~ -int -2 -~~END~~ - -exec babel_4344_s1.babel_4344_p1; -- TODO: should be accessible -go -~~START~~ -int -2 -~~END~~ - -select * from babel_4344_s1.babel_4344_f1(); -- TODO: should be accessible -go -~~START~~ -int -9 -~~END~~ - -select * from babel_4344_s2.babel_4344_t1; -go -~~START~~ -int -~~END~~ - -use master; -go - --- tsql --- create new objects in same schema -use babel_4344_d1; -go --- Grant the permissions again -grant select, insert, execute on schema::babel_4344_s1 to babel_4344_u1; -go -create table babel_4344_s1.babel_4344_t2(a int); -go -create view babel_4344_s1.babel_4344_v2 as select 2; -go -create proc babel_4344_s1.babel_4344_p2 as select 2; -go -CREATE FUNCTION babel_4344_s1.babel_4344_f2() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has SCHEMA privileges,objects should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t2 -go -~~START~~ -int -~~END~~ - -insert into babel_4344_s1.babel_4344_t1 values(4); -go -~~ROW COUNT: 1~~ - -select * from babel_4344_s1.babel_4344_v2; -go -~~START~~ -int -2 -~~END~~ - -exec babel_4344_s1.babel_4344_p2; -go -~~START~~ -int -2 -~~END~~ - -select * from babel_4344_s1.babel_4344_f2(); -go -~~START~~ -int -14 -~~END~~ - -use master; -go - --- tsql --- REVOKE OBJECT privileges -use babel_4344_d1; -go -REVOKE all on babel_4344_s1.babel_4344_t1 FROM babel_4344_u1; -go -REVOKE select on babel_4344_s1.babel_4344_t3(a) FROM babel_4344_u1; -go -REVOKE select on babel_4344_s1.babel_4344_v1 FROM babel_4344_u1; -go -REVOKE execute on babel_4344_s1.babel_4344_p1 FROM babel_4344_u1; -go -REVOKE execute on babel_4344_s1.babel_4344_f1 FROM babel_4344_u1; -go -REVOKE all on babel_4344_s1.babel_4344_f1 FROM babel_4344_u1; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -~~START~~ -int -2 -3 -3 -4 -~~END~~ - -insert into babel_4344_s1.babel_4344_t1 values(5); -go -~~ROW COUNT: 1~~ - -select * from babel_4344_s1.babel_4344_t3; -go -~~START~~ -int#!#int -~~END~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~START~~ -int -2 -~~END~~ - -exec babel_4344_s1.babel_4344_p1; -go -~~START~~ -int -2 -~~END~~ - -select * from babel_4344_s1.babel_4344_f1(); -go -~~START~~ -int -14 -~~END~~ - -select * from babel_4344_s2.babel_4344_t1; -go -~~START~~ -int -~~END~~ - -use master; -go - --- tsql --- REVOKE SCHEMA privileges -use babel_4344_d1; -go -revoke select, insert, execute on schema::babel_4344_s1 from babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has no privileges, shouldn't be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t1)~~ - -insert into babel_4344_s1.babel_4344_t1 values(5); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t1)~~ - -select * from babel_4344_s1.babel_4344_t3; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for table babel_4344_t3)~~ - -select * from babel_4344_s1.babel_4344_v1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for view babel_4344_v1)~~ - -exec babel_4344_s1.babel_4344_p1; -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for procedure babel_4344_p1)~~ - -select * from babel_4344_s1.babel_4344_f1(); -go -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: permission denied for function babel_4344_f1)~~ - -use master; -go - --- tsql --- Drop objects -use babel_4344_d1; -go - -drop table babel_4344_t1; -go - -drop table babel_4344_s1.babel_4344_t1; -go - -drop table babel_4344_t3; -go - -drop table babel_4344_s1.babel_4344_t3; -go - -drop table babel_4344_s1.babel_4344_t2; -go - -drop view babel_4344_v1; -go - -drop view babel_4344_s1.babel_4344_v1; -go - -drop view babel_4344_s1.babel_4344_v2; -go - -drop proc babel_4344_p1; -go - -drop proc babel_4344_s1.babel_4344_p1; -go - -drop proc babel_4344_s1.babel_4344_p2; -go - -drop function babel_4344_f1; -go - -drop function babel_4344_s1.babel_4344_f1; -go - -drop function babel_4344_s1.babel_4344_f2; -go - -drop schema babel_4344_s1; -go - -drop table babel_4344_s2.babel_4344_t1; -go - -drop schema babel_4344_s2; -go - -drop user babel_4344_u1; -go - -use master; -go - -drop database babel_4344_d1; -go - --- psql --- Need to terminate active session before cleaning up the login -SELECT pg_terminate_backend(pid) FROM pg_stat_get_activity(NULL) -WHERE sys.suser_name(usesysid) = 'babel_4344_l1' AND backend_type = 'client backend' AND usesysid IS NOT NULL; -go -~~START~~ -bool -t -~~END~~ - - --- Wait to sync with another session -SELECT pg_sleep(1); -go -~~START~~ -void - -~~END~~ - - --- tsql -drop login babel_4344_l1; -go diff --git a/test/JDBC/input/BABEL-CROSS-DB.mix b/test/JDBC/input/BABEL-CROSS-DB.mix index 630af3bad3..594fcd1b0e 100644 --- a/test/JDBC/input/BABEL-CROSS-DB.mix +++ b/test/JDBC/input/BABEL-CROSS-DB.mix @@ -338,12 +338,6 @@ DROP PROCEDURE p1 GO -- tsql -USE db1; -GO - -DROP TABLE db1_t1; -GO - USE master; GO diff --git a/test/JDBC/input/BABEL-GRANT.sql b/test/JDBC/input/BABEL-GRANT.sql index 3e0155ea28..c175c33857 100644 --- a/test/JDBC/input/BABEL-GRANT.sql +++ b/test/JDBC/input/BABEL-GRANT.sql @@ -20,10 +20,6 @@ GO --- Prepare Objects --- ----- SCHEMA -CREATE SCHEMA scm; -GO - ---- TABLE CREATE TABLE t1 ( a int, b int); GO @@ -59,18 +55,6 @@ GO --- Basic Grant / Revoke --- -GRANT SELECT ON SCHEMA::scm TO guest; -GO - -GRANT SELECT ON SCHEMA::scm TO PUBLIC; -GO - -REVOKE SELECT ON SCHEMA::scm FROM PUBLIC; -GO - -GRANT INSERT ON SCHEMA::scm TO guest; -GO - GRANT ALL ON OBJECT::t1 TO guest WITH GRANT OPTION; GO @@ -161,9 +145,6 @@ GO REVOKE ALL TO alogin; -- database permission GO -REVOKE SELECT ON SCHEMA::scm FROM guest; -GO - GRANT SHOWPLAN ON OBJECT::t1 TO guest; -- unsupported permission GO @@ -198,9 +179,6 @@ GO --- Clean Up --- -DROP SCHEMA scm; -GO - DROP VIEW IF EXISTS my_view; GO diff --git a/test/JDBC/input/BABEL-SESSION.mix b/test/JDBC/input/BABEL-SESSION.mix index d9f7be4a8c..41c1c85398 100644 --- a/test/JDBC/input/BABEL-SESSION.mix +++ b/test/JDBC/input/BABEL-SESSION.mix @@ -99,21 +99,6 @@ USE master; GO -- tsql -USE db1; -GO - -DROP TABLE tb1; -GO - -DROP TABLE janedoe_schema.t1; -GO - -DROP SCHEMA janedoe_schema; -GO - -USE master; -go - DROP DATABASE db1; GO diff --git a/test/JDBC/input/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.sql b/test/JDBC/input/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.sql index d05a2ea646..d5fc741aa2 100644 --- a/test/JDBC/input/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.sql +++ b/test/JDBC/input/BABEL-SP_COLUMNS_MANAGED-dep-vu-verify.sql @@ -1,10 +1,15 @@ -- sla 20000 +SET NOCOUNT ON +DECLARE @sp_columns_managed_var table(a nvarchar(128), b nvarchar(128), c nvarchar(128), d nvarchar(128), e int, f nvarchar(4000), g nvarchar(3), h nvarchar(128), i int, j int, k int, l int, m int, n int, o nvarchar(128), p nvarchar(128), q nvarchar(128), r nvarchar(128), s int, t int, u int) +INSERT INTO @sp_columns_managed_var EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases" +SELECT * FROM @sp_columns_managed_var ORDER BY a, b, c, d, e +SET NOCOUNT OFF -EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases"; -GO - -EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "SYSDATABASES"; -GO +SET NOCOUNT ON +DECLARE @sp_columns_managed_var1 table(a nvarchar(128), b nvarchar(128), c nvarchar(128), d nvarchar(128), e int, f nvarchar(4000), g nvarchar(3), h nvarchar(128), i int, j int, k int, l int, m int, n int, o nvarchar(128), p nvarchar(128), q nvarchar(128), r nvarchar(128), s int, t int, u int) +INSERT INTO @sp_columns_managed_var1 EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "SYSDATABASES" +SELECT * FROM @sp_columns_managed_var1 ORDER BY a, b, c, d, e +SET NOCOUNT OFF EXEC babel_sp_columns_managed_dep_vu_prepare_p1 "master", "dbo", "sysdatabases", "name"; GO diff --git a/test/JDBC/input/GRANT_SCHEMA-vu-cleanup.mix b/test/JDBC/input/GRANT_SCHEMA-vu-cleanup.mix deleted file mode 100644 index 156b92c61e..0000000000 --- a/test/JDBC/input/GRANT_SCHEMA-vu-cleanup.mix +++ /dev/null @@ -1,66 +0,0 @@ --- tsql --- Drop objects -use grant_schema_d1; -go - -drop table grant_schema_s1.grant_schema_t1; -go - -drop table grant_schema_s1.grant_schema_t2; -go - -drop table grant_schema_s1.grant_schema_t3; -go - -drop view grant_schema_s1.grant_schema_v1; -go - -drop view grant_schema_s1.grant_schema_v2; -go - -drop proc grant_schema_s1.grant_schema_p1; -go - -drop proc grant_schema_s1.grant_schema_p2; -go - -drop function grant_schema_s1.grant_schema_f1; -go - -drop function grant_schema_s1.grant_schema_f2; -go - -drop schema grant_schema_s1; -go - -drop table grant_schema_s2.grant_schema_t1; -go - -drop table grant_schema_s2.grant_schema_t2; -go - -drop schema grant_schema_s2; -go - -drop user grant_schema_u1; -go - -use master; -go - -drop database grant_schema_d1; -go - --- psql --- Need to terminate active session before cleaning up the login -SELECT pg_terminate_backend(pid) FROM pg_stat_get_activity(NULL) -WHERE sys.suser_name(usesysid) = 'grant_schema_l1' AND backend_type = 'client backend' AND usesysid IS NOT NULL; -go - --- Wait to sync with another session -SELECT pg_sleep(1); -go - --- tsql -drop login grant_schema_l1; -go \ No newline at end of file diff --git a/test/JDBC/input/GRANT_SCHEMA-vu-prepare.mix b/test/JDBC/input/GRANT_SCHEMA-vu-prepare.mix deleted file mode 100644 index 306cd64d58..0000000000 --- a/test/JDBC/input/GRANT_SCHEMA-vu-prepare.mix +++ /dev/null @@ -1,74 +0,0 @@ --- tsql --- create objects -create database grant_schema_d1; -go - -use grant_schema_d1; -go - -create login grant_schema_l1 with password = '12345678' -go - -create user grant_schema_u1 for login grant_schema_l1; -go - -create schema grant_schema_s1; -go - -create table grant_schema_s1.grant_schema_t1(a int); -go - -create table grant_schema_s1.grant_schema_t2(b int); -go - -create table grant_schema_s1.grant_schema_t3(c int); -go - -create view grant_schema_s1.grant_schema_v1 as select 2; -go - -create view grant_schema_s1.grant_schema_v2 as select 2; -go - -create proc grant_schema_s1.grant_schema_p1 as select 2; -go - -create proc grant_schema_s1.grant_schema_p2 as select 2; -go - -CREATE FUNCTION grant_schema_s1.grant_schema_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - -CREATE FUNCTION grant_schema_s1.grant_schema_f2() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - -create schema grant_schema_s2; -go - -create table grant_schema_s2.grant_schema_t1(a int); -go - -create table grant_schema_s2.grant_schema_t2(a int); -go - --- GRANT OBJECT privilege -grant select on grant_schema_s1.grant_schema_t1 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_t3 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_v1 to grant_schema_u1; -go -grant select on grant_schema_s1.grant_schema_v2 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_p1 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_p2 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_f1 to grant_schema_u1; -go -grant execute on grant_schema_s1.grant_schema_f2 to grant_schema_u1; -go -grant select on grant_schema_s2.grant_schema_t1 to grant_schema_u1; -go -grant select on grant_schema_s2.grant_schema_t2 to grant_schema_u1; -go \ No newline at end of file diff --git a/test/JDBC/input/GRANT_SCHEMA-vu-verify.mix b/test/JDBC/input/GRANT_SCHEMA-vu-verify.mix deleted file mode 100644 index 09e9a23336..0000000000 --- a/test/JDBC/input/GRANT_SCHEMA-vu-verify.mix +++ /dev/null @@ -1,179 +0,0 @@ --- tsql user=grant_schema_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go - -select * from grant_schema_s1.grant_schema_t2; -- case 1: has no permission -go - -select * from grant_schema_s1.grant_schema_v1; -go - -exec grant_schema_s1.grant_schema_p1; -go - -select * from grant_schema_s1.grant_schema_f1(); -go - --- tsql --- REVOKE OBJECT privilege -use grant_schema_d1; -go -revoke select on grant_schema_s1.grant_schema_t1 from grant_schema_u1; -go -revoke select on grant_schema_s1.grant_schema_v1 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_p1 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_f1 from grant_schema_u1; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has no privileges, should not be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go - -select * from grant_schema_s1.grant_schema_v1; -go - -exec grant_schema_s1.grant_schema_p1; -go - -select * from grant_schema_s1.grant_schema_f1(); -go - --- tsql --- GRANT SCHEMA privilege -use grant_schema_d1; -go -grant select, execute on schema::grant_schema_s1 to grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t1; -go - -select * from grant_schema_s1.grant_schema_t2; -go - -select * from grant_schema_s1.grant_schema_v1; -go - -exec grant_schema_s1.grant_schema_p1; -go - -select * from grant_schema_s1.grant_schema_f1(); -go - --- User has OBJECT and SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t3; -go - -select * from grant_schema_s1.grant_schema_v2; -go - -exec grant_schema_s1.grant_schema_p2; -go - -select * from grant_schema_s1.grant_schema_f2(); -go - --- tsql --- Case 6: User has SCHEMA privilege, REVOKE OBJECT privilege -use grant_schema_d1; -go -revoke select on grant_schema_s1.grant_schema_t3 from grant_schema_u1; -go -revoke select on grant_schema_s1.grant_schema_v2 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_p2 from grant_schema_u1; -go -revoke execute on grant_schema_s1.grant_schema_f2 from grant_schema_u1; -go - --- tsql user=grant_schema_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use grant_schema_d1; -go - -select * from grant_schema_s1.grant_schema_t3; -go - -select * from grant_schema_s1.grant_schema_v2; -go - -exec grant_schema_s1.grant_schema_p2; -go - -select * from grant_schema_s1.grant_schema_f2(); -go - --- tsql --- User has OBJECT privilege, REVOKE OBJECT privilege --- case 7: User has no privileges, should not be accessible. -use grant_schema_d1; -go -revoke select on grant_schema_s2.grant_schema_t2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t2; -go - --- tsql --- User has OBJECT privilege, REVOKE SCHEMA privilege --- case 8: User has OBJECT privileges, would not be accessible. -use grant_schema_d1; -go -revoke select on schema::grant_schema_s2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t1; -go - --- tsql --- User has OBJECT privilege, GRANT and REVOKE SCHEMA privilege --- case 5: User has OBJECT privileges, would not be accessible. -use grant_schema_d1; -go -grant select on schema::grant_schema_s2 to grant_schema_u1; -go - -revoke select on schema::grant_schema_s2 from grant_schema_u1; -go -use master; -go - --- tsql user=grant_schema_l1 password=12345678 -use grant_schema_d1; -go - -select * from grant_schema_s2.grant_schema_t1; -go - diff --git a/test/JDBC/input/GRANT_SCHEMA.mix b/test/JDBC/input/GRANT_SCHEMA.mix deleted file mode 100644 index 1572bea803..0000000000 --- a/test/JDBC/input/GRANT_SCHEMA.mix +++ /dev/null @@ -1,386 +0,0 @@ --- tsql --- create objects -create database babel_4344_d1; -go - -use babel_4344_d1; -go - -create login babel_4344_l1 with password = '12345678' -go - -create user babel_4344_u1 for login babel_4344_l1; -go - -create schema babel_4344_s1; -go - -create schema babel_4344_s2 authorization babel_4344_u1; -go - -create table babel_4344_t1(a int); -go - -create table babel_4344_s1.babel_4344_t1(a int); -go - -create table babel_4344_s2.babel_4344_t1(a int); -go - -create table babel_4344_t3(a int, b int); -go - -create table babel_4344_s1.babel_4344_t3(a int, b int); -go - -create view babel_4344_v1 as select 1; -go - -create view babel_4344_s1.babel_4344_v1 as select 2; -go - -create proc babel_4344_p1 as select 1; -go - -create proc babel_4344_s1.babel_4344_p1 as select 2; -go - -CREATE FUNCTION babel_4344_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.tables) END -go - -CREATE FUNCTION babel_4344_s1.babel_4344_f1() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go - --- tsql user=babel_4344_l1 password=12345678 -use babel_4344_d1; -go - --- User doesn't have any privileges, objects should not be accessible -select * from babel_4344_t1; -go -select * from babel_4344_s1.babel_4344_t1 -go -insert into babel_4344_s1.babel_4344_t1 values(1); -go -select * from babel_4344_v1; -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_p1; -go -exec babel_4344_s1.babel_4344_p1; -go -select * from babel_4344_f1(); -go -select * from babel_4344_s1.babel_4344_f1(); -go -use master; -go - --- tsql --- GRANT OBJECT privilege -use babel_4344_d1; -go -grant select on babel_4344_t1 to babel_4344_u1; -go -grant select on babel_4344_s1.babel_4344_t1 to babel_4344_u1; -go -grant all on babel_4344_s1.babel_4344_t1 to babel_4344_u1; -go -grant select on babel_4344_t3(a) to babel_4344_u1; -- column privilege -go -grant select on babel_4344_s1.babel_4344_t3(a) to babel_4344_u1; -- column privilege -go -grant select on babel_4344_v1 to babel_4344_u1; -go -grant select on babel_4344_s1.babel_4344_v1 to babel_4344_u1; -go -grant execute on babel_4344_p1 to babel_4344_u1; -go -grant execute on babel_4344_s1.babel_4344_p1 to babel_4344_u1; -go -grant execute on babel_4344_f1 to babel_4344_u1; -go -grant execute on babel_4344_s1.babel_4344_f1 to babel_4344_u1; -go --- Grant schema permission to its owner, should fail -grant select on schema::babel_4344_s2 to babel_4344_u1; -- should fail -go -grant select on schema::babel_4344_s2 to jdbc_user; -- should fail -go -grant select on schema::babel_4344_s2 to guest; -- should pass -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_t1; -go -select * from babel_4344_s1.babel_4344_t1 -go -insert into babel_4344_s1.babel_4344_t1 values(2); -go -select * from babel_4344_t3; -- not accessible, only column privilege is granted -go -select * from babel_4344_s1.babel_4344_t3 -- not accessible, only column privilege is granted -go -select * from babel_4344_v1; -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_p1; -go -exec babel_4344_s1.babel_4344_p1; -go -select * from babel_4344_f1(); -go -select * from babel_4344_s1.babel_4344_f1(); -go --- Grant schema permission to its owner -grant select on schema::babel_4344_s2 to babel_4344_u1; -- should fail -go -grant select on schema::babel_4344_s2 to guest; -- should pass -go -grant select on schema::babel_4344_s1 to babel_4344_u1; -- should fail -go -use master; -go - --- tsql --- GRANT SCHEMA privilege -use babel_4344_d1; -go -grant select, insert, execute on schema::babel_4344_s1 to babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT and SCHEMA privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -insert into babel_4344_s1.babel_4344_t1 values(3); -go -select * from babel_4344_s1.babel_4344_t3 -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_s1.babel_4344_p1; -go -select * from babel_4344_s1.babel_4344_f1(); -go -use master; -go - --- tsql --- REVOKE SCHEMA privilege -use babel_4344_d1; -go -revoke select, insert, execute on schema::babel_4344_s1 from babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has OBJECT privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -insert into babel_4344_s1.babel_4344_t1 values(3); -go -select * from babel_4344_s1.babel_4344_t3 -- not accessible -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_s1.babel_4344_p1; -- TODO: should be accessible -go -select * from babel_4344_s1.babel_4344_f1(); -- TODO: should be accessible -go -select * from babel_4344_s2.babel_4344_t1; -go -use master; -go - --- tsql --- create new objects in same schema -use babel_4344_d1; -go --- Grant the permissions again -grant select, insert, execute on schema::babel_4344_s1 to babel_4344_u1; -go -create table babel_4344_s1.babel_4344_t2(a int); -go -create view babel_4344_s1.babel_4344_v2 as select 2; -go -create proc babel_4344_s1.babel_4344_p2 as select 2; -go -CREATE FUNCTION babel_4344_s1.babel_4344_f2() RETURNS INT AS BEGIN RETURN (SELECT COUNT(*) FROM sys.objects) END -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has SCHEMA privileges,objects should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t2 -go -insert into babel_4344_s1.babel_4344_t1 values(4); -go -select * from babel_4344_s1.babel_4344_v2; -go -exec babel_4344_s1.babel_4344_p2; -go -select * from babel_4344_s1.babel_4344_f2(); -go -use master; -go - --- tsql --- REVOKE OBJECT privileges -use babel_4344_d1; -go -REVOKE all on babel_4344_s1.babel_4344_t1 FROM babel_4344_u1; -go -REVOKE select on babel_4344_s1.babel_4344_t3(a) FROM babel_4344_u1; -go -REVOKE select on babel_4344_s1.babel_4344_v1 FROM babel_4344_u1; -go -REVOKE execute on babel_4344_s1.babel_4344_p1 FROM babel_4344_u1; -go -REVOKE execute on babel_4344_s1.babel_4344_f1 FROM babel_4344_u1; -go -REVOKE all on babel_4344_s1.babel_4344_f1 FROM babel_4344_u1; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has SCHEMA privileges, should be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1 -go -insert into babel_4344_s1.babel_4344_t1 values(5); -go -select * from babel_4344_s1.babel_4344_t3; -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_s1.babel_4344_p1; -go -select * from babel_4344_s1.babel_4344_f1(); -go -select * from babel_4344_s2.babel_4344_t1; -go -use master; -go - --- tsql --- REVOKE SCHEMA privileges -use babel_4344_d1; -go -revoke select, insert, execute on schema::babel_4344_s1 from babel_4344_u1; -go -use master; -go - --- tsql user=babel_4344_l1 password=12345678 --- User has no privileges, shouldn't be accessible. -use babel_4344_d1; -go -select * from babel_4344_s1.babel_4344_t1; -go -insert into babel_4344_s1.babel_4344_t1 values(5); -go -select * from babel_4344_s1.babel_4344_t3; -go -select * from babel_4344_s1.babel_4344_v1; -go -exec babel_4344_s1.babel_4344_p1; -go -select * from babel_4344_s1.babel_4344_f1(); -go -use master; -go - --- tsql --- Drop objects -use babel_4344_d1; -go - -drop table babel_4344_t1; -go - -drop table babel_4344_s1.babel_4344_t1; -go - -drop table babel_4344_t3; -go - -drop table babel_4344_s1.babel_4344_t3; -go - -drop table babel_4344_s1.babel_4344_t2; -go - -drop view babel_4344_v1; -go - -drop view babel_4344_s1.babel_4344_v1; -go - -drop view babel_4344_s1.babel_4344_v2; -go - -drop proc babel_4344_p1; -go - -drop proc babel_4344_s1.babel_4344_p1; -go - -drop proc babel_4344_s1.babel_4344_p2; -go - -drop function babel_4344_f1; -go - -drop function babel_4344_s1.babel_4344_f1; -go - -drop function babel_4344_s1.babel_4344_f2; -go - -drop schema babel_4344_s1; -go - -drop table babel_4344_s2.babel_4344_t1; -go - -drop schema babel_4344_s2; -go - -drop user babel_4344_u1; -go - -use master; -go - -drop database babel_4344_d1; -go - --- psql --- Need to terminate active session before cleaning up the login -SELECT pg_terminate_backend(pid) FROM pg_stat_get_activity(NULL) -WHERE sys.suser_name(usesysid) = 'babel_4344_l1' AND backend_type = 'client backend' AND usesysid IS NOT NULL; -go - --- Wait to sync with another session -SELECT pg_sleep(1); -go - --- tsql -drop login babel_4344_l1; -go diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index ac6f8bf86b..2e8fd2a2c7 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -33,9 +33,6 @@ ignore#!#BABEL-3117-vu-prepare ignore#!#BABEL-3117-vu-verify ignore#!#BABEL-3655-vu-prepare ignore#!#BABEL-3655-vu-verify -ignore#!#GRANT_SCHEMA-vu-prepare -ignore#!#GRANT_SCHEMA-vu-verify -ignore#!#GRANT_SCHEMA-vu-cleanup ignore#!#sys-types-before-dep-vu-prepare ignore#!#sys-types-before-dep-vu-verify ignore#!#sys-types-before-dep-vu-cleanup diff --git a/test/JDBC/upgrade/13_6/schedule b/test/JDBC/upgrade/13_6/schedule index 1bbbdb8426..ba25064192 100644 --- a/test/JDBC/upgrade/13_6/schedule +++ b/test/JDBC/upgrade/13_6/schedule @@ -324,7 +324,6 @@ triggers_with_transaction BABEL-4046 getdate BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 TestDatatypeAggSort babel_index_nulls_order-before-15-5 diff --git a/test/JDBC/upgrade/13_9/schedule b/test/JDBC/upgrade/13_9/schedule index ef6a4961de..a971b993b3 100644 --- a/test/JDBC/upgrade/13_9/schedule +++ b/test/JDBC/upgrade/13_9/schedule @@ -320,7 +320,6 @@ triggers_with_transaction BABEL-4046 getdate BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 cast_eliminate TestDatatypeAggSort diff --git a/test/JDBC/upgrade/14_10/schedule b/test/JDBC/upgrade/14_10/schedule index 4dd95acdc3..0b1bb7ddba 100644 --- a/test/JDBC/upgrade/14_10/schedule +++ b/test/JDBC/upgrade/14_10/schedule @@ -410,7 +410,6 @@ smalldatetimefromparts-dep BABEL_4330 BABEL-4231 BABEL-4384 -GRANT_SCHEMA default_params BABEL-3326 cast_eliminate diff --git a/test/JDBC/upgrade/14_11/schedule b/test/JDBC/upgrade/14_11/schedule index 4dd95acdc3..0b1bb7ddba 100644 --- a/test/JDBC/upgrade/14_11/schedule +++ b/test/JDBC/upgrade/14_11/schedule @@ -410,7 +410,6 @@ smalldatetimefromparts-dep BABEL_4330 BABEL-4231 BABEL-4384 -GRANT_SCHEMA default_params BABEL-3326 cast_eliminate diff --git a/test/JDBC/upgrade/14_3/schedule b/test/JDBC/upgrade/14_3/schedule index 7d0863cec1..ee1b3f8b18 100644 --- a/test/JDBC/upgrade/14_3/schedule +++ b/test/JDBC/upgrade/14_3/schedule @@ -338,7 +338,6 @@ BABEL-4046 BABEL_4330 BABEL-2619 BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 cast_eliminate TestDatatypeAggSort diff --git a/test/JDBC/upgrade/14_5/schedule b/test/JDBC/upgrade/14_5/schedule index 7b2c45e1f3..9fe4585c96 100644 --- a/test/JDBC/upgrade/14_5/schedule +++ b/test/JDBC/upgrade/14_5/schedule @@ -353,7 +353,6 @@ getdate BABEL_4330 BABEL-2619 BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 cast_eliminate TestDatatypeAggSort diff --git a/test/JDBC/upgrade/14_6/schedule b/test/JDBC/upgrade/14_6/schedule index 00ec3f4823..7ad6936075 100644 --- a/test/JDBC/upgrade/14_6/schedule +++ b/test/JDBC/upgrade/14_6/schedule @@ -388,7 +388,6 @@ getdate BABEL_4330 BABEL-2619 BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 cast_eliminate TestDatatypeAggSort diff --git a/test/JDBC/upgrade/15_2/schedule b/test/JDBC/upgrade/15_2/schedule index 6fc69d7750..c18de8224d 100644 --- a/test/JDBC/upgrade/15_2/schedule +++ b/test/JDBC/upgrade/15_2/schedule @@ -416,7 +416,6 @@ BABEL-4046 getdate BABEL_4330 BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 default_params cast_eliminate diff --git a/test/JDBC/upgrade/15_4/schedule b/test/JDBC/upgrade/15_4/schedule index bf4ba49923..61b24ca550 100644 --- a/test/JDBC/upgrade/15_4/schedule +++ b/test/JDBC/upgrade/15_4/schedule @@ -450,10 +450,10 @@ BABEL-4175 sp_who BABEL_4330 BABEL-4410 -GRANT_SCHEMA AUTO_ANALYZE-before-15-5-or-14-10 default_params cast_eliminate TestDatatypeAggSort babel_index_nulls_order-before-15-5 BABEL-2999 + diff --git a/test/python/expected/sql_validation_framework/expected_create.out b/test/python/expected/sql_validation_framework/expected_create.out index 26777ae841..6e84326140 100644 --- a/test/python/expected/sql_validation_framework/expected_create.out +++ b/test/python/expected/sql_validation_framework/expected_create.out @@ -72,7 +72,6 @@ Could not find tests for procedure sys.printarg Could not find tests for procedure sys.sp_cursor_list Could not find tests for procedure sys.sp_describe_cursor Could not find tests for table sys.babelfish_helpcollation -Could not find tests for table sys.babelfish_schema_permissions Could not find tests for table sys.babelfish_syslanguages Could not find tests for table sys.service_settings Could not find tests for table sys.spt_datatype_info_table @@ -200,7 +199,6 @@ Could not find upgrade tests for procedure sys.sp_unprepare Could not find upgrade tests for procedure sys.sp_updatestats Could not find upgrade tests for table sys.babelfish_configurations Could not find upgrade tests for table sys.babelfish_helpcollation -Could not find upgrade tests for table sys.babelfish_schema_permissions Could not find upgrade tests for table sys.babelfish_syslanguages Could not find upgrade tests for table sys.service_settings Could not find upgrade tests for table sys.spt_datatype_info_table