summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2012-03-28 21:20:20 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2012-03-28 21:20:20 (GMT)
commit658af5c1f813e9c5de7d0afd70e69a276863e0f0 (patch)
treed49fa0887797cf108fd7470e96ca4c8aaef39fbf /src
parent81145a2968c8a1a573442606840e024cb39bd00d (diff)
downloadhdf5-658af5c1f813e9c5de7d0afd70e69a276863e0f0.zip
hdf5-658af5c1f813e9c5de7d0afd70e69a276863e0f0.tar.gz
hdf5-658af5c1f813e9c5de7d0afd70e69a276863e0f0.tar.bz2
[svn-r22174] Port r22173 from trunk to 1.8 branch
Purpose: Fix HDFFV-7762 Description: When copying an object with attribute creation order tracked, the attribute creation order was not copied correctly to the destination file, causing an error if the creation order was also indexed (due to attempting to insert duplicate keys) or incorrect creation orders otherwise. Fixed to copy the creation order correctly. Also fixed the attribute character set not being copied, and fixed an issue where an attribute opened with H5Aopen (or similar, but not by_idx), from an object using the latest format but without creation order being tracked, would always report the creation order as 0 (and marked as valid). Tested: jam, koala, ostrich (h5committest), durandal
Diffstat (limited to 'src')
-rw-r--r--src/H5Aint.c10
-rw-r--r--src/H5Oattribute.c6
2 files changed, 14 insertions, 2 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 09efb24..48d2546 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -799,6 +799,12 @@ H5A_set_version(const H5F_t *f, H5A_t *attr)
*
* Purpose: Copies a message from _MESG to _DEST in file
*
+ * Note that this function assumes that it is copying *all*
+ * the attributes in the object, specifically when it copies
+ * the creation order from source to destination. If this is
+ * to be used to copy only a single attribute, then the
+ * creation order must be handled differently. -NAF
+ *
* Return: Success: Ptr to _DEST
*
* Failure: NULL
@@ -853,6 +859,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
/* Copy attribute's name */
attr_dst->shared->name = H5MM_strdup(attr_src->shared->name);
HDassert(attr_dst->shared->name);
+ attr_dst->shared->encoding = attr_src->shared->encoding;
/* Copy attribute's datatype */
/* If source is named, we will keep dst as named, but we will not actually
@@ -1007,6 +1014,9 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
} /* end else */
} /* end if(attr_src->shared->data) */
+ /* Copy the creation order */
+ attr_dst->shared->crt_idx = attr_src->shared->crt_idx;
+
/* Recompute the version to encode the destination attribute */
if(H5A_set_version(file_dst, attr_dst) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version")
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 057caaf..e36d4ab 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -445,8 +445,10 @@ H5O_attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence,
if(NULL == (udata->attr = H5A_copy(NULL, (H5A_t *)mesg->native)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy attribute")
- /* Assign [somewhat arbitrary] creation order value, for older versions of the format */
- if(oh->version == H5O_VERSION_1)
+ /* Assign [somewhat arbitrary] creation order value, for older versions
+ * of the format or if creation order is not tracked */
+ if(oh->version == H5O_VERSION_1
+ || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED))
udata->attr->shared->crt_idx = sequence;
/* Stop iterating */