MCPcopy Create free account
hub / github.com/apache/arrow / LoadDsn

Method LoadDsn

cpp/src/arrow/flight/sql/odbc/odbc_impl/config/configuration.cc:137–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void Configuration::LoadDsn(const std::string& dsn) {
138 // Read keys before reading DSN to minimized unexpected behavior from ODBC driver
139 // managers.
140 auto customKeys = ReadAllKeys(dsn);
141
142 Set(FlightSqlConnection::DSN, dsn);
143 Set(FlightSqlConnection::HOST, ReadDsnString(dsn, FlightSqlConnection::HOST));
144 Set(FlightSqlConnection::PORT, ReadDsnString(dsn, FlightSqlConnection::PORT));
145 Set(FlightSqlConnection::TOKEN, ReadDsnString(dsn, FlightSqlConnection::TOKEN));
146 Set(FlightSqlConnection::UID, ReadDsnString(dsn, FlightSqlConnection::UID));
147 Set(FlightSqlConnection::PWD, ReadDsnString(dsn, FlightSqlConnection::PWD));
148 Set(FlightSqlConnection::TRUSTED_CERTS,
149 ReadDsnString(dsn, FlightSqlConnection::TRUSTED_CERTS));
150
151#ifdef __APPLE__
152 // macOS iODBC treats non-empty defaults as the real values when reading from system
153 // DSN, so we don't pass defaults on macOS.
154 // GH-49387 TODO: enable default values on macOS
155 Set(FlightSqlConnection::USE_ENCRYPTION,
156 ReadDsnString(dsn, FlightSqlConnection::USE_ENCRYPTION));
157 Set(FlightSqlConnection::USE_SYSTEM_TRUST_STORE,
158 ReadDsnString(dsn, FlightSqlConnection::USE_SYSTEM_TRUST_STORE));
159 Set(FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION,
160 ReadDsnString(dsn, FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION));
161#else
162 // Windows and Linux
163 Set(FlightSqlConnection::USE_ENCRYPTION,
164 ReadDsnString(dsn, FlightSqlConnection::USE_ENCRYPTION, DEFAULT_ENABLE_ENCRYPTION));
165 Set(FlightSqlConnection::USE_SYSTEM_TRUST_STORE,
166 ReadDsnString(dsn, FlightSqlConnection::USE_SYSTEM_TRUST_STORE,
167 DEFAULT_USE_CERT_STORE));
168 Set(FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION,
169 ReadDsnString(dsn, FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION,
170 DEFAULT_DISABLE_CERT_VERIFICATION));
171#endif // __APPLE__
172
173 RemoveAllKnownKeys(customKeys);
174 for (auto key : customKeys) {
175 std::string_view key_sv(key);
176 Set(key, ReadDsnString(dsn, key_sv));
177 }
178}
179
180void Configuration::Clear() { this->properties_.clear(); }
181

Callers 3

LoadPropertiesFromDSNFunction · 0.80
SQLConnectFunction · 0.80
ConfigDSNWFunction · 0.80

Calls 3

ReadAllKeysFunction · 0.85
ReadDsnStringFunction · 0.85
RemoveAllKnownKeysFunction · 0.85

Tested by

no test coverage detected