Skip to content
Snippets Groups Projects
Commit a23df4a6 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Provide a more verbose error when violating a unique key.

parent d92b96e3
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,7 @@ enum { TNT_ERRMSG_MAX = 512 }; ...@@ -108,7 +108,7 @@ enum { TNT_ERRMSG_MAX = 512 };
/* 53 */_(ER_NO_SUCH_INDEX, 2, "No index #%u is defined in space %u") \ /* 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") \ /* 54 */_(ER_NO_SUCH_FIELD, 2, "Field %u was not found in the tuple") \
/* 55 */_(ER_TUPLE_FOUND, 2, "Tuple already exists") \ /* 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") /* 57 */_(ER_NO_SUCH_SPACE, 2, "Space %u does not exist")
......
...@@ -175,7 +175,8 @@ space_validate(struct space *sp, struct tuple *old_tuple, ...@@ -175,7 +175,8 @@ space_validate(struct space *sp, struct tuple *old_tuple,
if (index->key_def->is_unique) { if (index->key_def->is_unique) {
struct tuple *tuple = [index findByTuple: new_tuple]; struct tuple *tuple = [index findByTuple: new_tuple];
if (tuple != NULL && tuple != old_tuple) if (tuple != NULL && tuple != old_tuple)
tnt_raise(ClientError, :ER_INDEX_VIOLATION); tnt_raise(ClientError, :ER_INDEX_VIOLATION,
index_n(index));
} }
} }
} }
......
...@@ -533,7 +533,7 @@ lua push_collection(5, 1038784, 'hey') ...@@ -533,7 +533,7 @@ lua push_collection(5, 1038784, 'hey')
--- ---
- 1038784: {26984, 'hey', 'hey', 'hey', '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') lua box.space[5]:insert(2^51, 'hello', 'world')
--- ---
- 2251799813685248: {'hello', 'world'} - 2251799813685248: {'hello', 'world'}
...@@ -545,3 +545,15 @@ lua box.space[5]:select(0, 2^51) ...@@ -545,3 +545,15 @@ lua box.space[5]:select(0, 2^51)
lua box.space[5]:truncate() 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()
---
...
...@@ -197,7 +197,11 @@ exec admin "lua push_collection(5, 1038784, 'hey')" ...@@ -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')"
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]:insert(2^51, 'hello', 'world')"
exec admin "lua box.space[5]:select(0, 2^51)" exec admin "lua box.space[5]:select(0, 2^51)"
exec admin "lua box.space[5]:truncate()" 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()"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment