mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
Merge branch 'master' into iaadeflate_upgrade_qpl_v1.1.0
This commit is contained in:
commit
f0710d7be1
@ -345,6 +345,7 @@ private:
|
||||
PreparedInsert(pqxx::connection & connection_, const String & table, const String & schema,
|
||||
const ColumnsWithTypeAndName & columns, const String & on_conflict_)
|
||||
: Inserter(connection_)
|
||||
, statement_name("insert_" + getHexUIntLowercase(thread_local_rng()))
|
||||
{
|
||||
WriteBufferFromOwnString buf;
|
||||
buf << getInsertQuery(schema, table, columns, IdentifierQuotingStyle::DoubleQuotes);
|
||||
@ -357,12 +358,14 @@ private:
|
||||
}
|
||||
buf << ") ";
|
||||
buf << on_conflict_;
|
||||
connection.prepare("insert", buf.str());
|
||||
connection.prepare(statement_name, buf.str());
|
||||
prepared = true;
|
||||
}
|
||||
|
||||
void complete() override
|
||||
{
|
||||
connection.unprepare("insert");
|
||||
connection.unprepare(statement_name);
|
||||
prepared = false;
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
@ -371,8 +374,24 @@ private:
|
||||
pqxx::params params;
|
||||
params.reserve(row.size());
|
||||
params.append_multi(row);
|
||||
tx.exec_prepared("insert", params);
|
||||
tx.exec_prepared(statement_name, params);
|
||||
}
|
||||
|
||||
~PreparedInsert() override
|
||||
{
|
||||
try
|
||||
{
|
||||
if (prepared)
|
||||
connection.unprepare(statement_name);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
const String statement_name;
|
||||
bool prepared = false;
|
||||
};
|
||||
|
||||
StorageMetadataPtr metadata_snapshot;
|
||||
|
Loading…
Reference in New Issue
Block a user