From 389d3bca4c11683ff07670d696b89a4b4ccb8e64 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sun, 15 Nov 2015 12:28:54 -0500 Subject: WT-2217: change WT_CURSOR.insert to clear "set" key/value on succesful return. --- src/cursor/cur_table.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/cursor/cur_table.c') diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c index 38359236b27..0d088d29a64 100644 --- a/src/cursor/cur_table.c +++ b/src/cursor/cur_table.c @@ -525,12 +525,20 @@ __curtable_insert(WT_CURSOR *cursor) 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. + * 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, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT); ret = __curtable_update(cursor); + + /* + * 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); goto err; } WT_ERR(ret); -- cgit v1.2.1 From a9bff0c5eae30e0b98fa2502a80a5e8c82f5a9c9 Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sun, 15 Nov 2015 14:19:55 -0500 Subject: WT-2217: don't clear the key/value set flags unless the insert call was successful. --- src/cursor/cur_table.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/cursor/cur_table.c') diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c index 0d088d29a64..a292d8838ca 100644 --- a/src/cursor/cur_table.c +++ b/src/cursor/cur_table.c @@ -530,7 +530,7 @@ __curtable_insert(WT_CURSOR *cursor) * 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); + WT_ERR(__curtable_update(cursor)); /* * WT_CURSOR.insert doesn't leave the cursor positioned, and the @@ -539,16 +539,16 @@ __curtable_insert(WT_CURSOR *cursor) * file object cursor insert semantics). */ F_CLR(primary, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); - goto err; - } - WT_ERR(ret); + } else { + WT_ERR(ret); - for (i = 1; i < WT_COLGROUPS(ctable->table); i++, cp++) { - (*cp)->recno = primary->recno; - WT_ERR((*cp)->insert(*cp)); - } + 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)); + } err: CURSOR_UPDATE_API_END(session, ret); return (ret); -- cgit v1.2.1 From 61f9f5518be0a1e5b23700c52cbc805f4c7bf1db Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Mon, 16 Nov 2015 16:25:52 +1100 Subject: WT-2217 Fix table inserts: keep the primary positioned during index updates. --- src/cursor/cur_table.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/cursor/cur_table.c') diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c index a292d8838ca..c5a00649334 100644 --- a/src/cursor/cur_table.c +++ b/src/cursor/cur_table.c @@ -520,26 +520,18 @@ __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)) { - /* - * !!! - * 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, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT); - WT_ERR(__curtable_update(cursor)); + /* + * !!! + * 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); - /* - * 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); - } else { + 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++) { @@ -550,7 +542,16 @@ __curtable_insert(WT_CURSOR *cursor) 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); } -- cgit v1.2.1