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("delete") != std::string::npos ||
|
||||||
sql.find("drop") != std::string::npos ||
|
sql.find("drop") != std::string::npos ||
|
||||||
sql.find("truncate") != 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
|
} // namespace orm
|
||||||
|
@ -273,7 +275,7 @@ void PgConnection::sendBatchedSql()
|
||||||
auto iter = preparedStatementsMap_.find(cmd->sql_);
|
auto iter = preparedStatementsMap_.find(cmd->sql_);
|
||||||
if (iter == preparedStatementsMap_.end())
|
if (iter == preparedStatementsMap_.end())
|
||||||
{
|
{
|
||||||
statName = utils::getUuid();
|
statName = newStmtName();
|
||||||
if (PQsendPrepare(connectionPtr_.get(),
|
if (PQsendPrepare(connectionPtr_.get(),
|
||||||
statName.c_str(),
|
statName.c_str(),
|
||||||
cmd->sql_.data(),
|
cmd->sql_.data(),
|
||||||
|
|
|
@ -252,7 +252,7 @@ void PgConnection::execSqlInLoop(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isRreparingStatement_ = true;
|
isRreparingStatement_ = true;
|
||||||
statementName_ = utils::getUuid();
|
statementName_ = newStmtName();
|
||||||
if (PQsendPrepare(connectionPtr_.get(),
|
if (PQsendPrepare(connectionPtr_.get(),
|
||||||
statementName_.c_str(),
|
statementName_.c_str(),
|
||||||
sql_.data(),
|
sql_.data(),
|
||||||
|
|
|
@ -91,6 +91,12 @@ class PgConnection : public DbConnection,
|
||||||
std::shared_ptr<PGconn> connectionPtr_;
|
std::shared_ptr<PGconn> connectionPtr_;
|
||||||
trantor::Channel channel_;
|
trantor::Channel channel_;
|
||||||
bool isRreparingStatement_{false};
|
bool isRreparingStatement_{false};
|
||||||
|
size_t preparedStatementsID_{0};
|
||||||
|
std::string newStmtName()
|
||||||
|
{
|
||||||
|
loop_->assertInLoopThread();
|
||||||
|
return std::to_string(++preparedStatementsID_);
|
||||||
|
}
|
||||||
void handleRead();
|
void handleRead();
|
||||||
void pgPoll();
|
void pgPoll();
|
||||||
void handleClosed();
|
void handleClosed();
|
||||||
|
|
Loading…
Reference in New Issue