Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ODBC to Match Vendor Update #31

Merged
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(ODBC_FOUND)

if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# add_subdirectory(winsetup)
add_subdirectory(winsetup)
list(APPEND LINK_LIB_LIST $<$<PLATFORM_ID:Windows>:odbccp32>)
list(APPEND LINK_LIB_LIST
$<$<PLATFORM_ID:Windows>:legacy_stdio_definitions>)
Expand Down
4 changes: 2 additions & 2 deletions src/prepared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SQLRETURN SQL_API SQLNumParams(SQLHSTMT statement_handle, SQLSMALLINT *parameter
if (!parameter_count_ptr) {
return SQL_ERROR;
}
*parameter_count_ptr = (SQLSMALLINT)hstmt->stmt->n_param;
*parameter_count_ptr = (SQLSMALLINT)hstmt->stmt->named_param_map.size();
return SQL_SUCCESS;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT statement_handle, SQLUSMALLINT param
return ret;
}

if (parameter_number <= 0 || parameter_number > hstmt->stmt->n_param) {
if (parameter_number <= 0 || parameter_number > hstmt->stmt->named_param_map.size()) {
return SQL_ERROR;
}
// TODO make global maps with type mappings for duckdb <> odbc
Expand Down
2 changes: 1 addition & 1 deletion src/statement/statement_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SQLRETURN duckdb::FinalizeStmt(duckdb::OdbcHandleStmt *hstmt) {
SQLStateType::ST_42000, hstmt->dbc->GetDataSourceName()));
}

hstmt->param_desc->ResetParams(hstmt->stmt->n_param);
hstmt->param_desc->ResetParams(hstmt->stmt->named_param_map.size());

hstmt->bound_cols.resize(hstmt->stmt->ColumnCount());

Expand Down
4 changes: 2 additions & 2 deletions test/isql-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def test(cmd, out=None, err=None, extra_commands=None, input_file=None):
test("SELECT ' '::TIME", err="[ISQL]ERROR")
test("SELECT '1'::TIME", err="[ISQL]ERROR")
test("SELECT '11'::TIME", err="[ISQL]ERROR")
test("SELECT '11:'::TIME", err="[ISQL]ERROR")
test("SELECT '11:11'::TIME", err="[ISQL]ERROR")
test("SELECT '11:'::TIME", out="11:00:00")
test("SELECT '11:11'::TIME", out="11:11:00")
test("SELECT '11:11:f'::TIME", err="[ISQL]ERROR")

### FROM test/sql/types/time/test_time.test #################################
Expand Down
10 changes: 5 additions & 5 deletions test/tests/catalog_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ static void TestSQLTablesSchema(HSTMT &hstmt) {
DATA_CHECK(hstmt, 4, "TABLE");

// No schema name should give all tables, including main schema
EXECUTE_AND_CHECK("SQLTables", SQLTables, hstmt, nullptr, 0, ConvertToSQLCHAR(""), SQL_NTS,
ConvertToSQLCHAR("%"), SQL_NTS, ConvertToSQLCHAR("TABLE"), SQL_NTS);
EXECUTE_AND_CHECK("SQLTables", SQLTables, hstmt, nullptr, 0, ConvertToSQLCHAR(""), SQL_NTS, ConvertToSQLCHAR("%"),
SQL_NTS, ConvertToSQLCHAR("TABLE"), SQL_NTS);

std::vector<std::array<std::string, 4>> expected_data = {
{"test_table_2", "ducks"}, {"bool_table", "main"}, {"bytea_table", "main"},
{"interval_table", "main"}, {"lo_test_table", "main"}, {"test_table_1", "main"}};
std::vector<std::array<std::string, 4>> expected_data = {{"test_table_2", "ducks"}, {"bool_table", "main"},
{"bytea_table", "main"}, {"interval_table", "main"},
{"lo_test_table", "main"}, {"test_table_1", "main"}};

for (int i = 0; i < expected_data.size(); i++) {
SQLRETURN ret = SQLFetch(hstmt);
Expand Down
2 changes: 1 addition & 1 deletion test/tests/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_CASE("Test Select Statement", "[odbc]") {
// Allocate a statement handle
EXECUTE_AND_CHECK("SQLAllocHandle (HSTMT)", SQLAllocHandle, SQL_HANDLE_STMT, dbc, &hstmt);

// Execute a simple query
// Execute a simple query
EXECUTE_AND_CHECK("SQLExecDirect (SELECT 1 UNION ALL SELECT 2)", SQLExecDirect, hstmt,
ConvertToSQLCHAR("SELECT 1 UNION ALL SELECT 2"), SQL_NTS);

Expand Down
Loading