diff --git a/src/box/errcode.h b/src/box/errcode.h index 54379d0ec99e1b974a8fe5d1f10b941169ab1803..d8b679d2605cf1413e82ef3a63a61d0736498883 100644 --- a/src/box/errcode.h +++ b/src/box/errcode.h @@ -54,8 +54,8 @@ struct errcode_record { /* 0 */_(ER_UNKNOWN, 2, "Unknown error") \ /* 1 */_(ER_ILLEGAL_PARAMS, 2, "Illegal parameters, %s") \ /* 2 */_(ER_MEMORY_ISSUE, 1, "Failed to allocate %u bytes in %s for %s") \ - /* 3 */_(ER_TUPLE_FOUND, 2, "Duplicate key exists in unique index '%s'") \ - /* 4 */_(ER_TUPLE_NOT_FOUND, 2, "Tuple doesn't exist in index '%s'") \ + /* 3 */_(ER_TUPLE_FOUND, 2, "Duplicate key exists in unique index '%s' in space '%s'") \ + /* 4 */_(ER_TUPLE_NOT_FOUND, 2, "Tuple doesn't exist in index '%s' in space '%s'") \ /* 5 */_(ER_UNSUPPORTED, 2, "%s does not support %s") \ /* 6 */_(ER_NONMASTER, 2, "Can't modify data on a replication slave. My master is: %s") \ /* 7 */_(ER_READONLY, 2, "Can't modify data because this server in read-only mode.") \ @@ -145,7 +145,7 @@ struct errcode_record { /* 91 */_(ER_PRIV_NOT_GRANTED, 2, "User '%s' does not have %s access on %s '%s'") \ /* 92 */_(ER_ROLE_NOT_GRANTED, 2, "User '%s' does not have role '%s'") \ /* 93 */_(ER_MISSING_SNAPSHOT, 2, "Can't find snapshot") \ - /* 94 */_(ER_CANT_UPDATE_PRIMARY_KEY, 2, "Attempt to modify a tuple field which is part of index %s") \ + /* 94 */_(ER_CANT_UPDATE_PRIMARY_KEY, 2, "Attempt to modify a tuple field which is part of index '%s' in space '%s'") \ /* 95 */_(ER_UPDATE_INTEGER_OVERFLOW, 2, "Integer overflow when performing '%c' operation on field %u") \ /* 96 */_(ER_GUEST_USER_PASSWORD, 2, "Setting password for guest user has no effect") \ diff --git a/src/box/memtx_hash.cc b/src/box/memtx_hash.cc index 4afad8dac1681834a15daa96bbbe37a917eb2e4a..93b7c63c658fc03fe83bbe273ef84301855cf7fa 100644 --- a/src/box/memtx_hash.cc +++ b/src/box/memtx_hash.cc @@ -30,6 +30,8 @@ #include "say.h" #include "tuple.h" #include "memtx_engine.h" +#include "space.h" +#include "schema.h" /* space_cache_find() */ #include "errinj.h" #include "third_party/PMurHash.h" @@ -294,7 +296,9 @@ MemtxHash::replace(struct tuple *old_tuple, struct tuple *new_tuple, "recover of int hash_table"); } } - tnt_raise(ClientError, errcode, index_name(this)); + struct space *sp = space_cache_find(key_def->space_id); + tnt_raise(ClientError, errcode, index_name(this), + space_name(sp)); } if (dup_tuple) diff --git a/src/box/memtx_tree.cc b/src/box/memtx_tree.cc index 528c156e0829462736dc0519e4c8caba116498e3..af0a95b2970a8b9860c3427b46fa822787cf37ae 100644 --- a/src/box/memtx_tree.cc +++ b/src/box/memtx_tree.cc @@ -29,6 +29,7 @@ #include "memtx_tree.h" #include "tuple.h" #include "space.h" +#include "schema.h" /* space_cache_find() */ #include "errinj.h" #include "memory.h" #include "fiber.h" @@ -250,7 +251,9 @@ MemtxTree::replace(struct tuple *old_tuple, struct tuple *new_tuple, bps_tree_index_delete(&tree, new_tuple); if (dup_tuple) bps_tree_index_insert(&tree, dup_tuple, 0); - tnt_raise(ClientError, errcode, index_name(this)); + struct space *sp = space_cache_find(key_def->space_id); + tnt_raise(ClientError, errcode, index_name(this), + space_name(sp)); } if (dup_tuple) return dup_tuple; diff --git a/src/box/sophia_index.cc b/src/box/sophia_index.cc index e7b47577c10c105d0e5f24447167cdd7996f5ca3..5bb10b2de896b5f00a7eb39b179366742d872b27 100644 --- a/src/box/sophia_index.cc +++ b/src/box/sophia_index.cc @@ -272,7 +272,10 @@ SophiaIndex::replace(struct tuple *old_tuple, struct tuple *new_tuple, error = 1; tuple_unref(dup_tuple); if (error) { - tnt_raise(ClientError, ER_TUPLE_FOUND, index_name(this)); + struct space *sp = + space_cache_find(key_def->space_id); + tnt_raise(ClientError, ER_TUPLE_FOUND, + index_name(this), space_name(sp)); } } } diff --git a/src/box/space.cc b/src/box/space.cc index 85777d1eb394860e670bc675c04382f96dd52391..261c455041bc68b150fe167cd33c362366e4f71e 100644 --- a/src/box/space.cc +++ b/src/box/space.cc @@ -202,7 +202,7 @@ space_check_update(struct space *space, Index *index = space->index[0]; if (tuple_compare(old_tuple, new_tuple, index->key_def)) tnt_raise(ClientError, ER_CANT_UPDATE_PRIMARY_KEY, - index_name(index)); + index_name(index), space_name(space)); } /* vim: set fm=marker */ diff --git a/test/big/hash.result b/test/big/hash.result index 9e3e9e7421c4cd9d3d94eb094995b1c7da3d2d79..d511bdc0773ae0a746072589a1f589b2c83829a5 100644 --- a/test/big/hash.result +++ b/test/big/hash.result @@ -538,7 +538,7 @@ hash.index['field3']:get{10} -- TupleFound (primary key) hash:insert{1, 10, 10, 10} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... hash.index['primary']:get{10} --- @@ -580,7 +580,7 @@ hash.index['field3']:get{10} -- TupleFound (key --1) hash:insert{10, 0, 10, 10} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... hash.index['primary']:get{10} --- @@ -627,7 +627,7 @@ hash.index['field1']:get{0} -- TupleFound (key --3) hash:insert{10, 10, 10, 0} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... hash.index['primary']:get{10} --- diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result index 18545202e29dd5085c32cfe4296c86cdcc44d0fb..f70bb6a9f001d4206d73b74f0614a7d98c9e2024 100644 --- a/test/big/hash_multipart.result +++ b/test/big/hash_multipart.result @@ -46,7 +46,7 @@ hash:insert{1, 'bar', 1, '', 4} -- try to insert a row with a duplicate key hash:insert{1, 'bar', 1, '', 5} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... -- output all rows --# setopt delimiter ';' diff --git a/test/big/lua.result b/test/big/lua.result index d41273ab2ce11a7c09dc55d23094ecf96b234cbd..31b231e74366ae11caee99997d58216b3ac2425a 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -106,7 +106,7 @@ space:insert{'1', 'hello', 'world'} ... space:insert{'2', 'hello', 'world'} --- -- error: Duplicate key exists in unique index 'minmax' +- error: Duplicate key exists in unique index 'minmax' in space 'tweedledum' ... space:drop() --- diff --git a/test/big/tree_pk.result b/test/big/tree_pk.result index b4979a34ced6a26a68c8213425766fa33b0ea7c0..d75f06d5a05073dceee7e4759d0e868991538bef 100644 --- a/test/big/tree_pk.result +++ b/test/big/tree_pk.result @@ -364,7 +364,7 @@ s0.index['i3']:select{10} -- TupleFound (primary key) s0:insert{1, 10, 10, 10} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... s0.index['primary']:get{10} --- @@ -409,7 +409,7 @@ s0.index['i3']:select{10} -- TupleFound (key #1) s0:insert{10, 0, 10, 10} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... s0.index['primary']:get{10} --- @@ -434,7 +434,7 @@ s0.index['i1']:select{0} -- TupleFound (key #1) s0:replace{2, 0, 10, 10} --- -- error: Duplicate key exists in unique index 'i1' +- error: Duplicate key exists in unique index 'i1' in space 'tweedledum' ... s0.index['primary']:get{10} --- @@ -459,7 +459,7 @@ s0.index['i1']:select{0} -- TupleFound (key #3) s0:insert{10, 10, 10, 0} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... s0.index['primary']:get{10} --- @@ -484,7 +484,7 @@ s0.index['i3']:select{0} -- TupleFound (key #3) s0:replace{2, 10, 10, 0} --- -- error: Duplicate key exists in unique index 'i1' +- error: Duplicate key exists in unique index 'i1' in space 'tweedledum' ... s0.index['primary']:get{10} --- diff --git a/test/big/tree_pk_multipart.result b/test/big/tree_pk_multipart.result index ab094e3899251d34fc3b2ccb7c2bec6b1c72ef29..f91db4f383f898401dd8e7b6c2681f36fcd7c40d 100644 --- a/test/big/tree_pk_multipart.result +++ b/test/big/tree_pk_multipart.result @@ -269,7 +269,8 @@ space:delete{'Vincent', 'The Wolf!', 0} ... space:update({'Vincent', 'The Wolf!', 1}, {{ '=', 1, 'Updated' }, {'=', 5, 'New'}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + 'tweedledum' ... space:update({'Updated', 'The Wolf!', 1}, {{ '=', 1, 'Vincent'}, { '#', 5, 1 }}) --- diff --git a/test/box/alter.result b/test/box/alter.result index e2a3ad5b6ee95110e41214dec2f6c6646f1e5f9a..67d91e2887797b7746b5a891a86e9fba75d7e781 100644 --- a/test/box/alter.result +++ b/test/box/alter.result @@ -13,7 +13,7 @@ ADMIN = 1 -- _space:insert{_space.id, ADMIN, 'test', 5 } --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... -- -- Bad space id @@ -27,14 +27,14 @@ _space:insert{'hello', 'world', 'test'} -- _space:insert{_space.id, ADMIN, 'test', 'world'} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... -- -- There is already a tuple for the system space -- _space:insert{_space.id, ADMIN, '_space', 'memtx', 0} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... _space:replace{_space.id, ADMIN, '_space', 'memtx', 0} --- @@ -42,7 +42,7 @@ _space:replace{_space.id, ADMIN, '_space', 'memtx', 0} ... _space:insert{_index.id, ADMIN, '_index', 'memtx', 0} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... _space:replace{_index.id, ADMIN, '_index', 'memtx', 0} --- @@ -71,11 +71,13 @@ _space:delete{_index.id} -- _space:update({_space.id}, {{'+', 1, 1}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + '_space' ... _space:update({_space.id}, {{'+', 1, 2}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + '_space' ... -- -- Create a space @@ -138,7 +140,7 @@ space:replace{0} ... _index:insert{_space.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_index' ... _index:replace{_space.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} --- @@ -146,7 +148,7 @@ _index:replace{_space.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} ... _index:insert{_index.id, 0, 'primary', 'tree', 1, 2, 0, 'num', 1, 'num'} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_index' ... _index:replace{_index.id, 0, 'primary', 'tree', 1, 2, 0, 'num', 1, 'num'} --- @@ -323,7 +325,7 @@ auto = box.schema.space.create('auto_original') ... auto2 = box.schema.space.create('auto', {id = auto.id}) --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... box.schema.space.drop('auto') --- diff --git a/test/box/alter_limits.result b/test/box/alter_limits.result index 3ba3ff295fa034499f5102db496bc4c155acc12a..e38eaac1c153bb2d04112b58206e97ef89c7aa3f 100644 --- a/test/box/alter_limits.result +++ b/test/box/alter_limits.result @@ -84,7 +84,7 @@ s.id -- duplicate id box.schema.space.create('tweedledee', { id = 3000 }) --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space '_space' ... -- stupid space id box.schema.space.create('tweedledee', { id = 'tweedledee' }) @@ -681,7 +681,7 @@ index = s:create_index('third', { type = 'hash', parts = { 3, 'num' } }) ... s.index.third:rename('second') --- -- error: Duplicate key exists in unique index 'name' +- error: Duplicate key exists in unique index 'name' in space '_index' ... s.index.third.id --- @@ -762,12 +762,12 @@ s.index.primary:select{} -- a duplicate in the created index index = s:create_index('nodups', { type = 'tree', unique=true, parts = { 2, 'num'} }) --- -- error: Duplicate key exists in unique index 'nodups' +- error: Duplicate key exists in unique index 'nodups' in space 'full' ... -- change of non-unique index to unique: same effect s.index.year:alter({unique=true}) --- -- error: Duplicate key exists in unique index 'year' +- error: Duplicate key exists in unique index 'year' in space 'full' ... s.index.primary:select{} --- @@ -844,7 +844,7 @@ s:insert{2, 1} ... s.index.secondary:alter{ unique = true } --- -- error: Duplicate key exists in unique index 'secondary' +- error: Duplicate key exists in unique index 'secondary' in space 'test' ... s:delete{2} --- @@ -855,7 +855,7 @@ s.index.secondary:alter{ unique = true } ... s:insert{2, 1} --- -- error: Duplicate key exists in unique index 'secondary' +- error: Duplicate key exists in unique index 'secondary' in space 'test' ... s:insert{2, 2} --- diff --git a/test/box/call.result b/test/box/call.result index 515118a7c7c020c840ce8a3fa38e4d1c33369c4d..42b24ee3b735953b2b9bc1f55aa6479043d1a777 100644 --- a/test/box/call.result +++ b/test/box/call.result @@ -327,11 +327,12 @@ call myinsert(3, 'old', 2) --- - error: errcode: ER_TUPLE_FOUND - errmsg: Duplicate key exists in unique index 'primary' + errmsg: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... space:update({3}, {{'=', 1, 4}, {'=', 2, 'new'}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + 'tweedledum' ... space:insert(space:get{3}:update{{'=', 1, 4}, {'=', 2, 'new'}}) space:delete{3} --- diff --git a/test/box/fiber.result b/test/box/fiber.result index 1116fd5e651be7cc6a1726eb04ce6d0782b2b6de..d86c51ba5046a04da565fb3bb3468b6f76315a8a 100644 --- a/test/box/fiber.result +++ b/test/box/fiber.result @@ -141,7 +141,7 @@ space:insert{1953719668, 'old', 1684234849} -- test that insert produces a duplicate key error space:insert{1953719668, 'old', 1684234849} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'tweedledum' ... space:update(1953719668, {{'=', 1, 1953719668}, {'=', 2, 'new'}}) --- diff --git a/test/box/misc.result b/test/box/misc.result index dbd9e79c8210eac37cefdf4d6f6297f58ad88bbe..8b9c75937e307c040fe36703a5bd7f15b84af4fd 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -296,7 +296,7 @@ pcall(myinsert, {1, 'hello'}) pcall(myinsert, {1, 'hello'}) --- - false -- Duplicate key exists in unique index 'primary' +- Duplicate key exists in unique index 'primary' in space 'tweedledum' ... box.space.tweedledum:truncate() --- diff --git a/test/box/net.box.result b/test/box/net.box.result index 7fb11049c6be505dbbc1ec774ad1a2237639fd91..7c66df2f3502f4aea92082c00d474b99f06858a6 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -228,7 +228,7 @@ cn.space.net_box_test_space:insert{234, 1,2,3} ... cn.space.net_box_test_space:insert{234, 1,2,3} --- -- error: Duplicate key exists in unique index 'primary' +- error: Duplicate key exists in unique index 'primary' in space 'net_box_test_space' ... cn.space.net_box_test_space.insert{234, 1,2,3} --- diff --git a/test/box/update.result b/test/box/update.result index 2262ba7a72ca62a8b6ccda7dff361bc6e76a2634..aab2c05663ca6f3bf2fdd5965ae6168fc57a26df 100644 --- a/test/box/update.result +++ b/test/box/update.result @@ -11,7 +11,7 @@ s:insert{1000001, 1000002, 1000003, 1000004, 1000005} ... s:update({1000001}, {{'#', 1, 1}}) --- -- error: Attempt to modify a tuple field which is part of index pk +- error: Attempt to modify a tuple field which is part of index 'pk' in space 'tweedledum' ... s:truncate() --- @@ -142,7 +142,7 @@ s:update({1}, {{'=', 2, 'set tuple'}, {'!', 2, 'inserted tuple'}, {'#', 3, 1}}) ... s:update({1}, {{'!', 1, 3}, {'!', 1, 2}}) --- -- error: Attempt to modify a tuple field which is part of index pk +- error: Attempt to modify a tuple field which is part of index 'pk' in space 'tweedledum' ... s:truncate() --- diff --git a/test/replication/cluster.result b/test/replication/cluster.result index cd477fdb75a4ec8f1405c33c984bfae4363e2dec..466fd24f2d6ad9b4dc324cce851ca4c9042d7e89 100644 --- a/test/replication/cluster.result +++ b/test/replication/cluster.result @@ -142,7 +142,8 @@ box.info.vclock[10] ... box.space._cluster:update(10, {{'=', 1, 11}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + '_cluster' ... box.info.server.id --- diff --git a/test/sophia/gh.result b/test/sophia/gh.result index cbe6fa5d15900340ae29338bb207f548c769cc54..0f91fd492e5a07289e5a33bcd9c1b70eb37ff606 100644 --- a/test/sophia/gh.result +++ b/test/sophia/gh.result @@ -153,7 +153,8 @@ s:insert{1,'X'} ... s:update({'X'}, {{'=', 2, 'Y'}}) --- -- error: Attempt to modify a tuple field which is part of index primary +- error: Attempt to modify a tuple field which is part of index 'primary' in space + 'tester' ... s:select{'X'} ---