0

My contract has two tables mcat and mcatmig.

Problem: scope request return wrong table name mcat........1 instead of mcatmig:

% cleos get scope teresacode
{
"rows": [{
    "code": "teresacode",
    "scope": "default",
    "table": "mcat",
    "payer": "teresacode",
    "count": 5688
    },{
    "code": "teresacode",
    "scope": "default",
    "table": "mcat........1",
    "payer": "teresacode",
    "count": 2844
    }
],
"more": ""
}

And there is no table with that name:

% cleos get table teresacode default "mcat........1"
Error 3060003: Contract Table Query Exception
Most likely, the given table doesn't exist in the blockchain.
Error Details:
Unsupported table name: mcat........1

And real table is accessible fine:

% cleos get table teresacode default "mcatmig"
{
"rows": [],
"more": false,
"next_key": ""
}

I believe this happened after copying a large number of rows from table mcat to table mcatmig.

Something like that:

[[eosio::action]] void mcat::move(int count) {
    mcat_t mcat{get_self(), name{"default"}};
    mcatmig_t mcatmig{get_self(), name{"default"}};

    auto it = mcat.begin();
    int i = 0;
    while(i < count && it != mcat.end()) {
        mcatmig.emplace(...);
        i++;
        mcat.erase(it);
        it = mcat.begin();
    }
}

Why scope request return weird table name? Is this a data corruption, move algorithm has a bug? Or it is an eosio bug? What do you think?

Thank you!

1

If your multi_index table has multiple indices by using indexed_by, additional index will be shown like ORIGINAL_TABLE_NAME........1. The last character will use remaining last 4 bits in eosio::name. This is why additional indices can exist up to 16. (4 bits, 0 - 15 will be translated into ., 1-5, a-j)

If you show the struct declarations and typedefs of mcat and mcatmig, I can answer more accurately.

2
  • You are awesome! Thank you! Is that even documented?
    – Teresa
    Jun 10 '20 at 7:34
  • I haven't seen documentation which explains this topic in detail. I got this information by analyzing source code by myself. :)
    – conr2d
    Jun 10 '20 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.