Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions cpp/src/arrow/flight/sql/odbc/odbc_impl/get_info_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,25 +395,21 @@ bool GetInfoCache::LoadInfoFromServer() {
// Unused by ODBC.
break;
case SqlInfoOptions::SQL_DDL_SCHEMA: {
// GH-49500 TODO: use scalar bool to determine `SQL_CREATE_SCHEMA` and
// `SQL_DROP_SCHEMA` values

// Note: this is a bitmask and we can't describe cascade or restrict
// flags.
info_[SQL_DROP_SCHEMA] = static_cast<uint32_t>(SQL_DS_DROP_SCHEMA);

// Note: this is a bitmask and we can't describe authorization or
// collation
info_[SQL_CREATE_SCHEMA] = static_cast<uint32_t>(SQL_CS_CREATE_SCHEMA);
bool supported =
reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value;
info_[SQL_DROP_SCHEMA] =
static_cast<uint32_t>(supported ? SQL_DS_DROP_SCHEMA : 0);
info_[SQL_CREATE_SCHEMA] =
static_cast<uint32_t>(supported ? SQL_CS_CREATE_SCHEMA : 0);
break;
}
case SqlInfoOptions::SQL_DDL_TABLE: {
// GH-49500 TODO: use scalar bool to determine `SQL_CREATE_TABLE` and
// `SQL_DROP_TABLE` values

// This is a bitmask and we cannot describe all clauses.
info_[SQL_CREATE_TABLE] = static_cast<uint32_t>(SQL_CT_CREATE_TABLE);
info_[SQL_DROP_TABLE] = static_cast<uint32_t>(SQL_DT_DROP_TABLE);
bool supported =
reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value;
info_[SQL_CREATE_TABLE] =
static_cast<uint32_t>(supported ? SQL_CT_CREATE_TABLE : 0);
info_[SQL_DROP_TABLE] =
static_cast<uint32_t>(supported ? SQL_DT_DROP_TABLE : 0);
break;
}
case SqlInfoOptions::SQL_ALL_TABLES_ARE_SELECTABLE: {
Expand Down Expand Up @@ -475,10 +471,15 @@ bool GetInfoCache::LoadInfoFromServer() {
break;
}
case SqlInfoOptions::SQL_CATALOG_AT_START: {
info_[SQL_CATALOG_LOCATION] = static_cast<uint16_t>(
reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value
? SQL_CL_START
: SQL_CL_END);
// Only use this as a fallback if ARROW_SQL_CATALOG_TERM has not already
// set SQL_CATALOG_LOCATION (to avoid conflicting writes depending on
// response key ordering).
SetDefaultIfMissing(
info_, SQL_CATALOG_LOCATION,
static_cast<uint16_t>(
reinterpret_cast<BooleanScalar*>(scalar->child_value().get())->value
? SQL_CL_START
: SQL_CL_END));
break;
}
case SqlInfoOptions::SQL_SELECT_FOR_UPDATE_SUPPORTED:
Expand Down
27 changes: 3 additions & 24 deletions cpp/src/arrow/flight/sql/odbc/tests/connection_info_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,18 +616,11 @@ TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoAlterTable) {
EXPECT_EQ(static_cast<SQLUINTEGER>(0), value);
}

TYPED_TEST(ConnectionInfoHandleTest, TestSQLGetInfoCatalogLocation) {
// GH-49482 TODO: resolve inconsitent return value for SQL_CATALOG_LOCATION and change
// test type to `ConnectionInfoTest`
this->ConnectWithString(this->GetConnectionString(), this->conn);

TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoCatalogLocation) {
SQLUSMALLINT value;
GetInfo(this->conn, SQL_CATALOG_LOCATION, &value);

EXPECT_EQ(static_cast<SQLUSMALLINT>(0), value);

EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(this->conn))
<< GetOdbcErrorMessage(SQL_HANDLE_DBC, this->conn);
}

TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoCatalogName) {
Expand Down Expand Up @@ -752,32 +745,18 @@ TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDropDomain) {
EXPECT_EQ(static_cast<SQLUINTEGER>(0), value);
}

TYPED_TEST(ConnectionInfoHandleTest, TestSQLGetInfoDropSchema) {
// GH-49482 TODO: resolve inconsitent return value for SQL_DROP_SCHEMA and change test
// type to `ConnectionInfoTest`
this->ConnectWithString(this->GetConnectionString(), this->conn);

TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDropSchema) {
SQLUINTEGER value;
GetInfo(this->conn, SQL_DROP_SCHEMA, &value);

EXPECT_EQ(static_cast<SQLUINTEGER>(0), value);

EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(this->conn))
<< GetOdbcErrorMessage(SQL_HANDLE_DBC, this->conn);
}

TYPED_TEST(ConnectionInfoHandleTest, TestSQLGetInfoDropTable) {
// GH-49482 TODO: resolve inconsitent return value for SQL_DROP_TABLE and change test
// type to `ConnectionInfoTest`
this->ConnectWithString(this->GetConnectionString(), this->conn);

TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDropTable) {
SQLUINTEGER value;
GetInfo(this->conn, SQL_DROP_TABLE, &value);

EXPECT_EQ(static_cast<SQLUINTEGER>(0), value);

EXPECT_EQ(SQL_SUCCESS, SQLDisconnect(this->conn))
<< GetOdbcErrorMessage(SQL_HANDLE_DBC, this->conn);
}

TYPED_TEST(ConnectionInfoTest, TestSQLGetInfoDropTranslation) {
Expand Down
Loading