diff --git a/contrib/babelfishpg_tsql/runtime/functions.c b/contrib/babelfishpg_tsql/runtime/functions.c index fd08dd1c74..2a62b1c00d 100644 --- a/contrib/babelfishpg_tsql/runtime/functions.c +++ b/contrib/babelfishpg_tsql/runtime/functions.c @@ -1310,8 +1310,10 @@ schema_id(PG_FUNCTION_ARGS) if (!user) { pfree(db_name); + if(guest_role_name) pfree(guest_role_name); + PG_RETURN_NULL(); } else if ((guest_role_name && strcmp(user, guest_role_name) == 0)) @@ -1324,6 +1326,7 @@ schema_id(PG_FUNCTION_ARGS) physical_name = get_physical_schema_name(db_name, name); } pfree(db_name); + if(guest_role_name) pfree(guest_role_name); } @@ -2233,10 +2236,12 @@ object_id(PG_FUNCTION_ARGS) pfree(db_name); pfree(schema_name); pfree(object_name); + if(guest_role_name) pfree(guest_role_name); if (object_type) pfree(object_type); + PG_RETURN_NULL(); } else if ((guest_role_name && strcmp(user, guest_role_name) == 0)) @@ -2249,6 +2254,7 @@ object_id(PG_FUNCTION_ARGS) schema_name = get_authid_user_ext_schema_name((const char *) db_name, user); physical_schema_name = get_physical_schema_name(db_name, schema_name); } + if(guest_role_name) pfree(guest_role_name); } @@ -2691,8 +2697,10 @@ type_id(PG_FUNCTION_ARGS) pfree(db_name); pfree(schema_name); pfree(object_name); + if(guest_role_name) pfree(guest_role_name); + PG_RETURN_NULL(); } else if ((guest_role_name && strcmp(user, guest_role_name) == 0)) @@ -2705,6 +2713,7 @@ type_id(PG_FUNCTION_ARGS) schema_name = get_authid_user_ext_schema_name((const char *) db_name, user); physical_schema_name = get_physical_schema_name(db_name, schema_name); } + if(guest_role_name) pfree(guest_role_name); } diff --git a/contrib/babelfishpg_tsql/src/catalog.c b/contrib/babelfishpg_tsql/src/catalog.c index d1187ffda1..2d290a53ea 100644 --- a/contrib/babelfishpg_tsql/src/catalog.c +++ b/contrib/babelfishpg_tsql/src/catalog.c @@ -3220,6 +3220,7 @@ create_guest_role_for_db(const char *dbname) SetConfigOption("createrole_self_grant", old_createrole_self_grant, PGC_USERSET, PGC_S_OVERRIDE); SetUserIdAndSecContext(save_userid, save_sec_context); set_cur_db(old_dbid, old_dbname); + if(guest) pfree(guest); } @@ -5008,8 +5009,8 @@ rename_tsql_db(char *old_db_name, char *new_db_name) /* * user_exists_for_db - * returns true if the user/role exists in the sys.babelfish_authid_user_ext catalog, - * false otherwise. + * returns true if the user/role exists in the sys.babelfish_authid_user_ext catalog, + * false otherwise. */ bool user_exists_for_db(const char *db_name, const char *user_name) diff --git a/contrib/babelfishpg_tsql/src/dbcmds.c b/contrib/babelfishpg_tsql/src/dbcmds.c index c0a18e6db5..47c0b8718b 100644 --- a/contrib/babelfishpg_tsql/src/dbcmds.c +++ b/contrib/babelfishpg_tsql/src/dbcmds.c @@ -638,6 +638,7 @@ create_bbf_db_internal(ParseState *pstate, const char *dbname, List *options, co add_to_bbf_authid_user_ext(guest, "guest", dbname, "guest", NULL, false, true, false); else add_to_bbf_authid_user_ext(guest, "guest", dbname, "guest", NULL, false, false, false); + pfree(guest); } } @@ -647,6 +648,7 @@ create_bbf_db_internal(ParseState *pstate, const char *dbname, List *options, co SetConfigOption("createrole_self_grant", old_createrole_self_grant, PGC_USERSET, PGC_S_OVERRIDE); SetUserIdAndSecContext(save_userid, save_sec_context); set_cur_db(old_dbid, old_dbname); + if(dbo_scm) pfree(dbo_scm); if(guest_scm) diff --git a/contrib/babelfishpg_tsql/src/hooks.c b/contrib/babelfishpg_tsql/src/hooks.c index cdb7f737e4..9f0b9bed12 100644 --- a/contrib/babelfishpg_tsql/src/hooks.c +++ b/contrib/babelfishpg_tsql/src/hooks.c @@ -4949,6 +4949,7 @@ get_local_schema_for_bbf_functions(Oid proc_nsp_oid) quote_identifier(func_dbo_schema)); ReleaseSysCache(tuple); + if(func_dbo_schema) pfree(func_dbo_schema); } diff --git a/contrib/babelfishpg_tsql/src/pl_exec-2.c b/contrib/babelfishpg_tsql/src/pl_exec-2.c index 0f9b80d21e..96f8e3238e 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec-2.c +++ b/contrib/babelfishpg_tsql/src/pl_exec-2.c @@ -3347,6 +3347,7 @@ void exec_stmt_dbcc_checkident(PLtsql_stmt_dbcc *stmt) } } pfree(db_name); + if(guest_role_name) pfree(guest_role_name); if(dbo_role_name) @@ -3404,6 +3405,7 @@ void exec_stmt_dbcc_checkident(PLtsql_stmt_dbcc *stmt) errmsg("'%s.%s' does not contain an identity column.", nsp_name, dbcc_stmt.table_name))); } + if(nsp_name) pfree(nsp_name); diff --git a/contrib/babelfishpg_tsql/src/pl_exec.c b/contrib/babelfishpg_tsql/src/pl_exec.c index 26f5f1168b..d2020bf0e5 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec.c +++ b/contrib/babelfishpg_tsql/src/pl_exec.c @@ -10401,8 +10401,10 @@ reset_search_path(PLtsql_stmt_execsql *stmt, char **old_search_path, bool *reset } pfree(cur_dbname); + if(dbo_schema) pfree(dbo_schema); + return false; } diff --git a/contrib/babelfishpg_tsql/src/pl_handler.c b/contrib/babelfishpg_tsql/src/pl_handler.c index 9012df0a01..26d092bf14 100644 --- a/contrib/babelfishpg_tsql/src/pl_handler.c +++ b/contrib/babelfishpg_tsql/src/pl_handler.c @@ -3283,6 +3283,7 @@ bbf_ProcessUtility(PlannedStmt *pstmt, set_session_properties(db_name); pfree(cur_user); pfree(db_name); + if(dbo_name) pfree(dbo_name); @@ -3409,8 +3410,10 @@ bbf_ProcessUtility(PlannedStmt *pstmt, } pfree(rolspec->rolename); + if(db_owner_name) pfree(db_owner_name); + rolspec->rolename = user_name; } } diff --git a/contrib/babelfishpg_tsql/src/procedures.c b/contrib/babelfishpg_tsql/src/procedures.c index 54e21845e1..5f4297b9ac 100644 --- a/contrib/babelfishpg_tsql/src/procedures.c +++ b/contrib/babelfishpg_tsql/src/procedures.c @@ -3381,6 +3381,7 @@ sp_babelfish_volatility(PG_FUNCTION_ARGS) physical_schema_name = get_physical_schema_name(db_name, logical_schema_name); pfree(logical_schema_name); } + if(guest_role_name) pfree(guest_role_name); } diff --git a/contrib/babelfishpg_tsql/src/rolecmds.c b/contrib/babelfishpg_tsql/src/rolecmds.c index b3fd0de6e3..ecf8c8f74a 100644 --- a/contrib/babelfishpg_tsql/src/rolecmds.c +++ b/contrib/babelfishpg_tsql/src/rolecmds.c @@ -661,6 +661,7 @@ grant_revoke_dbo_to_login(const char* login, const char* db_name, bool is_grant) CommandCounterIncrement(); pfree(query.data); + if(dbo_role_name) pfree(dbo_role_name); } @@ -1377,6 +1378,7 @@ add_existing_users_to_catalog(PG_FUNCTION_ARGS) add_to_bbf_authid_user_ext(guest, "guest", db_name, NULL, NULL, false, true, false); else add_to_bbf_authid_user_ext(guest, "guest", db_name, NULL, NULL, false, false, false); + pfree(guest); }