Use shorter stmt names in postgresql connections(#326)
This commit is contained in:
parent
cb95960e2d
commit
f07d9e03e1
|
@ -46,7 +46,9 @@ bool checkSql(const string_view &sql_)
|
|||
sql.find("delete") != std::string::npos ||
|
||||
sql.find("drop") != std::string::npos ||
|
||||
sql.find("truncate") != std::string::npos ||
|
||||
sql.find("lock") != std::string::npos);
|
||||
sql.find("lock") != std::string::npos ||
|
||||
sql.find("create") != std::string::npos ||
|
||||
sql.find("alter") != std::string::npos);
|
||||
}
|
||||
|
||||
} // namespace orm
|
||||
|
@ -273,7 +275,7 @@ void PgConnection::sendBatchedSql()
|
|||
auto iter = preparedStatementsMap_.find(cmd->sql_);
|
||||
if (iter == preparedStatementsMap_.end())
|
||||
{
|
||||
statName = utils::getUuid();
|
||||
statName = newStmtName();
|
||||
if (PQsendPrepare(connectionPtr_.get(),
|
||||
statName.c_str(),
|
||||
cmd->sql_.data(),
|
||||
|
|
|
@ -252,7 +252,7 @@ void PgConnection::execSqlInLoop(
|
|||
else
|
||||
{
|
||||
isRreparingStatement_ = true;
|
||||
statementName_ = utils::getUuid();
|
||||
statementName_ = newStmtName();
|
||||
if (PQsendPrepare(connectionPtr_.get(),
|
||||
statementName_.c_str(),
|
||||
sql_.data(),
|
||||
|
|
|
@ -91,6 +91,12 @@ class PgConnection : public DbConnection,
|
|||
std::shared_ptr<PGconn> connectionPtr_;
|
||||
trantor::Channel channel_;
|
||||
bool isRreparingStatement_{false};
|
||||
size_t preparedStatementsID_{0};
|
||||
std::string newStmtName()
|
||||
{
|
||||
loop_->assertInLoopThread();
|
||||
return std::to_string(++preparedStatementsID_);
|
||||
}
|
||||
void handleRead();
|
||||
void pgPoll();
|
||||
void handleClosed();
|
||||
|
|
Loading…
Reference in New Issue