void UnitRepoProxy::InsertUnitMergeableStmt ::insert(RepoTxn& txn, int64_t unitSn, int ix, Unit::MergeKind kind, Id id, TypedValue* value) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitMergeables") << " VALUES(@unitSn, @mergeableIx, @mergeableKind," " @mergeableId, @mergeableValue);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindInt("@mergeableIx", ix); query.bindInt("@mergeableKind", (int)kind); query.bindId("@mergeableId", id); if (value) { assert(kind == MergeKind::Define || kind == MergeKind::PersistentDefine || kind == MergeKind::Global); query.bindTypedValue("@mergeableValue", *value); } else { assert(kind == MergeKind::ReqDoc || kind == MergeKind::TypeAlias); query.bindNull("@mergeableValue"); } query.exec(); }
void UnitRepoProxy::InsertUnitStmt ::insert(RepoTxn& txn, int64& unitSn, const MD5& md5, const uchar* bc, size_t bclen, const uchar* bc_meta, size_t bc_meta_len, const TypedValue* mainReturn, const LineTable& lines) { BlobEncoder linesBlob; if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "Unit") << " VALUES(NULL, @md5, @bc, @bc_meta," " @mainReturn, @mergeable, @lines);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindMd5("@md5", md5); query.bindBlob("@bc", (const void*)bc, bclen); query.bindBlob("@bc_meta", bc_meta_len ? (const void*)bc_meta : (const void*)"", bc_meta_len); query.bindTypedValue("@mainReturn", *mainReturn); query.bindBool("@mergeable", mainReturn->_count); query.bindBlob("@lines", linesBlob(lines), /* static */ true); query.exec(); unitSn = query.getInsertedRowid(); }
void UnitRepoProxy::InsertUnitStmt ::insert(const UnitEmitter& ue, RepoTxn& txn, int64_t& unitSn, const MD5& md5, const unsigned char* bc, size_t bclen) { BlobEncoder dataBlob; if (!prepared()) { std::stringstream ssInsert; /* * Do not put preload into data; its needed to choose the * units in preloadRepo. */ ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "Unit") << " VALUES(NULL, @md5, @preload, @bc, @data);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindMd5("@md5", md5); query.bindInt("@preload", ue.m_preloadPriority); query.bindBlob("@bc", (const void*)bc, bclen); const_cast<UnitEmitter&>(ue).serdeMetaData(dataBlob); query.bindBlob("@data", dataBlob, /* static */ true); query.exec(); unitSn = query.getInsertedRowid(); }
void Repo::InsertFileHashStmt::insert(RepoTxn& txn, const StringData* path, const MD5& md5) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "FileMd5") << " VALUES(@path, @md5);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindStaticString("@path", path); query.bindMd5("@md5", md5); query.exec(); }
void LitstrRepoProxy::InsertLitstrStmt::insert(RepoTxn& txn, Id litstrId, const StringData* litstr) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "Litstr") << " VALUES(@litstrId, @litstr);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@litstrId", litstrId); query.bindStaticString("@litstr", litstr); query.exec(); }
void UnitRepoProxy::InsertUnitArrayStmt ::insert(RepoTxn& txn, int64 unitSn, Id arrayId, const StringData* array) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitArray") << " VALUES(@unitSn, @arrayId, @array);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindId("@arrayId", arrayId); query.bindStaticString("@array", array); query.exec(); }
void UnitRepoProxy::InsertUnitPreConstStmt ::insert(RepoTxn& txn, int64 unitSn, const PreConst& pc, Id id) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitPreConst") << " VALUES(@unitSn, @name, @value, @preConstId);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindStaticString("@name", pc.name); query.bindTypedValue("@value", pc.value); query.bindId("@preConstId", id); query.exec(); }
void UnitRepoProxy::InsertUnitArrayTypeTableStmt::insert( RepoTxn& txn, int64_t unitSn, const ArrayTypeTable& att) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitArrayTypeTable") << " VALUES(@unitSn, @arrayTypeTable);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); BlobEncoder dataBlob; dataBlob(att); query.bindBlob("@arrayTypeTable", dataBlob, /* static */ true); query.exec(); }
void UnitRepoProxy::InsertUnitSourceLocStmt ::insert(RepoTxn& txn, int64 unitSn, Offset pastOffset, int line0, int char0, int line1, int char1) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "UnitSourceLoc") << " VALUES(@unitSn, @pastOffset, @line0, @char0, @line1," " @char1);"; txn.prepare(*this, ssInsert.str()); } RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindOffset("@pastOffset", pastOffset); query.bindInt("@line0", line0); query.bindInt("@char0", char0); query.bindInt("@line1", line1); query.bindInt("@char1", char1); query.exec(); }
void PreClassRepoProxy::InsertPreClassStmt ::insert(const PreClassEmitter& pce, RepoTxn& txn, int64_t unitSn, Id preClassId, const StringData* name, PreClass::Hoistable hoistable) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "PreClass") << " VALUES(@unitSn, @preClassId, @name, @hoistable, " "@extraData);"; txn.prepare(*this, ssInsert.str()); } BlobEncoder extraBlob; RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindId("@preClassId", preClassId); query.bindStaticString("@name", name); query.bindInt("@hoistable", hoistable); const_cast<PreClassEmitter&>(pce).serdeMetaData(extraBlob); query.bindBlob("@extraData", extraBlob, /* static */ true); query.exec(); }
void FuncRepoProxy::InsertFuncStmt ::insert(const FuncEmitter& fe, RepoTxn& txn, int64_t unitSn, int funcSn, Id preClassId, const StringData* name, bool top) { if (!prepared()) { std::stringstream ssInsert; ssInsert << "INSERT INTO " << m_repo.table(m_repoId, "Func") << " VALUES(@unitSn, @funcSn, @preClassId, @name, " " @top, @extraData);"; txn.prepare(*this, ssInsert.str()); } BlobEncoder extraBlob; RepoTxnQuery query(txn, *this); query.bindInt64("@unitSn", unitSn); query.bindInt("@funcSn", funcSn); query.bindId("@preClassId", preClassId); query.bindStaticString("@name", name); query.bindBool("@top", top); const_cast<FuncEmitter&>(fe).serdeMetaData(extraBlob); query.bindBlob("@extraData", extraBlob, /* static */ true); query.exec(); }