Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for github Issue #1388 can't delete renamed dense attribute with corder tracking enabled #4462

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/H5Adense.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, cons
htri_t attr_sharable; /* Flag indicating attributes are shareable */
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
bool attr_exists; /* Attribute exists in v2 B-tree */
H5O_ainfo_t tainfo = *ainfo; /* Copy of ainfo */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_PACKAGE
Expand Down Expand Up @@ -977,8 +978,12 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, cons
else if (shared_mesg < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared");

/* Delete old attribute from dense storage */
if (H5A__dense_remove(f, ainfo, old_name) < 0)
/* Deactivate the field so that H5A__dense_remove() won't delete the new renamed attribute
that was just added to the creation order index v2 B-tree via H5A__dense_insert() */
tainfo.corder_bt2_addr = HADDR_UNDEF;

/* Only delete the old attribute (before rename) from the name index v2 B-tree */
if (H5A__dense_remove(f, (const H5O_ainfo_t *)&tainfo, old_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage");

done:
Expand Down
9 changes: 7 additions & 2 deletions test/tattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2898,6 +2898,11 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, true, "H5O__is_attr_dense_test");
}

/* Verify github issue #1388 that the last renamed attribute
with/without tracking corder can be deleted */
ret = H5Adelete(dataset, new_attrname);
CHECK(ret, FAIL, "H5Adelete");

/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
Expand Down Expand Up @@ -2930,8 +2935,8 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT);
CHECK(dataset, H5I_INVALID_HID, "H5Dopen2");

/* Verify renamed attributes */
for (u = 0; u < (max_compact * 2); u++) {
/* Verify renamed attributes (the last attribute was deleted) */
for (u = 0; u < (max_compact * 2 - 1); u++) {
unsigned value; /* Attribute value */

/* Open attribute */
Expand Down
Loading