Skip to content

Commit

Permalink
Use AccessExclusiveLock for truncating Babelfish catalogs (babelfish-…
Browse files Browse the repository at this point in the history
…for-postgresql#3178)

When truncating certain Babelfish catalogs, we use the
heap_truncate_one_rel function which expects the caller to hold the
AccessExclusiveLock on the catalog.

This commit updates the lock used for opening/closing the catalog from
RowExclusiveLock to AccessExclusiveLock.

Task: BABEL-5439

Signed-off-by: Sharu Goel <[email protected]>
  • Loading branch information
thephantomthief authored Nov 28, 2024
1 parent eb12d20 commit 4ad36c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contrib/babelfishpg_tsql/src/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,10 @@ void
clean_up_bbf_server_def()
{
/* Fetch the relation */
Relation bbf_servers_def_rel = table_open(get_bbf_servers_def_oid(), RowExclusiveLock);
Relation bbf_servers_def_rel = table_open(get_bbf_servers_def_oid(), AccessExclusiveLock);
/* Truncate the relation */
heap_truncate_one_rel(bbf_servers_def_rel);
table_close(bbf_servers_def_rel, RowExclusiveLock);
table_close(bbf_servers_def_rel, AccessExclusiveLock);
}

/*****************************************
Expand Down
4 changes: 2 additions & 2 deletions contrib/babelfishpg_tsql/src/rolecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2525,12 +2525,12 @@ babelfish_truncate_domain_mapping_table_internal(PG_FUNCTION_ARGS)
errmsg("Current login %s does not have permission to remove domain mapping entry",
GetUserNameFromId(GetSessionUserId(), true))));

bbf_domain_mapping_rel = table_open(get_bbf_domain_mapping_oid(), RowExclusiveLock);
bbf_domain_mapping_rel = table_open(get_bbf_domain_mapping_oid(), AccessExclusiveLock);

/* Truncate the relation */
heap_truncate_one_rel(bbf_domain_mapping_rel);

table_close(bbf_domain_mapping_rel, RowExclusiveLock);
table_close(bbf_domain_mapping_rel, AccessExclusiveLock);
return (Datum) 0;
}

Expand Down

0 comments on commit 4ad36c5

Please sign in to comment.