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

Method LoadDsn

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

Source from the content-addressed store, hash-verified

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

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