diff --git a/include/errcode.h b/include/errcode.h index 6e368f5077b96860c9e91ad7a5f31dec6197ee42..72ae7d9420e31529cb52afaeedf0eb5df2566eea 100644 --- a/include/errcode.h +++ b/include/errcode.h @@ -108,7 +108,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 53 */_(ER_NO_SUCH_INDEX, 2, "No index #%u is defined in space %u") \ /* 54 */_(ER_NO_SUCH_FIELD, 2, "Field %u was not found in the tuple") \ /* 55 */_(ER_TUPLE_FOUND, 2, "Tuple already exists") \ - /* 56 */_(ER_INDEX_VIOLATION, 2, "Duplicate key exists in a unique index") \ + /* 56 */_(ER_INDEX_VIOLATION, 2, "Duplicate key exists in unique index %d") \ /* 57 */_(ER_NO_SUCH_SPACE, 2, "Space %u does not exist") diff --git a/mod/box/space.m b/mod/box/space.m index d5fbcbf51b8a9dc57c69e7ef77277cf8e8918c70..048bb2dbf18160e78ab02dac4eed0c578ec99d2f 100644 --- a/mod/box/space.m +++ b/mod/box/space.m @@ -175,7 +175,8 @@ space_validate(struct space *sp, struct tuple *old_tuple, if (index->key_def->is_unique) { struct tuple *tuple = [index findByTuple: new_tuple]; if (tuple != NULL && tuple != old_tuple) - tnt_raise(ClientError, :ER_INDEX_VIOLATION); + tnt_raise(ClientError, :ER_INDEX_VIOLATION, + index_n(index)); } } } diff --git a/test/box_big/lua.result b/test/box_big/lua.result index cf8393e7b003b7194878e7ccc670d97a6a8a76cc..6698c0b0fdd27fa686b9f4ea6f2367fddede0481 100644 --- a/test/box_big/lua.result +++ b/test/box_big/lua.result @@ -533,7 +533,7 @@ lua push_collection(5, 1038784, 'hey') --- - 1038784: {26984, 'hey', 'hey', 'hey', 'hey'} ... -A test case for Bug#1060967: truncation of 64-bit numbers +# A test case for Bug#1060967: truncation of 64-bit numbers lua box.space[5]:insert(2^51, 'hello', 'world') --- - 2251799813685248: {'hello', 'world'} @@ -545,3 +545,15 @@ lua box.space[5]:select(0, 2^51) lua box.space[5]:truncate() --- ... +# Test that we print index number in error ER_INDEX_VIOLATION +lua box.space[1]:insert(1, 'hello', 'world') +--- + - 1: {'hello', 'world'} +... +lua box.space[1]:insert(2, 'hello', 'world') +--- +error: 'Duplicate key exists in unique index 1' +... +lua box.space[1]:truncate() +--- +... diff --git a/test/box_big/lua.test b/test/box_big/lua.test index e57494235f98a994a1d4b66fab5ebb87e105ad0f..4ccc898075e0cb2e941b7d1d071f7c2b48549600 100644 --- a/test/box_big/lua.test +++ b/test/box_big/lua.test @@ -197,7 +197,11 @@ exec admin "lua push_collection(5, 1038784, 'hey')" exec admin "lua push_collection(5, 1038784, 'hey')" exec admin "lua push_collection(5, 1038784, 'hey')" -print """A test case for Bug#1060967: truncation of 64-bit numbers""" +print """# A test case for Bug#1060967: truncation of 64-bit numbers""" exec admin "lua box.space[5]:insert(2^51, 'hello', 'world')" exec admin "lua box.space[5]:select(0, 2^51)" exec admin "lua box.space[5]:truncate()" +print """# Test that we print index number in error ER_INDEX_VIOLATION""" +exec admin "lua box.space[1]:insert(1, 'hello', 'world')" +exec admin "lua box.space[1]:insert(2, 'hello', 'world')" +exec admin "lua box.space[1]:truncate()"