Skip to content

Commit

Permalink
Merge pull request #457 from ClickHouse/remove-autogenerated-session-id
Browse files Browse the repository at this point in the history
Remove autogenerated session_id
  • Loading branch information
slvrtrn authored Oct 18, 2024
2 parents 204eb8d + 7801085 commit 50c1439
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ jobs:
echo REF: ${{ github.ref }}
ls -lahR ${{ github.workspace }}/build/
# Linux release artifacts are uploaded in Docker.yml
# That builds binaries based on CentOS 7, which makes those more portable.
# However, these binaries are uploaded to be available in GH's 'Actions', just in case.
- name: Upload the artifacts
if: ${{ matrix.compiler == 'GCC' && matrix.odbc_provider == 'UnixODBC' && matrix.build_type == 'Release' && matrix.runtime_link == 'dynamic-runtime' && matrix.third_parties == 'bundled-third-parties' }}
if: ${{ matrix.odbc_provider == 'UnixODBC' && matrix.build_type == 'Release' && matrix.runtime_link == 'dynamic-runtime' && matrix.third_parties == 'bundled-third-parties' }}
uses: actions/upload-artifact@v4
with:
name: clickhouse-odbc-linux-${{ matrix.compiler }}-${{ matrix.odbc_provider }}-${{ matrix.build_type }}
Expand Down
23 changes: 1 addition & 22 deletions driver/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/NumberParser.h> // TODO: switch to std
#include <Poco/URI.h>
#include <random>

#if !defined(WORKAROUND_DISABLE_SSL)
# include <Poco/Net/AcceptCertificateHandler.h>
Expand Down Expand Up @@ -48,15 +47,8 @@ void SSLInit(bool ssl_strict, const std::string & privateKeyFile, const std::str
}
#endif

std::string GenerateSessionId() {
std::mt19937 generator(std::random_device{}());
std::uniform_int_distribution<std::uint64_t> distribution(0);
return std::string("clickhouse_odbc_" + std::to_string(distribution(generator)));
}

Connection::Connection(Environment & environment)
: ChildType(environment),
session_id(GenerateSessionId())
: ChildType(environment)
{
resetConfiguration();
}
Expand Down Expand Up @@ -108,19 +100,6 @@ Poco::URI Connection::getUri() const {
if (!database_set)
uri.addQueryParameter("database", database);

// To use some features of CH (e.g. TEMPORARY TABLEs) we need a (named) session.
{
const auto & parameters = uri.getQueryParameters();
const auto p = std::find_if(parameters.begin(), parameters.end(), [](const auto & param_kv) {
return param_kv.first == "session_id";
});

// DO not overwrite user-set session_id, just in case...
if (p == parameters.end()) {
uri.addQueryParameter("session_id", session_id);
}
}

return uri;
}

Expand Down

0 comments on commit 50c1439

Please sign in to comment.