MCPcopy Create free account
hub / github.com/FISCO-BCOS/FISCO-BCOS / insert

Method insert

bcos-executor/src/precompiled/TablePrecompiled.cpp:693–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693void TablePrecompiled::insert(const std::string& tableName,
694 const std::shared_ptr<executor::TransactionExecutive>& _executive, bytesConstRef& data,
695 const PrecompiledGas::Ptr& gasPricer, const PrecompiledExecResult::Ptr& _callParameters)
696{
697 /// insert((string,string[]))
698 precompiled::EntryTuple insertEntry;
699 const auto& blockContext = _executive->blockContext();
700 auto codec = CodecWrapper(blockContext.hashHandler(), blockContext.isWasm());
701 codec.decode(data, insertEntry);
702
703 auto& key = std::get<0>(insertEntry);
704 auto& values = std::get<1>(insertEntry);
705
706 precompiled::TableInfo tableInfo;
707 // external call table manager desc
708 std::vector<std::string> columns;
709 auto originKey = key;
710 if (blockContext.blockVersion() >= bcos::protocol::BlockVersion::V3_2_VERSION)
711 {
712 desc(tableInfo, tableName, _executive, _callParameters, true);
713 if (isNumericalOrder(tableInfo.info_v320))
714 {
715 key = toNumericalOrder(key);
716 }
717 columns = std::get<2>(tableInfo.info_v320);
718 }
719 else
720 {
721 desc(tableInfo, tableName, _executive, _callParameters, false);
722 columns = std::get<1>(tableInfo.info);
723 }
724
725 if (c_fileLogLevel <= DEBUG) [[unlikely]]
726 {
727 PRECOMPILED_LOG(DEBUG) << LOG_BADGE("TablePrecompiled") << LOG_BADGE("INSERT")
728 << LOG_KV("tableName", tableName) << LOG_KV("originKey", originKey)
729 << LOG_KV("key", key) << LOG_KV("valueSize", values.size());
730 }
731
732 if (values.size() != columns.size())
733 {
734 PRECOMPILED_LOG(DEBUG) << LOG_BADGE("TablePrecompiled") << LOG_BADGE("INSERT")
735 << LOG_DESC("Table insert entry fields number mismatch")
736 << LOG_KV("valueSize", values.size())
737 << LOG_KV("fieldSize", columns.size());
738 BOOST_THROW_EXCEPTION(PrecompiledError{} << errinfo_comment("Table insert entry fields number mismatch"));
739 }
740 if (key.empty() && blockContext.blockVersion() >= BlockVersion::V3_3_VERSION) [[unlikely]]
741 {
742 BOOST_THROW_EXCEPTION(PrecompiledError{} << errinfo_comment("Table insert entry key is empty"));
743 }
744 checkLengthValidate(key, USER_TABLE_KEY_VALUE_MAX_LENGTH, CODE_TABLE_KEY_VALUE_LENGTH_OVERFLOW);
745 std::for_each(values.begin(), values.end(), [](std::string_view _v) {
746 checkLengthValidate(
747 _v, USER_TABLE_FIELD_VALUE_MAX_LENGTH, CODE_TABLE_FIELD_VALUE_LENGTH_OVERFLOW);
748 });
749
750 if (_executive->storage().getRow(tableName, key))

Callers 8

registerFuncMethod · 0.45
touchMethod · 0.45
fixBfs330Method · 0.45
rebuildBfs310Method · 0.45
recursiveBuildDirMethod · 0.45
appendColumnsMethod · 0.45
registerFuncMethod · 0.45

Calls 15

CodecWrapperClass · 0.85
toNumericalOrderFunction · 0.85
hashHandlerMethod · 0.80
setExecResultMethod · 0.80
setObjectMethod · 0.80
appendOperationMethod · 0.80
updateMemUsedMethod · 0.80
isWasmMethod · 0.45
decodeMethod · 0.45
blockVersionMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected