summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-12-11 13:31:14 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-12-11 13:31:14 +1100
commitd7030574d78b30949f88791af744d839252477d6 (patch)
tree0ad88465dbb5405f4b2530ec16145f75e99233cd
parentb3238a4f40c9734e6d708b1c53ab608e50158fcc (diff)
downloadmongo-d7030574d78b30949f88791af744d839252477d6.tar.gz
Fix a bug populating column groups with complex schema.
closes #409
-rw-r--r--src/schema/schema_plan.c12
-rw-r--r--src/schema/schema_project.c20
2 files changed, 17 insertions, 15 deletions
diff --git a/src/schema/schema_plan.c b/src/schema/schema_plan.c
index b06b48532ed..a9f41e79143 100644
--- a/src/schema/schema_plan.c
+++ b/src/schema/schema_plan.c
@@ -41,13 +41,13 @@ cgcols: cval = colgroup->colconf;
}
WT_RET(__wt_config_subinit(session, &conf, &cval));
for (; __wt_config_next(&conf, &k, &v) == 0; col++) {
- if (cg == matchcg && col == matchcol)
- getnext = 1;
- if (getnext && k.len == colname->len &&
+ if (k.len == colname->len &&
strncmp(colname->str, k.str, k.len) == 0) {
- foundcg = cg;
- foundcol = col;
- getnext = 0;
+ if (getnext) {
+ foundcg = cg;
+ foundcol = col;
+ }
+ getnext = (cg == matchcg && col == matchcol);
}
if (cg == 0 && table->ncolgroups > 0 &&
col == table->nkey_columns - 1)
diff --git a/src/schema/schema_project.c b/src/schema/schema_project.c
index 73b5e8bb9cc..904d17b6406 100644
--- a/src/schema/schema_project.c
+++ b/src/schema/schema_project.c
@@ -338,21 +338,23 @@ __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp,
if (skip)
break;
- /* Read the item we're about to overwrite. */
- next = p;
- if (p < end)
- WT_RET(__unpack_read(session, &pv,
- &next, (size_t)(end - p)));
- old_len = (size_t)(next - p);
-
/*
+ * Read the item we're about to overwrite.
+ *
* There is subtlety here: the value format
* may not exactly match the cursor's format.
* In particular, we need lengths with raw
* columns in the middle of a packed struct,
- * but not if they are at the end of a column.
+ * but not if they are at the end of a struct.
*/
- pv.u = vpv.u;
+ next = p;
+ if (p < end) {
+ WT_RET(__unpack_read(session, &pv,
+ &next, (size_t)(end - p)));
+ pv.u = vpv.u;
+ } else
+ pv = vpv;
+ old_len = (size_t)(next - p);
len = __pack_size(session, &pv);
offset = WT_PTRDIFF(p, buf->data);