summaryrefslogtreecommitdiff
path: root/src/cursor/cur_table.c
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2015-11-17 10:35:01 -0500
committerDon Anderson <dda@ddanderson.com>2015-11-17 10:35:01 -0500
commitee33b0875afe660fa3888a4361c9cf215f27d582 (patch)
tree07602931eda89abbedc4eb45c0b242ac8ffb97bd /src/cursor/cur_table.c
parenta22cde620d799e8019a72c427ba5b2b8e2e39489 (diff)
parentce8c091da8fbfcefd68ede316381455d116b9981 (diff)
downloadmongo-ee33b0875afe660fa3888a4361c9cf215f27d582.tar.gz
Merge branch 'develop' into wt-1315-join-cursor
Diffstat (limited to 'src/cursor/cur_table.c')
-rw-r--r--src/cursor/cur_table.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c
index 7d227e76c7b..952778d2c88 100644
--- a/src/cursor/cur_table.c
+++ b/src/cursor/cur_table.c
@@ -502,29 +502,38 @@ __curtable_insert(WT_CURSOR *cursor)
if (ctable->table->nindices > 0)
F_CLR(primary, WT_CURSTD_OVERWRITE);
ret = primary->insert(primary);
- F_SET(primary, flag_orig);
- if (ret == WT_DUPLICATE_KEY && F_ISSET(cursor, WT_CURSTD_OVERWRITE)) {
- /*
- * !!!
- * The insert failure clears these flags, but does not touch the
- * items. We could make a copy each time for overwrite cursors,
- * but for now we just reset the flags.
- */
- F_SET(primary, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT);
- ret = __curtable_update(cursor);
- goto err;
- }
- WT_ERR(ret);
+ /*
+ * !!!
+ * WT_CURSOR.insert clears the set internally/externally flags
+ * but doesn't touch the items. We could make a copy each time
+ * for overwrite cursors, but for now we just reset the flags.
+ */
+ F_SET(primary, flag_orig | WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT);
- for (i = 1; i < WT_COLGROUPS(ctable->table); i++, cp++) {
- (*cp)->recno = primary->recno;
- WT_ERR((*cp)->insert(*cp));
+ if (ret == WT_DUPLICATE_KEY && F_ISSET(cursor, WT_CURSTD_OVERWRITE))
+ WT_ERR(__curtable_update(cursor));
+ else {
+ WT_ERR(ret);
+
+ for (i = 1; i < WT_COLGROUPS(ctable->table); i++, cp++) {
+ (*cp)->recno = primary->recno;
+ WT_ERR((*cp)->insert(*cp));
+ }
+
+ WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), false));
}
- WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), false));
+ /*
+ * WT_CURSOR.insert doesn't leave the cursor positioned, and the
+ * application may want to free the memory used to configure the
+ * insert; don't read that memory again (matching the underlying
+ * file object cursor insert semantics).
+ */
+ F_CLR(primary, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET);
err: CURSOR_UPDATE_API_END(session, ret);
+
return (ret);
}